Skip to content

Commit 3a779e9

Browse files
author
Chris Park
committed
Merge branch 'develop'
2 parents 8192c1c + b84ffda commit 3a779e9

5 files changed

Lines changed: 36 additions & 27 deletions

File tree

docker/run_ruby.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ cp -r -n /source/. .
8787

8888
#Build rosette_api gem
8989
gem build rosette_api.gemspec
90-
gem install ./rosette_api-1.0.3.gem
90+
gem install ./rosette_api-*.gem
9191

9292
#Run the examples
9393
if [ ! -z ${API_KEY} ]; then

lib/request_builder.rb

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,15 @@ def prepare_multipart_request(params)
8484
post_body << "\r\n\r\n--#{boundary}--\r\n"
8585

8686
# Create the HTTP objects
87-
uri = URI.parse @alternate_url
88-
http = Net::HTTP.new uri.host, uri.port
89-
http.use_ssl = uri.scheme == 'https'
90-
request = Net::HTTP::Post.new uri.request_uri
87+
begin
88+
uri = URI.parse @alternate_url
89+
http = Net::HTTP.new uri.host, uri.port
90+
http.use_ssl = uri.scheme == 'https'
91+
request = Net::HTTP::Post.new uri.request_uri
92+
rescue
93+
raise RosetteAPIError.new 'connectionError', 'Failed to establish connection with Rosette API server.'
94+
end
95+
9196
request.add_field 'Content-Type', "multipart/form-data; boundary=#{boundary}"
9297
request.add_field 'X-RosetteAPI-Key', @user_key
9398
request.add_field 'X-RosetteAPI-Binding', 'ruby'
@@ -101,11 +106,15 @@ def prepare_multipart_request(params)
101106
#
102107
# Returns JSON response or raises RosetteAPIError if encountered.
103108
def send_get_request
104-
uri = URI.parse @alternate_url
105-
http = Net::HTTP.new uri.host, uri.port
106-
http.use_ssl = uri.scheme == 'https'
109+
begin
110+
uri = URI.parse @alternate_url
111+
http = Net::HTTP.new uri.host, uri.port
112+
http.use_ssl = uri.scheme == 'https'
107113

108-
request = Net::HTTP::Get.new uri.request_uri
114+
request = Net::HTTP::Get.new uri.request_uri
115+
rescue
116+
raise RosetteAPIError.new 'connectionError', 'Failed to establish connection with Rosette API server.'
117+
end
109118
request['X-RosetteAPI-Key'] = @user_key
110119

111120
self.get_response http, request

lib/rosette_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# This class allows you to access all Rosette API endpoints.
1010
class RosetteAPI
1111
# Version of Ruby binding
12-
BINDING_VERSION = '1.1.0'
12+
BINDING_VERSION = '1.1.1'
1313
# Rosette API language endpoint
1414
LANGUAGE_ENDPOINT = '/language'
1515
# Rosette API morphology endpoint

rosette_api.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
88
s.required_ruby_version = '>= 2.0.0'
99

1010
s.name = 'rosette_api'
11-
s.version = '1.1.0'
11+
s.version = '1.1.1'
1212
s.license = 'MIT'
1313

1414
s.summary = 'Rosette API gem that supports multilingual text-analytics.'
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
1919
s.authors = ['Basis Technology Corp']
2020
s.email = %q{support@rosette.com}
2121
s.homepage = %q{https://developer.rosette.com/}
22-
s.date = %q{2016-06-01}
22+
s.date = %q{2016-06-02}
2323

2424
all_files = `git ls-files -z`.split("\x0")
2525
s.files = all_files.grep(%r{^(bin|lib)/|^.rubocop.yml$})
@@ -28,4 +28,4 @@ Gem::Specification.new do |s|
2828
s.default_executable = 'rosette_api'
2929

3030
s.add_runtime_dependency('rubysl-securerandom', '~> 2.0')
31-
end
31+
end

tests/tests_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'User-Agent' => 'Ruby',
1919
'X-Rosetteapi-Key' => '0123456789',
2020
'X-Rosetteapi-Binding' => 'ruby',
21-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
21+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
2222
to_return(status: 200, body: {'test': 'language'}.to_json, headers: {})
2323
end
2424
it 'test language' do
@@ -55,7 +55,7 @@
5555
'User-Agent' => 'Ruby',
5656
'X-Rosetteapi-Key' => '0123456789',
5757
'X-Rosetteapi-Binding' => 'ruby',
58-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
58+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
5959
to_return(status: 200, body: {'test': 'morphology/complete'}.to_json, headers: {})
6060
end
6161
it 'test morphology complete' do
@@ -77,7 +77,7 @@
7777
'User-Agent' => 'Ruby',
7878
'X-Rosetteapi-Key' => '0123456789',
7979
'X-Rosetteapi-Binding' => 'ruby',
80-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
80+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
8181
to_return(status: 200, body: {'test': 'morphology/compound-components'}.to_json, headers: {})
8282
end
8383
it 'test morphology compound components' do
@@ -99,7 +99,7 @@
9999
'User-Agent' => 'Ruby',
100100
'X-Rosetteapi-Key' => '0123456789',
101101
'X-Rosetteapi-Binding' => 'ruby',
102-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
102+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
103103
to_return(status: 200, body: {'test': 'morphology/han-readings'}.to_json, headers: {})
104104
end
105105
it 'test morphology han readings' do
@@ -121,7 +121,7 @@
121121
'User-Agent' => 'Ruby',
122122
'X-Rosetteapi-Key' => '0123456789',
123123
'X-Rosetteapi-Binding' => 'ruby',
124-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
124+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
125125
to_return(status: 200, body: {'test': 'morphology/parts-of-speech'}.to_json, headers: {})
126126
end
127127
it 'test morphology parts of speech' do
@@ -143,7 +143,7 @@
143143
'User-Agent' => 'Ruby',
144144
'X-Rosetteapi-Key' => '0123456789',
145145
'X-Rosetteapi-Binding' => 'ruby',
146-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
146+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
147147
to_return(status: 200, body: {'test': 'morphology/lemmas'}.to_json, headers: {})
148148
end
149149
it 'test morphology lemmas' do
@@ -165,7 +165,7 @@
165165
'User-Agent' => 'Ruby',
166166
'X-Rosetteapi-Key' => '0123456789',
167167
'X-Rosetteapi-Binding' => 'ruby',
168-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
168+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
169169
to_return(status: 200, body: {'test': 'entities'}.to_json, headers: {})
170170
end
171171
it 'test entities' do
@@ -188,7 +188,7 @@
188188
'User-Agent' => 'Ruby',
189189
'X-Rosetteapi-Key' => '0123456789',
190190
'X-Rosetteapi-Binding' => 'ruby',
191-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
191+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
192192
to_return(status: 200, body: {'test': 'entities/linked'}.to_json, headers: {})
193193
end
194194
it 'test entities linked' do
@@ -218,7 +218,7 @@
218218
'User-Agent' => 'Ruby',
219219
'X-Rosetteapi-Key' => '0123456789',
220220
'X-Rosetteapi-Binding' => 'ruby',
221-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
221+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
222222
to_return(status: 200, body: {'test': 'categories'}.to_json, headers: {})
223223
end
224224
it 'test categories' do
@@ -240,7 +240,7 @@
240240
'User-Agent' => 'Ruby',
241241
'X-Rosetteapi-Key' => '0123456789',
242242
'X-Rosetteapi-Binding' => 'ruby',
243-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
243+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
244244
to_return(status: 200, body: {'test': 'relationships'}.to_json, headers: {})
245245
end
246246
it 'test relationships' do
@@ -262,7 +262,7 @@
262262
'User-Agent' => 'Ruby',
263263
'X-Rosetteapi-Key' => '0123456789',
264264
'X-Rosetteapi-Binding' => 'ruby',
265-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
265+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
266266
to_return(status: 200, body: {'test': 'name-translation'}.to_json, headers: {})
267267
end
268268
it 'test name translation' do
@@ -289,7 +289,7 @@
289289
'User-Agent' => 'Ruby',
290290
'X-Rosetteapi-Key' => '0123456789',
291291
'X-Rosetteapi-Binding' => 'ruby',
292-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
292+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
293293
to_return(status: 200, body: {'test': 'name-similarity'}.to_json, headers: {})
294294
end
295295
it 'test name similarity' do
@@ -325,7 +325,7 @@
325325
'User-Agent' => 'Ruby',
326326
'X-Rosetteapi-Key' => '0123456789',
327327
'X-Rosetteapi-Binding' => 'ruby',
328-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
328+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
329329
to_return(status: 200, body: {'test': 'tokens'}.to_json, headers: {})
330330
end
331331
it 'test tokens' do
@@ -347,7 +347,7 @@
347347
'User-Agent' => 'Ruby',
348348
'X-Rosetteapi-Key' => '0123456789',
349349
'X-Rosetteapi-Binding' => 'ruby',
350-
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
350+
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
351351
to_return(status: 200, body: {'test': 'sentences'}.to_json, headers: {})
352352
end
353353
it 'test sentences' do

0 commit comments

Comments
 (0)