caruby-scat 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- caruby-scat (1.1.1)
4
+ caruby-scat (1.2.1)
5
5
  bundler
6
- caruby-tissue (>= 2.1.4)
6
+ caruby-small
7
7
  haml
8
8
  jruby-openssl
9
9
  rack
10
10
  redis
11
11
  redis-store
12
12
  sinatra
13
- sinatra-authorization
14
13
 
15
14
  PATH
16
15
  remote: /Users/loneyf/workspace/caruby/core
@@ -22,6 +21,17 @@ PATH
22
21
  jinx-migrate (>= 2.1.1)
23
22
  rdbi
24
23
 
24
+ PATH
25
+ remote: /Users/loneyf/workspace/caruby/small
26
+ specs:
27
+ caruby-small (1.1.2)
28
+ bundler
29
+ caruby-tissue (>= 2.1.5)
30
+ jruby-openssl
31
+ rack
32
+ sinatra
33
+ sinatra-authorization
34
+
25
35
  PATH
26
36
  remote: /Users/loneyf/workspace/caruby/tissue
27
37
  specs:
@@ -39,7 +49,7 @@ PATH
39
49
  PATH
40
50
  remote: /Users/loneyf/workspace/jinx/json
41
51
  specs:
42
- jinx-json (2.1.2)
52
+ jinx-json (2.1.3)
43
53
  bundler
44
54
  jinx
45
55
  json_pure
@@ -57,7 +67,7 @@ GEM
57
67
  rack-test (>= 0.5.4)
58
68
  selenium-webdriver (~> 2.0)
59
69
  xpath (~> 0.1.4)
60
- childprocess (0.3.2)
70
+ childprocess (0.3.3)
61
71
  ffi (~> 1.0.6)
62
72
  columnize (0.3.6)
63
73
  cucumber (1.2.1)
@@ -70,7 +80,7 @@ GEM
70
80
  extensional (1.3.1)
71
81
  fastercsv (1.5.5)
72
82
  ffi (1.0.11-java)
73
- gherkin (2.11.0-java)
83
+ gherkin (2.11.1-java)
74
84
  json (>= 1.4.6)
75
85
  haml (3.1.6)
76
86
  jinx-migrate (2.1.2)
@@ -85,12 +95,12 @@ GEM
85
95
  addressable (~> 2.2.6)
86
96
  ffi (~> 1.0.9)
87
97
  spoon (~> 0.0.1)
88
- libwebsocket (0.1.3)
98
+ libwebsocket (0.1.4)
89
99
  addressable
90
100
  methlab (0.1.0)
91
- mime-types (1.18)
101
+ mime-types (1.19)
92
102
  multi_json (1.3.6)
93
- nokogiri (1.5.4-java)
103
+ nokogiri (1.5.5-java)
94
104
  rack (1.4.1)
95
105
  rack-test (0.6.1)
96
106
  rack (>= 1.0)
@@ -102,22 +112,21 @@ GEM
102
112
  redis (3.0.1)
103
113
  redis-store (1.1.1)
104
114
  redis (>= 2.2.0)
105
- rspec (2.10.0)
106
- rspec-core (~> 2.10.0)
107
- rspec-expectations (~> 2.10.0)
108
- rspec-mocks (~> 2.10.0)
109
- rspec-core (2.10.1)
110
- rspec-expectations (2.10.0)
115
+ rspec (2.11.0)
116
+ rspec-core (~> 2.11.0)
117
+ rspec-expectations (~> 2.11.0)
118
+ rspec-mocks (~> 2.11.0)
119
+ rspec-core (2.11.0)
120
+ rspec-expectations (2.11.1)
111
121
  diff-lcs (~> 1.1.3)
112
- rspec-mocks (2.10.1)
122
+ rspec-mocks (2.11.1)
113
123
  ruby-debug (0.10.4)
114
124
  columnize (>= 0.1)
115
125
  ruby-debug-base (~> 0.10.4.0)
116
126
  ruby-debug-base (0.10.4-java)
117
127
  rubyzip (0.9.9)
118
- selenium-webdriver (2.22.2)
128
+ selenium-webdriver (2.24.0)
119
129
  childprocess (>= 0.2.5)
120
- ffi (~> 1.0)
121
130
  libwebsocket (~> 0.1.3)
122
131
  multi_json (~> 1.0)
123
132
  rubyzip
@@ -144,6 +153,7 @@ DEPENDENCIES
144
153
  capybara
145
154
  caruby-core!
146
155
  caruby-scat!
156
+ caruby-small!
147
157
  caruby-tissue!
148
158
  cucumber
149
159
  jinx!
data/History.md CHANGED
@@ -1,5 +1,9 @@
1
1
  This history lists major release themes. See the git commits for change details.
2
2
 
3
+ 1.2.2 / 2012-07-18
4
+ ------------------
5
+ * Add scat executable.
6
+
3
7
  1.2.1 / 2012-06-18
4
8
  ------------------
5
9
  * Preserve fields.
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- Scat: a _S_imple _caT_issue application
2
- =============================================
1
+ Scat: a <em>S</em>imple <em>caT</em>issue application
2
+ ===========================================
3
3
  **Git**: [http://github.com/caruby/scat](http://github.com/caruby/scat)
4
4
  **Author**: OHSU Knight Cancer Institute
5
5
  **Copyright**: 2012
@@ -29,28 +29,28 @@ Features
29
29
 
30
30
  Requirements
31
31
  ------------
32
- The current Scat release requires the caTissue API client and Linux.
33
-
34
- After installation, the supported caTissue versions are listed by the following command:
35
-
36
- crtsmoke --version
32
+ The current Scat release only runs on Linux.
37
33
 
38
34
  Installation
39
35
  ------------
40
36
  Scat is installed on a caTissue server as a JRuby gem:
41
37
 
42
- sudo jgem install caruby-scat
38
+ `sudo jgem install caruby-scat`
39
+
40
+ See the caRuby Tissue [FAQ](http://caruby.tenderapp.com/kb) for configuring the caTissue API client.
43
41
 
44
- The log file is +/var/log/scat.log+. Ensure that the +/var/log+ directory is writable.
42
+ The log file is `/var/log/scat.log`. Ensure that the `/var/log` directory is writable
43
+ by the Linux user which starts Scat. The preferred Linux way to do this is to make `/var/log`
44
+ owned and writable by the `adm` group and add the user to that group.
45
45
 
46
46
  Usage
47
47
  -----
48
- 1. Execute +crtscat+ to start Scat.
48
+ 1. Execute `scat` in a console to start Scat.
49
49
 
50
- 2. Open a web browser on +http:://+_server_+:4567/+, where _server_ is the name of your server.
50
+ 2. Open a web browser on `http:://server:4567/`, where _server_ is the name of your server.
51
51
 
52
- 3. Scat starts on the specimen edit page. Hover over the edit form entry question mark to
53
- describe the field. Enter values for each field.
52
+ 3. Scat starts on the specimen edit page (see the screen shot below). Hover over the edit form
53
+ entry question mark to describe the field. Enter values for each field.
54
54
 
55
55
  4. Enter five or more letters in the Diagnosis or Tissue Site and wait briefly to
56
56
  bring up a list of matching caTissue values.
@@ -64,47 +64,63 @@ Within a session, the first save takes a while to find the Collection Protocol,
64
64
  other information. Subsequent saves are faster. Successive creation of new specimens
65
65
  for the same patient and pathology report are considerably faster.
66
66
 
67
+ Screen Shot:
68
+
69
+ ![alt text](https://github.com/caruby/scat/blob/master/doc/Scat.tiff?raw=true "The Scat display")
70
+
67
71
  Customization
68
72
  -------------
69
73
  Scat is a reference implementation which captures minimal specimen information. Adding
70
74
  edit fields is done in a single simple text configuration file.
71
75
 
72
- Enhance Scat for your own site as follows:
76
+ There are two ways to enhance Scat for your own site:
77
+
78
+ The quick-and-dirty approach:
79
+
80
+ 1. Edit the following file:
81
+
82
+ <pre>`jgem environment gemdir`/gems/caruby-scat*/conf/fields.yaml</pre>
83
+
84
+ 2. Add or remove fields to display.
85
+
86
+ 3. Refresh the Scat edit page.
87
+
88
+ The safe-and-sane approach:
73
89
 
74
90
  1. Install [git](http://git-scm.com/) on your workstation if necessary.
75
91
 
76
- 2. Install Scat as described in the Installation section above.
92
+ 2. Make a workspace directory on your workstation.
77
93
 
78
- 3. Make a workspace directory on your workstation.
94
+ 3. From that directory, execute the following:
79
95
 
80
- 4. From that directory, execute +git clone git://github.com/caruby/scat.git+
96
+ `git clone git://github.com/caruby/scat.git`
81
97
 
82
- 5. Modify the +conf/fields.yaml+ configuration file to add edit fields.
98
+ 4. Modify the `conf/fields.yaml` configuration file to add edit fields.
83
99
 
84
- 6. Modify the +scat/public/stylesheets/scat.css+ file to change the web display.
100
+ 5. Modify the `scat/public/stylesheets/scat.css` file to change the web display.
85
101
 
86
- 7. Add views and routes to this [Sinatra](http://www.sinatrarb.com/) application as you see fit.
102
+ 6. Add views and routes to this [Sinatra](http://www.sinatrarb.com/) application as you see fit.
87
103
 
88
- 8. Run Scat with your changes by executing the following in the workspace +scat+ directory:
104
+ 7. Run Scat with your changes by executing the following in the workspace `scat` directory:
89
105
 
90
- rackup
106
+ `rackup`
91
107
 
92
- 9. See your changes by opening a web browser on +http://localhost:4567/+.
108
+ 8. See your changes by opening a web browser on `http://localhost:4567/`.
93
109
 
94
- 11. Change the version number in the +lib/scat/version.rb+ file by appending a branch number,
95
- e.g. change the base version +1.2.2+ to +1.2.2.1+
110
+ 9. When you are satisfied with the changes, bump the version number in the `lib/scat/version.rb`
111
+ file by appending a branch number, e.g. change the base version `1.2.2` to `1.2.2.1`.
96
112
 
97
113
  10. Package your changes by executing the following:
98
114
 
99
- rake gem
115
+ `rake gem`
100
116
 
101
117
  11. Copy the resulting gem file to your server.
102
118
 
103
119
  12. On the server, install the new gem, e.g.:
104
120
 
105
- gem install caruby-scat-1.2.2.1.gem
121
+ `gem install caruby-scat-1.2.2.1.gem`
106
122
 
107
- You can make your changes public by forking the Scat repository:
123
+ You can proudly share your changes with the world by forking the Scat repository:
108
124
 
109
125
  1. Register for a [GitHub](https://github.com) account, if you don't already have one.
110
126
 
@@ -114,18 +130,18 @@ You can make your changes public by forking the Scat repository:
114
130
 
115
131
  4. Fork the repository to your GitHub account.
116
132
 
117
- 5. Set the git origin in your workstation +scat+ directory, e.g.:
133
+ 5. Set the git origin in your workstation `scat` directory, e.g.:
118
134
 
119
- git config --replace-all remote.origin.url git@github.com:mygitaccount/scat.git
135
+ `git config --replace-all remote.origin.url git@github.com:mygitaccount/scat.git`
120
136
 
121
137
  6. Commit the changes to your local git repository.
122
138
 
123
139
  7. Push the changes to your fork with the command:
124
140
 
125
- git push origin master
141
+ `git push origin master`
126
142
 
127
143
  Your GitHub fork is publicly visible. You can see other Scat forks by searching on the
128
- term +scat+ in GitHub.
144
+ term `scat` in GitHub.
129
145
 
130
146
 
131
147
 
data/bin/scat CHANGED
@@ -4,4 +4,5 @@
4
4
  #
5
5
 
6
6
  require 'scat'
7
- rackup --env production File.dirname(__FILE__) + '../config.ru'
7
+
8
+ `rackup --env production #{File.dirname(__FILE__) + '/../config.ru'}`
Binary file
@@ -0,0 +1,88 @@
1
+ require 'sinatra/authorization'
2
+
3
+ module Scat
4
+ module Authorization
5
+ include Sinatra::Authorization
6
+ # Runs the given block in an HTTP basic authorization context.
7
+ # The session status is set to the result of performing the given block.
8
+ #
9
+ # @yield perform the caTissue operation and return a status message
10
+ def protect!(&block)
11
+ login_required
12
+ session[:status] = perform!(session[:email], session[:password], &block)
13
+ end
14
+
15
+ # @return [CaTissue::User] the user who is submitting this edit
16
+ # @raise [ArgumentError] if there is no such caTissue user
17
+ def current_user
18
+ # The caTissue login name is the user's email address.
19
+ email = session[:email]
20
+ raise ScatError.new("The caTissue login is not available in this web session.") unless email
21
+ # the current caTissue User
22
+ user = CaTissue::User.new(:email_address => email)
23
+ # the cached caTissue User id
24
+ user_id = session[:user_id]
25
+ if user_id then
26
+ user.identifier = user_id
27
+ else
28
+ # Fetch the User and cache the id.
29
+ raise ScatError.new("User not found: #{user.email_address}") unless user.find
30
+ session[:user_id] = user.identifier
31
+ end
32
+ user
33
+ end
34
+
35
+ # Fix +Sinatra::Authorization.authorization_realm+ per the
36
+ # (https://github.com/sr/sinatra-authorization)[https://github.com/sr/sinatra-authorization]
37
+ # patch.
38
+ def authorization_realm
39
+ settings.authorization_realm
40
+ end
41
+
42
+ private
43
+
44
+ # Obtains the HTML Basic authorization username and password.
45
+ # Formats the caTissue login name as _username_+@+_domain_,
46
+ # where _domain_ is the domain portion of the system +hostname+.
47
+ #
48
+ # @param [String] the caTissue login name, with or without the +@+_domain_ suffix
49
+ # @param [String] the caTissue password
50
+ # @return [Boolean] the authorization result
51
+ def authorize(username, password)
52
+ email = session[:email] = infer_email_address(username)
53
+ session[:password] = password
54
+ # Try to start a session.
55
+ begin
56
+ CaTissue::Database.current.open(email, password) {}
57
+ logger.debug { "Scat captured the caTissue login name #{email} and password." }
58
+ true
59
+ rescue Exception => e
60
+ logger.debug { "Scat caTissue login #{email.qp} with password #{password.qp} is invalid." }
61
+ session[:status] = "caTissue login was unsuccessful - #{e.message}"
62
+ false
63
+ end
64
+ end
65
+
66
+ # Runs the given caTissue operation block with the given caTissue credentials.
67
+ #
68
+ # @yield (see #protect!)
69
+ # @return [String, nil] the status message
70
+ def perform!(email, password, &block)
71
+ login_required
72
+ CaTissue::Database.current.open(email, password, &block)
73
+ end
74
+
75
+ # @param [String] the username, with or without the +@+_domain_ suffix
76
+ # @param [String] the email address
77
+ def infer_email_address(username)
78
+ if username.index('@') then
79
+ username
80
+ else
81
+ # The email domain is the last two components of the hostname, e.g.
82
+ # the prod01.cluster.galena.edu domain is galena.edu.
83
+ domain = `hostname`.chomp[/[^.]+\.[^.]+$/]
84
+ domain.empty? ? username : [username, domain].join('@')
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,3 +1,3 @@
1
1
  module Scat
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
@@ -18,7 +18,7 @@ describe Scat do
18
18
  :malignant => 'Malignant',
19
19
  :quantity => '4'
20
20
  }
21
- @spc = Scat::Edit.instance.save(@params)
21
+ @spc = Scat::Edit.instance.save(@params, {})
22
22
  end
23
23
 
24
24
  subject { @spc }
@@ -39,7 +39,7 @@ describe Scat do
39
39
  before(:all) do
40
40
  oparams = @params.delete_if { |k, v| k == :malignant }
41
41
  oparams[:quantity] = '5'
42
- @other = Scat::Edit.instance.save(oparams)
42
+ @other = Scat::Edit.instance.save(oparams, {})
43
43
  end
44
44
 
45
45
  it "should save the additional specimen" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: caruby-scat
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.1
5
+ version: 1.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - OHSU
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-07-17 00:00:00 Z
13
+ date: 2012-07-18 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -146,12 +146,14 @@ files:
146
146
  - conf/fields.yaml
147
147
  - conf/redis.conf
148
148
  - config.ru
149
+ - doc/Scat.tiff
149
150
  - ext/README.txt
150
151
  - features/edit.feature
151
152
  - features/step_definitions/scat_steps.rb
152
153
  - features/support/env.rb
153
154
  - features/support/seed.rb
154
155
  - lib/scat.rb
156
+ - lib/scat/authorization.rb
155
157
  - lib/scat/autocomplete.rb
156
158
  - lib/scat/cache.rb
157
159
  - lib/scat/configuration.rb