stanford-mods 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,6 +60,7 @@ Example Using SearchWorks Mixins:
60
60
 
61
61
  == Releases
62
62
 
63
+ * <b>0.0.11</b> escape regex special characters when using short title in a regex
63
64
  * <b>0.0.10</b> get rid of ignore_me files
64
65
  * <b>0.0.9</b> add sw_subject_names and sw_subject_titles methods to searchworks mixin
65
66
  * <b>0.0.8</b> require stanford-mods/searchworks in stanford-mods (top level)
@@ -100,13 +100,13 @@ module Stanford
100
100
 
101
101
  # @return [String] value for title_245_search, title_display, title_full_display
102
102
  def sw_full_title
103
- full_titles ? full_titles.find { |s| s =~ Regexp.new(sw_short_title) } : nil
103
+ full_titles ? full_titles.find { |s| s =~ Regexp.new(Regexp.escape(sw_short_title)) } : nil
104
104
  end
105
105
 
106
106
  # this includes all titles except
107
107
  # @return [Array<String>] values for title_variant_search
108
108
  def sw_addl_titles
109
- full_titles.select { |s| s !~ Regexp.new(sw_short_title) }
109
+ full_titles.select { |s| s !~ Regexp.new(Regexp.escape(sw_short_title)) }
110
110
  end
111
111
 
112
112
  # Returns a sortable version of the main title
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "0.0.10"
4
+ VERSION = "0.0.11"
5
5
  end
6
6
  end
@@ -132,6 +132,13 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
132
132
  it "should be a String" do
133
133
  @smods_rec.sw_full_title.should == 'The Jerk A Tale of Tourettes'
134
134
  end
135
+ it 'should escape regex characters in the sw_short_title' do
136
+ m = "<mods #{@ns_decl}><titleInfo>
137
+ <title>Pius V. Saint, [Michaele Gisleri),</title>
138
+ </titleInfo></mods>"
139
+ @smods_rec.from_str m
140
+ @smods_rec.sw_full_title.should == 'Pius V. Saint, [Michaele Gisleri),'
141
+ end
135
142
  end
136
143
  context "additional titles (for title_variant_search)" do
137
144
  before(:all) do
@@ -153,6 +160,15 @@ describe "Searchworks mixin for Stanford::Mods::Record" do
153
160
  it "should include all alternative titles" do
154
161
  @addl_titles.should include('Alternative')
155
162
  end
163
+ it 'shold escape the short title in the regexp' do
164
+ m = "<mods #{@ns_decl}>
165
+ <titleInfo type='alternative'><title>Alternative</title></titleInfo>
166
+ <titleInfo><title>[Jerk)</title><nonSort>The</nonSort></titleInfo>
167
+ <titleInfo><title>Joke]</title></titleInfo>
168
+ </mods>"
169
+ @smods_rec.from_str(m)
170
+ @addl_titles = @smods_rec.sw_addl_titles
171
+ end
156
172
  end
157
173
  context "sort title" do
158
174
  it "should be a String" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford-mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-07 00:00:00.000000000 Z
13
+ date: 2013-03-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mods
@@ -167,18 +167,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
167
  - - ! '>='
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
- segments:
171
- - 0
172
- hash: -3519337351591429375
173
170
  required_rubygems_version: !ruby/object:Gem::Requirement
174
171
  none: false
175
172
  requirements:
176
173
  - - ! '>='
177
174
  - !ruby/object:Gem::Version
178
175
  version: '0'
179
- segments:
180
- - 0
181
- hash: -3519337351591429375
182
176
  requirements: []
183
177
  rubyforge_project:
184
178
  rubygems_version: 1.8.24