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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2U0ZTMyZDhmZDA4ZTE3YWNjNDk0MTYwMDEzNTM4MTQ5MDY2NzQwOQ==
4
+ Yzk3ZWE5NmVjYjkwZWY5M2IxZTc2NmIyZmIxNGIwYjllYjMxNGY1OA==
5
5
  data.tar.gz: !binary |-
6
- YzQ0MDdjMGIyMjYzNmU1NmZkY2Q5MzRkNTcxNWRhNjkyZTE3ZDQ3ZA==
6
+ ZGYyZTVjODFjMjlhNTQ4Nzk5ZmVkN2UzNzAwMTkzNTQ4MzRlNGIwYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MThiMzE1MWJmNmQ3YzZiNjczYTY5MjU0OGIxYmRlOWQ5MTc5ZmQ2NzM5OTY4
10
- MjRmMWQ5M2RjYzEzNGFjZGVlYjkwOWU2N2M3ZWFjMTM5OTFkOTk1YjEzZGM2
11
- ZjQ5M2MwMTM4YzFlZGNjOTdmMzBlZGZjM2IwOGNjNDg5NzJhMjA=
9
+ ODE0NTkyNTkwZWMxZWM4MjMwNjJhMjhiMjM4MjM1MzNiNDU4ZmZkYWExZmFl
10
+ ZTYzM2ZkNTc2ODc3OTNlNDNkOWFmNmY0MjZmY2I3YmNhNmU1ZGY3MmYzZjVh
11
+ OTJhNGZkYjZjNzM1ZTFmZWY1Mzg4ODYxMGQxYjY5OTFmZjc3YWE=
12
12
  data.tar.gz: !binary |-
13
- MmZhNzUyNTk5ODhiYWI5ZjdiNjVhZThhZTdlMTgyZDM3MzdhODhlOThkZjE4
14
- ZWNmNzg4NzkwYzFmNmQ1OTA4MDk5MTY5N2IyODAwNWJhYjg4ZDY5NjY1YzVl
15
- NGQ1YjllODU3M2Q0M2E0MjczN2VlMzUxZTVhYmU2ZjJhODcxYTg=
13
+ MGU1MTFjNThkNjZiNTM3NWE1MTYzMTJjMTc0YmYzMzk1YzQzYWFiOWIxOGM5
14
+ ZDNiNzJlNDMxYWMzMTBhYmVhMjg5MDgxNGJjODhmN2VhMjNmYWY3MzZhNDk2
15
+ OTY5MzgwN2RmOTQ5NTQ4NWFlOWI1NWY1OWQxM2U4NGJiYWQwYzY=
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/borrow_direct.svg)](http://badge.fury.io/rb/borrow_direct)
1
2
  [![Build Status](https://travis-ci.org/jrochkind/borrow_direct.svg)](https://travis-ci.org/jrochkind/borrow_direct)
2
3
 
3
4
  # BorrowDirect
@@ -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
- # We don't do any normalization to author at present.
70
- title = normalized_title(title, :max_title_words => options[:max_title_words])
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.
@@ -1,3 +1,3 @@
1
1
  module BorrowDirect
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -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 => author}, @generator.normalized_author_title_params(:author => author, :title => title))
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.10.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-12 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient