Skip to content

Commit b4d957c

Browse files
authored
Merge pull request #58 from rosette-api/DEVOPS-247-address-similarity
Add /address-similarity
2 parents 429041f + aab53b4 commit b4d957c

File tree

14 files changed

+373
-186
lines changed

14 files changed

+373
-186
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
/tmp/
1313
Gemfile.lock
1414

15+
# Jetbrains
16+
**/.idea/*
17+
1518
## Specific to RubyMotion:
1619
.dat*
1720
.repl_history

.rubocop_todo.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2019-11-03 23:25:34 +0000 using RuboCop version 0.76.0.
3+
# on 2019-11-04 18:38:39 +0000 using RuboCop version 0.76.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 3
9+
# Offense count: 4
1010
Metrics/AbcSize:
1111
Max: 44
1212

13-
# Offense count: 8
13+
# Offense count: 10
1414
# Configuration parameters: CountComments, ExcludedMethods.
1515
# ExcludedMethods: refine
1616
Metrics/BlockLength:
17-
Max: 707
17+
Max: 786
1818

1919
# Offense count: 2
2020
# Configuration parameters: CountComments.
2121
Metrics/ClassLength:
22-
Max: 218
22+
Max: 228
2323

2424
# Offense count: 1
2525
Metrics/CyclomaticComplexity:
2626
Max: 8
2727

28-
# Offense count: 9
28+
# Offense count: 11
2929
# Configuration parameters: CountComments, ExcludedMethods.
3030
Metrics/MethodLength:
3131
Max: 51
@@ -39,10 +39,12 @@ Metrics/ParameterLists:
3939
Metrics/PerceivedComplexity:
4040
Max: 8
4141

42-
# Offense count: 8
42+
# Offense count: 10
4343
# Rubocop not hip to RDoc directives.
4444
Style/CommentedKeyword:
4545
Exclude:
46+
- 'lib/address_parameter.rb'
47+
- 'lib/address_similarity_parameters.rb'
4648
- 'lib/bad_request_error.rb'
4749
- 'lib/bad_request_format_error.rb'
4850
- 'lib/document_parameters.rb'
@@ -67,14 +69,14 @@ Style/IfUnlessModifier:
6769
Exclude:
6870
- 'lib/rosette_api.rb'
6971

70-
# Offense count: 12
72+
# Offense count: 14
7173
# Cop supports --auto-correct.
7274
# Configuration parameters: .
7375
# SupportedStyles: compact, exploded
7476
Style/RaiseArgs:
7577
EnforcedStyle: compact
7678

77-
# Offense count: 9
79+
# Offense count: 15
7880
# Cop supports --auto-correct.
7981
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
8082
# URISchemes: http, https

DEVELOPER.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ gem build rosette_api.gemspec
6060
#### Install the gem
6161

6262
```
63-
gem install rosette_api-1.12.1.gem
63+
gem install rosette_api-*.gem
6464
```

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Basis Technology Corp
22

3-
Copyright (C) 2015-2015 by Basis Technology Corp and the contributors
3+
Copyright (C) 2015-2019 by Basis Technology Corp and the contributors
44

55
Complete list of developers available at our web site:
66

examples/README.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
1-
Ruby Examples
2-
============
3-
Each example class can be run independently.
1+
## Endpoint Examples
42

5-
Each example file demonstrates one of the capabilities of the Rosette Platform.
3+
These examples are scripts that can be run independently to demonstrate the Rosette API functionality.
64

7-
A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolchain also supports it.
8-
9-
## Running the example
10-
You can run your desired `_endpoint_.rb` file to see it in action.
5+
Each example file demonstrates one of the capabilities of the Rosette Platform. Each example, when run, prints its output to the console.
116

12-
`ruby _endpoint_.rb api_key(required) alternate_url(optional)`
7+
Here are some methods for running the examples. Each example will also accept an optional parameter for
8+
overriding the default URL. To use, place the url parameter after the key parameter.
139

14-
For example, run `ruby categories.js <your_key>` if you want to see the categories
15-
functionality demonstrated.
10+
A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolchain also supports it.
1611

17-
All files require you to input your Rosette API User Key after `--key` to run.
18-
For example: `ruby ping.js 1234567890`
12+
#### Docker/Latest Version From RubyGems
13+
```
14+
git clone [email protected]:rosette-api/ruby.git
15+
cd ruby
16+
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
1917
20-
To run all of the examples:
21-
`find -maxdepth 1 -name *.rb -exec ruby {} api_key alternate_url`
18+
gem install rosette_api
2219
23-
Each example, when run, prints its output to the console.
20+
cd /source/examples
21+
ruby ping.rb $API_KEY
22+
```
2423

25-
## Docker ##
26-
A Docker image for running the examples against the compiled source library is available on Docker Hub.
24+
#### Docker/Latest Source
25+
```
26+
git clone [email protected]:rosette-api/ruby.git
27+
cd ruby
28+
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
2729
28-
Command: `docker run -e API_KEY=api-key -v "<binding root directory>:/source" rosetteapi/docker-ruby`
30+
cd /source
31+
gem build rosette_api.gemspec
32+
gem install rosette_api*.gem
2933
30-
Additional environment settings:
31-
`-e ALT_URL=<alternative URL>`
32-
`-e FILENAME=<single filename>`
34+
cd examples
35+
ruby ping.rb $API_KEY
36+
```

examples/address_similarity.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
require 'rosette_api'
4+
5+
api_key, url = ARGV
6+
7+
rosette_api = if url
8+
RosetteAPI.new(api_key, url)
9+
else
10+
RosetteAPI.new(api_key)
11+
end
12+
13+
begin
14+
address1 = AddressParameter.new(
15+
house_number: '1600',
16+
road: 'Pennsylvania Ave NW',
17+
city: 'Washington',
18+
state: 'DC',
19+
post_code: '20500'
20+
)
21+
address2 = AddressParameter.new(
22+
house_number: '160',
23+
road: 'Pennsilvana Avenue',
24+
city: 'Washington',
25+
state: 'D.C.',
26+
post_code: '20500'
27+
)
28+
params = AddressSimilarityParameters.new(address1, address2)
29+
response = rosette_api.get_address_similarity(params)
30+
puts JSON.pretty_generate(response)
31+
rescue RosetteAPIError => e
32+
printf('Rosette API Error (%<status_code>s): %<message>s',
33+
status_code: e.status_code,
34+
message: e.message)
35+
end

examples/docker/Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/docker/README.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/docker/run_ruby.sh

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)