altadata 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +149 -0
- data/Rakefile +21 -0
- data/altadata.gemspec +31 -0
- data/lib/altadata.rb +4 -0
- data/lib/altadata/client.rb +198 -0
- data/lib/altadata/version.rb +5 -0
- data/spec/altadata_spec.rb +97 -0
- data/spec/spec_helper.rb +16 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ba3bd8d384a691b9367ca59cd75fc5f8c373dc92ac7b12b731272a932f3ef66e
|
4
|
+
data.tar.gz: 366e45a3aeed84b93658f00090dc4d3cf128e1323d2c888a1d38cc226cf5ae12
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b78fa04c30a8879b9e404389741266bb9527379b7b140a5e61a5f329bb3c0b070503ea7b57595c7ffe39e102b06410b4fd1814d251c39d7f02182833029d6ed
|
7
|
+
data.tar.gz: 515c57033050a32ce2954def0cd150b3be52e2a5c0a547dd8e7099fff5b587593b52a321d60b8390bc730ad4a53035fc73e2c7d10d93c97bca5aacfb48dedc4d
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 ALTADATA
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# ALTADATA Ruby Client
|
2
|
+
|
3
|
+
ALTADATA Ruby gem provides convenient access to the ALTADATA API from applications written in the Ruby language.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'altadata'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install altadata
|
20
|
+
|
21
|
+
|
22
|
+
## Quickstart
|
23
|
+
|
24
|
+
Obtain an API key in your dashboard and initialize the client:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'altadata'
|
28
|
+
|
29
|
+
client = Altadata::Client.new(api_key='YOUR_API_KEY')
|
30
|
+
```
|
31
|
+
|
32
|
+
## Retrieving Data
|
33
|
+
|
34
|
+
You can get the entire data with the code below.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
data = client.get_data(product_code = PRODUCT_CODE).load
|
38
|
+
```
|
39
|
+
|
40
|
+
## Retrieving Subscription Info
|
41
|
+
|
42
|
+
You can get your subscription info with the code below.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
product_list = client.list_subscription
|
46
|
+
```
|
47
|
+
|
48
|
+
## Retrieving Data Header Info
|
49
|
+
|
50
|
+
You can get your data header with the code below.
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
client.get_header(product_code = PRODUCT_CODE)
|
54
|
+
```
|
55
|
+
|
56
|
+
## Retrieving Data with Conditions
|
57
|
+
|
58
|
+
You can get data with using various conditions.
|
59
|
+
|
60
|
+
The columns you can apply these filter operations to are limited to the **filtered columns**.
|
61
|
+
|
62
|
+
> You can find the **filtered columns** in the data section of the data product page.
|
63
|
+
|
64
|
+
### equal condition
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
PRODUCT_CODE = 'co_10_jhucs_03'
|
68
|
+
|
69
|
+
data =
|
70
|
+
client.get_data(product_code = PRODUCT_CODE)
|
71
|
+
.equal(condition_column = 'province_state', condition_value = 'Alabama')
|
72
|
+
.load
|
73
|
+
```
|
74
|
+
|
75
|
+
### in condition
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
PRODUCT_CODE = 'co_10_jhucs_03'
|
79
|
+
|
80
|
+
data =
|
81
|
+
client.get_data(product_code = PRODUCT_CODE)
|
82
|
+
.condition_in(condition_column = 'province_state', condition_value = %w[Montana Utah])
|
83
|
+
.load
|
84
|
+
```
|
85
|
+
|
86
|
+
> condition_value parameter of condition_in method must be Array
|
87
|
+
|
88
|
+
### sort operation
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
PRODUCT_CODE = 'co_10_jhucs_03'
|
92
|
+
|
93
|
+
data =
|
94
|
+
client.get_data(product_code = PRODUCT_CODE)
|
95
|
+
.sort(order_column = 'reported_date', order_method = 'desc')
|
96
|
+
.load
|
97
|
+
```
|
98
|
+
|
99
|
+
> Default value of order_method parameter is 'asc' and order_method parameter must be 'asc' or 'desc'
|
100
|
+
|
101
|
+
|
102
|
+
### select specific columns
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
PRODUCT_CODE = 'co_10_jhucs_03'
|
106
|
+
|
107
|
+
data =
|
108
|
+
client.get_data(product_code = PRODUCT_CODE)
|
109
|
+
.select(selected_column = %w[reported_date province_state mortality_rate])
|
110
|
+
.load
|
111
|
+
```
|
112
|
+
|
113
|
+
> selected_column parameter of select method must be Array
|
114
|
+
|
115
|
+
### get the specified amount of data
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
PRODUCT_CODE = 'co_10_jhucs_03'
|
119
|
+
|
120
|
+
data =
|
121
|
+
client.get_data(product_code = PRODUCT_CODE, size = 20)
|
122
|
+
.load
|
123
|
+
```
|
124
|
+
|
125
|
+
## Retrieving Data with Multiple Conditions
|
126
|
+
|
127
|
+
You can use multiple condition at same time.
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
PRODUCT_CODE = 'co_10_jhucs_03'
|
131
|
+
|
132
|
+
data =
|
133
|
+
client.get_data(product_code = PRODUCT_CODE, size = 100)
|
134
|
+
.condition_in(condition_column = "province_state", condition_value = %w[Montana Utah])
|
135
|
+
.sort(order_column = 'mortality_rate', order_method = 'desc')
|
136
|
+
.select(selected_column = %w[reported_date province_state mortality_rate])
|
137
|
+
.load
|
138
|
+
```
|
139
|
+
|
140
|
+
## Development
|
141
|
+
|
142
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
143
|
+
|
144
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
145
|
+
|
146
|
+
|
147
|
+
## License
|
148
|
+
|
149
|
+
The gem is available as open source under the terms of the [MIT License](https://github.com/altabering/altadata-ruby/blob/master/LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler/setup'
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
rescue LoadError
|
9
|
+
puts 'although not required, bundler is recommened for running the tests'
|
10
|
+
end
|
11
|
+
|
12
|
+
task default: :spec
|
13
|
+
|
14
|
+
require 'rspec/core/rake_task'
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
|
17
|
+
require 'rubocop/rake_task'
|
18
|
+
RuboCop::RakeTask.new do |task|
|
19
|
+
task.requires << 'rubocop-performance'
|
20
|
+
task.requires << 'rubocop-rspec'
|
21
|
+
end
|
data/altadata.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('lib/altadata/version', __dir__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'altadata'
|
7
|
+
spec.version = Altadata::VERSION
|
8
|
+
spec.authors = ['ALTADATA']
|
9
|
+
spec.email = ['contact@altadata.io']
|
10
|
+
spec.summary = 'Ruby gem for the ALTADATA API'
|
11
|
+
spec.description = 'ALTADATA Ruby gem provides convenient access to the ALTADATA API from applications written in the Ruby language.'
|
12
|
+
spec.homepage = 'https://github.com/altabering/altadata-ruby'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
spec.platform = Gem::Platform::RUBY
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
16
|
+
|
17
|
+
spec.files = Dir['README.md', 'LICENSE', 'CHANGELOG.md', 'lib/**/*.rb', 'lib/**/*.rake',
|
18
|
+
'altadata.gemspec', '.github/*.md', 'Gemfile', 'Rakefile']
|
19
|
+
spec.test_files = Dir['spec/**/*.rb']
|
20
|
+
spec.extra_rdoc_files = ['README.md']
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'faraday', '~> 1.0'
|
24
|
+
spec.add_dependency 'json', '>= 1.8.0'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.6'
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 1.1'
|
29
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.5'
|
30
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
|
31
|
+
end
|
data/lib/altadata.rb
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Altadata
|
7
|
+
class Client
|
8
|
+
attr_accessor :api_key
|
9
|
+
|
10
|
+
##
|
11
|
+
# Sets the api key and api urls required to access the Altadata API.
|
12
|
+
def initialize(api_key)
|
13
|
+
@api_key = api_key
|
14
|
+
@data_api_url = 'https://www.altadata.io/data/api/'
|
15
|
+
@subscription_api_url = "https://www.altadata.io/subscription/api/subscriptions?api_key=#{@api_key}"
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# Retrieves customer's subscription info
|
20
|
+
def list_subscription
|
21
|
+
response = Faraday.get(@subscription_api_url)
|
22
|
+
JSON.parse(response.body)
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Controls types of parameters
|
27
|
+
def check_parameter(parameter_name, parameter, data_type)
|
28
|
+
raise "#{parameter_name} parameter must be #{data_type}" unless parameter.is_a? data_type
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Retrieves data header as an array
|
33
|
+
def get_header(product_code)
|
34
|
+
check_parameter('product_code', product_code, String)
|
35
|
+
|
36
|
+
request_url = "#{@data_api_url}#{product_code}/?format=json&page=1&api_key=#{@api_key}"
|
37
|
+
response = Faraday.get(request_url)
|
38
|
+
JSON.parse(response.body)[0].keys
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Initializes retrieve data process
|
43
|
+
def get_data(product_code, size = nil)
|
44
|
+
check_parameter('product_code', product_code, String)
|
45
|
+
|
46
|
+
unless size.nil?
|
47
|
+
check_parameter('size', size, Integer)
|
48
|
+
raise 'size parameter must be greater than 0' unless size.positive?
|
49
|
+
end
|
50
|
+
|
51
|
+
@size = size
|
52
|
+
@request_url_base = "#{@data_api_url}#{product_code}/?format=json"
|
53
|
+
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Select specific columns in the retrieve data process
|
59
|
+
def select(selected_column)
|
60
|
+
check_parameter('selected_column', selected_column, Array)
|
61
|
+
|
62
|
+
selected_column_text = selected_column.join(',')
|
63
|
+
@request_url_base += "&columns=#{selected_column_text}"
|
64
|
+
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# Sort data by given column and method in the retrieve data process
|
70
|
+
def sort(order_column, order_method = 'asc')
|
71
|
+
check_parameter('order_column', order_column, String)
|
72
|
+
check_parameter('order_method', order_method, String)
|
73
|
+
order_method_array = %w[asc desc]
|
74
|
+
raise "order_method parameter must be 'asc' or 'desc'" unless order_method_array.include? order_method
|
75
|
+
|
76
|
+
@request_url_base += "&order_by=#{order_column}_#{order_method}"
|
77
|
+
|
78
|
+
self
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# 'Equal' condition by given column and value in the retrieve data process
|
83
|
+
def equal(condition_column, condition_value)
|
84
|
+
check_parameter('condition_column', condition_column, String)
|
85
|
+
|
86
|
+
@request_url_base += "&#{condition_column}_eq=#{condition_value}"
|
87
|
+
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# 'Not Equal' condition by given column and value in the retrieve data process
|
93
|
+
def not_equal(condition_column, condition_value)
|
94
|
+
check_parameter('condition_column', condition_column, String)
|
95
|
+
|
96
|
+
@request_url_base += "&#{condition_column}_neq=#{condition_value}"
|
97
|
+
|
98
|
+
self
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# 'Greater than' condition by given column and value in the retrieve data process
|
103
|
+
def greater_than(condition_column, condition_value)
|
104
|
+
check_parameter('condition_column', condition_column, String)
|
105
|
+
|
106
|
+
@request_url_base += "&#{condition_column}_gt=#{condition_value}"
|
107
|
+
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# 'Greater than equal' condition by given column and value in the retrieve data process
|
113
|
+
def greater_than_equal(condition_column, condition_value)
|
114
|
+
check_parameter('condition_column', condition_column, String)
|
115
|
+
|
116
|
+
@request_url_base += "&#{condition_column}_gte=#{condition_value}"
|
117
|
+
|
118
|
+
self
|
119
|
+
end
|
120
|
+
|
121
|
+
##
|
122
|
+
# 'Less than' condition by given column and value in the retrieve data process
|
123
|
+
def less_than(condition_column, condition_value)
|
124
|
+
check_parameter('condition_column', condition_column, String)
|
125
|
+
|
126
|
+
@request_url_base += "&#{condition_column}_lt=#{condition_value}"
|
127
|
+
|
128
|
+
self
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# 'Less than equal' condition by given column and value in the retrieve data process
|
133
|
+
def less_than_equal(condition_column, condition_value)
|
134
|
+
check_parameter('condition_column', condition_column, String)
|
135
|
+
|
136
|
+
@request_url_base += "&#{condition_column}_lte=#{condition_value}"
|
137
|
+
|
138
|
+
self
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# 'In' condition by given column and value in the retrieve data process
|
143
|
+
def condition_in(condition_column, condition_value)
|
144
|
+
check_parameter('condition_column', condition_column, String)
|
145
|
+
check_parameter('condition_value', condition_value, Array)
|
146
|
+
|
147
|
+
condition_value_text = condition_value.join(',')
|
148
|
+
@request_url_base += "&#{condition_column}_in=#{condition_value_text}"
|
149
|
+
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
##
|
154
|
+
# 'Not in' condition by given column and value in the retrieve data process
|
155
|
+
def condition_not_in(condition_column, condition_value)
|
156
|
+
check_parameter('condition_column', condition_column, String)
|
157
|
+
check_parameter('condition_value', condition_value, Array)
|
158
|
+
|
159
|
+
condition_value_text = condition_value.join(',')
|
160
|
+
@request_url_base += "&#{condition_column}_notin=#{condition_value_text}"
|
161
|
+
|
162
|
+
self
|
163
|
+
end
|
164
|
+
|
165
|
+
##
|
166
|
+
# Fetch data with configurations given before
|
167
|
+
def load
|
168
|
+
data = []
|
169
|
+
page = 1
|
170
|
+
total_size = 0
|
171
|
+
|
172
|
+
loop do
|
173
|
+
request_url = "#{@request_url_base}&page=#{page}&api_key=#{@api_key}"
|
174
|
+
response = Faraday.get(request_url)
|
175
|
+
|
176
|
+
response_json = JSON.parse(response.body)
|
177
|
+
|
178
|
+
break if response_json.empty?
|
179
|
+
|
180
|
+
response_json.each do |item|
|
181
|
+
data << item
|
182
|
+
end
|
183
|
+
|
184
|
+
unless @size.nil?
|
185
|
+
total_size += response_json.length
|
186
|
+
|
187
|
+
break if total_size > @size
|
188
|
+
end
|
189
|
+
|
190
|
+
page += 1
|
191
|
+
end
|
192
|
+
|
193
|
+
data = data.first(@size) unless @size.nil?
|
194
|
+
|
195
|
+
data
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../lib/altadata'
|
4
|
+
|
5
|
+
API_KEY = ENV['TEST_API_KEY']
|
6
|
+
PRODUCT_CODE = 'co_10_jhucs_03'
|
7
|
+
|
8
|
+
RSpec.describe Altadata do
|
9
|
+
client = Altadata::Client.new(api_key = API_KEY)
|
10
|
+
|
11
|
+
it 'has a version number' do
|
12
|
+
expect(Altadata::VERSION).not_to be nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'has a valid return at list_subscription method ' do
|
16
|
+
subscription_info = client.list_subscription
|
17
|
+
product_code_arr = []
|
18
|
+
|
19
|
+
subscription_info.each do |info|
|
20
|
+
product_code_arr << info['offer']['code']
|
21
|
+
end
|
22
|
+
|
23
|
+
product_code_list = %w[CO_10_JHUCS_04 CO_08_UNXXX_04
|
24
|
+
CO_10_JHUCS_03 CO_07_IDEAX_02]
|
25
|
+
|
26
|
+
expect(product_code_arr).to eq(product_code_list)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'has a valid return at get_header method ' do
|
30
|
+
header = %w[reported_date province_state population lat
|
31
|
+
lng confirmed prev_confirmed_1d new_confirmed
|
32
|
+
peak_confirmed_1d_flag active deaths prev_deaths_1d
|
33
|
+
new_deaths most_deaths_1d_flag recovered
|
34
|
+
hospitalization_rate incidence_rate mortality_rate
|
35
|
+
people_hospitalized people_tested testing_rate]
|
36
|
+
|
37
|
+
expect(client.get_header(product_code = PRODUCT_CODE)).to eq(header)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has a valid return at get_data method with sort' do
|
41
|
+
data =
|
42
|
+
client.get_data(product_code = PRODUCT_CODE, size = 10)
|
43
|
+
.equal(condition_column = 'province_state', condition_value = 'Alabama')
|
44
|
+
.sort(order_column = 'reported_date', order_method = 'asc')
|
45
|
+
.load
|
46
|
+
|
47
|
+
expect(data[0]['reported_date']).to eq('2020-04-12')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'has a valid return at get_data method with select' do
|
51
|
+
selected_columns = %w[reported_date province_state mortality_rate]
|
52
|
+
data =
|
53
|
+
client.get_data(product_code = PRODUCT_CODE, size = 10)
|
54
|
+
.select(selected_column = selected_columns)
|
55
|
+
.load
|
56
|
+
|
57
|
+
expect(data[0].keys).to eq(selected_columns)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'has a valid return at get_data method with in' do
|
61
|
+
data =
|
62
|
+
client.get_data(product_code = PRODUCT_CODE, size = 250)
|
63
|
+
.condition_in(condition_column = 'province_state', condition_value = %w[Montana Utah])
|
64
|
+
.load
|
65
|
+
|
66
|
+
province_state_arr = []
|
67
|
+
|
68
|
+
data.each do |item|
|
69
|
+
province_state_arr << item['province_state']
|
70
|
+
end
|
71
|
+
|
72
|
+
province_state_arr.uniq!
|
73
|
+
|
74
|
+
expect(province_state_arr).to eq(%w[Montana Utah])
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'has a valid return at get_data method with not in' do
|
78
|
+
check_list = %w[Montana Utah Alabama]
|
79
|
+
|
80
|
+
data =
|
81
|
+
client.get_data(product_code = PRODUCT_CODE, size = 250)
|
82
|
+
.condition_not_in(condition_column = 'province_state', condition_value = check_list)
|
83
|
+
.load
|
84
|
+
|
85
|
+
province_state_arr = []
|
86
|
+
|
87
|
+
data.each do |item|
|
88
|
+
province_state_arr << item['province_state']
|
89
|
+
end
|
90
|
+
|
91
|
+
province_state_arr.uniq!
|
92
|
+
|
93
|
+
check_list.each do |item|
|
94
|
+
expect(province_state_arr).not_to include(item)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'altadata'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# Enable flags like --only-failures and --next-failure
|
8
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
9
|
+
|
10
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
11
|
+
config.disable_monkey_patching!
|
12
|
+
|
13
|
+
config.expect_with :rspec do |c|
|
14
|
+
c.syntax = :expect
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: altadata
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ALTADATA
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-performance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.5'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.37'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.37'
|
111
|
+
description: ALTADATA Ruby gem provides convenient access to the ALTADATA API from
|
112
|
+
applications written in the Ruby language.
|
113
|
+
email:
|
114
|
+
- contact@altadata.io
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files:
|
118
|
+
- README.md
|
119
|
+
files:
|
120
|
+
- CHANGELOG.md
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- altadata.gemspec
|
126
|
+
- lib/altadata.rb
|
127
|
+
- lib/altadata/client.rb
|
128
|
+
- lib/altadata/version.rb
|
129
|
+
- spec/altadata_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
homepage: https://github.com/altabering/altadata-ruby
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 2.5.0
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubygems_version: 3.0.3
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Ruby gem for the ALTADATA API
|
154
|
+
test_files:
|
155
|
+
- spec/altadata_spec.rb
|
156
|
+
- spec/spec_helper.rb
|