From 86c997cdb4dcc7c8b00425084649bbda1761206b Mon Sep 17 00:00:00 2001 From: Chris Park Date: Fri, 27 Oct 2017 11:05:37 -0400 Subject: [PATCH 1/5] --no-cache Jenkinsfile examples --- Jenkinsfile.examples | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.examples b/Jenkinsfile.examples index 00a6627..272e7f1 100644 --- a/Jenkinsfile.examples +++ b/Jenkinsfile.examples @@ -11,7 +11,7 @@ node { } stage("Build Dockerfile") { dir ("${DOCKERFILE_DIR}") { - docker.build("${TEST_CONTAINER}") + sh "docker build --no-cache -t ${TEST_CONTAINER} ." } } stage("Run Examples") { From 0c873ce7adca99d62babfb221c0e4bbd46d1fb83 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Fri, 27 Oct 2017 14:04:04 -0400 Subject: [PATCH 2/5] Jenkinsfile mod - Updated to look for upstream ALT_URL --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4330a17..314bbd1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,9 @@ node { checkout scm } stage("Test with Docker") { - withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) { + echo "${env.ALT_URL}" + def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}" + withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) { sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosetteapi/docker-ruby" } } From 39cb764d195d10efba3f6371cc272369eab36de8 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Fri, 27 Oct 2017 14:05:53 -0400 Subject: [PATCH 3/5] Updated Jenkinsfile.examples - to look for upstream ALT_URL --- Jenkinsfile.examples | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile.examples b/Jenkinsfile.examples index 272e7f1..b52c575 100644 --- a/Jenkinsfile.examples +++ b/Jenkinsfile.examples @@ -15,8 +15,9 @@ node { } } stage("Run Examples") { - withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) { - sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source ${TEST_CONTAINER}" + echo "${env.ALT_URL}" + def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}" + withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) { sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source ${TEST_CONTAINER}" } } slack(true) From d4a6fb1ab2918c8d79d3a018641313d3e6bb9427 Mon Sep 17 00:00:00 2001 From: Christopher Park Date: Wed, 3 Jan 2018 14:18:01 -0500 Subject: [PATCH 4/5] RCB-542 1.9 release (#51) * Added User-Agent - created unit test - updated mocks to use User-Agent * WS-1272 Multilingual example * Example updates --- examples/categories.rb | 2 +- examples/entities.rb | 2 +- examples/language_multilingual.rb | 20 +++++++++++ examples/morphology_complete.rb | 2 +- examples/name_deduplication.rb | 2 +- examples/name_similarity.rb | 4 +-- examples/name_translation.rb | 2 +- examples/relationships.rb | 2 +- examples/sentences.rb | 2 +- examples/sentiment.rb | 2 +- examples/syntax_dependencies.rb | 2 +- examples/text_embedding.rb | 2 +- examples/tokens.rb | 2 +- lib/request_builder.rb | 6 ++++ lib/rosette_api.rb | 5 +++ tests/tests_spec.rb | 56 ++++++++++++++++++------------- 16 files changed, 76 insertions(+), 37 deletions(-) create mode 100644 examples/language_multilingual.rb diff --git a/examples/categories.rb b/examples/categories.rb index a2e6328..39cdfbd 100644 --- a/examples/categories.rb +++ b/examples/categories.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -categories_url_data = 'http://www.onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/' +categories_url_data = "http://www.onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/" begin params = DocumentParameters.new(content_uri: categories_url_data) response = rosette_api.get_categories(params) diff --git a/examples/entities.rb b/examples/entities.rb index 7af0f13..e30f5ca 100644 --- a/examples/entities.rb +++ b/examples/entities.rb @@ -9,7 +9,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -entities_text_data = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS" +entities_text_data = "The Securities and Exchange Commission today announced the leadership of the agency’s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency’s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency’s Washington D.C. headquarters as well as coordinating with litigators in the SEC’s 11 regional offices around the country." begin params = DocumentParameters.new(content: entities_text_data, genre: 'social-media') response = rosette_api.get_entities(params) diff --git a/examples/language_multilingual.rb b/examples/language_multilingual.rb new file mode 100644 index 0000000..b4af0c3 --- /dev/null +++ b/examples/language_multilingual.rb @@ -0,0 +1,20 @@ +require 'rosette_api' + +api_key, url = ARGV + +if !url + rosette_api = RosetteAPI.new(api_key) +else + rosette_api = RosetteAPI.new(api_key, url) +end + +language_multilingual_data = "On Thursday, as protesters gathered in Washington D.C., the United States Federal Communications Commission under Chairman Ajit Pai voted 3-2 to overturn a 2015 decision, commonly called Net Neutrality, that forbade Internet service providers (ISPs) such as Verizon, Comcast, and AT&T from blocking individual websites or charging websites or customers more for faster load times. Quatre femmes ont été nommées au Conseil de rédaction de la loi du Qatar. Jeudi, le décret royal du Qatar a annoncé que 28 nouveaux membres ont été nommés pour le Conseil de la Choura du pays. ذكرت مصادر أمنية يونانية، أن 9 موقوفين من منظمة \"د هـ ك ب ج\" الذين كانت قد أوقفتهم الشرطة اليونانية في وقت سابق كانوا يخططون لاغتيال الرئيس التركي رجب طيب أردوغان." +begin + params = DocumentParameters.new(content: language_multilingual_data) + params.rosette_options = { 'multilingual' => 'true' } + params.custom_headers = { 'X-RosetteAPI-App' => 'ruby-app' } + response = rosette_api.get_language(params) + puts JSON.pretty_generate(response) +rescue RosetteAPIError => rosette_api_error + printf('Rosette API Error (%s): %s', rosette_api_error.status_code, rosette_api_error.message) +end diff --git a/examples/morphology_complete.rb b/examples/morphology_complete.rb index 0603749..a5cdfe6 100644 --- a/examples/morphology_complete.rb +++ b/examples/morphology_complete.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -morphology_complete_data = "The quick brown fox jumped over the lazy dog. Yes he did." +morphology_complete_data = "The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)" begin params = DocumentParameters.new(content: morphology_complete_data) response = rosette_api.get_morphology_complete(params) diff --git a/examples/name_deduplication.rb b/examples/name_deduplication.rb index d022949..504456c 100644 --- a/examples/name_deduplication.rb +++ b/examples/name_deduplication.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -name_dedupe_data = 'John Smith,Johnathon Smith,Fred Jones' +name_dedupe_data = "Alice Terry,Alice Thierry,Betty Grable,Betty Gable,Norma Shearer,Norm Shearer,Brigitte Helm,Bridget Helem,Judy Holliday,Julie Halliday" threshold = 0.75 names = name_dedupe_data.split(',').map { |n| NameParameter.new(n) } diff --git a/examples/name_similarity.rb b/examples/name_similarity.rb index f03683a..44cd2d5 100644 --- a/examples/name_similarity.rb +++ b/examples/name_similarity.rb @@ -8,8 +8,8 @@ rosette_api = RosetteAPI.new(api_key, url) end -matched_name_data1 = 'Michael Jackson' -matched_name_data2 = '迈克尔·杰克逊' +matched_name_data1 = "Michael Jackson" +matched_name_data2 = "迈克尔·杰克逊" begin name1 = NameParameter.new(matched_name_data1, entity_type: 'PERSON', language: 'eng') params = NameSimilarityParameters.new(name1, matched_name_data2) diff --git a/examples/name_translation.rb b/examples/name_translation.rb index 0d3ca25..63c0ae0 100644 --- a/examples/name_translation.rb +++ b/examples/name_translation.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -translated_name_data = 'معمر محمد أبو منيار القذاف' +translated_name_data = "معمر محمد أبو منيار القذاف" begin params = NameTranslationParameters.new(translated_name_data, 'eng', target_script: 'Latn') response = rosette_api.get_name_translation(params) diff --git a/examples/relationships.rb b/examples/relationships.rb index d7b1e0b..529be4d 100644 --- a/examples/relationships.rb +++ b/examples/relationships.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -relationships_text_data = "Bill Gates, Microsoft's former CEO, is a philanthropist." +relationships_text_data = "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems. According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008. Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials. At the time, Timms was the head of FLIR’s Middle East office in Dubai." begin params = DocumentParameters.new(content: relationships_text_data) params.rosette_options = { accuracyMode: 'PRECISION' } diff --git a/examples/sentences.rb b/examples/sentences.rb index afdb362..d93d4f5 100644 --- a/examples/sentences.rb +++ b/examples/sentences.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -sentences_data = "This land is your land. This land is my land\nFrom California to the New York island;\nFrom the red wood forest to the Gulf Stream waters\n\nThis land was made for you and Me.\n\nAs I was walking that ribbon of highway,\nI saw above me that endless skyway:\nI saw below me that golden valley:\nThis land was made for you and me." +sentences_data = "This land is your land. This land is my land, from California to the New York island; from the red wood forest to the Gulf Stream waters. This land was made for you and Me. As I was walking that ribbon of highway, I saw above me that endless skyway: I saw below me that golden valley: This land was made for you and me." begin params = DocumentParameters.new diff --git a/examples/sentiment.rb b/examples/sentiment.rb index 016017a..de8dea8 100644 --- a/examples/sentiment.rb +++ b/examples/sentiment.rb @@ -10,7 +10,7 @@ end file = Tempfile.new(%w[foo .html]) -sentiment_file_data = 'New Ghostbusters Film

Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, “The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.”

' +sentiment_file_data = "New Ghostbusters Film

Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, “The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.”

" file.write(sentiment_file_data) file.close begin diff --git a/examples/syntax_dependencies.rb b/examples/syntax_dependencies.rb index 4b40327..4e7f9be 100644 --- a/examples/syntax_dependencies.rb +++ b/examples/syntax_dependencies.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -syntax_dependencies_data = 'Yoshinori Ohsumi, a Japanese cell biologist, was awarded the Nobel Prize in Physiology or Medicine on Monday.' +syntax_dependencies_data = "Yoshinori Ohsumi, a Japanese cell biologist, was awarded the Nobel Prize in Physiology or Medicine on Monday." begin params = DocumentParameters.new(content: syntax_dependencies_data) response = rosette_api.get_syntax_dependencies(params) diff --git a/examples/text_embedding.rb b/examples/text_embedding.rb index 35e3cc4..6d89b69 100644 --- a/examples/text_embedding.rb +++ b/examples/text_embedding.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -embeddings_data = 'Cambridge, Massachusetts' +embeddings_data = "Cambridge, Massachusetts" begin params = DocumentParameters.new(content: embeddings_data) response = rosette_api.get_text_embedding(params) diff --git a/examples/tokens.rb b/examples/tokens.rb index de53adb..594a7ca 100644 --- a/examples/tokens.rb +++ b/examples/tokens.rb @@ -8,7 +8,7 @@ rosette_api = RosetteAPI.new(api_key, url) end -tokens_data = '北京大学生物系主任办公室内部会议' +tokens_data = "北京大学生物系主任办公室内部会议" begin params = DocumentParameters.new(content: tokens_data) response = rosette_api.get_tokens(params) diff --git a/lib/request_builder.rb b/lib/request_builder.rb index 12c8bd8..1fd094f 100644 --- a/lib/request_builder.rb +++ b/lib/request_builder.rb @@ -17,6 +17,8 @@ class RequestBuilder attr_accessor :user_key # Rosette API binding version attr_accessor :binding_version + # User-Agent string + attr_reader :user_agent def initialize(user_key, alternate_url, http_client, params = {}, url_parameters = nil, binding_version) @user_key = user_key @@ -24,6 +26,7 @@ def initialize(user_key, alternate_url, http_client, params = {}, url_parameters @http_client = http_client @params = params @binding_version = binding_version + @user_agent = 'Ruby/' + binding_version + '/' + RUBY_VERSION return unless url_parameters @alternate_url = @alternate_url + '?' + URI.encode_www_form(url_parameters) @@ -61,6 +64,7 @@ def prepare_plain_request(params) request['X-RosetteAPI-Key'] = @user_key request['Content-Type'] = 'application/json' request['Accept'] = 'application/json' + request['User-Agent'] = @user_agent request['X-RosetteAPI-Binding'] = 'ruby' request['X-RosetteAPI-Binding-Version'] = @binding_version request.body = params.to_json @@ -123,6 +127,7 @@ def prepare_multipart_request(params) end request.add_field 'Content-Type', "multipart/form-data; boundary=#{boundary}" + request.add_field 'User-Agent', @user_agent request.add_field 'X-RosetteAPI-Key', @user_key request.add_field 'X-RosetteAPI-Binding', 'ruby' request.add_field 'X-RosetteAPI-Binding-Version', @binding_version @@ -143,6 +148,7 @@ def send_get_request raise RosetteAPIError.new 'connectionError', 'Failed to establish connection with Rosette API server.' end request['X-RosetteAPI-Key'] = @user_key + request['User-Agent'] = @user_agent get_response @http_client, request end diff --git a/lib/rosette_api.rb b/lib/rosette_api.rb index 2b03ac4..24bc442 100644 --- a/lib/rosette_api.rb +++ b/lib/rosette_api.rb @@ -398,6 +398,11 @@ def ping .send_get_request end + # Gets the User-Agent string + def user_agent + RequestBuilder.new(@user_key, @alternate_url + PING, @http_client, @url_parameters, BINDING_VERSION).user_agent + end + private # Checks that the right parameter type is being passed in. diff --git a/tests/tests_spec.rb b/tests/tests_spec.rb index 195de7a..05cb496 100644 --- a/tests/tests_spec.rb +++ b/tests/tests_spec.rb @@ -9,6 +9,14 @@ RSpec.configure do |config| config.before(:example) { @content = 'Sample Content' } config.before(:example) { @json = {content: 'Sample Content'}.to_json } + config.before(:example) { @user_agent = 'Ruby/' + RosetteAPI::BINDING_VERSION + '/' + RUBY_VERSION } + end + + describe '.user_agent' do + it 'check User-Agent string' do + result = RosetteAPI.new('0123456789').user_agent + expect(result).to eq @user_agent + end end describe '.get_language' do @@ -18,7 +26,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -52,7 +60,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -73,7 +81,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -94,7 +102,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -115,7 +123,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -136,7 +144,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -157,7 +165,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -179,7 +187,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -210,7 +218,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -231,7 +239,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -253,7 +261,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -280,7 +288,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -318,7 +326,7 @@ headers: {'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -331,7 +339,7 @@ headers: {'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -382,7 +390,7 @@ headers: {'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -415,7 +423,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -436,7 +444,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -457,7 +465,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -476,7 +484,7 @@ stub_request(:get, 'https://api.rosette.com/rest/v1/info') .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789' }) .to_return(status: 200, body: '{"test": "info"}', headers: {}) end @@ -491,7 +499,7 @@ stub_request(:get, 'https://api.rosette.com/rest/v1/ping') .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789' }) .to_return(status: 200, body: '{"test": "ping"}', headers: {}) end @@ -508,7 +516,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0', @@ -529,7 +537,7 @@ stub_request(:get, 'https://api.rosette.com/rest/v1/info') .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789' }) .to_return(status: 409, body: '{"code": "incompatibleClientVersion"}', headers: {}) end @@ -545,7 +553,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) @@ -566,7 +574,7 @@ headers: { 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', - 'User-Agent' => 'Ruby', + 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', 'X-Rosetteapi-Binding-Version' => '1.8.0' }) From 62d8a9785ea579ec3abf7d492456ce665f83dde3 Mon Sep 17 00:00:00 2001 From: Seth Gransky Date: Wed, 17 Jan 2018 20:05:37 +0000 Subject: [PATCH 5/5] Version 1.9.0 --- lib/rosette_api.rb | 2 +- rosette_api.gemspec | 4 ++-- tests/tests_spec.rb | 42 +++++++++++++++++++++--------------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/rosette_api.rb b/lib/rosette_api.rb index 24bc442..bf85870 100644 --- a/lib/rosette_api.rb +++ b/lib/rosette_api.rb @@ -10,7 +10,7 @@ # This class allows you to access all Rosette API endpoints. class RosetteAPI # Version of Ruby binding - BINDING_VERSION = '1.8.0' + BINDING_VERSION = '1.9.0' # Rosette API language endpoint LANGUAGE_ENDPOINT = '/language'.freeze # Rosette API morphology endpoint diff --git a/rosette_api.gemspec b/rosette_api.gemspec index 23eb2a9..3b97d31 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.8.0' + s.version = '1.9.0' 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{2017-10-24} + s.date = %q{2018-01-17} all_files = `git ls-files -z`.split("\x0") s.files = all_files.grep(%r{^(bin|lib)/|^.rubocop.yml$}) diff --git a/tests/tests_spec.rb b/tests/tests_spec.rb index 05cb496..82909d7 100644 --- a/tests/tests_spec.rb +++ b/tests/tests_spec.rb @@ -29,7 +29,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "language"}', headers: {}) end it 'test language' do @@ -63,7 +63,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "morphology/complete"}', headers: {}) end it 'test morphology complete' do @@ -84,7 +84,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "morphology/compound-components"}', headers: {}) end it 'test morphology compound components' do @@ -105,7 +105,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "morphology/han-readings"}', headers: {}) end it 'test morphology han readings' do @@ -126,7 +126,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "morphology/parts-of-speech"}', headers: {}) end it 'test morphology parts of speech' do @@ -147,7 +147,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "morphology/lemmas"}', headers: {}) end it 'test morphology lemmas' do @@ -168,7 +168,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "entities"}', headers: {}) end it 'test entities' do @@ -190,7 +190,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "entities"}', headers: {}) end it 'test entities without qids' do @@ -221,7 +221,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "categories"}', headers: {}) end it 'test categories' do @@ -242,7 +242,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "relationships"}', headers: {}) end it 'test relationships' do @@ -264,7 +264,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "name-translation"}', headers: {}) end it 'test name translation' do @@ -291,7 +291,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "name-similarity"}', headers: {}) end it 'test name similarity' do @@ -329,7 +329,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "name-deduplication"}', headers: {}) nothresh_json = { names: names.map(&:load_param) }.to_json @@ -342,7 +342,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "name-deduplication"}', headers: {}) end it 'test name deduplication' do @@ -393,7 +393,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "transliteration"}', headers: {}) end it 'test transliteration' do @@ -426,7 +426,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "tokens"}', headers: {}) end it 'test tokens' do @@ -447,7 +447,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "topics"}', headers: {}) end it 'test topics' do @@ -468,7 +468,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "sentences"}', headers: {}) end it 'test sentences' do @@ -519,7 +519,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0', + 'X-Rosetteapi-Binding-Version' => '1.9.0', 'X-RosetteApi-App' => 'ruby-app' }) .to_return(status: 200, body: '{"test": "language"}', headers: {}) end @@ -556,7 +556,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "language"}', headers: {}) end it 'test text_embedding' do @@ -577,7 +577,7 @@ 'User-Agent' => @user_agent, 'X-Rosetteapi-Key' => '0123456789', 'X-Rosetteapi-Binding' => 'ruby', - 'X-Rosetteapi-Binding-Version' => '1.8.0' }) + 'X-Rosetteapi-Binding-Version' => '1.9.0' }) .to_return(status: 200, body: '{"test": "language"}', headers: {}) end it 'test syntax_dependencies' do