From b5811e87cac876473d559b59bfe4519cc9270c16 Mon Sep 17 00:00:00 2001 From: fiona Date: Mon, 23 May 2016 13:39:14 -0400 Subject: [PATCH 1/4] Improved error handling when connection to RosetteAPI cannot be established. --- lib/request_builder.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/request_builder.rb b/lib/request_builder.rb index d254e98..60967ff 100644 --- a/lib/request_builder.rb +++ b/lib/request_builder.rb @@ -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' @@ -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 From bfeed9183546c7c3006c95e6f54357837221ca48 Mon Sep 17 00:00:00 2001 From: fiona Date: Mon, 23 May 2016 15:44:00 -0400 Subject: [PATCH 2/4] Updated binding_version. --- lib/rosette_api.rb | 2 +- rosette_api.gemspec | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rosette_api.rb b/lib/rosette_api.rb index 25f852a..dd122f4 100644 --- a/lib/rosette_api.rb +++ b/lib/rosette_api.rb @@ -9,7 +9,7 @@ # This class allows you to access all Rosette API endpoints. class RosetteAPI # Version of Ruby binding - BINDING_VERSION = '1.0.2' + BINDING_VERSION = '1.0.5' # Rosette API language endpoint LANGUAGE_ENDPOINT = '/language' # Rosette API morphology endpoint diff --git a/rosette_api.gemspec b/rosette_api.gemspec index dc2298a..3206250 100644 --- a/rosette_api.gemspec +++ b/rosette_api.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.0.0' s.name = 'rosette_api' - s.version = '1.0.3' + s.version = '1.0.5' s.license = 'MIT' s.summary = 'Rosette API gem that supports multilingual text-analytics.' @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.authors = ['Basis Technology Corp'] s.email = %q{support@rosette.com} s.homepage = %q{https://developer.rosette.com/} - s.date = %q{2016-05-03} + s.date = %q{2016-05-23} all_files = `git ls-files -z`.split("\x0") s.files = all_files.grep(%r{^(bin|lib)/|^.rubocop.yml$}) From aa9c7959c1e5c8cad44a213cb496c3eaf8534155 Mon Sep 17 00:00:00 2001 From: fiona Date: Wed, 25 May 2016 13:56:24 -0400 Subject: [PATCH 3/4] Fixed binding version in tests --- docker/run_ruby.sh | 2 +- tests/tests_spec.rb | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docker/run_ruby.sh b/docker/run_ruby.sh index acbe8f9..5c8e1e9 100644 --- a/docker/run_ruby.sh +++ b/docker/run_ruby.sh @@ -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 diff --git a/tests/tests_spec.rb b/tests/tests_spec.rb index b39c1c8..ab2ce2f 100644 --- a/tests/tests_spec.rb +++ b/tests/tests_spec.rb @@ -18,7 +18,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'language'}.to_json, headers: {}) end it 'test language' do @@ -55,7 +55,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'morphology/complete'}.to_json, headers: {}) end it 'test morphology complete' do @@ -77,7 +77,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'morphology/compound-components'}.to_json, headers: {}) end it 'test morphology compound components' do @@ -99,7 +99,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'morphology/han-readings'}.to_json, headers: {}) end it 'test morphology han readings' do @@ -121,7 +121,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'morphology/parts-of-speech'}.to_json, headers: {}) end it 'test morphology parts of speech' do @@ -143,7 +143,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'morphology/lemmas'}.to_json, headers: {}) end it 'test morphology lemmas' do @@ -165,7 +165,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'entities'}.to_json, headers: {}) end it 'test entities' do @@ -188,7 +188,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'entities/linked'}.to_json, headers: {}) end it 'test entities linked' do @@ -218,7 +218,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'categories'}.to_json, headers: {}) end it 'test categories' do @@ -240,7 +240,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'relationships'}.to_json, headers: {}) end it 'test relationships' do @@ -262,7 +262,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'name-translation'}.to_json, headers: {}) end it 'test name translation' do @@ -289,7 +289,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'name-similarity'}.to_json, headers: {}) end it 'test name similarity' do @@ -325,7 +325,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'tokens'}.to_json, headers: {}) end it 'test tokens' do @@ -347,7 +347,7 @@ 'User-Agent' => 'Ruby', 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.0.2'}). + 'X-Rosetteapi-Binding-Version' => '1.0.5'}). to_return(status: 200, body: {'test': 'sentences'}.to_json, headers: {}) end it 'test sentences' do From b84ffda1cc16e82a3caa7e3ddcf22be641c9f16f Mon Sep 17 00:00:00 2001 From: Chris Park Date: Thu, 2 Jun 2016 10:14:55 -0400 Subject: [PATCH 4/4] Version 1.1.1 (minor changes missed during publish) --- lib/rosette_api.rb | 2 +- rosette_api.gemspec | 6 +++--- tests/tests_spec.rb | 28 ++++++++++++++-------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/rosette_api.rb b/lib/rosette_api.rb index d5ee54d..fa45459 100644 --- a/lib/rosette_api.rb +++ b/lib/rosette_api.rb @@ -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 diff --git a/rosette_api.gemspec b/rosette_api.gemspec index e9fdd94..a3ca17f 100644 --- a/rosette_api.gemspec +++ b/rosette_api.gemspec @@ -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.' @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.authors = ['Basis Technology Corp'] s.email = %q{support@rosette.com} 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$}) @@ -28,4 +28,4 @@ Gem::Specification.new do |s| s.default_executable = 'rosette_api' s.add_runtime_dependency('rubysl-securerandom', '~> 2.0') -end \ No newline at end of file +end diff --git a/tests/tests_spec.rb b/tests/tests_spec.rb index c1c62d1..4ca672a 100644 --- a/tests/tests_spec.rb +++ b/tests/tests_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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