gfw_api_client 0.2.0
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/.coveralls.yml +1 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +27 -0
- data/CHANGELOG.md +12 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +15 -0
- data/LICENSE +21 -0
- data/README.md +72 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/gfw_api_client.gemspec +32 -0
- data/lib/gfw_api_client.rb +31 -0
- data/lib/gfw_api_client/data_set.rb +51 -0
- data/lib/gfw_api_client/version.rb +3 -0
- data/spec/gfw_api_client_settings_spec.rb +9 -0
- data/spec/gfw_api_client_spec.rb +166 -0
- data/spec/spec_helper.rb +9 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fceaaa2c885ad790a36d409f996f04c1606a002d
|
4
|
+
data.tar.gz: a6e3f1fa4e6b146d17be101ccf429062f2847b64
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b33e5c52e2cce0603fa7517c4493b787cf5311f195f06c62164d6db6303f29cd69aa61d9f0d71b4000b2a983fb8f4b52ca7450b23925ada454e757a1ca16501
|
7
|
+
data.tar.gz: 0a322482c928b34223c39b646885b5fdbfb0de16a6bc9f5b82a6363dcc8352d646c1a13667e23b3b7e14ea84d66b4b8a4da8477f6ef0c884c4a825c1c165f1e7
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
|
4
|
+
rvm:
|
5
|
+
- 2.2
|
6
|
+
- 2.1
|
7
|
+
- 2.0
|
8
|
+
- jruby
|
9
|
+
|
10
|
+
script: 'bundle exec rake'
|
11
|
+
|
12
|
+
env:
|
13
|
+
- RAILS_VERSION="~>4.0.0"
|
14
|
+
- RAILS_VERSION="~>4.1.0"
|
15
|
+
- RAILS_VERSION="~>4.2.0"
|
16
|
+
|
17
|
+
notifications:
|
18
|
+
email:
|
19
|
+
recipients:
|
20
|
+
- sebastian.schkudlara@vizzuality.com
|
21
|
+
on_failure: change
|
22
|
+
on_success: never
|
23
|
+
|
24
|
+
addons:
|
25
|
+
code_climate:
|
26
|
+
repo_token: 851f51bdc878dfe4cd38c44ec651743ae58c93793a84298b68758b5e97ad186a
|
27
|
+
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# 0.2.0
|
2
|
+
|
3
|
+
* Move API credentials to gfw.yml file
|
4
|
+
|
5
|
+
# 0.1.1
|
6
|
+
|
7
|
+
* Get data for table spaces (imazon-alerts, umd-loss-gain, 'forma-alerts, nasa-active-fires, quicc-alerts, terrai-alerts)
|
8
|
+
* Fixes for url if not all params present
|
9
|
+
|
10
|
+
# 0.1.0
|
11
|
+
|
12
|
+
* Initial release
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## Contributing
|
2
|
+
In the spirit of [free software][free-sw], **everyone** is encouraged to help improve this project.
|
3
|
+
|
4
|
+
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
|
5
|
+
|
6
|
+
[issues]: https://github.com/vizzuality/gfw-ruby-client-library/issues
|
7
|
+
|
8
|
+
## Submitting an Issue
|
9
|
+
We use the [GitHub issue tracker][issues] to track bugs and features. Before
|
10
|
+
submitting a bug report or feature request, check to make sure it hasn't
|
11
|
+
already been submitted. When submitting a bug report, please include a [Gist][]
|
12
|
+
that includes a stack trace and any details that may be necessary to reproduce
|
13
|
+
the bug, including your gem version, Ruby version, and operating system.
|
14
|
+
Ideally, a bug report should include a pull request with failing specs.
|
15
|
+
|
16
|
+
[gist]: https://gist.github.com/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Vizzuality
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Gfw API Client
|
2
|
+
|
3
|
+
[](https://travis-ci.org/Vizzuality/gfw-ruby-client-library) [](https://coveralls.io/r/Vizzuality/gfw-ruby-client-library) [](https://codeclimate.com/github/Vizzuality/gfw-ruby-client-library) [](http://inch-ci.org/github/Vizzuality/gfw-ruby-client-library)
|
4
|
+
|
5
|
+
A Ruby Client library for the [GFW-API](https://github.com/wri/gfw-api). For now this library should not be used for any production apps.
|
6
|
+
|
7
|
+
## Requirements and Known Limitations
|
8
|
+
|
9
|
+
Tested with Ruby 2.0.0, 2.1.0, 2.2.0, JRuby (1.9 mode)
|
10
|
+
|
11
|
+
Requires Rails >= 4.0
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'gfw_api_client'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install gfw_api_client
|
28
|
+
|
29
|
+
Make the following constants, in config/gfw.yaml file:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
development:
|
33
|
+
gfw_api_url: http://staging.gfw-apis.appspot.com
|
34
|
+
|
35
|
+
test:
|
36
|
+
gfw_api_url: http://staging.gfw-apis.appspot.com
|
37
|
+
|
38
|
+
# Read values from the environment in production mode.
|
39
|
+
production:
|
40
|
+
gfw_api_url: <%= ENV["GFW_API_URL"] %>
|
41
|
+
```
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
Available data sets (table_space): imazon-alerts, umd-loss-gain, forma-alerts, nasa-active-fires, quicc-alerts, terrai-alerts
|
46
|
+
|
47
|
+
### Params:
|
48
|
+
|
49
|
+
[table_space, concessions, wdpa_id, use_id, type, country, region, start_date, end_date, geo_json]
|
50
|
+
|
51
|
+
### Sample:
|
52
|
+
```ruby
|
53
|
+
require 'gfw_api_client'
|
54
|
+
|
55
|
+
GfwApiClient.find_set({'table_space' => 'forma-alerts', 'concessions' => 'iso', 'country' => 'BRA', 'region' => '3', 'start_date' => '2014-01-01', 'end_date' => '2015-01-01'})
|
56
|
+
```
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
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).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at http://github.com/vizzuality/gfw-ruby-client-library.
|
67
|
+
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
72
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gfw_api_client"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gfw_api_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "gfw_api_client"
|
8
|
+
s.version = GfwApiClient::VERSION
|
9
|
+
s.authors = ["Sebastian Schkudlara"]
|
10
|
+
s.email = ["sebastian.schkudlara@vizzuality.com"]
|
11
|
+
s.license = "MIT"
|
12
|
+
|
13
|
+
s.summary = "Global Forest Watch Ruby API Client Library"
|
14
|
+
s.description = "A Ruby Client library for the Global Forest Watch API https://github.com/wri/gfw-api"
|
15
|
+
s.homepage = "http://github.com/vizzuality/gfw-ruby-client-library"
|
16
|
+
|
17
|
+
s.extra_rdoc_files = ["README.md"]
|
18
|
+
s.files = %w(gfw_api_client.gemspec Rakefile LICENSE CHANGELOG.md README.md Gemfile)
|
19
|
+
|
20
|
+
s.rdoc_options = ["--main", "README.md"]
|
21
|
+
|
22
|
+
s.files = `git ls-files -z`.split("\x0")
|
23
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
|
27
|
+
s.add_runtime_dependency 'typhoeus', '~> 0.7'
|
28
|
+
|
29
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
31
|
+
s.add_development_dependency 'coveralls', '~> 0.8'
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'typhoeus'
|
2
|
+
|
3
|
+
require 'gfw_api_client/version'
|
4
|
+
require 'gfw_api_client/data_set'
|
5
|
+
|
6
|
+
module GfwApiClient
|
7
|
+
|
8
|
+
def self.find_set(options)
|
9
|
+
|
10
|
+
table_space = options['table_space'] if options['table_space']
|
11
|
+
concessions = options['concessions'] if options['concessions']
|
12
|
+
country = options['country'] if options['country']
|
13
|
+
region = options['region'] if options['region']
|
14
|
+
start_date = options['start_date'] if options['start_date']
|
15
|
+
end_date = options['end_date'] if options['end_date']
|
16
|
+
date = options['date'] if options['date']
|
17
|
+
wdpa_id = options['wdpa_id'] if options['wdpa_id']
|
18
|
+
use_id = options['use_id'] if options['use_id']
|
19
|
+
type = options['type'] if options['type']
|
20
|
+
geojson = options['geo_json'] if options['geo_json']
|
21
|
+
api_url = options['api_url'] if options['api_url']
|
22
|
+
|
23
|
+
period = if (start_date && end_date)
|
24
|
+
start_date + ',' + end_date
|
25
|
+
end
|
26
|
+
|
27
|
+
DataSet.find_set(table_space, concessions, country, region, wdpa_id, use_id, type, period, geojson, api_url) if table_space
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class DataSet
|
2
|
+
|
3
|
+
def self.find_set(table_space, concessions=nil, country=nil, region=nil, wdpa_id=nil, use_id=nil, type=nil, period=nil, geojson=nil, api_url=nil)
|
4
|
+
|
5
|
+
if api_url
|
6
|
+
# Get client credentials for GFW API from params
|
7
|
+
gfw_api_url = api_url
|
8
|
+
else
|
9
|
+
# Get client credentials for GFW API from YML file
|
10
|
+
gfw_api_url = if defined?(Rails)
|
11
|
+
YAML::load_file(File.join('config/gfw.yml'))[Rails.env]['gfw_api_url']
|
12
|
+
else
|
13
|
+
'http://staging.gfw-apis.appspot.com'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
base_url = "#{gfw_api_url}/forest-change/#{table_space}"
|
18
|
+
|
19
|
+
request = case concessions
|
20
|
+
when 'iso'
|
21
|
+
path = "#{base_url}/admin/#{country}"
|
22
|
+
path += "/#{region}" if region
|
23
|
+
path += "?period=#{period}" if period
|
24
|
+
|
25
|
+
Typhoeus::Request.new(path, followlocation: true)
|
26
|
+
when 'wdpa'
|
27
|
+
path = "#{base_url}/wdpa/#{wdpa_id}"
|
28
|
+
path += "?period=#{period}" if period
|
29
|
+
|
30
|
+
Typhoeus::Request.new(path, followlocation: true)
|
31
|
+
when 'use'
|
32
|
+
path = "#{base_url}/use/#{type}/#{use_id}"
|
33
|
+
path += "?period=#{period}" if period
|
34
|
+
|
35
|
+
Typhoeus::Request.new(path, followlocation: true)
|
36
|
+
when 'geojson'
|
37
|
+
path = "#{base_url}?type=geojson&geojson=#{CGI::escape(geojson)}"
|
38
|
+
path += "&period=#{period}" if period
|
39
|
+
|
40
|
+
Typhoeus::Request.new(path, followlocation: true)
|
41
|
+
end
|
42
|
+
|
43
|
+
request.on_complete do |response|
|
44
|
+
response if response.success?
|
45
|
+
end
|
46
|
+
|
47
|
+
request.run
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'GfwApiClient data sets' do
|
4
|
+
%w(imazon-alerts
|
5
|
+
umd-loss-gain
|
6
|
+
forma-alerts
|
7
|
+
nasa-active-fires
|
8
|
+
quicc-alerts
|
9
|
+
terrai-alerts
|
10
|
+
).each do |table_space|
|
11
|
+
|
12
|
+
describe "get #{table_space} data" do
|
13
|
+
|
14
|
+
it "returns a json with data for #{table_space} wdpa" do
|
15
|
+
@options = {}
|
16
|
+
@options['table_space'] = "#{table_space}"
|
17
|
+
@options['concessions'] = 'wdpa'
|
18
|
+
@options['wdpa_id'] = '352219'
|
19
|
+
@options['start_date'] = '2014-01-01'
|
20
|
+
@options['end_date'] = '2015-01-01'
|
21
|
+
|
22
|
+
@data_table = GfwApiClient.find_set(@options)
|
23
|
+
@data_table_body = JSON.parse(@data_table.body)
|
24
|
+
|
25
|
+
expect(@data_table.code).to eq(200)
|
26
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
27
|
+
expect(@data_table_body['params']['begin']).to be == '2014-01-01'
|
28
|
+
expect(@data_table_body['params']['end']).to be == '2015-01-01'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns a json with data for #{table_space} iso" do
|
32
|
+
@options = {}
|
33
|
+
@options['table_space'] = "#{table_space}"
|
34
|
+
@options['concessions'] = 'iso'
|
35
|
+
@options['country'] = 'BRA'
|
36
|
+
@options['region'] = '3'
|
37
|
+
@options['start_date'] = '2014-01-01'
|
38
|
+
@options['end_date'] = '2015-01-01'
|
39
|
+
|
40
|
+
@data_table = GfwApiClient.find_set(@options)
|
41
|
+
@data_table_body = JSON.parse(@data_table.body)
|
42
|
+
|
43
|
+
expect(@data_table.code).to eq(200)
|
44
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
45
|
+
expect(@data_table_body['params']['begin']).to be == '2014-01-01'
|
46
|
+
expect(@data_table_body['params']['end']).to be == '2015-01-01'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns a json with data for #{table_space} use" do
|
50
|
+
@options = {}
|
51
|
+
@options['table_space'] = "#{table_space}"
|
52
|
+
@options['concessions'] = 'use'
|
53
|
+
@options['use_id'] = '5602'
|
54
|
+
@options['type'] = 'mining'
|
55
|
+
@options['start_date'] = '2014-01-01'
|
56
|
+
@options['end_date'] = '2015-01-01'
|
57
|
+
|
58
|
+
@data_table = GfwApiClient.find_set(@options)
|
59
|
+
@data_table_body = JSON.parse(@data_table.body)
|
60
|
+
|
61
|
+
expect(@data_table.code).to eq(200)
|
62
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
63
|
+
expect(@data_table_body['params']['begin']).to be == '2014-01-01'
|
64
|
+
expect(@data_table_body['params']['end']).to be == '2015-01-01'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns a json with data for #{table_space} geojson" do
|
68
|
+
@options = {}
|
69
|
+
@options['table_space'] = "#{table_space}"
|
70
|
+
@options['concessions'] = 'geojson'
|
71
|
+
@options['geo_json'] = '{"type":"Polygon","coordinates":[[[-63.8333,-12.3427],[-63.6218,-12.2407],[-63.6465,-12.4446],[-63.8333,-12.3427]]]}'
|
72
|
+
@options['start_date'] = '2008-01-01'
|
73
|
+
@options['end_date'] = '2014-01-01'
|
74
|
+
|
75
|
+
@data_table = GfwApiClient.find_set(@options)
|
76
|
+
@data_table_body = JSON.parse(@data_table.body)
|
77
|
+
|
78
|
+
expect(@data_table.code).to eq(200)
|
79
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
80
|
+
expect(@data_table_body['params']['begin']).to be == '2008-01-01'
|
81
|
+
expect(@data_table_body['params']['end']).to be == '2014-01-01'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns a json with data for #{table_space} iso if not all params present" do
|
85
|
+
@options = {}
|
86
|
+
@options['table_space'] = "#{table_space}"
|
87
|
+
@options['concessions'] = 'iso'
|
88
|
+
@options['country'] = 'BRA'
|
89
|
+
@options['start_date'] = '2014-01-01'
|
90
|
+
|
91
|
+
@data_table = GfwApiClient.find_set(@options)
|
92
|
+
@data_table_body = JSON.parse(@data_table.body)
|
93
|
+
|
94
|
+
expect(@data_table.code).to eq(200)
|
95
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
96
|
+
expect(@data_table_body['params']['begin']).to be_nil
|
97
|
+
expect(@data_table_body['params']['end']).to be_nil
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns a json with data for #{table_space} wdpa if not all params present" do
|
101
|
+
@options = {}
|
102
|
+
@options['table_space'] = "#{table_space}"
|
103
|
+
@options['concessions'] = 'wdpa'
|
104
|
+
@options['wdpa_id'] = '352219'
|
105
|
+
|
106
|
+
@data_table = GfwApiClient.find_set(@options)
|
107
|
+
@data_table_body = JSON.parse(@data_table.body)
|
108
|
+
|
109
|
+
expect(@data_table.code).to eq(200)
|
110
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns a json with data for #{table_space} use if not all params present" do
|
114
|
+
@options = {}
|
115
|
+
@options['table_space'] = "#{table_space}"
|
116
|
+
@options['concessions'] = 'use'
|
117
|
+
@options['use_id'] = '5602'
|
118
|
+
@options['type'] = 'mining'
|
119
|
+
|
120
|
+
@data_table = GfwApiClient.find_set(@options)
|
121
|
+
@data_table_body = JSON.parse(@data_table.body)
|
122
|
+
|
123
|
+
expect(@data_table.code).to eq(200)
|
124
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
125
|
+
end
|
126
|
+
|
127
|
+
it "returns a json with data for #{table_space} geojson if not all params present" do
|
128
|
+
@options = {}
|
129
|
+
@options['table_space'] = "#{table_space}"
|
130
|
+
@options['concessions'] = 'geojson'
|
131
|
+
@options['geo_json'] = '{"type":"Polygon","coordinates":[[[-63.8333,-12.3427],[-63.6218,-12.2407],[-63.6465,-12.4446],[-63.8333,-12.3427]]]}'
|
132
|
+
@options['start_date'] = '2001-01-01' if table_space == 'umd-loss-gain' #date should be present for umd-loss-gain table_space
|
133
|
+
@options['end_date'] = '2015-01-01' if table_space == 'umd-loss-gain' #date should be present for umd-loss-gain table_space
|
134
|
+
|
135
|
+
@data_table = GfwApiClient.find_set(@options)
|
136
|
+
@data_table_body = JSON.parse(@data_table.body)
|
137
|
+
|
138
|
+
expect(@data_table.code).to eq(200)
|
139
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
140
|
+
expect(@data_table_body['params']['begin']).to be_nil unless table_space == 'umd-loss-gain'
|
141
|
+
expect(@data_table_body['params']['end']).to be_nil unless table_space == 'umd-loss-gain'
|
142
|
+
end
|
143
|
+
|
144
|
+
it "returns a json with data for #{table_space} iso and api_url param" do
|
145
|
+
@options = {}
|
146
|
+
@options['table_space'] = "#{table_space}"
|
147
|
+
@options['concessions'] = 'iso'
|
148
|
+
@options['country'] = 'BRA'
|
149
|
+
@options['region'] = '3'
|
150
|
+
@options['start_date'] = '2014-01-01'
|
151
|
+
@options['end_date'] = '2015-01-01'
|
152
|
+
@options['api_url'] = 'http://staging.gfw-apis.appspot.com'
|
153
|
+
|
154
|
+
@data_table = GfwApiClient.find_set(@options)
|
155
|
+
@data_table_body = JSON.parse(@data_table.body)
|
156
|
+
|
157
|
+
expect(@data_table.code).to eq(200)
|
158
|
+
expect(@data_table_body['meta']['id']).to be == table_space
|
159
|
+
expect(@data_table_body['params']['begin']).to be == '2014-01-01'
|
160
|
+
expect(@data_table_body['params']['end']).to be == '2015-01-01'
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gfw_api_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sebastian Schkudlara
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: typhoeus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
69
|
+
description: A Ruby Client library for the Global Forest Watch API https://github.com/wri/gfw-api
|
70
|
+
email:
|
71
|
+
- sebastian.schkudlara@vizzuality.com
|
72
|
+
executables:
|
73
|
+
- console
|
74
|
+
- setup
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files:
|
77
|
+
- README.md
|
78
|
+
files:
|
79
|
+
- ".coveralls.yml"
|
80
|
+
- ".gitignore"
|
81
|
+
- ".rspec"
|
82
|
+
- ".travis.yml"
|
83
|
+
- CHANGELOG.md
|
84
|
+
- CONTRIBUTING.md
|
85
|
+
- Gemfile
|
86
|
+
- LICENSE
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- bin/console
|
90
|
+
- bin/setup
|
91
|
+
- gfw_api_client.gemspec
|
92
|
+
- lib/gfw_api_client.rb
|
93
|
+
- lib/gfw_api_client/data_set.rb
|
94
|
+
- lib/gfw_api_client/version.rb
|
95
|
+
- spec/gfw_api_client_settings_spec.rb
|
96
|
+
- spec/gfw_api_client_spec.rb
|
97
|
+
- spec/spec_helper.rb
|
98
|
+
homepage: http://github.com/vizzuality/gfw-ruby-client-library
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options:
|
104
|
+
- "--main"
|
105
|
+
- README.md
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.2.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Global Forest Watch Ruby API Client Library
|
124
|
+
test_files:
|
125
|
+
- spec/gfw_api_client_settings_spec.rb
|
126
|
+
- spec/gfw_api_client_spec.rb
|
127
|
+
- spec/spec_helper.rb
|