nace 0.1.0
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 +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/data/revision_two_classifications.yml +1021 -0
- data/lib/nace.rb +4 -0
- data/lib/nace/look_up_methods.rb +72 -0
- data/lib/nace/revision2.rb +14 -0
- data/lib/nace/version.rb +3 -0
- data/nace.gemspec +36 -0
- metadata +102 -0
data/lib/nace.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module Nace
|
|
2
|
+
module LookUpMethods
|
|
3
|
+
|
|
4
|
+
# Look up name of given code of classification
|
|
5
|
+
#
|
|
6
|
+
# Example:
|
|
7
|
+
# name_for("G.47.9")
|
|
8
|
+
# => "Retail trade not in stores, stalls or markets"
|
|
9
|
+
|
|
10
|
+
def name_for code
|
|
11
|
+
classifications[code.to_s] || nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Look up code of given name of classification
|
|
15
|
+
#
|
|
16
|
+
# Example:
|
|
17
|
+
# code_for("Retail trade not in stores, stalls or markets")
|
|
18
|
+
# => "G.47.9"
|
|
19
|
+
|
|
20
|
+
def code_for name
|
|
21
|
+
classifications.each { |k,v| return k if v == name }
|
|
22
|
+
nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Lists all sub classifications of a specific classification
|
|
26
|
+
# If none code given, look up will return root classifications
|
|
27
|
+
#
|
|
28
|
+
# Look up always returns items of the next lower level of classification
|
|
29
|
+
#
|
|
30
|
+
# Example:
|
|
31
|
+
# look_up("S")
|
|
32
|
+
# => {
|
|
33
|
+
# "S.94"=>"Activities of membership organisations",
|
|
34
|
+
# "S.95"=>"Repair of computers and personal and household goods",
|
|
35
|
+
# "S.96"=>"Other personal service activities"
|
|
36
|
+
# }
|
|
37
|
+
#
|
|
38
|
+
# Example
|
|
39
|
+
# look_up("S.94")
|
|
40
|
+
# => {
|
|
41
|
+
# "S.94.1"=>"Activities of business, employers and professional membership organisations",
|
|
42
|
+
# "S.94.2"=>"Activities of trade unions",
|
|
43
|
+
# "S.94.9"=>"Activities of other membership organisations"
|
|
44
|
+
# }
|
|
45
|
+
#
|
|
46
|
+
|
|
47
|
+
def look_up code = nil
|
|
48
|
+
filter = if code==nil
|
|
49
|
+
/^[A-Z]$/
|
|
50
|
+
else
|
|
51
|
+
code = code.split(".")
|
|
52
|
+
case code.size
|
|
53
|
+
when 1
|
|
54
|
+
/^#{code[0]}.[0-9]*$/
|
|
55
|
+
when 2
|
|
56
|
+
/^#{code[0]}.#{code[1]}.[0-9]$/
|
|
57
|
+
when 3 then
|
|
58
|
+
if code[2].size == 1
|
|
59
|
+
/^#{code[0]}.#{code[1]}.#{code[2]}[0-9]$/
|
|
60
|
+
else
|
|
61
|
+
/^#{code[0]}.#{code[1]}.#{code[2]}$/
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
return {} if filter.nil?
|
|
67
|
+
|
|
68
|
+
classifications.select{ |k,v| k =~ filter }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
data/lib/nace/version.rb
ADDED
data/nace.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'nace/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "nace"
|
|
8
|
+
spec.version = Nace::VERSION
|
|
9
|
+
spec.authors = ["Frederic Walch"]
|
|
10
|
+
spec.email = ["frederic.walch@informatik.hu-berlin.de"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Nace Revision 2 Lookup Library"
|
|
13
|
+
spec.description = "Check github repository for more in-depth information."
|
|
14
|
+
spec.homepage = "https://github.com/freder1c/nace-revision-two"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
"public gem pushes."
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "exe"
|
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nace
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Frederic Walch
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-04-26 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.14'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.14'
|
|
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
|
+
description: Check github repository for more in-depth information.
|
|
56
|
+
email:
|
|
57
|
+
- frederic.walch@informatik.hu-berlin.de
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".rspec"
|
|
64
|
+
- ".travis.yml"
|
|
65
|
+
- CODE_OF_CONDUCT.md
|
|
66
|
+
- Gemfile
|
|
67
|
+
- README.md
|
|
68
|
+
- Rakefile
|
|
69
|
+
- bin/console
|
|
70
|
+
- bin/setup
|
|
71
|
+
- lib/data/revision_two_classifications.yml
|
|
72
|
+
- lib/nace.rb
|
|
73
|
+
- lib/nace/look_up_methods.rb
|
|
74
|
+
- lib/nace/revision2.rb
|
|
75
|
+
- lib/nace/version.rb
|
|
76
|
+
- nace.gemspec
|
|
77
|
+
homepage: https://github.com/freder1c/nace-revision-two
|
|
78
|
+
licenses:
|
|
79
|
+
- MIT
|
|
80
|
+
metadata:
|
|
81
|
+
allowed_push_host: https://rubygems.org
|
|
82
|
+
post_install_message:
|
|
83
|
+
rdoc_options: []
|
|
84
|
+
require_paths:
|
|
85
|
+
- lib
|
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0'
|
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
requirements: []
|
|
97
|
+
rubyforge_project:
|
|
98
|
+
rubygems_version: 2.6.11
|
|
99
|
+
signing_key:
|
|
100
|
+
specification_version: 4
|
|
101
|
+
summary: Nace Revision 2 Lookup Library
|
|
102
|
+
test_files: []
|