umlaut 4.0.0.beta5 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +5 -7
- data/app/helpers/umlaut/html_head_helper.rb +1 -1
- data/app/models/referent.rb +6 -4
- data/app/models/service_response.rb +4 -0
- data/app/service_adaptors/amazon.rb +5 -3
- data/app/service_adaptors/hathi_trust.rb +1 -2
- data/app/service_adaptors/scopus2.rb +2 -1
- data/bin/umlaut +7 -3
- data/lib/generators/umlaut/install_generator.rb +17 -1
- data/lib/truncate_to_db_limit.rb +51 -0
- data/lib/umlaut/version.rb +2 -2
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODZiYTQzNWJjMzkwMDAyZjZhMTNiODlhYzhlMmFjOGIwNTc0ZTVjYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDk2ODYwYTM1M2UwM2QzMDg4ZGNlNDQxNWIwNjQ0YjVjN2JhZDE3NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTlmOTFjNzA2ZDU2ZDYwZDQ3MTJjNTk4Y2YxM2U0MTk1NGI4OTE1ZDk2YzM3
|
10
|
+
MjcyYjlkNjA5NTViZWNlMGM4Njk5YTJkZGFkMDdkZmY2YzBiYzg5ZWE2YjVk
|
11
|
+
MzZhZDViMmRhZWQyZjQwOWM0YzMwYWFjMTRjYTQ3YWQ2ODZkMmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODRjOTg4MWY2NWIyNDYwMmU3MmU3ZWY2ZmE2MDg1ZDU4YzU1ZDJiMWU1YWVj
|
14
|
+
YmUxMjYwZTllMWZmNTc0NWI2MzJiN2Q2Nzk2MzcxODQxYjg5M2U3NTgyMzMz
|
15
|
+
NTllZGUxYTU5ZDQyMzI5NzY4ZGY4ZjY4YmMxMWM5YTY4OWE4YTM=
|
data/README.md
CHANGED
@@ -6,8 +6,6 @@
|
|
6
6
|
[](https://coveralls.io/r/team-umlaut/umlaut)
|
7
7
|
<!--[](http://rails-brakeman.com/team-umlaut/umlaut)-->
|
8
8
|
|
9
|
-
(Umlaut 4.0.0.beta1 is out, and this README refers to Umlaut 4.x, and we recommend starting with Umlaut 4.x even though it's only in beta. Install with `gem install umlaut --pre`)
|
10
|
-
|
11
9
|
Umlaut is software for libraries (the kind with books).
|
12
10
|
|
13
11
|
It could be described as a front-end layer on top of an existing OpenURL
|
@@ -46,11 +44,11 @@ The Rails/Umlaut super-concise expert summary is:
|
|
46
44
|
|
47
45
|
* `$ gem install umlaut`
|
48
46
|
* Then run the umlaut app generator: `$ umlaut my_new_app`
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
* That will make a new rails app
|
48
|
+
* without spring or turbolinks
|
49
|
+
* using mysql (sqlite3 does not work for umlaut)
|
50
|
+
* it will add the umlaut gem to your app
|
51
|
+
* and it will run umlaut's generator to add a couple more files to your app, equivalent of `$ rails generate umlaut:install`
|
54
52
|
|
55
53
|
* set up your db in config/databases.yml and run `rake db:migrate`
|
56
54
|
* configuration in `./config/umlaut_services.yml` and `./app/controllers/umlaut_controller.rb`
|
@@ -7,7 +7,7 @@ module Umlaut::HtmlHeadHelper
|
|
7
7
|
def render_opensearch_link
|
8
8
|
tag("link", :rel => "search", :type => "application/opensearchdescription+xml",
|
9
9
|
:title => umlaut_config.opensearch_short_name,
|
10
|
-
:href => url_for(:controller=>'open_search', :only_path=>false))
|
10
|
+
:href => url_for(:controller=>'/open_search', :only_path=>false))
|
11
11
|
end
|
12
12
|
|
13
13
|
# used on non-js progress page, we need to refresh the page
|
data/app/models/referent.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'i18n'
|
2
|
+
require 'truncate_to_db_limit'
|
2
3
|
|
3
4
|
# Note: There are a few actual attributes stored as Columns in referent --
|
4
5
|
# these were originally used for identifying a Referent identifying the
|
@@ -16,11 +17,12 @@ class Referent < ActiveRecord::Base
|
|
16
17
|
has_many :referent_values
|
17
18
|
has_many :permalinks
|
18
19
|
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
# We really should get rid of these 'mirror' attributes, but
|
21
|
+
# in the meantime truncate them.
|
22
|
+
include TruncateToDbLimit
|
23
|
+
truncate_to_db_limit :volume, :year, :issn, :isbn
|
23
24
|
|
25
|
+
|
24
26
|
# Pass in :permalink => :force to force creation of a permalink, otherwise
|
25
27
|
# no permalink is created by this method, one can be lazily created when
|
26
28
|
# needed.
|
@@ -164,6 +164,7 @@ Generally only for fulltext. Right now only supplied by SFX.
|
|
164
164
|
method can convenient.
|
165
165
|
|
166
166
|
=end
|
167
|
+
require 'truncate_to_db_limit'
|
167
168
|
class ServiceResponse < ActiveRecord::Base
|
168
169
|
@@built_in_fields = [:display_text, :url, :notes, :response_key, :value_string, :value_alt_string, :value_text, :id]
|
169
170
|
belongs_to :request
|
@@ -173,6 +174,9 @@ class ServiceResponse < ActiveRecord::Base
|
|
173
174
|
# object.
|
174
175
|
attr_accessor :http_request_params
|
175
176
|
|
177
|
+
include TruncateToDbLimit
|
178
|
+
truncate_to_db_limit :display_text
|
179
|
+
|
176
180
|
# Constants for 'match_reliability' value.
|
177
181
|
MatchExact = 'exact'
|
178
182
|
MatchUnsure = 'unsure'
|
@@ -109,6 +109,7 @@ class Amazon < Service
|
|
109
109
|
|
110
110
|
selected_aws_vals = {}
|
111
111
|
if ( @make_aws_call )
|
112
|
+
|
112
113
|
aws_response = make_aws_request( isbn )
|
113
114
|
|
114
115
|
return request.dispatched(self, true) if aws_response.blank?
|
@@ -189,7 +190,8 @@ class Amazon < Service
|
|
189
190
|
err = (aws.at("ItemLookupErrorResponse")) if err.blank?
|
190
191
|
|
191
192
|
unless (err.blank?)
|
192
|
-
if (err.at('Code').text == 'AWS.InvalidParameterValue')
|
193
|
+
if ((err.at('Code').text == 'AWS.InvalidParameterValue') ||
|
194
|
+
(err.at('Code').text == 'AWS.ECommerceService.ItemNotAccessible'))
|
193
195
|
# Indicates an ISBN that Amazon doesn't know about, or that
|
194
196
|
# was mal-formed. We can't tell the difference, so either
|
195
197
|
# way let's silently ignore.
|
@@ -306,9 +308,9 @@ class Amazon < Service
|
|
306
308
|
look_inside = false
|
307
309
|
|
308
310
|
# Check for search_inside or look_inside if we're configured
|
309
|
-
# to supply
|
311
|
+
# to supply "excerpts" or search_inside, that's what we
|
310
312
|
# need it for.
|
311
|
-
if ( @service_types.include?("
|
313
|
+
if ( @service_types.include?("excerpts") ||
|
312
314
|
@service_types.include?("search_inside"))
|
313
315
|
|
314
316
|
|
@@ -127,8 +127,7 @@ class HathiTrust < Service
|
|
127
127
|
def get_bibkey_parameters(rft)
|
128
128
|
# filter out special chars that ought not to be in there anyway,
|
129
129
|
# and that HathiTrust barfs on.
|
130
|
-
isbn =
|
131
|
-
isbn = isbn.gsub(/[\-\[\]]/, '') unless isbn.blank?
|
130
|
+
isbn = get_isbn(rft)
|
132
131
|
|
133
132
|
oclcnum = get_identifier(:info, "oclcnum", rft)
|
134
133
|
oclcnum = oclcnum.gsub(/[\-\[\]]/, '') unless oclcnum.blank?
|
@@ -139,7 +139,8 @@ class Scopus2 < Service
|
|
139
139
|
code = error.at_xpath("./status/statusCode")
|
140
140
|
message = error.at_xpath("./status/statusText")
|
141
141
|
end
|
142
|
-
|
142
|
+
|
143
|
+
e = StandardError.new("Scopus returned error HTTP status #{response.code}: #{code}: #{message}: scopus query: #{url}")
|
143
144
|
return request.dispatched(self, DispatchedService::FailedFatal, e)
|
144
145
|
end
|
145
146
|
|
data/bin/umlaut
CHANGED
@@ -43,15 +43,19 @@ def run
|
|
43
43
|
|
44
44
|
puts "#{command}\n\n"
|
45
45
|
|
46
|
-
system command
|
46
|
+
success = system command
|
47
47
|
|
48
|
-
|
48
|
+
if success
|
49
|
+
post_install_message!
|
50
|
+
else
|
51
|
+
puts "\nError installing Umlaut app.\n\n"
|
52
|
+
end
|
49
53
|
end
|
50
54
|
|
51
55
|
def command_line(options)
|
52
56
|
umlaut_template_path = File.expand_path(File.dirname(__FILE__) + '/../lib/generators/umlaut_app_template.rb')
|
53
57
|
|
54
|
-
return "rails _#{options.rails_version}_ new -d mysql --skip-spring
|
58
|
+
return "rails _#{options.rails_version}_ new #{options.app_path} -d mysql --skip-spring -m #{umlaut_template_path}"
|
55
59
|
end
|
56
60
|
|
57
61
|
def parse_options!
|
@@ -96,7 +96,13 @@ module Umlaut
|
|
96
96
|
|
97
97
|
def asset_hooks
|
98
98
|
guarded(:asset_hooks) do
|
99
|
-
generate
|
99
|
+
# generate tries to invoke rails from the command line, at which point
|
100
|
+
# it will complain about not yet having a db defined.
|
101
|
+
#generate("umlaut:asset_hooks")
|
102
|
+
|
103
|
+
# try like so instead which seems to work, and is faster too.
|
104
|
+
log :generate, "umlaut:asset_hooks"
|
105
|
+
Rails::Generators.invoke("umlaut:asset_hooks")
|
100
106
|
end
|
101
107
|
end
|
102
108
|
|
@@ -105,6 +111,16 @@ module Umlaut
|
|
105
111
|
copy_file("app/controllers/umlaut_controller.rb")
|
106
112
|
end
|
107
113
|
end
|
114
|
+
|
115
|
+
def config_colorize_logging
|
116
|
+
guarded(:config_colorize_logging) do
|
117
|
+
application(nil, env: "production") do
|
118
|
+
"# Umlaut generated this, because Umlaut does some colorized\n" +
|
119
|
+
" # logging, and Rails really ought to default to false in production.\n" +
|
120
|
+
" config.colorize_logging = false\n"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
108
124
|
|
109
125
|
def post_install_message
|
110
126
|
say("\n Umlaut installed, now:", :yellow)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# An ActiveRecord extension that will let you automatically truncate
|
2
|
+
# certain attributes to the maximum length allowed by the DB.
|
3
|
+
#
|
4
|
+
# require 'truncate_to_db_limit'
|
5
|
+
# class Something < ActiveRecord::Base
|
6
|
+
# include TruncateToDbLimit
|
7
|
+
# truncate_to_db_limit :short_attr, :short_attr2
|
8
|
+
# #...
|
9
|
+
#
|
10
|
+
# Truncation is done in a before_validate hook, so won't happen until
|
11
|
+
# you try to save.
|
12
|
+
#
|
13
|
+
module TruncateToDbLimit
|
14
|
+
extend ActiveSupport::Concern
|
15
|
+
|
16
|
+
included do
|
17
|
+
class_attribute :'_truncate_to_db_limit_attributes', instance_accessor: false
|
18
|
+
before_validation :do_truncate_to_db_limit!
|
19
|
+
|
20
|
+
|
21
|
+
def self.truncate_to_db_limit(*attribute_names)
|
22
|
+
self._truncate_to_db_limit_attributes = attribute_names
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
def do_truncate_to_db_limit!
|
30
|
+
|
31
|
+
|
32
|
+
self.class._truncate_to_db_limit_attributes.each do |attribute_name|
|
33
|
+
|
34
|
+
ar_attr = self.class.columns_hash[attribute_name.to_s]
|
35
|
+
|
36
|
+
unless ar_attr
|
37
|
+
raise ArgumentError.new("truncate_to_db_limit #{attribute_name}: No such attribute")
|
38
|
+
end
|
39
|
+
|
40
|
+
limit = ar_attr.limit
|
41
|
+
|
42
|
+
unless limit && limit.to_i != 0
|
43
|
+
raise ArgumentError.new("truncate_to_db_limit #{attribute_name}: Limit not known")
|
44
|
+
end
|
45
|
+
|
46
|
+
normalized = send(attribute_name).try {|v| v.slice(0, limit)}
|
47
|
+
send("#{attribute_name}=", normalized)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/lib/umlaut/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Umlaut
|
2
|
-
VERSION = "4.0.0
|
2
|
+
VERSION = "4.0.0"
|
3
3
|
|
4
4
|
# This is used in Umlaut's .gemspec for generating the gem,
|
5
5
|
# and is also used in the umlaut app generator to make sure
|
6
6
|
# we're generating with a compatible Rails version.
|
7
|
-
RAILS_COMPAT_SPEC = [">= 3.2.12", "
|
7
|
+
RAILS_COMPAT_SPEC = [">= 3.2.12", "< 4.2.0"]
|
8
8
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umlaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind, et al
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,9 +17,9 @@ dependencies:
|
|
17
17
|
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.12
|
20
|
-
- -
|
20
|
+
- - <
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 4.2.0
|
22
|
+
version: 4.2.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +27,9 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.2.12
|
30
|
-
- -
|
30
|
+
- - <
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 4.2.0
|
32
|
+
version: 4.2.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: jquery-rails
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -506,6 +506,7 @@ files:
|
|
506
506
|
- lib/tasks/umlaut_asset_compile.rake
|
507
507
|
- lib/tasks/umlaut_migrate_permalinks.rake
|
508
508
|
- lib/term_color.rb
|
509
|
+
- lib/truncate_to_db_limit.rb
|
509
510
|
- lib/umlaut.rb
|
510
511
|
- lib/umlaut/routes.rb
|
511
512
|
- lib/umlaut/version.rb
|
@@ -523,9 +524,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
523
524
|
version: '0'
|
524
525
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
525
526
|
requirements:
|
526
|
-
- - ! '
|
527
|
+
- - ! '>='
|
527
528
|
- !ruby/object:Gem::Version
|
528
|
-
version:
|
529
|
+
version: '0'
|
529
530
|
requirements: []
|
530
531
|
rubyforge_project:
|
531
532
|
rubygems_version: 2.4.1
|