Skip to content

Commit

Permalink
Merge pull request #58 from rosette-api/DEVOPS-247-address-similarity
Browse files Browse the repository at this point in the history
Add /address-similarity
  • Loading branch information
seth-mg authored Nov 4, 2019
2 parents 429041f + aab53b4 commit b4d957c
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 186 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/tmp/
Gemfile.lock

# Jetbrains
**/.idea/*

## Specific to RubyMotion:
.dat*
.repl_history
Expand Down
20 changes: 11 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-11-03 23:25:34 +0000 using RuboCop version 0.76.0.
# on 2019-11-04 18:38:39 +0000 using RuboCop version 0.76.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Offense count: 4
Metrics/AbcSize:
Max: 44

# Offense count: 8
# Offense count: 10
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 707
Max: 786

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 218
Max: 228

# Offense count: 1
Metrics/CyclomaticComplexity:
Max: 8

# Offense count: 9
# Offense count: 11
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 51
Expand All @@ -39,10 +39,12 @@ Metrics/ParameterLists:
Metrics/PerceivedComplexity:
Max: 8

# Offense count: 8
# Offense count: 10
# Rubocop not hip to RDoc directives.
Style/CommentedKeyword:
Exclude:
- 'lib/address_parameter.rb'
- 'lib/address_similarity_parameters.rb'
- 'lib/bad_request_error.rb'
- 'lib/bad_request_format_error.rb'
- 'lib/document_parameters.rb'
Expand All @@ -67,14 +69,14 @@ Style/IfUnlessModifier:
Exclude:
- 'lib/rosette_api.rb'

# Offense count: 12
# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: .
# SupportedStyles: compact, exploded
Style/RaiseArgs:
EnforcedStyle: compact

# Offense count: 9
# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ gem build rosette_api.gemspec
#### Install the gem

```
gem install rosette_api-1.12.1.gem
gem install rosette_api-*.gem
```
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Basis Technology Corp

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

Complete list of developers available at our web site:

Expand Down
48 changes: 26 additions & 22 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
Ruby Examples
============
Each example class can be run independently.
## Endpoint Examples

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

A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolchain also supports it.

## Running the example
You can run your desired `_endpoint_.rb` file to see it in action.
Each example file demonstrates one of the capabilities of the Rosette Platform. Each example, when run, prints its output to the console.

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

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

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

## Docker ##
A Docker image for running the examples against the compiled source library is available on Docker Hub.
#### Docker/Latest Source
```
git clone [email protected]:rosette-api/ruby.git
cd ruby
docker run -it -v $(pwd):/source --entrypoint bash ruby:2.6-slim-stretch
Command: `docker run -e API_KEY=api-key -v "<binding root directory>:/source" rosetteapi/docker-ruby`
cd /source
gem build rosette_api.gemspec
gem install rosette_api*.gem
Additional environment settings:
`-e ALT_URL=<alternative URL>`
`-e FILENAME=<single filename>`
cd examples
ruby ping.rb $API_KEY
```
35 changes: 35 additions & 0 deletions examples/address_similarity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require 'rosette_api'

api_key, url = ARGV

rosette_api = if url
RosetteAPI.new(api_key, url)
else
RosetteAPI.new(api_key)
end

begin
address1 = AddressParameter.new(
house_number: '1600',
road: 'Pennsylvania Ave NW',
city: 'Washington',
state: 'DC',
post_code: '20500'
)
address2 = AddressParameter.new(
house_number: '160',
road: 'Pennsilvana Avenue',
city: 'Washington',
state: 'D.C.',
post_code: '20500'
)
params = AddressSimilarityParameters.new(address1, address2)
response = rosette_api.get_address_similarity(params)
puts JSON.pretty_generate(response)
rescue RosetteAPIError => e
printf('Rosette API Error (%<status_code>s): %<message>s',
status_code: e.status_code,
message: e.message)
end
17 changes: 0 additions & 17 deletions examples/docker/Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions examples/docker/README.md

This file was deleted.

98 changes: 0 additions & 98 deletions examples/docker/run_ruby.sh

This file was deleted.

Loading

0 comments on commit b4d957c

Please sign in to comment.