Skip to content

Commit

Permalink
Create the top-level command structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
j2blake committed Jun 18, 2015
1 parent 1963857 commit 8a68b2e
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.buildpath
.project
.README.md.html
51 changes: 33 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Purpose
- Detect whether changes to the code have resulted in any changes to the pages that are served.
- Test a small canary set to detect obvious problems. When the obvious problems are fixed, enlarge the set and
- Test a small "canary set" to detect obvious problems. When the obvious problems are fixed, enlarge the set and
repeat until the entire site is tested. Or simply test the entire set to begin with.

## Use cases
Expand Down Expand Up @@ -33,33 +33,38 @@ in addition to the URL, each request may specify POST or GET, HTTP headers, and
## Commands

```
vivosnap prepare uri-list [classlist_file] [VIVO_homepage_URL] [uri_list_file]
vivosnap.rb prepare uri-list [classlist_file] [VIVO_homepage_URL] [uri_list_file]
```
**NOT IMPLEMENTED**
Create a list of URIs. You provide a file with class URIs, and a URL for VIVO.
The tool will make requests of VIVOs ListRDF API, and write the results to the URI list file.

```
vivosnap prepare session-list [uri_list_file] [account_email] [account_password] [session_list_file]
vivosnap.rb prepare session-list [uri_list_file] [account_email] [account_password] [session_list_file]
```
**NOT IMPLEMENTED**
Create a session list.
You provide a file of URIs, and the tool will generate the URLs needed to fetch the profile pages for those URIs.
If you want a login on each session, provide the email address and password of the desired login account.

```
vivosnap prepare self-editor-account [VIVO_homepage_URL] [uri_list_file] [admin_email] [admin_password] [editor_email] [editor_password]
vivosnap.rb prepare self-editor-account [VIVO_homepage_URL] [uri_list_file] [admin_email] [admin_password] [editor_email] [editor_password]
```
**NOT IMPLEMENTED**
Write triples to the user accounts model of the VIVO to create the self-editor-account (unless it exists already)
and to make it a proxy editor for all of the URLs in the list.

```
vivosnap prepare sub-list [session_list_file] [count] [sub_list_file]
vivosnap.rb prepare sub-list [session_list_file] [count] [sub_list_file]
```
**NOT IMPLEMENTED**
Create a smaller session list from an existing one.
The new list will have the specified number of entries, extracted at even intervals from the existing list.

```
vivosnap capture [VIVO_homepage_URL] [session_list_file] [responses_directory] {OVERWRITE|REPLACE}
vivosnap.rb capture [VIVO_homepage_URL] [session_list_file] [responses_directory] {OVERWRITE|REPLACE}
```
**NOT IMPLEMENTED**
Capture a snapshot. Provide the URL of the VIVO home page, and a session list, and the tool will
make the requests, storing the responses in the given directory.
If the responses directory does not exist, it will be created, providing its parent directory exists.
Expand All @@ -68,32 +73,42 @@ If the responses directory is not empty, you must specify either OVERWRITE or RE
- REPLACE deletes the contents of the directory before running.

```
vivosnap compare [reference_responses_directory] [test_responses_directory] {expected_changes_file} [differences_directory]
vivosnap.rb compare [reference_responses_directory] [test_responses_directory] {expected_changes_file} [differences_directory]
```
**NOT IMPLEMENTED**
Compare two snapshots.
The test snapshot is expected to be a subset of the reference snapshot (or equivalent), taken at a later time.
The list of expected changes, if present, will be applied when comparing responses.
The differences between the snapshots will be stored in the given directory.

```
vivosnap re-compare [differences_directory] [expected_changes_file] [new_differences_directory]
vivosnap.rb compare again [differences_directory] [expected_changes_file] [new_differences_directory]
```
**NOT IMPLEMENTED**
Re-compare just the differences between two snapshots, presumably with a different list of expected changes.
The original snapshot directories must still exist, because the differences directory will reference them.

```
vivosnap.rb display [differences_directory]
```
**NOT IMPLEMENTED**
A simple tool that allows you to view differences. You must configure your DIFF tool. Note that this
does not allow for expected changes.


## Data structure details

### Session list
Here is a silly pseudo-syntax. URLs are all relative to the VIVO home page.
```
line session
session [login ==> ] request [ ==> request ]*
login LOGIN email pass
request url [method | header | parameter]*
method GET | POST
header key(value)
parameter key=value
value must be in single quotes if contains space
Here is a pseudo-syntax. URLs are all relative to the VIVO home page.
```
line === session
session === [login ==> ] request [ ==> request ]*
login === LOGIN email pass
request === url [method | header | parameter]*
method === GET | POST
header === key(value)
parameter === key=value
value === must be in single quotes if contains space
```

#### Examples
Expand Down
9 changes: 9 additions & 0 deletions cmd_capture/cmd_capture.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CmdCapture
def initialize(args)
bogus "CmdCapture.initialize NOT IMPLEMENTED"
end

def run()
bogus "CmdCapture.run NOT IMPLEMENTED"
end
end
9 changes: 9 additions & 0 deletions cmd_compare/cmd_compare.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CmdCompare
def initialize(args)
bogus "CmdCompare.initialize NOT IMPLEMENTED"
end

def run()
bogus "CmdCompare.run NOT IMPLEMENTED"
end
end
10 changes: 10 additions & 0 deletions cmd_compare_again/cmd_compare_again.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CmdCompareAgain
def initialize(args)
bogus "CmdCompareAgain.initialize NOT IMPLEMENTED"
end

def run()
bogus "CmdCompareAgain.run NOT IMPLEMENTED"
end
end

10 changes: 10 additions & 0 deletions cmd_display/cmd_display.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CmdDisplay
def initialize(args)
bogus "CmdDisplay.initialize NOT IMPLEMENTED"
end

def run()
bogus "CmdDisplay.run NOT IMPLEMENTED"
end
end

10 changes: 10 additions & 0 deletions cmd_prepare_self_editor_account/cmd_prepare_self_editor_account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CmdPrepareSelfEditorAccount
def initialize(args)
bogus "CmdPrepareSelfEditorAccount.initialize NOT IMPLEMENTED"
end

def run()
bogus "CmdPrepareSelfEditorAccount.run NOT IMPLEMENTED"
end
end

10 changes: 10 additions & 0 deletions cmd_prepare_session_list/cmd_prepare_session_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CmdPrepareSessionList
def initialize(args)
bogus "CmdPrepareSessionList.initialize NOT IMPLEMENTED"
end

def run()
bogus "CmdPrepareSessionList.run NOT IMPLEMENTED"
end
end

10 changes: 10 additions & 0 deletions cmd_prepare_sub_list/cmd_prepare_sub_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CmdPrepareSubList
def initialize(args)
bogus "CmdPrepareSubList.initialize NOT IMPLEMENTED"
end

def run()
bogus "CmdPrepareSubList.run NOT IMPLEMENTED"
end
end

9 changes: 9 additions & 0 deletions cmd_prepare_uri_list/cmd_prepare_uri_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CmdPrepareUriList
def initialize(args)
bogus "CmdPrepareUriList.initialize NOT IMPLEMENTED"
end

def run()
bogus "CmdPrepareUriList.run NOT IMPLEMENTED"
end
end
27 changes: 27 additions & 0 deletions common.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Helpful classes and utility methods.
#
class UserInputError < StandardError
end

class SettingsError < StandardError
end

def warning(message)
puts("WARNING: #{message}")
end

module Kernel
def bogus(message)
puts(">>>>>>>>>>>>>BOGUS #{message}")
end
end

require_relative 'cmd_prepare_uri_list/cmd_prepare_uri_list'
require_relative 'cmd_prepare_session_list/cmd_prepare_session_list'
require_relative 'cmd_prepare_self_editor_account/cmd_prepare_self_editor_account'
require_relative 'cmd_prepare_sub_list/cmd_prepare_sub_list'
require_relative 'cmd_capture/cmd_capture'
require_relative 'cmd_compare/cmd_compare'
require_relative 'cmd_compare_again/cmd_compare_again'
require_relative 'cmd_display/cmd_display'
51 changes: 51 additions & 0 deletions vivosnap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /usr/bin/env ruby

require_relative 'common'

class Vivosnap
COMMANDS = [
[:CmdPrepareUriList, ['prepare', 'uri-list']],
[:CmdPrepareSessionList, ['prepare', 'session-list']],
[:CmdPrepareSelfEditorAccount, ['prepare', 'self-editor-account']],
[:CmdPrepareSubList, ['prepare', 'sub-list']],
[:CmdCapture, ['capture']],
[:CmdCompareAgain, ['compare', 'again']],
[:CmdCompare, ['compare']],
[:CmdDisplay, ['display']]
]

def initialize(args)
COMMANDS.each do |cmd|
cmd_args = cmd[1]
matching_args = args.take(cmd_args.size)
remaining_args = args.drop(cmd_args.size)
if cmd_args == matching_args
@cmd_instance = Object.const_get(cmd[0]).new(remaining_args)
return
end
end
raise UserInputError.new("Arguments not valid: #{args.join(' ')}\nValid choices are #{format_cmds}")
end

def format_cmds()
"\n #{COMMANDS.map {|c| c[1].join(' ') }.join("\n ")}"
end

def run()
@cmd_instance.run()
end
end

#
# ---------------------------------------------------------
# MAIN ROUTINE
# ---------------------------------------------------------
#

begin
Vivosnap.new(ARGV).run
rescue UserInputError
puts
puts $!
puts
end

0 comments on commit 8a68b2e

Please sign in to comment.