refworks 0.0.12 → 0.0.13

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.
data/README.md CHANGED
@@ -118,3 +118,4 @@ Useful Links
118
118
  RefWorks API Reference: http://rwt.refworks.com/rwapireference/
119
119
  RefWorks Tagged Format Reference: http://www.refworks.com/rwathens/help/RefWorks_Tagged_Format.htm
120
120
 
121
+
@@ -3,13 +3,15 @@ require "mash"
3
3
 
4
4
  #noinspection RubyTooManyInstanceVariablesInspection,RubyTooManyMethodsInspection
5
5
  class Reference
6
- attr_accessor :rt, :rt_num, :rt_string, :sr, :id, :a1, :t1, :jf, :jo, :yr, :fd,
7
- :vo, :is, :sp, :op, :k1, :ab, :no, :a2, :t2, :ed, :pb, :pp, :a3,
8
- :a4, :a5, :t3, :sn, :av, :ad, :an, :la, :cl, :sf, :ot, :lk, :do,
6
+ attr_accessor :rt, :rt_num, :rt_string, :sr, :id, :t1, :jf, :jo, :yr, :fd,
7
+ :vo, :is, :sp, :op, :ab, :no, :t2, :ed, :pb, :pp,
8
+ :t3, :sn, :av, :ad, :an, :la, :cl, :sf, :ot, :lk, :do,
9
9
  :cn, :db, :ds, :ip, :rd, :st, :u1, :u2, :u3, :u4, :u5, :u6, :u7,
10
10
  :u8, :u9, :u10, :u11, :u12, :u13, :u14, :u15, :ul, :sl, :ll, :cr,
11
- :wt, :a6, :wv, :wp, :ol, :pmid, :pmcid,
11
+ :wt, :wv, :wp, :ol, :pmid, :pmcid,
12
12
  :fl, :cd, :md
13
+ # the following need special setter behavior (custom setters below) so they only get standard readers
14
+ attr_reader :k1, :a1, :a2, :a3, :a4, :a5, :a6
13
15
 
14
16
  # expecting a HTTParty-parsed RWResult reference hash to be passed in
15
17
  def initialize(rawref)
@@ -43,12 +45,10 @@ class Reference
43
45
  # to a Ruby data structure. Which one it produces depends upon how
44
46
  # many authors there are. All values are converted to Arrays, even one item
45
47
  # values, for consistency. I do this for any field which can have more than one value.
46
- # If not an array, and not a value, set nil
47
- @a1 = if ref[:a1].class == Array then
48
- ref[:a1]
49
- else
50
- ref[:a1] ? ref[:a1].lines.to_a : nil
51
- end
48
+ # To accomplish this, I use the "friendly name" setters (e.g. self.authors) so that I don't
49
+ # have to override the auto-generated setters that are created via attr_accessor. This affects
50
+ # the a1-a6 fields plus the k1 field.
51
+ @a1 = self.a1=(ref[:a1])
52
52
 
53
53
  @t1 = ref[:t1]
54
54
 
@@ -62,14 +62,14 @@ class Reference
62
62
  @op = ref[:op]
63
63
 
64
64
  if ref[:k1]
65
- @k1 = ref[:k1].class == Array ? ref[:k1] : ref[:k1].lines.to_a
65
+ self.k1=(ref[:k1])
66
66
  end
67
67
 
68
68
  @ab = ref[:ab]
69
69
  @no = ref[:no]
70
70
 
71
71
  if ref[:a2]
72
- @a2 = ref[:a2].class == Array ? ref[:a2] : ref[:a2].lines.to_a
72
+ self.a2=(ref[:a2])
73
73
  end
74
74
 
75
75
  @t2 = ref[:t2]
@@ -79,15 +79,15 @@ class Reference
79
79
  @pp = ref[:pp]
80
80
 
81
81
  if ref[:a3]
82
- @a3 = ref[:a3].class == Array ? ref[:a3] : ref[:a3].lines.to_a
82
+ self.a3=(ref[:a3])
83
83
  end
84
84
 
85
85
  if ref[:a4]
86
- @a4 = ref[:a4].class == Array ? ref[:a4] : ref[:a4].lines.to_a
86
+ self.a4=(ref[:a4])
87
87
  end
88
88
 
89
89
  if ref[:a5]
90
- @a5 = ref[:a5].class == Array ? ref[:a5] : ref[:a5].lines.to_a
90
+ self.a5=(ref[:a5])
91
91
  end
92
92
 
93
93
  @t3 = ref[:t3]
@@ -129,7 +129,7 @@ class Reference
129
129
  @wt = ref[:wt]
130
130
 
131
131
  if ref[:a6]
132
- @a6 = ref[:a6].class == Array ? ref[:a6] : ref[:a6].lines.to_a
132
+ self.a6=(ref[:a6])
133
133
  end
134
134
 
135
135
  @wv = ref[:wv]
@@ -144,6 +144,38 @@ class Reference
144
144
  @md = ref[:md]
145
145
  end
146
146
 
147
+ # setters for attributes which need special setter behavior to handle the fact that the input
148
+ # may be either a string or an Array and we want to standardize on Arrays for our internal storage
149
+ # this probably could be cleaned up with some sort of metaprogramming hack, but it's only seven of 'em
150
+
151
+ def k1=(val)
152
+ @k1 = val.class == Array ? val : val.lines.to_a
153
+ end
154
+
155
+ def a1=(val)
156
+ @a1 = val.class == Array ? val : val.lines.to_a
157
+ end
158
+
159
+ def a2=(val)
160
+ @a2 = val.class == Array ? val : val.lines.to_a
161
+ end
162
+
163
+ def a3=(val)
164
+ @a3 = val.class == Array ? val : val.lines.to_a
165
+ end
166
+
167
+ def a4=(val)
168
+ @a4 = val.class == Array ? val : val.lines.to_a
169
+ end
170
+
171
+ def a5=(val)
172
+ @a5 = val.class == Array ? val : val.lines.to_a
173
+ end
174
+
175
+ def a6=(val)
176
+ @a6 = val.class == Array ? val : val.lines.to_a
177
+ end
178
+
147
179
  # method to produce RefWorks XML format
148
180
  def to_refworks_xml
149
181
  @xml = "<reference>"
@@ -260,7 +292,7 @@ class Reference
260
292
  end
261
293
 
262
294
  def primary_authors=(val)
263
- self.a1 = val
295
+ self.a1 = val.class == Array ? val : val.lines.to_a
264
296
  end
265
297
 
266
298
  # alias
@@ -270,7 +302,7 @@ class Reference
270
302
 
271
303
  # alias
272
304
  def authors=(val)
273
- self.a1 = val
305
+ self.a1 = val.class == Array ? val : val.lines.to_a
274
306
  end
275
307
 
276
308
  def primary_title
@@ -359,7 +391,7 @@ class Reference
359
391
  end
360
392
 
361
393
  def keyword=(val)
362
- self.k1=val
394
+ self.k1 = val
363
395
  end
364
396
 
365
397
  def keywords
@@ -367,7 +399,7 @@ class Reference
367
399
  end
368
400
 
369
401
  def keywords=(val)
370
- self.k1=val
402
+ self.k1 = val
371
403
  end
372
404
 
373
405
  def abstract
@@ -391,7 +423,7 @@ class Reference
391
423
  end
392
424
 
393
425
  def secondary_authors=(val)
394
- self.a2=val
426
+ self.a2= val.class == Array ? val : val.lines.to_a
395
427
  end
396
428
 
397
429
  def secondary_title
@@ -431,7 +463,7 @@ class Reference
431
463
  end
432
464
 
433
465
  def tertiary_authors=(val)
434
- self.a3=val
466
+ self.a3= val.class == Array ? val : val.lines.to_a
435
467
  end
436
468
 
437
469
  def quaternary_authors
@@ -439,7 +471,7 @@ class Reference
439
471
  end
440
472
 
441
473
  def quaternary_authors=(val)
442
- self.a4=val
474
+ self.a4= val.class == Array ? val : val.lines.to_a
443
475
  end
444
476
 
445
477
  def quinary_authors
@@ -447,7 +479,7 @@ class Reference
447
479
  end
448
480
 
449
481
  def quinary_authors=(val)
450
- self.a5=val
482
+ self.a5= val.class == Array ? val : val.lines.to_a
451
483
  end
452
484
 
453
485
  def tertiary_title
@@ -765,7 +797,7 @@ class Reference
765
797
  end
766
798
 
767
799
  def website_editors=(val)
768
- self.a6=val
800
+ self.a6= val.class == Array ? val : val.lines.to_a
769
801
  end
770
802
 
771
803
  def website_version
@@ -5,11 +5,13 @@ class Response
5
5
  def initialize(raw_response)
6
6
  # The RefWorks API emits invalid XML. Specifically, when the session is invalid, the ResultMsg field
7
7
  # which comes back contains some illegal raw characters. This is the only set of transformations I
8
- # could find which completely eliminate the junk characters, but it may be breaking other things.
8
+ # could find which completely eliminate the junk characters.
9
9
 
10
10
  # Trying to work around the malformed response bug
11
11
  p raw_response.body
12
+ # Replace non UTF-8 chars with the empty string
12
13
  raw_response.body.encode!('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '')
14
+ # Remove characters which are not allowed to appear in XML messages
13
15
  raw_response.body.gsub!(/[\u0001-\u0019]/,'')
14
16
  p raw_response.body
15
17
 
@@ -1,3 +1,3 @@
1
1
  class Refworks
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Fran Fabrizio
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-03-21 00:00:00.000000000 Z
12
+ date: 2014-03-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: httparty
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: require_all
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: mash
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -60,8 +67,6 @@ executables: []
60
67
  extensions: []
61
68
  extra_rdoc_files: []
62
69
  files:
63
- - README.md
64
- - lib/refworks.rb
65
70
  - lib/refworks/authentication/authentication_request.rb
66
71
  - lib/refworks/authentication/authentication_response.rb
67
72
  - lib/refworks/authentication/delsess/authentication_delsess_request.rb
@@ -151,7 +156,6 @@ files:
151
156
  - lib/refworks/properties/typelabels/properties_typelabels_request.rb
152
157
  - lib/refworks/properties/typelabels/properties_typelabels_response.rb
153
158
  - lib/refworks/properties/typelabels/typelabel.rb
154
- - lib/refworks/reference.rb
155
159
  - lib/refworks/reference/add/reference_add_request.rb
156
160
  - lib/refworks/reference/add/reference_add_response.rb
157
161
  - lib/refworks/reference/addcomment/reference_addcomment_request.rb
@@ -164,6 +168,7 @@ files:
164
168
  - lib/refworks/reference/get/reference_get_response.rb
165
169
  - lib/refworks/reference/reference_request.rb
166
170
  - lib/refworks/reference/reference_response.rb
171
+ - lib/refworks/reference.rb
167
172
  - lib/refworks/request.rb
168
173
  - lib/refworks/response.rb
169
174
  - lib/refworks/retrieve/advancesearch/retrieve_advancesearch_request.rb
@@ -206,27 +211,31 @@ files:
206
211
  - lib/refworks/savedsearch/savedsearch_request.rb
207
212
  - lib/refworks/savedsearch/savedsearch_response.rb
208
213
  - lib/refworks/version.rb
214
+ - lib/refworks.rb
215
+ - README.md
209
216
  homepage: http://github.umn.edu/mpc/refworks-api-ruby
210
217
  licenses: []
211
- metadata: {}
212
218
  post_install_message:
213
219
  rdoc_options: []
214
220
  require_paths:
215
221
  - lib
216
222
  required_ruby_version: !ruby/object:Gem::Requirement
223
+ none: false
217
224
  requirements:
218
225
  - - ! '>='
219
226
  - !ruby/object:Gem::Version
220
227
  version: 1.9.2
221
228
  required_rubygems_version: !ruby/object:Gem::Requirement
229
+ none: false
222
230
  requirements:
223
231
  - - ! '>='
224
232
  - !ruby/object:Gem::Version
225
233
  version: 1.3.6
226
234
  requirements: []
227
235
  rubyforge_project: refworks
228
- rubygems_version: 2.2.0
236
+ rubygems_version: 1.8.24
229
237
  signing_key:
230
- specification_version: 4
238
+ specification_version: 3
231
239
  summary: A Ruby interface to the RefWorks API.
232
240
  test_files: []
241
+ has_rdoc:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YTRjYjQwNjE2MjBiNmUyY2FmZWFhYzg5OGFkMjU5ODI0OTgyNzI5Zg==
5
- data.tar.gz: !binary |-
6
- MzZiMmIzY2ZjMzllOTJkMjdkODFiM2UxOWU3YjFhZDYyNjg1NTgwNQ==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- OGVhZjY0NzRmY2FhYTllNjhjOWI3MDUxODJmMzEwMjlkMWJlMmIyMWViNzZm
10
- YzA2NTNiOGM0Mzc5YTc4MDhiMDQ4NDRmZGEyNjYzNDRkMmI5NDZhZTZhYTBh
11
- YzQxZjdjM2QyMWZjMmEzY2M1OTk4MzNlNjVkODliNzMwNzllZWQ=
12
- data.tar.gz: !binary |-
13
- NzY4MmIxYzE0NjZiNWE5OWIzODc5OTgxNTg1ZTQ5NmRhYjU2OTUxOWQwZDIy
14
- NjI0OTRhODgwMjUyNjBlOWNiYTFkNGUxOTNhZDQzMjNkMDBmNmQyOTBmZTM0
15
- N2U4Yjk0NTE0NGMwMzhhZWI2YWFiZTNiOGFhZWM1ZWJjMDAxNzE=