naics 1.0.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.
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in naics.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Ed de Almeida
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,95 @@
1
+ # NAICS
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/naics.svg)](https://badge.fury.io/rb/naics) [![Code Climate](https://codeclimate.com/github/EdDeAlmeidaJr/naics_search/badges/gpa.svg)](https://codeclimate.com/github/EdDeAlmeidaJr/naics_search) [![Issue Count](https://codeclimate.com/github/EdDeAlmeidaJr/naics_search/badges/issue_count.svg)](https://codeclimate.com/github/EdDeAlmeidaJr/naics_search)
4
+
5
+ NAICS = North American Industry Classification System
6
+
7
+ Every industry in the USA has a NAICS code and sometimes you need to know what this code means. This is what this Ruby gem does.
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'naics'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install naics
25
+
26
+
27
+ ## Usage
28
+
29
+ In order to use this gem, do
30
+
31
+ ```ruby
32
+ require 'naics'
33
+ ```
34
+
35
+ in your code, and use the method `#search('string_with_the_code')`. The result will be an object in the format
36
+
37
+ {
38
+ :code => "string_with_the_code",
39
+ :description => "Description for the code given, if it exists",
40
+ :explanation => "A short paragraph explaining what the code means."
41
+ }
42
+
43
+ For example, in you run
44
+
45
+ ```ruby
46
+ NAICS.search('423830')
47
+ ```
48
+
49
+ your output will be
50
+
51
+ {
52
+ :code => "432830",
53
+ :description => "Machinery and Equipment Merchant Wholesalers",
54
+ :explanation => "This industry comprises establishments primarily engaged in the merchant wholesale distribution of specialized machinery, equipment, and related parts generally used in manufacturing, oil well, and warehousing activities."
55
+ }
56
+
57
+ **Important:** If you get `:description => nil` and `:explanation => nil`, this only means the code you provided does not exist.
58
+
59
+
60
+ ## Command line
61
+
62
+ This gem also provides a command line executable you may use. Only type
63
+
64
+ $ naics 432830
65
+
66
+ and you'll get an output like:
67
+
68
+ Code: 423830
69
+ Description: Machinery and Equipment Merchant Wholesalers
70
+ Explanation: This industry comprises establishments primarily engaged in the merchant wholesale distribution of specialized machinery, equipment, and related parts generally used in manufacturing, oil well, and warehousing activities.
71
+
72
+ **Important:** If you get no text in `Description:` and `Explanation`, this only means the code you provided does not exist.
73
+
74
+
75
+ ## Development
76
+
77
+ 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.
78
+
79
+ 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).
80
+
81
+
82
+ ## Things to do for future releases
83
+
84
+ - Search NAICS codes for given keywords.
85
+
86
+
87
+ ## Contributing
88
+
89
+ Bug reports and pull requests are welcome on GitHub at https://github.com/EdDeAlmeidaJr/naics_search.
90
+
91
+
92
+ ## License
93
+
94
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
95
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "naics"
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,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'slop'
4
+ require 'naics'
5
+ require 'pp'
6
+
7
+ opts = Slop.parse do |o|
8
+
9
+ # If --version is among the parameters, show version and exit
10
+ o.on '-v', '--version' do
11
+ NAICS.version_info
12
+ exit
13
+ end
14
+
15
+ end
16
+
17
+ code = opts.arguments[0]
18
+
19
+ puts "Code: #{code}"
20
+
21
+ res = NAICS::search(code)
22
+
23
+ res.each { |k,v| puts "#{k.capitalize}: #{v}" }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ require 'httparty'
2
+ require 'nokogiri'
3
+
4
+ require 'naics/version'
5
+
6
+ module NAICS
7
+
8
+ @search_url = 'https://www.naics.com/naics-code-description/'
9
+
10
+ def self.search(code)
11
+ @code = code
12
+ @doc = Nokogiri::HTML(result_page)
13
+ result = Hash.new
14
+ result[:code] = code
15
+ result[:description] = description
16
+ result[:explanation] = explanation
17
+ result
18
+ end
19
+
20
+ def self.result_page
21
+ HTTParty.post(@search_url, :query => {:code => @code})
22
+ end
23
+
24
+ def self.description
25
+ arr = @doc.css("h3[class='sixDigit']").text.split
26
+ arr.shift
27
+ (arr.length > 0) ? arr.join(' ') : nil
28
+ end
29
+
30
+ def self.explanation
31
+ @doc.css("p[class='copy sixDigitCopy']").text.strip.split('Illustrative Examples:')[0]
32
+ end
33
+
34
+ def self.version_info
35
+ puts "NAICS gem - v#{NAICS::VERSION}"
36
+ puts "Author: Ed de Almeida (edvaldoajunior@gmail.com)"
37
+ end
38
+
39
+ end
@@ -0,0 +1,3 @@
1
+ module NAICS
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'naics/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "naics"
8
+ spec.version = NAICS::VERSION
9
+ spec.authors = ["Ed de Almeida"]
10
+ spec.email = ["edvaldoajunior@gmail.com"]
11
+
12
+ spec.summary = %q{This gem gets the description corresponding to a certain NAICS code.}
13
+ spec.description = %q{This gem gets the description corresponding to a certain NAICS code. NAICS stands for North American Industry Classification System and this code is useful in any system dealing with companies' registration.}
14
+ spec.homepage = "https://github.com/EdDeAlmeidaJr/naics_search"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "bin"
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+
28
+ spec.add_runtime_dependency "nokogiri", "~> 1.7"
29
+ spec.add_runtime_dependency "httparty", "~> 0.14"
30
+ spec.add_runtime_dependency "slop", "~> 4.4"
31
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: naics
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ed de Almeida
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-07 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.14'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: slop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.4'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.4'
97
+ description: This gem gets the description corresponding to a certain NAICS code.
98
+ NAICS stands for North American Industry Classification System and this code is
99
+ useful in any system dealing with companies' registration.
100
+ email:
101
+ - edvaldoajunior@gmail.com
102
+ executables:
103
+ - console
104
+ - naics
105
+ - setup
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".codeclimate.yml"
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - ".rubocop.yml"
113
+ - ".travis.yml"
114
+ - Gemfile
115
+ - LICENSE.txt
116
+ - README.md
117
+ - Rakefile
118
+ - bin/console
119
+ - bin/naics
120
+ - bin/setup
121
+ - lib/naics.rb
122
+ - lib/naics/version.rb
123
+ - naics.gemspec
124
+ homepage: https://github.com/EdDeAlmeidaJr/naics_search
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.5.2
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: This gem gets the description corresponding to a certain NAICS code.
148
+ test_files: []