refworks 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzU5NzhjZDUyNzFkMmQ4ZDFkNGYyNTM1N2IwNjM3MzEzMjE3OTExNg==
4
+ NmU5OGMyYTczZTdiMjM0NTE4ZjM1OGFhYmZiNjM5NDhjM2ExZGYwYg==
5
5
  data.tar.gz: !binary |-
6
- ZGQyODU2NWVjOTlmM2Y2N2UxYTViZTA1MzY5ZGE0NzIyMjgxZDg0Ng==
6
+ NDNiMDQwMmRkYWYyZTRjMWM3NDRiNTMyNTRkNDI5YWJmZWJjNjRjZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzcxNDE0ZDM3YTk5YWI5ZWM4YTdiNzA1NTVmYzczNWUyNjQxODgyNjY3MGM3
10
- N2ZhNWQyODhlMThjNGNiNjA5MGI0Y2FkYjdjMmYyZDc5YTBlYWIxN2IzNjNj
11
- ZWQ2MGFmZWVmNDg3ZDM2NjIyNjRkNjI0MGVjODJkMTBiYTNiNTA=
9
+ OWMwYmRlODc5M2Y5OTUxMzZlMTgxM2YwZTVkMzQxOTM4ZDg3YTFjYzIxMjFj
10
+ MjM3ZDA2ZWYzNjEyYjRhNjdkOTAyZDQxZjgxODhhYjgxZmY3MTVlM2VhNzVh
11
+ M2M3NzRlZWJjODQzZTU1ZDQ0YTliNGY4Zjc1NDY0OWJkNjUzMjM=
12
12
  data.tar.gz: !binary |-
13
- YWVlMDk5NWU0ZDJlOTVkYWY0OGU5MWYwNDllZjQzMmIzOTZmODMwMGFjZGQ1
14
- MzUyZmU1NDRlOWViYjMzNzUzMWFkNzljODg0ZWM2ZWYyZDlmYmI4MTYxMmE0
15
- MjJjOWU0NzcyYThkNWMyNmIyN2Q1Y2ZlYWUyYWVhOGI5ZWI3MzQ=
13
+ YmJkOTllZWJjMmZlYTUxN2NlMzIxZDAwNjI1MjY4NDlmOGFmNDI2MDE0ZTY4
14
+ OGQyNTQwN2Q4ZDQ4NmFjMzNiMDZkNDBlZDg1NWViYmNiMDg2MzY5NThiZjVj
15
+ OWEyMmM1YjZkMDIwNjViM2Y5ZGY2NjU3ZDA2ODY1ODhlMjk3NzU=
data/lib/refworks.rb CHANGED
@@ -18,6 +18,7 @@ class Refworks
18
18
  include HTTParty
19
19
 
20
20
  attr_reader :api_url, :access_key, :secret_key, :login_name, :password, :group_code, :id, :sess
21
+ attr_writer :sess
21
22
 
22
23
  # Create a new Refworks client instance.
23
24
  # @example
@@ -55,28 +56,32 @@ class Refworks
55
56
 
56
57
  # probably should check here that I have the minimal set of required attributes to continue
57
58
 
58
- # Can't do much without a session, so get one now
59
- # May need to refactor this - there are parts of the API that don't strictly need a session
60
- if (@group_code)
61
- response = request('authentication', 'newsess',
62
- {
63
- :login_name => @login_name,
64
- :group_code => @group_code,
65
- :password => @password,
66
- }
67
- )
59
+ # Can't do much without a session, so get one now if one wasn't passed in
60
+ if params[:sess]
61
+ @sess = params[:sess]
68
62
  else
69
- response = request('authentication', 'newsess',
70
- {
71
- :login_name => @login_name,
72
- :id => @id,
73
- :password => @password,
74
- }
75
- )
76
- end
63
+ # May need to refactor this - there are parts of the API that don't strictly need a session
64
+ if (@group_code)
65
+ response = request('authentication', 'newsess',
66
+ {
67
+ :login_name => @login_name,
68
+ :group_code => @group_code,
69
+ :password => @password,
70
+ }
71
+ )
72
+ else
73
+ response = request('authentication', 'newsess',
74
+ {
75
+ :login_name => @login_name,
76
+ :id => @id,
77
+ :password => @password,
78
+ }
79
+ )
80
+ end
77
81
 
78
- # Grab the session string.
79
- @sess = response.sess
82
+ # Grab the session string.
83
+ @sess = response.sess
84
+ end
80
85
 
81
86
  # Need some error checking here
82
87
  end
@@ -3,6 +3,17 @@ class Response
3
3
  attr_reader :body, :parsed_response, :result_code, :result_msg, :process_time
4
4
 
5
5
  def initialize(raw_response)
6
+ # The RefWorks API emits invalid XML. Specifically, when the session is invalid, the ResultMsg field
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.
9
+
10
+ p raw_response.body
11
+
12
+ raw_response.body.encode!('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')
13
+ raw_response.body.gsub!(/[\u0001-\u0019]/,'?')
14
+
15
+ p raw_response.body
16
+
6
17
  @body = raw_response.body
7
18
  @parsed_response = raw_response.parsed_response
8
19
  @result_code = parsed_response["refworks"]["RWResult"]["result"]
@@ -1,3 +1,3 @@
1
1
  class Refworks
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fran Fabrizio