population_growth 0.1.0 → 0.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +29 -9
- data/lib/population_growth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0dc897b307bfb82d8b66c32c9ae943331330b26
|
4
|
+
data.tar.gz: d8a43d289803b39e71ade12ec94796e31bd91d6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebeee41ce5fed506be4144609c446c54ef8e0dc3396349dbd08bfa60a545bcda497824b5406be7f810de2ffd72148d55e9f0c7c5003441bcf4ad7770863e25ad
|
7
|
+
data.tar.gz: c33da760a59e3eba989a060e2e6bc3a9f0f93af94999d0e176b14655c7987cb627dd222ee87979ccb77e37c0cf2cb04cb46ed244f7c6efd8070e19f22b6fff4a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# PopulationGrowth
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This is an api client for the Population Growth API
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
7
|
+
I published this gem on RubyGems so the below instructions should work for pulling it down.
|
8
|
+
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
@@ -20,19 +20,39 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install population_growth
|
22
22
|
|
23
|
+
If neither of those options above work, you can just clone this repo and do a `bundle console` or build it locally in order to play with it.
|
24
|
+
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
Every request will go through the `PopulationGrowth::Client` object. To start, instantiate it
|
28
|
+
|
29
|
+
`client = PopulationGrowth::Client.new` If we had access token requirements then we would pass them in here.
|
30
|
+
|
31
|
+
To get population data for a particular location
|
32
|
+
|
33
|
+
`location = client.locations.find(zip: 'your_zip_code_here')`
|
34
|
+
|
35
|
+
`location` will now have the following methods:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
location.zip_code
|
39
|
+
location.cbsa
|
40
|
+
location.msa
|
41
|
+
location.pop_2015
|
42
|
+
location.pop_2014
|
43
|
+
location.data
|
44
|
+
```
|
26
45
|
|
27
|
-
|
46
|
+
`location.data` provides a hash with all the attributes at once
|
28
47
|
|
29
|
-
|
48
|
+
## Discussion
|
30
49
|
|
31
|
-
|
50
|
+
- `client.locations` returns an instance of `PopulationGrowth::LocationsConnection` which contains all the avaialable actions we can take for the locations resource (get, create, update, etc.)
|
51
|
+
- `client.locations.find(zip: 'some_zip')` returns an instance of `PopulationGrowth::Location`, which is basically just a wrapper for the api data that comes in.
|
32
52
|
|
33
|
-
|
53
|
+
- The attempt here was to have each client method be an instance of a resource connection. It made more sense to me to keep all knowledge about how to interact with a particular resource into the resource connection object.
|
54
|
+
- I've worked on a couple API clients before where the client acts as the central hub and each method represents an single endpoint. If you have dozens of resources, each with multiple endpoints, then it becomes too difficult to maintain the client object.
|
34
55
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/population_growth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
56
|
|
37
57
|
## License
|
38
58
|
|