Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Jun 2, 2016
2 parents 8192c1c + b84ffda commit 3a779e9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docker/run_ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ cp -r -n /source/. .

#Build rosette_api gem
gem build rosette_api.gemspec
gem install ./rosette_api-1.0.3.gem
gem install ./rosette_api-*.gem

#Run the examples
if [ ! -z ${API_KEY} ]; then
Expand Down
25 changes: 17 additions & 8 deletions lib/request_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ def prepare_multipart_request(params)
post_body << "\r\n\r\n--#{boundary}--\r\n"

# Create the HTTP objects
uri = URI.parse @alternate_url
http = Net::HTTP.new uri.host, uri.port
http.use_ssl = uri.scheme == 'https'
request = Net::HTTP::Post.new uri.request_uri
begin
uri = URI.parse @alternate_url
http = Net::HTTP.new uri.host, uri.port
http.use_ssl = uri.scheme == 'https'
request = Net::HTTP::Post.new uri.request_uri
rescue
raise RosetteAPIError.new 'connectionError', 'Failed to establish connection with Rosette API server.'
end

request.add_field 'Content-Type', "multipart/form-data; boundary=#{boundary}"
request.add_field 'X-RosetteAPI-Key', @user_key
request.add_field 'X-RosetteAPI-Binding', 'ruby'
Expand All @@ -101,11 +106,15 @@ def prepare_multipart_request(params)
#
# Returns JSON response or raises RosetteAPIError if encountered.
def send_get_request
uri = URI.parse @alternate_url
http = Net::HTTP.new uri.host, uri.port
http.use_ssl = uri.scheme == 'https'
begin
uri = URI.parse @alternate_url
http = Net::HTTP.new uri.host, uri.port
http.use_ssl = uri.scheme == 'https'

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

self.get_response http, request
Expand Down
2 changes: 1 addition & 1 deletion lib/rosette_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# This class allows you to access all Rosette API endpoints.
class RosetteAPI
# Version of Ruby binding
BINDING_VERSION = '1.1.0'
BINDING_VERSION = '1.1.1'
# Rosette API language endpoint
LANGUAGE_ENDPOINT = '/language'
# Rosette API morphology endpoint
Expand Down
6 changes: 3 additions & 3 deletions rosette_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.0.0'

s.name = 'rosette_api'
s.version = '1.1.0'
s.version = '1.1.1'
s.license = 'MIT'

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

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

s.add_runtime_dependency('rubysl-securerandom', '~> 2.0')
end
end
28 changes: 14 additions & 14 deletions tests/tests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'language'}.to_json, headers: {})
end
it 'test language' do
Expand Down Expand Up @@ -55,7 +55,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'morphology/complete'}.to_json, headers: {})
end
it 'test morphology complete' do
Expand All @@ -77,7 +77,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'morphology/compound-components'}.to_json, headers: {})
end
it 'test morphology compound components' do
Expand All @@ -99,7 +99,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'morphology/han-readings'}.to_json, headers: {})
end
it 'test morphology han readings' do
Expand All @@ -121,7 +121,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'morphology/parts-of-speech'}.to_json, headers: {})
end
it 'test morphology parts of speech' do
Expand All @@ -143,7 +143,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'morphology/lemmas'}.to_json, headers: {})
end
it 'test morphology lemmas' do
Expand All @@ -165,7 +165,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'entities'}.to_json, headers: {})
end
it 'test entities' do
Expand All @@ -188,7 +188,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'entities/linked'}.to_json, headers: {})
end
it 'test entities linked' do
Expand Down Expand Up @@ -218,7 +218,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'categories'}.to_json, headers: {})
end
it 'test categories' do
Expand All @@ -240,7 +240,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'relationships'}.to_json, headers: {})
end
it 'test relationships' do
Expand All @@ -262,7 +262,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'name-translation'}.to_json, headers: {})
end
it 'test name translation' do
Expand All @@ -289,7 +289,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'name-similarity'}.to_json, headers: {})
end
it 'test name similarity' do
Expand Down Expand Up @@ -325,7 +325,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'tokens'}.to_json, headers: {})
end
it 'test tokens' do
Expand All @@ -347,7 +347,7 @@
'User-Agent' => 'Ruby',
'X-Rosetteapi-Key' => '0123456789',
'X-Rosetteapi-Binding' => 'ruby',
'X-Rosetteapi-Binding-Version' => '1.1.0'}).
'X-Rosetteapi-Binding-Version' => '1.1.1'}).
to_return(status: 200, body: {'test': 'sentences'}.to_json, headers: {})
end
it 'test sentences' do
Expand Down

0 comments on commit 3a779e9

Please sign in to comment.