taxing 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 52f04cedff86231ab715847be2d50a10348a4d1e
4
+ data.tar.gz: 5bab0bd0da3e8148a6b82ce2a6493190f71c2c10
5
+ SHA512:
6
+ metadata.gz: 974be0a67e031eff1dacf4c22117ee004fe672f9e558063cfe2a69a5526c3c20a51eec91f27c62689b8421ef40298fac669638f07573d8e5b6863e841c618b8f
7
+ data.tar.gz: 053c0f80a9d69349e7a98769e00aae4e68bb5a4b03123be7be9b590dce2470f7f7166e8d219d0b70535a1fcb522eeaa2e2b23f51a0fbaca31b18bf43cb939eb9
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in taxing.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Finbarr Taylor
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.
@@ -0,0 +1,85 @@
1
+ ## Taxing
2
+
3
+ This gem scrapes US tax rates for individual states or the whole country.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'taxing'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install taxing
20
+
21
+ ## Usage
22
+
23
+ The rates are returned as hashes with the following keys as symbols:
24
+
25
+ ```
26
+ state
27
+ zip_code
28
+ tax_region_name
29
+ tax_region_code
30
+ combined_rate
31
+ state_rate
32
+ county_rate
33
+ city_rate
34
+ special_rate
35
+ ```
36
+
37
+ Here's an example of one rate:
38
+
39
+ ```ruby
40
+ {
41
+ :state=>"CA",
42
+ :zip_code=>"90001",
43
+ :tax_region_name=>"LOS ANGELES COUNTY",
44
+ :tax_region_code=>"AHBG",
45
+ :combined_rate=>"0.090000",
46
+ :state_rate=>"0.065000",
47
+ :county_rate=>"0.010000",
48
+ :city_rate=>"0",
49
+ :special_rate=>"0.015000"
50
+ }
51
+ ```
52
+
53
+ To load all of the rates for one state:
54
+
55
+ ```ruby
56
+ Taxing::Rate.state("CA")
57
+ > [{...}, ...]
58
+ ```
59
+
60
+ To load all of the rates for the USA:
61
+
62
+ ```ruby
63
+ Taxing::Rate.all
64
+ > [{...}, ...]
65
+ ```
66
+
67
+ The methods above can optionally take a `Time` instance as the second argument, and the gem will look up tax rates from that time. They may not all be available. If you get an error when trying to load rates, try passing in a `Time` object for 1 month ago, e.g., `Taxing::Rate.state("CA", 1.month.ago)` (assuming Rails).
68
+
69
+ This gem is not intended to be used as an API. You should scrape the rates periodically and cache them locally.
70
+
71
+ ## Development
72
+
73
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
74
+
75
+ 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).
76
+
77
+ ## Contributing
78
+
79
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/taxing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
80
+
81
+
82
+ ## License
83
+
84
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
85
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "taxing"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require "taxing/version"
2
+ require "taxing/rate"
3
+
4
+ module Taxing
5
+ end
@@ -0,0 +1,40 @@
1
+ require "csv"
2
+ require "httparty"
3
+
4
+ class Taxing::Rate
5
+ include HTTParty
6
+ base_uri "https://s3-us-west-2.amazonaws.com/taxrates.csv"
7
+
8
+ STATES = ["AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", "MO", "MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VA", "VT", "WA", "WI", "WV", "WY"].freeze
9
+
10
+ def self.all(t=Time.now)
11
+ STATES.flat_map do |state_name|
12
+ state(state_name, t)
13
+ end
14
+ end
15
+
16
+ def self.state(state_name, t=Time.now)
17
+ raise "invalid state" unless STATES.include?(state_name)
18
+ raw = get("/TAXRATES_ZIP5_#{state_name}#{t.year}#{t.month}.csv").body
19
+ skipped = false
20
+ rates = []
21
+ CSV.parse(raw).each do |row|
22
+ unless skipped
23
+ skipped = true
24
+ next
25
+ end
26
+ rates << {
27
+ state: row[0],
28
+ zip_code: row[1],
29
+ tax_region_name: row[2],
30
+ tax_region_code: row[3],
31
+ combined_rate: row[4],
32
+ state_rate: row[5],
33
+ county_rate: row[6],
34
+ city_rate: row[7],
35
+ special_rate: row[8]
36
+ }
37
+ end
38
+ rates
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module Taxing
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'taxing/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "taxing"
8
+ spec.version = Taxing::VERSION
9
+ spec.authors = ["Finbarr Taylor"]
10
+ spec.email = ["finbarrtaylor@gmail.com"]
11
+
12
+ spec.summary = %q{The missing US tax rate scraper.}
13
+ spec.description = %q{Scrape tax rates for individual US states or the whole country.}
14
+ spec.homepage = "https://github.com/finbarr/taxing"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_dependency "httparty", "~> 0.13"
25
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: taxing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Finbarr Taylor
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.13'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.13'
55
+ description: Scrape tax rates for individual US states or the whole country.
56
+ email:
57
+ - finbarrtaylor@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CODE_OF_CONDUCT.md
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - lib/taxing.rb
71
+ - lib/taxing/rate.rb
72
+ - lib/taxing/version.rb
73
+ - taxing.gemspec
74
+ homepage: https://github.com/finbarr/taxing
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.6
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: The missing US tax rate scraper.
98
+ test_files: []