sic 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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 569edf2b9bb52f07613331bc37218fec5dfd4fb2
4
+ data.tar.gz: 1ccfb2cc07efa715414af48bdfbaf8fb94afe988
5
+ SHA512:
6
+ metadata.gz: 283acb712414f260cae456de9c98efe8049ad1552c52c7a18bf6033cdbec04b9397a2502e20edc2f6acdff003b28d28a60c88a784c7364ccedb3946340a70ede
7
+ data.tar.gz: 65ac80e5f9a2f5405197e5586ccb4e75442c31e07d90c858b82fb7f88c8a39a0196b57ec61c5d532b74e7fd7a4234649781fd6f43156ce4f52b247d6c5d68144
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .ruby-version
11
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -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,91 @@
1
+ # SIC
2
+
3
+ SIC = Standard Industrial Classification
4
+
5
+ Every industry in the USA has a SIC code and sometimes you need to know what this code means. This is what this Ruby gem does.
6
+
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'sic'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install sic
23
+
24
+
25
+ ## Usage
26
+
27
+ In order to use this gem, do
28
+
29
+ ```ruby
30
+ require 'sic'
31
+ ```
32
+
33
+ in your code, and use the method `#search('string_with_the_code')`. The result will be an object in the format
34
+
35
+ {
36
+ :code => "string_with_the_code",
37
+ :description => "Description for the code given, if it exists"
38
+ }
39
+
40
+ For example, in you run
41
+
42
+ ```ruby
43
+ SIC.search('5084')
44
+ ```
45
+
46
+ your output will be
47
+
48
+ {
49
+ :code => "5084",
50
+ :description => "Industrial Machinery and Equipment"
51
+ }
52
+
53
+ **Important:** If you get `:description => nil`, this only means the code you provided does not exist.
54
+
55
+
56
+ ## Command line
57
+
58
+ This gem also provides a command line executable you may use. Only type
59
+
60
+ $ naics 5084
61
+
62
+ and you'll get an output like:
63
+
64
+ Code: 5084
65
+ Description: Industrial Machinery and Equipment
66
+
67
+
68
+ **Important:** If you get no text in `Description:`, this only means the code you provided does not exist.
69
+
70
+
71
+ ## Development
72
+
73
+ 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.
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
+
78
+ ## Things to do for future releases
79
+
80
+ - Search SIC codes for given keywords.
81
+
82
+
83
+ ## Contributing
84
+
85
+ Bug reports and pull requests are welcome on GitHub at https://github.com/EdDeAlmeidaJr/sic_search.
86
+
87
+
88
+ ## License
89
+
90
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
91
+
@@ -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 "sic"
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,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
data/bin/sic ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'slop'
4
+ require 'sic'
5
+
6
+ opts = Slop.parse do |o|
7
+
8
+ # If --version is among the parameters, show version and exit
9
+ o.on '-v', '--version' do
10
+ SIC.version_info
11
+ exit
12
+ end
13
+
14
+ end
15
+
16
+ code = opts.arguments[0]
17
+
18
+ res = SIC::search(code)
19
+
20
+ res.each { |k,v| puts "#{k.capitalize}: #{v}" }
@@ -0,0 +1,34 @@
1
+ require 'httparty'
2
+ require 'nokogiri'
3
+
4
+ require 'sic/version'
5
+
6
+ module SIC
7
+
8
+ @search_url = 'https://www.osha.gov/pls/imis/sicsearch.html'
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
17
+ end
18
+
19
+ def self.result_page
20
+ HTTParty.post(@search_url, :query => {:p_sic => @code})
21
+ end
22
+
23
+ def self.description
24
+ arr = @doc.css("div.well a").text.split
25
+ arr.shift
26
+ (arr.length > 0) ? arr.join(' ') : nil
27
+ end
28
+
29
+ def self.version_info
30
+ puts "SIC gem - v#{SIC::VERSION}"
31
+ puts "Author: Ed de Almeida (edvaldoajunior@gmail.com)"
32
+ end
33
+
34
+ end
@@ -0,0 +1,3 @@
1
+ module SIC
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 'sic/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sic"
8
+ spec.version = SIC::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 SIC code.}
13
+ spec.description = %q{This gem gets the description corresponding to a certain SIC code. SIC stands for Standard Industrial Classification and this code is useful in any system dealing with companies' registration.}
14
+ spec.homepage = "https://github.com/EdDeAlmeidaJr/sic_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,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sic
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 SIC code. SIC
98
+ stands for Standard Industrial Classification and this code is useful in any system
99
+ dealing with companies' registration.
100
+ email:
101
+ - edvaldoajunior@gmail.com
102
+ executables:
103
+ - console
104
+ - setup
105
+ - sic
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - ".travis.yml"
112
+ - Gemfile
113
+ - LICENSE.txt
114
+ - README.md
115
+ - Rakefile
116
+ - bin/console
117
+ - bin/setup
118
+ - bin/sic
119
+ - lib/sic.rb
120
+ - lib/sic/version.rb
121
+ - sic.gemspec
122
+ homepage: https://github.com/EdDeAlmeidaJr/sic_search
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.5.2
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: This gem gets the description corresponding to a certain SIC code.
146
+ test_files: []