refworks 0.0.7 → 0.0.8
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 +8 -8
- data/lib/refworks.rb +25 -20
- data/lib/refworks/response.rb +11 -0
- data/lib/refworks/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmU5OGMyYTczZTdiMjM0NTE4ZjM1OGFhYmZiNjM5NDhjM2ExZGYwYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDNiMDQwMmRkYWYyZTRjMWM3NDRiNTMyNTRkNDI5YWJmZWJjNjRjZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWMwYmRlODc5M2Y5OTUxMzZlMTgxM2YwZTVkMzQxOTM4ZDg3YTFjYzIxMjFj
|
10
|
+
MjM3ZDA2ZWYzNjEyYjRhNjdkOTAyZDQxZjgxODhhYjgxZmY3MTVlM2VhNzVh
|
11
|
+
M2M3NzRlZWJjODQzZTU1ZDQ0YTliNGY4Zjc1NDY0OWJkNjUzMjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
60
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
79
|
-
|
82
|
+
# Grab the session string.
|
83
|
+
@sess = response.sess
|
84
|
+
end
|
80
85
|
|
81
86
|
# Need some error checking here
|
82
87
|
end
|
data/lib/refworks/response.rb
CHANGED
@@ -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"]
|
data/lib/refworks/version.rb
CHANGED