lymbix 0.3.4 → 0.3.5
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/Changelog +1 -0
- data/lib/lymbix/base.rb +26 -2
- data/lib/lymbix/request.rb +9 -5
- data/lib/lymbix/response.rb +11 -6
- metadata +9 -4
data/Changelog
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
v.0.3.5 - added tonalize_article, tonalize_paragraph which belongs to the 2.0 version of gyrus, also modified the request to include the version header
|
1
2
|
v.0.3.4 - fixed issue when setting host it still kept default host instead
|
2
3
|
v.0.3.3 - gem now uses configuration class to set host properties for gyrus
|
3
4
|
v.0.3.2 - made incorrect changes to gem
|
data/lib/lymbix/base.rb
CHANGED
@@ -169,10 +169,26 @@ module Lymbix
|
|
169
169
|
|
170
170
|
# END
|
171
171
|
|
172
|
+
def word_data(phrase)
|
173
|
+
response = request(:post, 'word_data', {:phrase => phrase}).data
|
174
|
+
end
|
175
|
+
|
176
|
+
def update_user_app_config(user_app_config_xml)
|
177
|
+
response = request(:post, 'update_user_app_config', {:user_app_config => user_app_config_xml},{:version => 2}).data
|
178
|
+
end
|
179
|
+
|
180
|
+
def checksum_user_app_config
|
181
|
+
response = request(:get, 'checksum_user_app_config',nil,{:version => 2}).data
|
182
|
+
end
|
183
|
+
|
172
184
|
def tonalize_words(phrase)
|
173
185
|
response = request(:post, 'tonalize_words', {:phrase => phrase}).data
|
174
186
|
end
|
175
187
|
|
188
|
+
def tonalize_paragraph(paragraph)
|
189
|
+
response = request(:post, 'tonalize_paragraph', {:paragraph => paragraph}, {:version => 2}).data
|
190
|
+
end
|
191
|
+
|
176
192
|
def tone_alternates(phrase)
|
177
193
|
response = request(:post, 'suggestions',{:phrase => phrase}).data
|
178
194
|
end
|
@@ -181,6 +197,10 @@ module Lymbix
|
|
181
197
|
response = request(:post, 'suggest_alternates',{:phrase => phrase, :alternates => alternates}).data
|
182
198
|
end
|
183
199
|
|
200
|
+
def tonalize_article(article)
|
201
|
+
response = request(:post, 'tonalize_article',{:article => article},{:version => 2}).data
|
202
|
+
end
|
203
|
+
|
184
204
|
def all_connotative_categories
|
185
205
|
response = request(:get, 'connotative_categories')
|
186
206
|
all_cc = []
|
@@ -206,8 +226,12 @@ module Lymbix
|
|
206
226
|
end
|
207
227
|
|
208
228
|
private
|
209
|
-
def request(action, method, data = nil)
|
210
|
-
|
229
|
+
def request(action, method, data = nil,headers = nil)
|
230
|
+
if headers
|
231
|
+
Lymbix::Request.new(action, method, {:app_id => @app_id, :auth_key => @auth_key, :lymbix_user_id => @lymbix_user_id, :version => headers[:version]}, data).run
|
232
|
+
else
|
233
|
+
Lymbix::Request.new(action, method, {:app_id => @app_id, :auth_key => @auth_key, :lymbix_user_id => @lymbix_user_id, :version => 1}, data).run
|
234
|
+
end
|
211
235
|
end
|
212
236
|
|
213
237
|
end
|
data/lib/lymbix/request.rb
CHANGED
@@ -16,7 +16,7 @@ module Lymbix
|
|
16
16
|
|
17
17
|
def connection
|
18
18
|
options = {}
|
19
|
-
options[:headers] = {:accept => "application/json", :APP_ID => self.header_hash[:app_id].to_s, :LYMBIX_USER_ID => self.header_hash[:lymbix_user_id], :AUTHENTICATION => self.header_hash[:auth_key]}
|
19
|
+
options[:headers] = {:accept => "application/json", :APP_ID => self.header_hash[:app_id].to_s, :LYMBIX_USER_ID => self.header_hash[:lymbix_user_id], :AUTHENTICATION => self.header_hash[:auth_key], :VERSION => self.header_hash[:version]}
|
20
20
|
RestClient::Resource.new(self.url, options)
|
21
21
|
end
|
22
22
|
|
@@ -24,25 +24,29 @@ module Lymbix
|
|
24
24
|
case(self.http_method)
|
25
25
|
when :get
|
26
26
|
self.connection[self.method].get do |resp|
|
27
|
+
begin
|
27
28
|
case resp.code
|
28
29
|
when 200
|
29
30
|
self.response = resp.body
|
30
31
|
when 401
|
31
32
|
raise RestClient::Unauthorized
|
32
|
-
else
|
33
|
-
raise Exception
|
34
33
|
end
|
34
|
+
rescue
|
35
|
+
puts resp.inspect
|
36
|
+
end
|
35
37
|
end
|
36
38
|
when :post
|
37
39
|
self.connection[self.method].post(object) do |resp|
|
40
|
+
begin
|
38
41
|
case resp.code
|
39
42
|
when 200
|
40
43
|
self.response = resp.body
|
41
44
|
when 401
|
42
45
|
raise RestClient::Unauthorized
|
43
|
-
else
|
44
|
-
raise Exception
|
45
46
|
end
|
47
|
+
rescue
|
48
|
+
puts resp.inspect
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
48
52
|
Response.new(self.response)
|
data/lib/lymbix/response.rb
CHANGED
@@ -7,15 +7,20 @@ module Lymbix
|
|
7
7
|
|
8
8
|
def initialize(response)
|
9
9
|
unless response == "null"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@success
|
10
|
+
begin
|
11
|
+
@data = JSON.parse(response.to_s)
|
12
|
+
unless @data.class == Array
|
13
|
+
if @data["success"] == "false"
|
14
|
+
@success = false
|
15
|
+
else
|
16
|
+
@success = true
|
17
|
+
end
|
14
18
|
else
|
15
19
|
@success = true
|
16
20
|
end
|
17
|
-
|
18
|
-
|
21
|
+
rescue
|
22
|
+
@success = false
|
23
|
+
@data = response
|
19
24
|
end
|
20
25
|
else
|
21
26
|
@success = false
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lymbix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Patrick Roy
|
@@ -17,7 +18,7 @@ autorequire:
|
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2010-
|
21
|
+
date: 2010-09-14 00:00:00 -03:00
|
21
22
|
default_executable:
|
22
23
|
dependencies: []
|
23
24
|
|
@@ -53,23 +54,27 @@ rdoc_options: []
|
|
53
54
|
require_paths:
|
54
55
|
- lib
|
55
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
56
58
|
requirements:
|
57
59
|
- - ">="
|
58
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
59
62
|
segments:
|
60
63
|
- 0
|
61
64
|
version: "0"
|
62
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
63
67
|
requirements:
|
64
68
|
- - ">="
|
65
69
|
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
66
71
|
segments:
|
67
72
|
- 0
|
68
73
|
version: "0"
|
69
74
|
requirements: []
|
70
75
|
|
71
76
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.3.
|
77
|
+
rubygems_version: 1.3.7
|
73
78
|
signing_key:
|
74
79
|
specification_version: 3
|
75
80
|
summary: The Lymbix gem provides an interface to gyrus (connotative logic and database).
|