arcgis-opendata 0.0.5 → 0.0.6
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 +4 -4
- data/README.md +24 -0
- data/lib/client.rb +18 -4
- data/lib/version.rb +3 -0
- data/opendata.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45bd9d987a78c6dd42d3990c6dd2f23976afb633
|
4
|
+
data.tar.gz: 8a70222a96289c8832b1f6e97720e014066ffeb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c9666b49c7acd7dc8421fd0d10b9aebd280ea9e3c5e6a0fc3a4bd0dce5cd48e43829ef8d168edb07b3fb49e471004762dc14c137c6b62d97d82c8567d1559f1
|
7
|
+
data.tar.gz: 64b8053ab24c769b06fae0376b0bd851c40f39bac1ca39710cd30ee70ded33058b9f9a8bce6ebef32c0652f913d1bd2b13d7ba3c7f8a9851364a4de56a36549a
|
data/README.md
CHANGED
@@ -37,6 +37,30 @@ You can also instantiate an instance directly from the Opendata module
|
|
37
37
|
client = Opendata.new('https://opendata.arcgis.com')
|
38
38
|
```
|
39
39
|
|
40
|
+
### Example Dataset Queries
|
41
|
+
|
42
|
+
Search Parameters are JSONAPI compliant. To learn more about the JSONAPI parameters go to their section
|
43
|
+
about [fetching data](http://jsonapi.org/format/#fetching) at jsonapi.org
|
44
|
+
|
45
|
+
Parameters supported for `dataset_list`
|
46
|
+
|
47
|
+
| Parameter | Type | Description | Usage |
|
48
|
+
| --------- | ---- | ----------- | ----- |
|
49
|
+
| q | String | query to perform against the datasets resource | `client#dataset_list(q: 'census')` |
|
50
|
+
| sort | String | specifies sort criteria. prepend with a '-' to signify a descending sort| `client#dataset_list(sort: '-updated_at')` |
|
51
|
+
| include | String | comma-separate list of resources to 'side-load' | `client#dataset_list(include: 'organizations,sites')` |
|
52
|
+
| fields | nested | allows the client to specify a subset of attributes to be returned by the API | `client#dataset_list(fields: { datasets: 'title,url'})` |
|
53
|
+
| filter | nested | filter the datasets on filterable attributes | `client#dataset_list(filter: { content: 'spatial dataset'})` |
|
54
|
+
| page | nested | specify paging parameters. | `client#dataset_list(page: { size: 25, number: 2})`
|
55
|
+
|
56
|
+
Parameters supported for `dataset_show`
|
57
|
+
|
58
|
+
| Parameter | Type | Description | Usage |
|
59
|
+
| --------- | ---- | ----------- | ----- |
|
60
|
+
| include | String | comma-separate list of resources to 'side-load' | `client#dataset_list(include: 'organizations,sites')` |
|
61
|
+
| fields | nested | allows the client to specify a subset of attributes to be returned by the API | `client#dataset_list(fields: { datasets: 'title,url'})` |
|
62
|
+
|
63
|
+
|
40
64
|
Make queries for datasets
|
41
65
|
```ruby
|
42
66
|
client = Opendata.new('https://opendata.arcgis.com')
|
data/lib/client.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
+
require 'version'
|
1
2
|
require 'faraday'
|
2
3
|
require 'uri'
|
3
4
|
|
4
5
|
module Opendata
|
5
6
|
|
6
|
-
VERSION = '0.0.5'.freeze
|
7
|
-
|
8
7
|
class Client
|
9
8
|
|
10
9
|
# Constructor for Opendata::Client instances
|
@@ -20,16 +19,31 @@ module Opendata
|
|
20
19
|
# @param params [Hash] query parameters for Dataset resources
|
21
20
|
# @return [Object] Faraday::Response object
|
22
21
|
def dataset_list(params = {})
|
23
|
-
connection.get(
|
22
|
+
connection.get(dataset_list_request(params))
|
23
|
+
end
|
24
|
+
|
25
|
+
# Makes requests for 'logical collections' of Dataset resources (zero-to-many potential dataset resources)
|
26
|
+
# @param params [Hash] query parameters for Dataset resources
|
27
|
+
# @return [String] request url based on the parameters specfied
|
28
|
+
def dataset_list_request(params = {})
|
29
|
+
DATASETS_API_PATH + param_to_query_string(params)
|
24
30
|
end
|
25
31
|
|
26
32
|
# Makes requests for a 'logical object' for a specific Dataset resource (zero-to-one potential dataset resources)
|
27
33
|
# @param id [String] The dataset id
|
28
34
|
# @param params [Hash] Additional request parameters
|
35
|
+
# @return [Object] Faraday::Response object
|
29
36
|
def dataset_show(id, params = {})
|
30
37
|
raise '#dataset_show must receive a dataset id' if id.nil?
|
38
|
+
connection.get(dataset_show_url(id, params))
|
39
|
+
end
|
31
40
|
|
32
|
-
|
41
|
+
# Returns the url based on the id and url parameters specified
|
42
|
+
# @param id [String] The dataset id
|
43
|
+
# @param params [Hash] Additional request parameters
|
44
|
+
# @return [String] request url based on id and parameters specified
|
45
|
+
def dataset_show_url(id, params = {})
|
46
|
+
DATASETS_API_PATH + "/#{id}" + param_to_query_string(params)
|
33
47
|
end
|
34
48
|
|
35
49
|
def param_to_query_string(params)
|
data/lib/version.rb
ADDED
data/opendata.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arcgis-opendata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Harris
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- bin/setup
|
98
98
|
- lib/client.rb
|
99
99
|
- lib/opendata.rb
|
100
|
+
- lib/version.rb
|
100
101
|
- opendata.gemspec
|
101
102
|
homepage: https://github.com/esridc/arcgis-opendata.rb
|
102
103
|
licenses:
|