umlaut_journal_tocs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +37 -0
  4. data/app/item_decorators/umlaut_journal_tocs_decorator.rb +50 -0
  5. data/app/service_adaptors/journal_tocs_adapter.rb +51 -0
  6. data/app/views/umlaut_journal_tocs/_bento_item.html.erb +80 -0
  7. data/app/views/umlaut_journal_tocs/_resolve_section.html.erb +10 -0
  8. data/config/locales/en.yml +5 -0
  9. data/config/routes.rb +2 -0
  10. data/lib/tasks/umlaut_journal_tocs_tasks.rake +4 -0
  11. data/lib/umlaut_journal_tocs.rb +26 -0
  12. data/lib/umlaut_journal_tocs/engine.rb +18 -0
  13. data/lib/umlaut_journal_tocs/version.rb +3 -0
  14. data/test/controller_test.rb +36 -0
  15. data/test/dummy/README.rdoc +28 -0
  16. data/test/dummy/Rakefile +6 -0
  17. data/test/dummy/app/assets/javascripts/application.js +17 -0
  18. data/test/dummy/app/assets/stylesheets/application.css +19 -0
  19. data/test/dummy/app/controllers/application_controller.rb +5 -0
  20. data/test/dummy/app/controllers/umlaut_controller.rb +136 -0
  21. data/test/dummy/app/helpers/application_helper.rb +2 -0
  22. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/test/dummy/bin/bundle +3 -0
  24. data/test/dummy/bin/rails +4 -0
  25. data/test/dummy/bin/rake +4 -0
  26. data/test/dummy/bin/setup +29 -0
  27. data/test/dummy/config.ru +4 -0
  28. data/test/dummy/config/application.rb +26 -0
  29. data/test/dummy/config/boot.rb +5 -0
  30. data/test/dummy/config/database.yml +60 -0
  31. data/test/dummy/config/environment.rb +5 -0
  32. data/test/dummy/config/environments/development.rb +45 -0
  33. data/test/dummy/config/environments/production.rb +83 -0
  34. data/test/dummy/config/environments/test.rb +42 -0
  35. data/test/dummy/config/initializers/assets.rb +11 -0
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  37. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/test/dummy/config/initializers/inflections.rb +16 -0
  40. data/test/dummy/config/initializers/mime_types.rb +4 -0
  41. data/test/dummy/config/initializers/session_store.rb +3 -0
  42. data/test/dummy/config/initializers/umlaut_journal_tocs.rb +20 -0
  43. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/test/dummy/config/locales/en.yml +23 -0
  45. data/test/dummy/config/routes.rb +57 -0
  46. data/test/dummy/config/secrets.yml +22 -0
  47. data/test/dummy/config/umlaut_services.yml +23 -0
  48. data/test/dummy/db/migrate/20150901192508_umlaut_init.umlaut.rb +106 -0
  49. data/test/dummy/db/migrate/20150901192509_umlaut_add_service_response_index.umlaut.rb +10 -0
  50. data/test/dummy/db/schema.rb +118 -0
  51. data/test/dummy/public/404.html +67 -0
  52. data/test/dummy/public/422.html +67 -0
  53. data/test/dummy/public/500.html +66 -0
  54. data/test/dummy/public/favicon.ico +0 -0
  55. data/test/journal_tocs_adapter_test.rb +93 -0
  56. data/test/support/vcr_filter.rb +45 -0
  57. data/test/test_helper.rb +39 -0
  58. data/test/vcr_cassettes/generates_no_response.yml +49 -0
  59. data/test/vcr_cassettes/generates_response.yml +952 -0
  60. data/test/vcr_cassettes/gets_results.yml +804 -0
  61. data/test/vcr_cassettes/registers_proper_error.yml +40 -0
  62. metadata +200 -0
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,136 @@
1
+ require 'umlaut'
2
+
3
+ # Superclass for all Umlaut controllers, to hold default behavior,
4
+ # also hold global configuration. It's a superclass rather than a module,
5
+ # so we can use Rails 3 hieararchical superclass view lookup too if we want,
6
+ # for general umlaut views. And also so local app can over-ride
7
+ # methods here once, and have it apply to all Umlaut controllers.
8
+ # But there's not much magic in here or anything, the
9
+ # common behavior is ordinary methods available to be called, mostly.
10
+ #
11
+ # This class is copied into the local app -- the default implementation
12
+ # does nothing but 'include Umlaut::ControllerBehavior'
13
+ #
14
+ # You will ordinarily set config here, and can also over-ride
15
+ # methods from Umlaut::ControllerBehavior if desired. Or add
16
+ # additional helpers to over-ride Umlaut helpers if needed.
17
+ class UmlautController < ApplicationController
18
+ include Umlaut::ControllerBehavior
19
+
20
+ # Some suggested configuration. More config keys
21
+ # are available, see UmlautConfigurable.set_default_configuration!
22
+ # implementation for list. Configuration actually uses
23
+ # a Confstruct object.
24
+
25
+ umlaut_config.configure do
26
+ # app_name 'Find It'
27
+
28
+ # URL to image to use for link resolver in some self-links,
29
+ # OR name of image asset in local app.
30
+ #link_img_url "http//something"
31
+
32
+ # string used in standard layout footer to identify your app.
33
+ # mark it html_safe if it includes html
34
+ # footer_credit "Find It service provided by <a href='http://www.university.edu/'>My University</a>".html_safe
35
+
36
+
37
+ # Sometimes Umlaut sends out email, what email addr should it be from?
38
+ # from_email_addr 'no_reply@umlaut.example.com'
39
+
40
+ # Local layout for UmlautController's, instead of
41
+ # built in 'umlaut' layout?
42
+ # layout "application"
43
+
44
+ # A help url used on error page and a few other places.
45
+ # help_url "http://www.library.jhu.edu/services/askalib/index.html"
46
+
47
+ # If OpenURL came from manual entry of title/ISSN, and no match is found in
48
+ # link resolver knowledge base, display a warning to the user of potential
49
+ # typo?
50
+ # entry_not_in_kb_warning true
51
+
52
+ # uncomment this line to show localization (language) selector
53
+ # in default umlaut layout header.
54
+ # show_localization_selector true
55
+
56
+ # rfr_ids used for umlaut generated pages.
57
+ # rfr_ids do
58
+ # opensearch "info:sid/umlaut.code4lib.org:opensearch"
59
+ # citation "info:sid/umlaut.code4lib.org:citation"
60
+ # azlist 'info:sid/umlaut.code4lib.org:azlist'
61
+ # end
62
+
63
+ # Referent filters. Sort of like SFX source parsers.
64
+ # hash, key is regexp to match a sid, value is filter object
65
+ # (see lib/referent_filters )
66
+ # add_referent_filters!( :match => /.*/, :filter => DissertationCatch.new )
67
+
68
+ # Turn off permalink-generation? If you don't want it at all, or
69
+ # don't want it temporarily because you are pointing at a database
70
+ # that won't last.
71
+ # create_permalinks false
72
+
73
+ # How many seconds between updates of the background updater for background
74
+ # services?
75
+ # poll_wait_seconds 4
76
+
77
+ # Configuration for the 'search' functions -- A-Z lookup
78
+ # and citation entry.
79
+ search do
80
+ # Is your SFX database connection, defined in database.yml under
81
+ # sfx_db and used for A-Z searches, Sfx4 or do you want to use Sfx4Solr?
82
+ # Other SearchMethods in addition to SFX direct db may be provided later.
83
+ #az_search_method SearchMethods::Sfx4
84
+ #az_search_method SearchMethods::Sfx4Solr::Local
85
+
86
+ # When talking directly to the SFX A-Z list database, you may
87
+ # need to set this, if you have multiple A-Z profiles configured
88
+ # and don't want to use the 'default.
89
+ # sfx_az_profile "default"
90
+
91
+ # can set to "_blank" etc.
92
+ # result_link_target nil
93
+
94
+ # On 0 hits from search screen, ordinarily we redirect to resolve
95
+ # screen becuase Resolve might be able to provide other useful
96
+ # services such as ILL or backed by other KB's. But to instead
97
+ # display a "no results" page, set:
98
+ # display_zero_hit_results true
99
+ end
100
+
101
+ # config only relevant to SFX use
102
+ sfx do
103
+ # base sfx url to use for search actions, error condition backup,
104
+ # and some other purposes. For search actions (A-Z), direct database
105
+ # connection to your SFX db also needs to be defined in database.yml
106
+ # sfx_base_url 'http://sfx.library.jhu.edu:8000/jhu_sfx?'
107
+ #
108
+
109
+
110
+ # Umlaut tries to figure out from the SFX knowledge base
111
+ # which hosts are "SFX controlled", to avoid duplicating SFX
112
+ # urls with urls from catalog. But sometimes it misses some, or
113
+ # alternate hostnames for some. Regexps matching against
114
+ # urls can be included here. Eg,
115
+ # additional_sfx_controlled_urls [
116
+ # %r{^http://([^\.]\.)*pubmedcentral\.com}
117
+ # ]
118
+ # additional_sfx_controlled_urls []
119
+
120
+
121
+ end
122
+
123
+ # You can use Umlaut's built-in feedback form if you want
124
+ # See https://github.com/team-umlaut/umlaut/wiki/Umlaut's-Feedback-Form
125
+ # feedback do
126
+ # main_library {:email_address => "dummy@example.org", :label => "Main Library"}
127
+ # end
128
+
129
+ # Advanced topic, you can declaratively configure
130
+ # what sections of the resolve page are output where
131
+ # and how using resolve_sections and add_resolve_sections!
132
+
133
+ resolve_sections.insert_section UmlautJournalTocs.resolve_section_definition
134
+
135
+ end
136
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "umlaut_journal_tocs"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+
22
+ # Do not swallow errors in after_commit/after_rollback callbacks.
23
+ config.active_record.raise_in_transactional_callbacks = true
24
+ end
25
+ end
26
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,60 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+ #
12
+ # UMLAUT: mysql db with mysql2 adapter strongly recommended for Umlaut, in both
13
+ # production and development. sqlite3 has unclear semantics under threaded
14
+ # concurrency which umlaut uses, and in many cases simply does not work.
15
+ #
16
+ # A higher pool size than ordinary is recommended because of umlaut's
17
+ # use of concurrency. Perhaps as large as the number of services
18
+ # you have configured to run in the same wave, plus another few.
19
+ #
20
+ # development:
21
+ # adapter: mysql2
22
+ # host:
23
+ # username:
24
+ # password:
25
+ # database:
26
+ # pool: 15
27
+
28
+
29
+ development:
30
+ <<: *default
31
+ database: db/development.sqlite3
32
+
33
+ # Warning: The database defined as "test" will be erased and
34
+ # re-generated from your development database when you run "rake".
35
+ # Do not set this db to the same as development or production.
36
+ test:
37
+ <<: *default
38
+ database: db/test.sqlite3
39
+
40
+ production:
41
+ <<: *default
42
+ database: db/production.sqlite3
43
+
44
+ #
45
+ # UMLAUT: for the 'search' functions (A-Z title lookup) to work, you need
46
+ # a direct database connection to the SFX database, under 'sfx_db' key.
47
+ # You should manually set up a new read-only MySQL account in the SFX db
48
+ # for this purpose, rather than use one of the full-access existing SFX
49
+ # mysql accounts.
50
+ #
51
+ #sfx_db:
52
+ # adapter: mysql2
53
+ # host: my_sfx_host.u.edu
54
+ # port: 3310 # 3310 is defualt SFX embedded mysql port
55
+ # database: sfxlcl41 # or other sfx instance db
56
+ # username:
57
+ # password:
58
+ # pool: 5
59
+ # encoding: utf8
60
+ #
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,45 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ #
11
+ # UMLAUT: Umlaut's use of threading makes Rails dev-mode class reloading tricky
12
+ # It seems to be be mostly okay with cache_classes=false AND eager_load=true
13
+ # but beware of editing files while background requests are running.
14
+ config.eager_load = true
15
+
16
+ # Show full error reports and disable caching.
17
+ config.consider_all_requests_local = true
18
+ config.action_controller.perform_caching = false
19
+
20
+ # Don't care if the mailer can't send.
21
+ config.action_mailer.raise_delivery_errors = false
22
+
23
+ # Print deprecation notices to the Rails logger.
24
+ config.active_support.deprecation = :log
25
+
26
+ # Raise an error on page load if there are pending migrations.
27
+ config.active_record.migration_error = :page_load
28
+
29
+ # Debug mode disables concatenation and preprocessing of assets.
30
+ # This option may cause significant delays in view rendering with a large
31
+ # number of complex assets.
32
+ config.assets.debug = true
33
+
34
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
+ # yet still be able to expire them through the digest params.
36
+ config.assets.digest = true
37
+
38
+ # Adds additional error checking when serving assets at runtime.
39
+ # Checks for improperly declared sprockets dependencies.
40
+ # Raises helpful error messages.
41
+ config.assets.raise_runtime_errors = true
42
+
43
+ # Raises error for missing translations
44
+ # config.action_view.raise_on_missing_translations = true
45
+ end
@@ -0,0 +1,83 @@
1
+ Rails.application.configure do
2
+ # Umlaut generated this, because Umlaut does some colorized
3
+ # logging, and Rails really ought to default to false in production.
4
+ config.colorize_logging = false
5
+
6
+ # Settings specified here will take precedence over those in config/application.rb.
7
+
8
+ # Code is not reloaded between requests.
9
+ config.cache_classes = true
10
+
11
+ # Eager load code on boot. This eager loads most of Rails and
12
+ # your application in memory, allowing both threaded web servers
13
+ # and those relying on copy on write to perform better.
14
+ # Rake tasks automatically ignore this option for performance.
15
+ config.eager_load = true
16
+
17
+ # Full error reports are disabled and caching is turned on.
18
+ config.consider_all_requests_local = false
19
+ config.action_controller.perform_caching = true
20
+
21
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
22
+ # Add `rack-cache` to your Gemfile before enabling this.
23
+ # For large-scale production use, consider using a caching reverse proxy like
24
+ # NGINX, varnish or squid.
25
+ # config.action_dispatch.rack_cache = true
26
+
27
+ # Disable serving static files from the `/public` folder by default since
28
+ # Apache or NGINX already handles this.
29
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
30
+
31
+ # Compress JavaScripts and CSS.
32
+ config.assets.js_compressor = :uglifier
33
+ # config.assets.css_compressor = :sass
34
+
35
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
36
+ config.assets.compile = false
37
+
38
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
39
+ # yet still be able to expire them through the digest params.
40
+ config.assets.digest = true
41
+
42
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
43
+
44
+ # Specifies the header that your server uses for sending files.
45
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
46
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
47
+
48
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
49
+ # config.force_ssl = true
50
+
51
+ # Use the lowest log level to ensure availability of diagnostic information
52
+ # when problems arise.
53
+ config.log_level = :debug
54
+
55
+ # Prepend all log lines with the following tags.
56
+ # config.log_tags = [ :subdomain, :uuid ]
57
+
58
+ # Use a different logger for distributed setups.
59
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
60
+
61
+ # Use a different cache store in production.
62
+ # config.cache_store = :mem_cache_store
63
+
64
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
65
+ # config.action_controller.asset_host = 'http://assets.example.com'
66
+
67
+ # Ignore bad email addresses and do not raise email delivery errors.
68
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
69
+ # config.action_mailer.raise_delivery_errors = false
70
+
71
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
72
+ # the I18n.default_locale when a translation cannot be found).
73
+ config.i18n.fallbacks = true
74
+
75
+ # Send deprecation notices to registered listeners.
76
+ config.active_support.deprecation = :notify
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+
81
+ # Do not dump schema after migrations.
82
+ config.active_record.dump_schema_after_migration = false
83
+ end