qa 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -13
  3. data/lib/generators/qa/install/USAGE +2 -0
  4. data/lib/generators/qa/install/install_generator.rb +2 -1
  5. data/lib/generators/qa/local/USAGE +5 -0
  6. data/lib/generators/qa/local/local_generator.rb +9 -0
  7. data/lib/generators/qa/local/templates/config/authorities.yml +1 -0
  8. data/lib/generators/qa/local/templates/config/authorities/states.yml +101 -0
  9. data/lib/qa/authorities/local.rb +3 -1
  10. data/lib/qa/version.rb +1 -1
  11. data/spec/controllers/terms_controller_spec.rb +13 -3
  12. data/spec/internal/Gemfile +11 -16
  13. data/spec/internal/Gemfile.lock +51 -44
  14. data/spec/internal/Rakefile +1 -1
  15. data/spec/internal/app/assets/stylesheets/application.css +5 -3
  16. data/spec/internal/app/views/layouts/application.html.erb +2 -2
  17. data/spec/internal/bin/rails +4 -0
  18. data/spec/internal/bin/rake +4 -0
  19. data/spec/internal/bin/spring +18 -0
  20. data/spec/internal/config/authorities.yml +1 -0
  21. data/spec/internal/config/authorities/authority_A.yml +10 -0
  22. data/spec/internal/config/authorities/authority_B.yml +7 -0
  23. data/spec/internal/config/authorities/authority_C.yml +4 -0
  24. data/spec/internal/config/authorities/authority_D.yml +4 -0
  25. data/spec/internal/config/authorities/states.yml +101 -0
  26. data/spec/internal/config/database.yml +8 -8
  27. data/spec/internal/config/environment.rb +1 -1
  28. data/spec/internal/config/environments/development.rb +10 -2
  29. data/spec/internal/config/environments/production.rb +6 -3
  30. data/spec/internal/config/environments/test.rb +5 -2
  31. data/spec/internal/config/initializers/cookies_serializer.rb +3 -0
  32. data/spec/internal/config/initializers/mime_types.rb +0 -1
  33. data/spec/internal/config/initializers/session_store.rb +1 -1
  34. data/spec/internal/config/routes.rb +1 -1
  35. data/spec/internal/config/secrets.yml +22 -0
  36. data/spec/internal/db/development.sqlite3 +0 -0
  37. data/spec/internal/db/migrate/{20140611161143_create_qa_subject_mesh_terms.qa.rb → 20140620210534_create_qa_subject_mesh_terms.qa.rb} +0 -0
  38. data/spec/internal/db/migrate/{20140611161144_create_qa_mesh_tree.qa.rb → 20140620210535_create_qa_mesh_tree.qa.rb} +0 -0
  39. data/spec/internal/db/migrate/{20140611161145_add_term_lower_to_qa_subject_mesh_terms.qa.rb → 20140620210536_add_term_lower_to_qa_subject_mesh_terms.qa.rb} +0 -0
  40. data/spec/internal/db/schema.rb +1 -1
  41. data/spec/internal/db/test.sqlite3 +0 -0
  42. data/spec/internal/lib/generators/test_app_generator.rb +9 -1
  43. data/spec/internal/log/development.log +339 -206
  44. data/spec/internal/public/404.html +20 -11
  45. data/spec/internal/public/422.html +20 -11
  46. data/spec/internal/public/500.html +19 -10
  47. data/spec/internal/test/test_helper.rb +1 -3
  48. data/spec/lib/authorities_local_spec.rb +0 -4
  49. data/spec/spec_helper.rb +0 -4
  50. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -1
  51. metadata +40 -14
  52. data/spec/internal/config/initializers/secret_token.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8822d1805cf5688f8efa87ccabaf20d5e84a07dd
4
- data.tar.gz: 97edb3df48fa497fafaa6e82c7a98b793cbe952b
3
+ metadata.gz: 5476914ef50c24ee9e61ae4de9b22256afb74f14
4
+ data.tar.gz: 14ccb1b89224b5f8b7c92c795ace430059d8f869
5
5
  SHA512:
6
- metadata.gz: 4f271ed20bc568662f0f74a84804b6eb23c659f9894dc0719bd567210b501dec1a93c733d51aee9260519ee59ae1518e07726eaa56ad2716af0e3bd1adc20a5e
7
- data.tar.gz: eb5de6d6f4f892d8661568a6e889cb22ca408acc2957a19a308261763383ab34fc1661dc35b2758775dcdde92d0f0d59b4c7f7867a4a8f77ecddf7d266778022
6
+ metadata.gz: fedee18c0bfe503d1cc4d9f2d67515a012d28e826bcd0aa64e01e0802649923c1c92529104d52ba8fd2c2ac9b4504a76bf23f72b0670e345ef6dce3a2af231da
7
+ data.tar.gz: 112f321514ff9bb46fc832f0b3cdb8a60dcc0283f68afc530b0ddafaf156e7501e7d52d7139aa07f1435c3c7fb330d6ac16f0773511c761f6e2f7dbff4c984fd
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Questioning Authority
2
2
 
3
- [![Build Status](https://travis-ci.org/projecthydra/questioning_authority.png?branch=master)](https://travis-ci.org/projecthydra/questioning_authority) [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa)
3
+ [![Build Status](https://travis-ci.org/projecthydra-labs/questioning_authority.png?branch=master)](https://travis-ci.org/projecthydra-labs/questioning_authority) [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa)
4
4
 
5
5
  You should question your authorities.
6
6
 
@@ -28,7 +28,7 @@ as return a complete list of terms.
28
28
  Some authorities, such as Library of Congress, allow sub-authorities which is an additional parameter that
29
29
  further defines the kind of authority to use with the context of a larger one.
30
30
 
31
- ## How do use this?
31
+ ## How do I use this?
32
32
 
33
33
  Add the gem to your Gemfile
34
34
 
@@ -111,19 +111,38 @@ QA then presents this data to you in JSON format:
111
111
  etc...
112
112
  ]
113
113
 
114
- # Local Authority Files
114
+ ### Local Authorities
115
115
 
116
- ### YAML file of terms
116
+ For simple use cases when you have a few terms that don't change very often.
117
117
 
118
- #### Location and Naming Convention
118
+ Run the generator to install configuration files and an example authority.
119
119
 
120
- Local authorities are specified in YAML files, one for each sub-authority. By default, local
121
- authority YAML files are located in config/authorities/ . This location can be changed by editing
122
- the :local_path entry in config/authorities.yml. Relative paths are assumed to be relative to
123
- Rails.root.
120
+ rails generate qa:local
124
121
 
125
- Local authority YAML files are named for the sub-authority they represent. For example, a YAML file
126
- for the "states" sub-authority would be named states.yml.
122
+ This will install a sample states authority file that lists all the states in the U.S. To query it,
123
+
124
+ /qa/search/local/states?q=Nor
125
+
126
+ Results are in JSON.
127
+
128
+ [{"id":"NC","label":"North Carolina"},{"id":"ND","label":"North Dakota"}]
129
+
130
+ The entire list can also be returned using:
131
+
132
+ /qa/terms/local/states/
133
+
134
+ Local authorities are stored as YAML files, one for each sub-authority. By default, local
135
+ authority YAML files are located in `config/authorities/`. This location can be changed by editing
136
+ the `:local_path` entry in `config/authorities.yml`. Relative paths are assumed to be relative to
137
+ `Rails.root`.
138
+
139
+ Local authority YAML files are named for the sub-authority they represent. The included example "states" sub-authority
140
+ is named states.yml.
141
+
142
+ To create your own local authority, create a .yml file, place it in the configured directory and query it
143
+ using the file's name as the sub-authority. For example, if I create `foo.yml`, I would then search it using:
144
+
145
+ /qa/search/local/foo?q=search_term
127
146
 
128
147
  #### Supported formats
129
148
 
@@ -174,9 +193,9 @@ To develop this gem, clone the repository, then run:
174
193
  This will install the gems, create a dummy application under spec/internal and run the tests. After you've made changes, remove the entire spec/internal
175
194
  directory so that further tests and run against a new dummy application.
176
195
 
177
- ## Dependencies and Compatability
196
+ ## Compatability
178
197
 
179
- Rails 4
198
+ Currently, it is compatible with Rails 4.0 and 4.1 under both Ruby 2.0 and 2.1.
180
199
 
181
200
  # Help
182
201
 
@@ -1,5 +1,7 @@
1
1
  Description:
2
2
  Installs QA into your rails application.
3
+ * adds the routes to your config/routes file
4
+ * adds the oclcts config file for using that authority
3
5
 
4
6
  Example:
5
7
  rails generate qa:install
@@ -7,7 +7,8 @@ class Qa::InstallGenerator < Rails::Generators::Base
7
7
  end
8
8
  end
9
9
 
10
- def copy_configs
10
+ def copy_oclcts_configs
11
11
  copy_file "config/oclcts-authorities.yml", "config/oclcts-authorities.yml"
12
12
  end
13
+
13
14
  end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Installs the configuration files for local authorities. Includes an example states.yml file for reference.
3
+
4
+ Example:
5
+ rails generate qa:local
@@ -0,0 +1,9 @@
1
+ class Qa::LocalGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def copy_local_authority_configs
5
+ copy_file "config/authorities.yml", "config/authorities.yml"
6
+ directory "config/authorities"
7
+ end
8
+
9
+ end
@@ -0,0 +1 @@
1
+ :local_path: "config/authorities"
@@ -0,0 +1,101 @@
1
+ :terms:
2
+ - :id: AL
3
+ :term: Alabama
4
+ - :id: AK
5
+ :term: Alaska
6
+ - :id: AZ
7
+ :term: Arizona
8
+ - :id: AR
9
+ :term: Arkansas
10
+ - :id: CA
11
+ :term: California
12
+ - :id: CO
13
+ :term: Colorado
14
+ - :id: CT
15
+ :term: Connecticut
16
+ - :id: DE
17
+ :term: Delaware
18
+ - :id: FL
19
+ :term: Florida
20
+ - :id: GA
21
+ :term: Georgia
22
+ - :id: HI
23
+ :term: Hawaii
24
+ - :id: ID
25
+ :term: Idaho
26
+ - :id: IL
27
+ :term: Illinois
28
+ - :id: IN
29
+ :term: Indiana
30
+ - :id: IA
31
+ :term: Iowa
32
+ - :id: KS
33
+ :term: Kansas
34
+ - :id: KY
35
+ :term: Kentucky
36
+ - :id: LA
37
+ :term: Louisana
38
+ - :id: ME
39
+ :term: Maine
40
+ - :id: MD
41
+ :term: Maryland
42
+ - :id: MA
43
+ :term: Massachusetts
44
+ - :id: MI
45
+ :term: Michigan
46
+ - :id: MN
47
+ :term: Minnesota
48
+ - :id: MS
49
+ :term: Mississippi
50
+ - :id: MO
51
+ :term: Missouri
52
+ - :id: MT
53
+ :term: Montana
54
+ - :id: NE
55
+ :term: Nebraska
56
+ - :id: NV
57
+ :term: Nevada
58
+ - :id: NH
59
+ :term: New Hampshire
60
+ - :id: NJ
61
+ :term: New Jersey
62
+ - :id: NM
63
+ :term: New Mexico
64
+ - :id: NY
65
+ :term: New York
66
+ - :id: NC
67
+ :term: North Carolina
68
+ - :id: ND
69
+ :term: North Dakota
70
+ - :id: OH
71
+ :term: Ohio
72
+ - :id: OK
73
+ :term: Oklahoma
74
+ - :id: OR
75
+ :term: Oregon
76
+ - :id: PA
77
+ :term: Pennsylvania
78
+ - :id: RI
79
+ :term: Rhode Island
80
+ - :id: SC
81
+ :term: Sourth Carolina
82
+ - :id: SD
83
+ :term: South Dakota
84
+ - :id: TN
85
+ :term: Tennessee
86
+ - :id: TX
87
+ :term: Texas
88
+ - :id: UT
89
+ :term: Utah
90
+ - :id: VT
91
+ :term: Vermont
92
+ - :id: VA
93
+ :term: Virginia
94
+ - :id: WA
95
+ :term: Washington
96
+ - :id: WV
97
+ :term: West Virginia
98
+ - :id: WI
99
+ :term: Wisconsin
100
+ - :id: WY
101
+ :term: Wyoming
@@ -3,6 +3,8 @@ module Qa::Authorities
3
3
  class Local < Qa::Authorities::Base
4
4
  extend Deprecation
5
5
 
6
+ attr_accessor :results
7
+
6
8
  class << self
7
9
  def sub_authority(name)
8
10
  @sub_authorities ||= {}
@@ -22,7 +24,7 @@ module Qa::Authorities
22
24
  delegate :sub_authority, to: self
23
25
 
24
26
  def search(q, sub_authority)
25
- sub_authority(sub_authority).search(q)
27
+ @results = sub_authority(sub_authority).search(q)
26
28
  end
27
29
 
28
30
  def full_record(id, sub_authority)
data/lib/qa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qa
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -32,7 +32,7 @@ describe Qa::TermsController do
32
32
 
33
33
  end
34
34
 
35
- context "with successful queries" do
35
+ context "with a successful query" do
36
36
 
37
37
  before :each do
38
38
  stub_request(:get, "http://id.loc.gov/search/?format=json&q=").
@@ -60,9 +60,19 @@ describe Qa::TermsController do
60
60
 
61
61
  end
62
62
 
63
- describe "#show" do
64
- it "the path resolves"
63
+ context "when returning all terms" do
64
+
65
+ it "should return all local authority state terms" do
66
+ get :index, { :vocab => "local", :sub_authority => "states" }
67
+ response.should be_success
68
+ end
69
+
65
70
  end
66
71
 
67
72
  end
73
+
74
+ describe "#show" do
75
+ it "the path resolves"
76
+ end
77
+
68
78
  end
@@ -1,36 +1,30 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
- gem 'rails', '4.0.5'
5
3
 
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.1.1'
6
6
  # Use sqlite3 as the database for Active Record
7
7
  gem 'sqlite3'
8
-
9
8
  # Use SCSS for stylesheets
10
- gem 'sass-rails', '~> 4.0.2'
11
-
9
+ gem 'sass-rails', '~> 4.0.3'
12
10
  # Use Uglifier as compressor for JavaScript assets
13
11
  gem 'uglifier', '>= 1.3.0'
14
-
15
12
  # Use CoffeeScript for .js.coffee assets and views
16
13
  gem 'coffee-rails', '~> 4.0.0'
17
-
18
14
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
19
- # gem 'therubyracer', platforms: :ruby
15
+ # gem 'therubyracer', platforms: :ruby
20
16
 
21
17
  # Use jquery as the JavaScript library
22
18
  gem 'jquery-rails'
23
-
24
19
  # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
25
20
  gem 'turbolinks'
26
-
27
21
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
28
- gem 'jbuilder', '~> 1.2'
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0', group: :doc
29
25
 
30
- group :doc do
31
- # bundle exec rake doc:rails generates the API under doc/api.
32
- gem 'sdoc', require: false
33
- end
26
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
27
+ gem 'spring', group: :development
34
28
 
35
29
  # Use ActiveModel has_secure_password
36
30
  # gem 'bcrypt', '~> 3.1.7'
@@ -39,8 +33,9 @@ end
39
33
  # gem 'unicorn'
40
34
 
41
35
  # Use Capistrano for deployment
42
- # gem 'capistrano', group: :development
36
+ # gem 'capistrano-rails', group: :development
43
37
 
44
38
  # Use debugger
45
39
  # gem 'debugger', group: [:development, :test]
40
+
46
41
  gem 'qa', :path => '/Users/awead/Projects/Github/projecthydra-labs/questioning_authority'
@@ -1,44 +1,46 @@
1
1
  PATH
2
2
  remote: /Users/awead/Projects/Github/projecthydra-labs/questioning_authority
3
3
  specs:
4
- qa (0.1.0)
4
+ qa (0.2.1)
5
5
  activerecord-import
6
6
  deprecation
7
7
  nokogiri (~> 1.6.0)
8
- rails (~> 4.0.0)
8
+ rails (>= 3.2.13, < 5.0)
9
9
  rest-client
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actionmailer (4.0.5)
15
- actionpack (= 4.0.5)
14
+ actionmailer (4.1.1)
15
+ actionpack (= 4.1.1)
16
+ actionview (= 4.1.1)
16
17
  mail (~> 2.5.4)
17
- actionpack (4.0.5)
18
- activesupport (= 4.0.5)
19
- builder (~> 3.1.0)
20
- erubis (~> 2.7.0)
18
+ actionpack (4.1.1)
19
+ actionview (= 4.1.1)
20
+ activesupport (= 4.1.1)
21
21
  rack (~> 1.5.2)
22
22
  rack-test (~> 0.6.2)
23
- activemodel (4.0.5)
24
- activesupport (= 4.0.5)
25
- builder (~> 3.1.0)
26
- activerecord (4.0.5)
27
- activemodel (= 4.0.5)
28
- activerecord-deprecated_finders (~> 1.0.2)
29
- activesupport (= 4.0.5)
30
- arel (~> 4.0.0)
31
- activerecord-deprecated_finders (1.0.3)
23
+ actionview (4.1.1)
24
+ activesupport (= 4.1.1)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ activemodel (4.1.1)
28
+ activesupport (= 4.1.1)
29
+ builder (~> 3.1)
30
+ activerecord (4.1.1)
31
+ activemodel (= 4.1.1)
32
+ activesupport (= 4.1.1)
33
+ arel (~> 5.0.0)
32
34
  activerecord-import (0.5.0)
33
35
  activerecord (>= 3.0)
34
- activesupport (4.0.5)
36
+ activesupport (4.1.1)
35
37
  i18n (~> 0.6, >= 0.6.9)
36
- minitest (~> 4.2)
37
- multi_json (~> 1.3)
38
+ json (~> 1.7, >= 1.7.7)
39
+ minitest (~> 5.1)
38
40
  thread_safe (~> 0.1)
39
- tzinfo (~> 0.3.37)
40
- arel (4.0.2)
41
- builder (3.1.4)
41
+ tzinfo (~> 1.1)
42
+ arel (5.0.1.20140414130214)
43
+ builder (3.2.2)
42
44
  coffee-rails (4.0.1)
43
45
  coffee-script (>= 2.2.0)
44
46
  railties (>= 4.0.0, < 5.0)
@@ -52,9 +54,9 @@ GEM
52
54
  execjs (2.2.0)
53
55
  hike (1.2.3)
54
56
  i18n (0.6.9)
55
- jbuilder (1.5.3)
56
- activesupport (>= 3.0.0)
57
- multi_json (>= 1.2.0)
57
+ jbuilder (2.1.1)
58
+ activesupport (>= 3.0.0, < 5)
59
+ multi_json (~> 1.2)
58
60
  jquery-rails (3.1.0)
59
61
  railties (>= 3.0, < 5.0)
60
62
  thor (>= 0.14, < 2.0)
@@ -64,7 +66,7 @@ GEM
64
66
  treetop (~> 1.4.8)
65
67
  mime-types (1.25.1)
66
68
  mini_portile (0.6.0)
67
- minitest (4.7.5)
69
+ minitest (5.3.5)
68
70
  multi_json (1.10.1)
69
71
  nokogiri (1.6.2.1)
70
72
  mini_portile (= 0.6.0)
@@ -72,17 +74,19 @@ GEM
72
74
  rack (1.5.2)
73
75
  rack-test (0.6.2)
74
76
  rack (>= 1.0)
75
- rails (4.0.5)
76
- actionmailer (= 4.0.5)
77
- actionpack (= 4.0.5)
78
- activerecord (= 4.0.5)
79
- activesupport (= 4.0.5)
77
+ rails (4.1.1)
78
+ actionmailer (= 4.1.1)
79
+ actionpack (= 4.1.1)
80
+ actionview (= 4.1.1)
81
+ activemodel (= 4.1.1)
82
+ activerecord (= 4.1.1)
83
+ activesupport (= 4.1.1)
80
84
  bundler (>= 1.3.0, < 2.0)
81
- railties (= 4.0.5)
82
- sprockets-rails (~> 2.0.0)
83
- railties (4.0.5)
84
- actionpack (= 4.0.5)
85
- activesupport (= 4.0.5)
85
+ railties (= 4.1.1)
86
+ sprockets-rails (~> 2.0)
87
+ railties (4.1.1)
88
+ actionpack (= 4.1.1)
89
+ activesupport (= 4.1.1)
86
90
  rake (>= 0.8.7)
87
91
  thor (>= 0.18.1, < 2.0)
88
92
  rake (10.3.2)
@@ -99,12 +103,13 @@ GEM
99
103
  sdoc (0.4.0)
100
104
  json (~> 1.8)
101
105
  rdoc (~> 4.0, < 5.0)
106
+ spring (1.1.3)
102
107
  sprockets (2.11.0)
103
108
  hike (~> 1.2)
104
109
  multi_json (~> 1.0)
105
110
  rack (~> 1.0)
106
111
  tilt (~> 1.1, != 1.3.0)
107
- sprockets-rails (2.0.1)
112
+ sprockets-rails (2.1.3)
108
113
  actionpack (>= 3.0)
109
114
  activesupport (>= 3.0)
110
115
  sprockets (~> 2.8)
@@ -117,8 +122,9 @@ GEM
117
122
  polyglot (>= 0.3.1)
118
123
  turbolinks (2.2.2)
119
124
  coffee-rails
120
- tzinfo (0.3.39)
121
- uglifier (2.5.0)
125
+ tzinfo (1.2.1)
126
+ thread_safe (~> 0.1)
127
+ uglifier (2.5.1)
122
128
  execjs (>= 0.3.0)
123
129
  json (>= 1.8.0)
124
130
 
@@ -127,12 +133,13 @@ PLATFORMS
127
133
 
128
134
  DEPENDENCIES
129
135
  coffee-rails (~> 4.0.0)
130
- jbuilder (~> 1.2)
136
+ jbuilder (~> 2.0)
131
137
  jquery-rails
132
138
  qa!
133
- rails (= 4.0.5)
134
- sass-rails (~> 4.0.2)
135
- sdoc
139
+ rails (= 4.1.1)
140
+ sass-rails (~> 4.0.3)
141
+ sdoc (~> 0.4.0)
142
+ spring
136
143
  sqlite3
137
144
  turbolinks
138
145
  uglifier (>= 1.3.0)