colo_biz 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -26
- data/colo_biz.gemspec +2 -2
- data/lib/colo_biz/data_fetcher.rb +3 -11
- data/lib/colo_biz/query_method.rb +0 -10
- data/spec/live_spec.rb +4 -3
- data/spec/spec_helper.rb +0 -81
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24adbfca1f1511313ea582db4ad53ba7e5bcdc2f
|
4
|
+
data.tar.gz: acf1bd13b05e50ff72431bfd3aeef1d19a4f60fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0749201947d907b4508793fc60b1a8e062b35a2ab5ad1fab675a00756bf9f09184723218c5fb80fb912ef5b00e7a8e8983c5df5fcd844a72554631cfd4fb42f4
|
7
|
+
data.tar.gz: f2f50a121875b163d6578a59fbdfbb7a5608ea104a87dda27901bbfd0a0f170364126b0168a385b00ae4516a95e724ba6d95c8671de10aa74e648e5ef84a3cc1
|
data/README.md
CHANGED
@@ -2,42 +2,48 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/CaseyKelly/Colorado-Business-Entities-API-Gem.svg)](https://travis-ci.org/CaseyKelly/Colorado-Business-Entities-API-Gem)
|
4
4
|
|
5
|
-
A Ruby interface to the Colorado Business Entities API.
|
5
|
+
A Ruby interface to the Colorado Business Entities API. Documentation for the API can be found at https://data.colorado.gov/developers/docs/colorado-business-entities.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
gem install colo_biz
|
9
9
|
|
10
|
-
##
|
11
|
-
Any queries made with the ColoBiz::DataFetcher module will return an array of
|
12
|
-
For the time being the search_by_entity_name does a soft search but all other search terms must match exactly except for case.
|
13
|
-
Our gem covers most of the queries with a method taking a single argument right out of the box. However you can modify any query method by entering what you want to use as a search term then adding "&" and a clause or field search after it.
|
14
|
-
[Socrata](http://dev.socrata.com/docs/queries.html) gives some examples of useful clauses to add. Here is an example of how to use a couple. If you wanted to find all the businesses in Evergreen, CO you would first use the ColoBiz::DataFetcher.new.search_by_principle_city(city_name) method and pass in "evergreen" as the argument. The default limit if you do not set it is 1000 which is too low for almost any search. You can increase the limit returned to the max of 50000 by including "&$limit=50000" at the end of the string you pass in as the argument for the method. Your final method would look like .search_by_principle_city("evergreen&$limit=50000"). This would return all Business entities in evergreen; about 9000. You could also add [Fields](https://data.colorado.gov/developers/docs/colorado-business-entities) to filter by. An example of this is to modify the above search to only return LLC's by adding &entitytype=DLLC to the end of the arguement we're passing the query method: ColoBiz::DataFetcher.new.search_by_principle_city("evergreen&$limit=50000&entitytype=FLLC") Notice that you must use either DLLC for "Domestic Limited Liability Company" or FLLC for "Foreign Limited Liability Company".
|
15
|
-
If you feel comfortable with the clauses and fields described above you may be more comfortable stringing them together for your own query to use in the .custom_query(query) method. We did not write a pagination method to return more than 50000 results because it would be stored in memory. The entire dataset is about 1.3 million entities which we feel would be unwieldy in active memory as a single array of objects. If you are comfortable using [pagination](http://dev.socrata.com/docs/paging.html), you want more than 500000 results, and your writing to a data base then you can iterate over our custom query method and write to a database.
|
10
|
+
## Configuration
|
11
|
+
Any queries made with the ColoBiz::DataFetcher module will return an array of businesses. For each business, all the business' attributes are returned in a JSON hash. The attributes of each object can be called by their [field name](https://data.colorado.gov/developers/docs/colorado-business-entities) in snake case.
|
16
12
|
|
13
|
+
For example, the field name principalcity can be called on any business object as:
|
14
|
+
```ruby
|
15
|
+
@bizentity.principal_city
|
16
|
+
```
|
17
|
+
For the time being, the search_by_entity_name does a soft search but all other search terms must match exactly except for case.
|
17
18
|
|
18
|
-
|
19
|
+
Our gem covers most of the queries with a method taking a single argument right out of the box, however, you can modify any query method by entering what you want to use as a search term then adding "&" and a clause or field search after it.
|
19
20
|
|
20
|
-
[
|
21
|
+
[Socrata](http://dev.socrata.com/docs/queries.html) gives some examples of useful clauses to add. Here are some examples of how to use a couple. If you wanted to find all the businesses in Evergreen, CO you would first use the ColoBiz::DataFetcher.new.search_by_principle_city(city_name) method and pass in "evergreen" as the argument.
|
22
|
+
```ruby
|
23
|
+
ColoBiz::DataFetcher.new.search_by_principle_city("evergreen")
|
24
|
+
```
|
21
25
|
|
22
|
-
##
|
23
|
-
|
24
|
-
|
25
|
-
CODE EXAMPLE
|
26
|
-
```
|
26
|
+
## Number of Responses
|
27
|
+
|
28
|
+
The default number of responses is only 1,000. You can increase the limit returned, up to the max of 50,000, by including "&$limit=50000" at the end of the string you pass in as the argument for the method. Your final method would look like .search_by_principle_city("evergreen&$limit=50000"). This would return all Business entities in evergreen; about 9,000.
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
You can also filter the data with [fields](https://data.colorado.gov/developers/docs/colorado-business-entities). An example of this is to modify the above search to only return LLC's by adding "&entitytype=DLLC" to the end of the argument we're passing the query method:
|
31
|
+
```ruby
|
32
|
+
ColoBiz::DataFetcher.new.search_by_principle_city("evergreen&$limit=50000&entitytype=FLLC")
|
33
|
+
```
|
34
|
+
Notice that you must use either DLLC for "Domestic Limited Liability Company" or FLLC for "Foreign Limited Liability Company".
|
30
35
|
|
31
|
-
|
32
|
-
```ruby
|
33
|
-
CODE EXAMPLE
|
34
|
-
```
|
36
|
+
If you feel comfortable with the clauses and fields described above you may be more comfortable stringing them together for your own query to use in the .custom_query(query) method. We did not write a pagination method to return more than 50,000 results because it would be stored in memory.
|
35
37
|
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
CODE EXAMPLE
|
39
|
-
```
|
38
|
+
The entire dataset is about 1.3 million entities which we feel would be unwieldy in active memory as a single array of objects. If you are comfortable using [pagination](http://dev.socrata.com/docs/paging.html), you want more than 500,000 results and your writing to a database, then you can iterate over our custom query method and write to a database.
|
40
39
|
|
41
40
|
## Authors
|
42
|
-
|
43
|
-
|
41
|
+
Finnegan Hewitt
|
42
|
+
+ GitHub: [@FBH037](https://github.com/FBH037)
|
43
|
+
+ <fbhewitt@gmail.com>
|
44
|
+
|
45
|
+
Casey Kelly
|
46
|
+
+ GitHub: [@CaseyKelly](https://github.com/CaseyKelly)
|
47
|
+
+ <casey.kelly@colorado.edu>
|
48
|
+
|
49
|
+
NOTE: We built this gem recently while in gSchool in Denver. If you have any questions or suggestions about how to make this gem more useful, feel free to email us.
|
data/colo_biz.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'colo_biz'
|
3
|
-
s.version = '0.0
|
4
|
-
s.date = '2015-04-
|
3
|
+
s.version = '0.1.0' #semver.org
|
4
|
+
s.date = '2015-04-10'
|
5
5
|
s.summary = "Colorado Business Entities Gem"
|
6
6
|
s.description = "A gem that turns the CO Business Entity API into ruby methods."
|
7
7
|
s.authors = ["Finnegan Hewitt", "Casey Kelly"]
|
@@ -1,14 +1,8 @@
|
|
1
|
-
# require 'faraday'
|
2
|
-
# require 'json'
|
3
|
-
# require 'rspec'
|
4
|
-
# require_relative 'biz_entity'
|
5
|
-
# require_relative 'core_ext/nil'
|
6
|
-
# require_relative 'query_method'
|
7
1
|
|
8
2
|
module ColoBiz
|
9
3
|
class DataFetcher
|
10
4
|
include ColoBiz::QueryMethod
|
11
|
-
|
5
|
+
|
12
6
|
def initialize
|
13
7
|
@conn = Faraday.new(:url => 'https://data.colorado.gov') do |faraday|
|
14
8
|
faraday.request :url_encoded # form-encode POST params
|
@@ -18,10 +12,8 @@ module ColoBiz
|
|
18
12
|
end
|
19
13
|
|
20
14
|
def biz_entity
|
21
|
-
|
22
|
-
|
23
|
-
# req.headers['X-App-Token'] =
|
24
|
-
# req.headers['Content-Type'] =
|
15
|
+
response = @conn.get do |req|
|
16
|
+
req.url "/resource/colorado-business-entities.json"
|
25
17
|
end
|
26
18
|
@parsed = JSON.parse(response.body)
|
27
19
|
make_biz_entities(@parsed)
|
@@ -20,7 +20,6 @@ module ColoBiz
|
|
20
20
|
make_biz_entities(parsed)
|
21
21
|
end
|
22
22
|
|
23
|
-
#not tested yet
|
24
23
|
def search_by_principal_city(city_name)
|
25
24
|
response = @conn.get do |req|
|
26
25
|
req.url "/resource/colorado-business-entities.json?principalcity=#{city_name}"
|
@@ -29,7 +28,6 @@ module ColoBiz
|
|
29
28
|
make_biz_entities(parsed)
|
30
29
|
end
|
31
30
|
|
32
|
-
#not tested yet
|
33
31
|
def search_by_principal_state(state_name)
|
34
32
|
response = @conn.get do |req|
|
35
33
|
req.url "/resource/colorado-business-entities.json?principalstate=#{state_name}"
|
@@ -38,7 +36,6 @@ module ColoBiz
|
|
38
36
|
make_biz_entities(parsed)
|
39
37
|
end
|
40
38
|
|
41
|
-
#not tested yet
|
42
39
|
def search_by_principal_zipcode(zipcode)
|
43
40
|
response = @conn.get do |req|
|
44
41
|
req.url "/resource/colorado-business-entities.json?principalzipcode=#{zipcode}"
|
@@ -47,7 +44,6 @@ module ColoBiz
|
|
47
44
|
make_biz_entities(parsed)
|
48
45
|
end
|
49
46
|
|
50
|
-
#not tested yet
|
51
47
|
def search_by_principal_country(two_letter_country_code)
|
52
48
|
response = @conn.get do |req|
|
53
49
|
req.url "/resource/colorado-business-entities.json?principalcountry=#{two_letter_country_code}"
|
@@ -56,9 +52,7 @@ module ColoBiz
|
|
56
52
|
make_biz_entities(parsed)
|
57
53
|
end
|
58
54
|
|
59
|
-
#mailing address, city, state, zipcode, and country are skipped here
|
60
55
|
|
61
|
-
#not tested yet
|
62
56
|
#e.g. "Withdrawn"
|
63
57
|
def search_by_entity_status(entity_status)
|
64
58
|
response = @conn.get do |req|
|
@@ -70,7 +64,6 @@ module ColoBiz
|
|
70
64
|
|
71
65
|
|
72
66
|
#e.g. "Water Company"
|
73
|
-
#not tested
|
74
67
|
def search_by_entity_type_verbatum(entity_type_verbatum)
|
75
68
|
response = @conn.get do |req|
|
76
69
|
req.url "/resource/colorado-business-entities.json?entitytypeverbatum=#{entity_type_verbatum}"
|
@@ -80,7 +73,6 @@ module ColoBiz
|
|
80
73
|
end
|
81
74
|
|
82
75
|
#Must be the acronym for the type. e.g. "WC" for water company
|
83
|
-
#not tested
|
84
76
|
def search_by_entity_type(entity_type)
|
85
77
|
response = @conn.get do |req|
|
86
78
|
req.url "/resource/colorado-business-entities.json?entitytype=#{entity_type}"
|
@@ -90,7 +82,6 @@ module ColoBiz
|
|
90
82
|
end
|
91
83
|
|
92
84
|
#first and last name are not case sensitive
|
93
|
-
#not tested
|
94
85
|
def search_by_agent_full_name(first_name, last_name)
|
95
86
|
response = @conn.get do |req|
|
96
87
|
req.url "/resource/colorado-business-entities.json?agentfirstname=#{first_name}&agentlastname=#{last_name}"
|
@@ -101,7 +92,6 @@ module ColoBiz
|
|
101
92
|
|
102
93
|
#skipped agent middle name, agent suffix, agent organization name, agent principle address 1 and 2
|
103
94
|
|
104
|
-
#not tested
|
105
95
|
def search_by_agent_principal_city(agent_principal_city)
|
106
96
|
response = @conn.get do |req|
|
107
97
|
req.url "/resource/colorado-business-entities.json?agentprincipalcity=#{agent_principal_city}"
|
data/spec/live_spec.rb
CHANGED
@@ -22,9 +22,10 @@ require 'spec_helper'
|
|
22
22
|
gold_hill = ColoBiz::DataFetcher.new.search_by_entity_name("GOLD HILL MESA JOINT VENTURE, LLC")
|
23
23
|
expect(gold_hill.first.entity_name).to eq "GOLD HILL MESA JOINT VENTURE, LLC"
|
24
24
|
end
|
25
|
-
|
25
|
+
it 'returns a hash of entity information on successfull request' do
|
26
|
+
gold_hill = ColoBiz::DataFetcher.new.search_by_entity_name("GOLD HILL MESA JOINT VENTURE, LLC")
|
27
|
+
expect(gold_hill.first.entity_name).to eq "GOLD HILL MESA JOINT VENTURE, LLC"
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
end
|
29
|
-
|
30
|
-
# end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,91 +1,10 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
-
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
-
# files.
|
6
|
-
#
|
7
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
-
# a separate helper file that requires the additional dependencies and performs
|
12
|
-
# the additional setup, and require it from the spec files that actually need
|
13
|
-
# it.
|
14
|
-
#
|
15
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
-
# users commonly want.
|
17
|
-
#
|
18
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
1
|
RSpec.configure do |config|
|
20
|
-
# rspec-expectations config goes here. You can use an alternate
|
21
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
-
# assertions if you prefer.
|
23
2
|
config.expect_with :rspec do |expectations|
|
24
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
-
# and `failure_message` of custom matchers include text for helper methods
|
26
|
-
# defined using `chain`, e.g.:
|
27
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
-
# # => "be bigger than 2 and smaller than 4"
|
29
|
-
# ...rather than:
|
30
|
-
# # => "be bigger than 2"
|
31
3
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
4
|
end
|
33
|
-
|
34
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
5
|
config.mock_with :rspec do |mocks|
|
37
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
-
# a real object. This is generally recommended, and will default to
|
39
|
-
# `true` in RSpec 4.
|
40
6
|
mocks.verify_partial_doubles = true
|
41
7
|
end
|
42
8
|
|
43
|
-
# The settings below are suggested to provide a good initial experience
|
44
|
-
# with RSpec, but feel free to customize to your heart's content.
|
45
|
-
=begin
|
46
|
-
# These two settings work together to allow you to limit a spec run
|
47
|
-
# to individual examples or groups you care about by tagging them with
|
48
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
-
# get run.
|
50
|
-
config.filter_run :focus
|
51
|
-
config.run_all_when_everything_filtered = true
|
52
|
-
|
53
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
54
|
-
# recommended. For more details, see:
|
55
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
56
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
57
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
58
|
-
config.disable_monkey_patching!
|
59
|
-
|
60
|
-
# This setting enables warnings. It's recommended, but in some cases may
|
61
|
-
# be too noisy due to issues in dependencies.
|
62
|
-
config.warnings = true
|
63
|
-
|
64
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
65
|
-
# file, and it's useful to allow more verbose output when running an
|
66
|
-
# individual spec file.
|
67
|
-
if config.files_to_run.one?
|
68
|
-
# Use the documentation formatter for detailed output,
|
69
|
-
# unless a formatter has already been configured
|
70
|
-
# (e.g. via a command-line flag).
|
71
|
-
config.default_formatter = 'doc'
|
72
|
-
end
|
73
|
-
|
74
|
-
# Print the 10 slowest examples and example groups at the
|
75
|
-
# end of the spec run, to help surface which specs are running
|
76
|
-
# particularly slow.
|
77
|
-
config.profile_examples = 10
|
78
|
-
|
79
|
-
# Run specs in random order to surface order dependencies. If you find an
|
80
|
-
# order dependency and want to debug it, you can fix the order by providing
|
81
|
-
# the seed, which is printed after each run.
|
82
|
-
# --seed 1234
|
83
|
-
config.order = :random
|
84
9
|
|
85
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
86
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
87
|
-
# test failures related to randomization by passing the same `--seed` value
|
88
|
-
# as the one that triggered the failure.
|
89
|
-
Kernel.srand config.seed
|
90
|
-
=end
|
91
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colo_biz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finnegan Hewitt
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|