qa 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -21
  3. data/Rakefile +1 -1
  4. data/app/controllers/qa/terms_controller.rb +22 -53
  5. data/config/routes.rb +4 -7
  6. data/lib/qa/authorities.rb +3 -1
  7. data/lib/qa/authorities/base.rb +27 -8
  8. data/lib/qa/authorities/getty.rb +56 -0
  9. data/lib/qa/authorities/loc.rb +27 -131
  10. data/lib/qa/authorities/loc_subauthority.rb +90 -0
  11. data/lib/qa/authorities/local.rb +38 -21
  12. data/lib/qa/authorities/local_subauthority.rb +18 -0
  13. data/lib/qa/authorities/mesh.rb +16 -23
  14. data/lib/qa/authorities/mesh_tools/mesh_data_parser.rb +0 -25
  15. data/lib/qa/authorities/mesh_tools/mesh_importer.rb +0 -2
  16. data/lib/qa/authorities/oclcts.rb +17 -24
  17. data/lib/qa/authorities/tgnlang.rb +4 -18
  18. data/lib/qa/authorities/web_service_base.rb +3 -10
  19. data/lib/qa/version.rb +1 -1
  20. data/spec/controllers/terms_controller_spec.rb +93 -44
  21. data/spec/fixtures/aat-response.txt +108 -0
  22. data/spec/fixtures/getty-aat-find-response.json +2494 -0
  23. data/spec/fixtures/loc-response.txt +1521 -17
  24. data/spec/fixtures/loc-subject-find-response.txt +24 -0
  25. data/spec/internal/Gemfile +16 -13
  26. data/spec/internal/Gemfile.lock +121 -86
  27. data/spec/internal/app/assets/javascripts/application.js +1 -1
  28. data/spec/internal/app/assets/stylesheets/application.css +1 -1
  29. data/spec/internal/bin/rails +1 -5
  30. data/spec/internal/bin/rake +0 -4
  31. data/spec/internal/bin/setup +29 -0
  32. data/spec/internal/config.ru +1 -1
  33. data/spec/internal/config/application.rb +3 -0
  34. data/spec/internal/config/boot.rb +1 -2
  35. data/spec/internal/config/environments/development.rb +4 -0
  36. data/spec/internal/config/environments/production.rb +14 -18
  37. data/spec/internal/config/environments/test.rb +5 -2
  38. data/spec/internal/config/initializers/assets.rb +11 -0
  39. data/spec/internal/config/initializers/cookies_serializer.rb +1 -1
  40. data/spec/internal/config/secrets.yml +2 -2
  41. data/spec/internal/db/development.sqlite3 +0 -0
  42. data/spec/internal/db/migrate/{20140620210534_create_qa_subject_mesh_terms.qa.rb → 20150311214117_create_qa_subject_mesh_terms.qa.rb} +0 -0
  43. data/spec/internal/db/migrate/{20140620210535_create_qa_mesh_tree.qa.rb → 20150311214118_create_qa_mesh_tree.qa.rb} +0 -0
  44. data/spec/internal/db/migrate/{20140620210536_add_term_lower_to_qa_subject_mesh_terms.qa.rb → 20150311214119_add_term_lower_to_qa_subject_mesh_terms.qa.rb} +0 -0
  45. data/spec/internal/db/schema.rb +3 -3
  46. data/spec/internal/db/test.sqlite3 +0 -0
  47. data/spec/internal/lib/generators/test_app_generator.rb +0 -1
  48. data/spec/internal/log/development.log +498 -207
  49. data/spec/internal/test/test_helper.rb +0 -3
  50. data/spec/lib/authorities_getty_spec.rb +71 -0
  51. data/spec/lib/authorities_loc_spec.rb +98 -65
  52. data/spec/lib/authorities_loc_subauthorities.rb +81 -0
  53. data/spec/lib/authorities_local_spec.rb +53 -79
  54. data/spec/lib/authorities_local_subauthorities_spec.rb +43 -0
  55. data/spec/lib/authorities_mesh_spec.rb +16 -12
  56. data/spec/lib/authorities_oclcts_spec.rb +17 -17
  57. data/spec/lib/authorities_tgnlang_spec.rb +4 -7
  58. data/spec/lib/mesh_data_parser_spec.rb +13 -13
  59. data/spec/lib/tasks/mesh.rake_spec.rb +4 -4
  60. data/spec/models/subject_mesh_term_spec.rb +5 -5
  61. data/spec/routing/route_spec.rb +34 -0
  62. data/spec/spec_helper.rb +5 -22
  63. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -1
  64. metadata +44 -12
  65. data/lib/qa/authorities/local/subauthority.rb +0 -65
  66. data/spec/internal/bin/spring +0 -18
@@ -1,65 +0,0 @@
1
- module Qa::Authorities
2
- # This is really just a sub-authority for Local
3
- class Subauthority
4
- attr_reader :name
5
- def initialize(name)
6
- @name = name
7
- end
8
-
9
- def terms
10
- @terms ||= load_sub_authority_terms
11
- end
12
-
13
- def search(q)
14
- r = q.blank? ? terms : terms.select { |term| /\b#{q.downcase}/.match(term[:term].downcase) }
15
- r.map do |res|
16
- { :id => res[:id], :label => res[:term] }.with_indifferent_access
17
- end
18
- end
19
-
20
- def full_record(id)
21
- terms.find { |term| term[:id] == id } || {}
22
- end
23
-
24
- class << self
25
- def sub_authorities_path
26
- config_path = AUTHORITIES_CONFIG[:local_path]
27
- if config_path.starts_with?(File::Separator)
28
- return config_path
29
- end
30
- File.join(Rails.root, config_path)
31
- end
32
-
33
- def names
34
- @sub_auth_names ||=
35
- begin
36
- sub_auths = []
37
- Dir.foreach(sub_authorities_path) { |file| sub_auths << File.basename(file, File.extname(file)) }
38
- sub_auths
39
- end
40
- end
41
- end
42
-
43
- private
44
- def load_sub_authority_terms
45
- sub_authority_hash = YAML.load(File.read(sub_authority_filename))
46
- terms = sub_authority_hash.with_indifferent_access.fetch(:terms, [])
47
- normalize_terms(terms)
48
- end
49
-
50
- def sub_authority_filename
51
- File.join(self.class.sub_authorities_path, "#{name}.yml")
52
- end
53
-
54
- def normalize_terms(terms)
55
- terms.map do |term|
56
- if term.is_a? String
57
- { :id => term, :term => term }.with_indifferent_access
58
- else
59
- term[:id] ||= term[:term]
60
- term
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This file loads spring without using Bundler, in order to be fast
4
- # It gets overwritten when you run the `spring binstub` command
5
-
6
- unless defined?(Spring)
7
- require "rubygems"
8
- require "bundler"
9
-
10
- if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
11
- ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12
- ENV["GEM_HOME"] = ""
13
- Gem.paths = ENV
14
-
15
- gem "spring", match[1]
16
- require "spring/binstub"
17
- end
18
- end