borrow_direct 0.10.0 → 0.11.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 +1 -0
- data/lib/borrow_direct/generate_query.rb +17 -2
- data/lib/borrow_direct/version.rb +1 -1
- data/test/generate_query_test.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Yzk3ZWE5NmVjYjkwZWY5M2IxZTc2NmIyZmIxNGIwYjllYjMxNGY1OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGYyZTVjODFjMjlhNTQ4Nzk5ZmVkN2UzNzAwMTkzNTQ4MzRlNGIwYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODE0NTkyNTkwZWMxZWM4MjMwNjJhMjhiMjM4MjM1MzNiNDU4ZmZkYWExZmFl
|
10
|
+
ZTYzM2ZkNTc2ODc3OTNlNDNkOWFmNmY0MjZmY2I3YmNhNmU1ZGY3MmYzZjVh
|
11
|
+
OTJhNGZkYjZjNzM1ZTFmZWY1Mzg4ODYxMGQxYjY5OTFmZjc3YWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGU1MTFjNThkNjZiNTM3NWE1MTYzMTJjMTc0YmYzMzk1YzQzYWFiOWIxOGM5
|
14
|
+
ZDNiNzJlNDMxYWMzMTBhYmVhMjg5MDgxNGJjODhmN2VhMjNmYWY3MzZhNDk2
|
15
|
+
OTY5MzgwN2RmOTQ5NTQ4NWFlOWI1NWY1OWQxM2U4NGJiYWQwYzY=
|
data/README.md
CHANGED
@@ -66,8 +66,9 @@ module BorrowDirect
|
|
66
66
|
title = options[:title].dup if options[:title]
|
67
67
|
author = options[:author].dup if options[:author]
|
68
68
|
|
69
|
-
|
70
|
-
title
|
69
|
+
|
70
|
+
title = normalized_title(title, :max_title_words => options[:max_title_words])
|
71
|
+
author = normalized_author(author)
|
71
72
|
|
72
73
|
results = {}
|
73
74
|
results[:title] = title if title && ! title.empty?
|
@@ -117,6 +118,20 @@ module BorrowDirect
|
|
117
118
|
return title
|
118
119
|
end
|
119
120
|
|
121
|
+
# Lowercase, and try to get just the last name out of something
|
122
|
+
# that looks like a cataloging authorized heading.
|
123
|
+
def normalized_author(author)
|
124
|
+
return "" if author.nil? || author.empty?
|
125
|
+
|
126
|
+
author = author.downcase
|
127
|
+
# Just take everything before the comma if we have one
|
128
|
+
if author =~ /\A(.*),/
|
129
|
+
author = $1
|
130
|
+
end
|
131
|
+
|
132
|
+
return author
|
133
|
+
end
|
134
|
+
|
120
135
|
|
121
136
|
|
122
137
|
# Escape a query value.
|
data/test/generate_query_test.rb
CHANGED
@@ -91,7 +91,7 @@ describe "GenerateQuery" do
|
|
91
91
|
it "passes through simple author and title" do
|
92
92
|
author ="John Smith"
|
93
93
|
title = "Some Book"
|
94
|
-
assert_equal( {:title => "some book", :author =>
|
94
|
+
assert_equal( {:title => "some book", :author => 'john smith'}, @generator.normalized_author_title_params(:author => author, :title => title))
|
95
95
|
end
|
96
96
|
|
97
97
|
it "works with just a title" do
|
@@ -121,11 +121,17 @@ describe "GenerateQuery" do
|
|
121
121
|
assert_equal({:title => "el revolución"}, @generator.normalized_author_title_params(:title => "El Revolución!: Cuban poster art"))
|
122
122
|
end
|
123
123
|
|
124
|
+
it "normalizes author to what looks like last name" do
|
125
|
+
assert_equal({:title => "book", :author => "scott"}, @generator.normalized_author_title_params(:title => "Book", :author => "Scott, James C"))
|
126
|
+
end
|
127
|
+
|
124
128
|
it "full normalized_author_title_query" do
|
125
129
|
url = @generator.normalized_author_title_query(:title => "A Book: Subtitle", :author => "Smith, John" )
|
126
130
|
query = assert_bd_query_url(url)
|
127
131
|
end
|
128
132
|
|
133
|
+
|
134
|
+
|
129
135
|
end
|
130
136
|
|
131
137
|
def assert_bd_query_url(url)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: borrow_direct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|