jgm-cloudlib 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/cloudlib.gemspec +1 -1
  2. data/lib/cloudlib.rb +5 -3
  3. metadata +1 -1
data/cloudlib.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cloudlib"
3
- s.version = "0.3.3"
3
+ s.version = "0.3.4"
4
4
  s.date = "2008-12-29"
5
5
  s.summary = "Tools for maintaining a library of books and articles in Amazon S3 and SimpleDB"
6
6
  s.email = "jgm@berkeley.edu"
data/lib/cloudlib.rb CHANGED
@@ -168,12 +168,14 @@ class Entry
168
168
  else
169
169
  'all'
170
170
  end
171
- vals = val.split
171
+ # split hyphenated names into components, since a query might just have one
172
+ vals = val.split(/[-[:space:]]+/)
172
173
  vals.map do |v|
173
174
  if key_full == 'year' # there is no year_words field
174
175
  "['year' #{comparison} '#{v}']"
175
176
  else
176
- "['#{key_full}_words' = '#{v}']"
177
+ v_escaped = v.gsub(/\\/,"\\\\\\\\").gsub(/'/,"\\\\'")
178
+ "['#{key_full}_words' = '#{v_escaped}']"
177
179
  end
178
180
  end.join(" intersection ")
179
181
  end.join(" intersection ")
@@ -315,7 +317,7 @@ class Entry
315
317
  self.attributes[attribute] = newval
316
318
  unless ['url', 'doi', 'keywords'].member?(attribute)
317
319
  self.attributes[attribute + "_lowercase"] = newval.map {|a| a.downcase}
318
- self.attributes[attribute + "_words"] = self.attributes[attribute + "_lowercase"].map {|a| a.split(/[[:space:][:punct:]] */)}.flatten
320
+ self.attributes[attribute + "_words"] = self.attributes[attribute + "_lowercase"].map {|a| a.split(/[[:punct:]]*[[:space:]]+|-+/)}.flatten.reject {|a| a.empty?}
319
321
  end
320
322
  # recalculate all_words
321
323
  tit_auth_words = ['title', 'authors', 'editors', 'booktitle'].map {|att| self.attributes[att + "_words"] || []}.flatten
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jgm-cloudlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John MacFarlane