isic 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a2323b19c16c5cd28edfbacaf7214eb9424bd94
4
- data.tar.gz: 62ab729d46d57141beaf15b6fe64b0e47eae110f
3
+ metadata.gz: 62478098d091e51fa80c2114f6f59129a7363184
4
+ data.tar.gz: 79cbbdfa3e270afe77b4caa5c15ce6c82f1fb1c1
5
5
  SHA512:
6
- metadata.gz: 465fcab80ecf3dc9b4c1c54df21194ed9ddf7b6a94dba34bd08c8f5118008dad836b33c2b0deb6b27122ac8cf1b984b6b0f123e6c7fa3f3bbe61f1aa870f9df5
7
- data.tar.gz: 8c77cfde6db469a3aa54876c58008573fe08f51163cc08aaed5c2abb0e6ac35e98d2edd47cee0e6cc5e24bc48a595bf0982df2469ca8bc7b872676b5c562210d
6
+ metadata.gz: aa8ed1e97d6818f3802df2353a814223bdcb20300071ab8aa1879cbecd5a31b8394afbffc7f7a21741518683c0ba5e43b072df43db76e692bf535c22b33998a0
7
+ data.tar.gz: f57c83696e0dd13b037589bde76bc057f2b69749c11d27f5555122be515fbce6d5c6fcd9b643e020db42f0ba249620711acb7ad18b1684b3a9d8cff903273fc4
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "awesome_print"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "simplecov"
24
26
  end
@@ -20,11 +20,11 @@ module Isic
20
20
  when /\d{4}/
21
21
  {class: @code, group: @code[0..2], division: @code[0..1], section: section(@code[0..1])}
22
22
  when /\d{3}/
23
- [group: @code, division: @code[0..1], section: section(@code[0..1])]
23
+ {group: @code, division: @code[0..1], section: section(@code[0..1])}
24
24
  when /\d{2}/
25
- [division: @code, section: section(@code)]
25
+ {division: @code, section: section(@code)}
26
26
  when /[A-Z]/
27
- [section: @code]
27
+ {section: @code}
28
28
  end
29
29
  end
30
30
 
@@ -1,3 +1,3 @@
1
1
  module Isic
2
- VERSION = "0.9.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ module Isic
4
+
5
+ describe Entity do
6
+
7
+ describe '#classify' do
8
+
9
+ context 'in english' do
10
+
11
+ let(:class_classification) { Isic::Entity.new("0891").classify }
12
+ let(:group_classification) { Isic::Entity.new("089").classify }
13
+ let(:division_classification) { Isic::Entity.new("08").classify }
14
+ let(:section_classification) { Isic::Entity.new("B").classify }
15
+
16
+ it "class is classified with section, division, group and class" do
17
+ expect(class_classification).to eq({
18
+ :class => {:code => "0891", :description => "Mining of chemical and fertilizer minerals"},
19
+ :group => {:code => "089", :description => "Mining and quarrying n.e.c."},
20
+ :division => {:code => "08", :description => "Other mining and quarrying"},
21
+ :section => {:code => "B", :description => "Mining and quarrying"}
22
+ })
23
+ end
24
+
25
+ it "group is classified with section, division and group" do
26
+ expect(group_classification).to eq({
27
+ :group => {:code => "089", :description => "Mining and quarrying n.e.c."},
28
+ :division => {:code => "08", :description => "Other mining and quarrying"},
29
+ :section => {:code => "B", :description => "Mining and quarrying"}
30
+ })
31
+ end
32
+
33
+ it "division is classified with section and division" do
34
+ expect(division_classification).to eq({
35
+ :division => {:code => "08", :description => "Other mining and quarrying"},
36
+ :section => {:code => "B", :description => "Mining and quarrying"}
37
+ })
38
+ end
39
+
40
+ it "section is classified with section" do
41
+ expect(section_classification).to eq({
42
+ :section => {:code => "B", :description => "Mining and quarrying"}
43
+ })
44
+ end
45
+
46
+ end
47
+
48
+ context 'in spanish' do
49
+
50
+ let(:class_classification) { Isic::Entity.new("0891").classify(translation: :es) }
51
+
52
+ it "classifies with section, division, group and class" do
53
+ expect(class_classification).to eq({
54
+ :class => {:code => "0891", :description => "Extracción de minerales para la fabricación de abonos y productos químicos"},
55
+ :group => {:code => "089", :description => "Explotación de minas y canteras n.c.p."},
56
+ :division => {:code => "08", :description => "Explotación de otras minas y canteras"},
57
+ :section => {:code => "B", :description => "Explotación de minas y canteras"}
58
+ })
59
+ end
60
+
61
+ end
62
+
63
+ context 'in french' do
64
+
65
+ let(:class_classification) { Isic::Entity.new("0891").classify(translation: :fr) }
66
+
67
+ it "classifies with section, division, group and class" do
68
+ expect(class_classification).to eq({
69
+ :class => {:code => "0891", :description => "Extraction de minerais pour l'industrie chimique et d'engrais naturels"},
70
+ :group => {:code => "089", :description => "Activités extractives, n.c.a."},
71
+ :division => {:code => "08", :description => "Autres activités extractives"},
72
+ :section => {:code => "B", :description => "Activités extractives"}
73
+ })
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,104 @@
1
+ require 'spec_helper'
2
+
3
+ module Isic
4
+
5
+ describe 'Isic methods' do
6
+
7
+ context 'when english' do
8
+
9
+ let(:sections) { Isic.sections }
10
+ let(:divisions) { Isic.divisions(section: "B") }
11
+ let(:groups) { Isic.groups(division: "08") }
12
+ let(:classes) { Isic.classes(group: "089") }
13
+
14
+ it 'returns all the sections in english' do
15
+ expect(sections).to eq([{:code => "A", :description => "Agriculture, forestry and fishing"}, {:code => "B", :description => "Mining and quarrying"}, {:code => "C", :description => "Manufacturing"}, {:code => "D", :description => "Electricity, gas, steam and air conditioning supply"}, {:code => "E", :description => "Water supply; sewerage, waste management and remediation activities"}, {:code => "F", :description => "Construction"}, {:code => "G", :description => "Wholesale and retail trade; repair of motor vehicles and motorcycles"}, {:code => "H", :description => "Transportation and storage"}, {:code => "I", :description => "Accommodation and food service activities"}, {:code => "J", :description => "Information and communication"}, {:code => "K", :description => "Financial and insurance activities"}, {:code => "L", :description => "Real estate activities"}, {:code => "M", :description => "Professional, scientific and technical activities"}, {:code => "N", :description => "Administrative and support service activities"}, {:code => "O", :description => "Public administration and defence; compulsory social security"}, {:code => "P", :description => "Education"}, {:code => "Q", :description => "Human health and social work activities"}, {:code => "R", :description => "Arts, entertainment and recreation"}, {:code => "S", :description => "Other service activities"}, {:code => "T", :description => "Activities of households as employers; undifferentiated goods- and services-producing activities of households for own use"}, {:code => "U", :description => "Activities of extraterritorial organizations and bodies"}])
16
+ end
17
+
18
+ it 'returns all the divisions of the B section in english' do
19
+ expect(divisions).to eq([{:code => "05", :description => "Mining of coal and lignite"}, {:code => "06", :description => "Extraction of crude petroleum and natural gas"}, {:code => "07", :description => "Mining of metal ores"}, {:code => "08", :description => "Other mining and quarrying"}, {:code => "09", :description => "Mining support service activities"}])
20
+ end
21
+
22
+ it 'returns all the groups of the 08 division in english' do
23
+ expect(groups).to eq([{:code => "081", :description => "Quarrying of stone, sand and clay"}, {:code => "089", :description => "Mining and quarrying n.e.c."}])
24
+ end
25
+
26
+ it 'returns all the classes of the 089 group in english' do
27
+ expect(classes).to eq([{:code => "0891", :description => "Mining of chemical and fertilizer minerals"}, {:code => "0892", :description => "Extraction of peat"}, {:code => "0893", :description => "Extraction of salt"}, {:code => "0899", :description => "Other mining and quarrying n.e.c."}])
28
+ end
29
+
30
+ end
31
+
32
+ context 'when no specifying the parent entity' do
33
+
34
+ let(:divisions) { Isic.divisions }
35
+ let(:groups) { Isic.groups }
36
+ let(:classes) { Isic.classes }
37
+
38
+ it 'returns no divisions' do
39
+ expect(divisions).to match_array([])
40
+ end
41
+
42
+ it 'returns no groups' do
43
+ expect(groups).to match_array([])
44
+ end
45
+
46
+ it 'returns no classes' do
47
+ expect(classes).to match_array([])
48
+ end
49
+
50
+ end
51
+
52
+ context 'when spanish' do
53
+
54
+ let(:sections) { Isic.sections(translation: :es) }
55
+ let(:divisions) { Isic.divisions(section: "B",translation: :es) }
56
+ let(:groups) { Isic.groups(division: "08", translation: :es) }
57
+ let(:classes) { Isic.classes(group: "089", translation: :es) }
58
+
59
+ it 'returns all the sections in english' do
60
+ expect(sections).to eq([{:code=>"A", :description=>"Agricultura, ganadería, silvicultura y pesca"}, {:code=>"B", :description=>"Explotación de minas y canteras"}, {:code=>"C", :description=>"Industrias manufactureras"}, {:code=>"D", :description=>"Suministro de electricidad, gas, vapor y aire acondicionado"}, {:code=>"E", :description=>"Suministro de agua; evacuación de aguas residuales, gestión de desechos y descontaminación"}, {:code=>"F", :description=>"Construcción"}, {:code=>"G", :description=>"Comercio al por mayor y al por menor; reparación de vehículos automotores y motocicletas"}, {:code=>"H", :description=>"Transporte y almacenamiento"}, {:code=>"I", :description=>"Actividades de alojamiento y de servicio de comidas"}, {:code=>"J", :description=>"Información y comunicaciones"}, {:code=>"K", :description=>"Actividades financieras y de seguros"}, {:code=>"L", :description=>"Actividades inmobiliarias"}, {:code=>"M", :description=>"Actividades profesionales, científicas y técnicas"}, {:code=>"N", :description=>"Actividades de servicios administrativos y de apoyo"}, {:code=>"O", :description=>"Administración pública y defensa; planes de seguridad social de afiliación obligatoria"}, {:code=>"P", :description=>"Enseñanza"}, {:code=>"Q", :description=>"Actividades de atención de la salud humana y de asistencia social"}, {:code=>"R", :description=>"Actividades artísticas, de entretenimiento y recreativas"}, {:code=>"S", :description=>"Otras actividades de servicios"}, {:code=>"T", :description=>"Actividades de los hogares como empleadores; actividades no diferenciadas de los hogares como productores de bienes y servicios para uso propio"}, {:code=>"U", :description=>"Actividades de organizaciones y órganos extraterritoriales"}])
61
+ end
62
+
63
+ it 'returns all the divisions of the B section in english' do
64
+ expect(divisions).to eq([{:code=>"05", :description=>"Extracción de carbón de piedra y lignito"}, {:code=>"06", :description=>"Extracción de petróleo crudo y gas natural"}, {:code=>"07", :description=>"Extracción de minerales metalíferos"}, {:code=>"08", :description=>"Explotación de otras minas y canteras"}, {:code=>"09", :description=>"Actividades de servicios de apoyo para la explotación de minas y canteras"}])
65
+ end
66
+
67
+ it 'returns all the groups of the 08 division in english' do
68
+ expect(groups).to eq([{:code=>"081", :description=>"Extracción de piedra, arena y arcilla"}, {:code=>"089", :description=>"Explotación de minas y canteras n.c.p."}])
69
+ end
70
+
71
+ it 'returns all the classes of the 089 group in english' do
72
+ expect(classes).to eq([{:code=>"0891", :description=>"Extracción de minerales para la fabricación de abonos y productos químicos"}, {:code=>"0892", :description=>"Extracción de turba"}, {:code=>"0893", :description=>"Extracción de sal"}, {:code=>"0899", :description=>"Explotación de otras minas y canteras n.c.p."}])
73
+ end
74
+
75
+ end
76
+
77
+ context 'when french' do
78
+
79
+ let(:sections) { Isic.sections(translation: :fr) }
80
+ let(:divisions) { Isic.divisions(section: "B",translation: :fr) }
81
+ let(:groups) { Isic.groups(division: "08", translation: :fr) }
82
+ let(:classes) { Isic.classes(group: "089", translation: :fr) }
83
+
84
+ it 'returns all the sections in english' do
85
+ expect(sections).to eq([{:code=>"A", :description=>"Agriculture, sylviculture et pêche"}, {:code=>"B", :description=>"Activités extractives"}, {:code=>"C", :description=>"Activités de fabrication"}, {:code=>"D", :description=>"Production et distribution d'électricité, de gaz, de vapeur et climatisation"}, {:code=>"E", :description=>"Distribution d'eau; réseau d'assainissement; gestion des déchets et activités de remise en état"}, {:code=>"F", :description=>"Construction"}, {:code=>"G", :description=>"Commerce de gros et de détail, réparations de véhicules automobiles et de motocycles"}, {:code=>"H", :description=>"Transport et entreposage"}, {:code=>"I", :description=>"Activités d'hébergement et de restauration"}, {:code=>"J", :description=>"Information et communication"}, {:code=>"K", :description=>"Activités financières et d'assurances"}, {:code=>"L", :description=>"Activités immobilières"}, {:code=>"M", :description=>"Activités professionnelles, scientifiques et techniques"}, {:code=>"N", :description=>"Activités de services administratifs et d'appui"}, {:code=>"O", :description=>"Administration publique et défense; sécurité sociale obligatoire"}, {:code=>"P", :description=>"Éducation"}, {:code=>"Q", :description=>"Santé et et activités d'action sociale"}, {:code=>"R", :description=>"Arts, spectacles et loisirs"}, {:code=>"S", :description=>"Autres activités de services"}, {:code=>"T", :description=>"Activités des ménages privés employant du personnel domestique; activités non différenciées de production de biens et de services des ménages privés pour usage propre"}, {:code=>"U", :description=>"Activités des organisations et organismes extra-territoriaux"}])
86
+ end
87
+
88
+ it 'returns all the divisions of the B section in english' do
89
+ expect(divisions).to eq([{:code=>"05", :description=>"Extraction de charbon et de lignite"}, {:code=>"06", :description=>"Extraction de pétrole brut et de gaz naturel"}, {:code=>"07", :description=>"Extraction de minerais métalliques"}, {:code=>"08", :description=>"Autres activités extractives"}, {:code=>"09", :description=>"Activités annexes de l'extraction"}])
90
+ end
91
+
92
+ it 'returns all the groups of the 08 division in english' do
93
+ expect(groups).to eq([{:code=>"081", :description=>"Extraction de pierres, de sables et d'argiles"}, {:code=>"089", :description=>"Activités extractives, n.c.a."}])
94
+ end
95
+
96
+ it 'returns all the classes of the 089 group in english' do
97
+ expect(classes).to eq([{:code=>"0891", :description=>"Extraction de minerais pour l'industrie chimique et d'engrais naturels"}, {:code=>"0892", :description=>"Extraction de tourbe"}, {:code=>"0893", :description=>"Extraction de sel"}, {:code=>"0899", :description=>"Autres activités extractives, n.c.a."}])
98
+ end
99
+
100
+ end
101
+
102
+ end
103
+
104
+ end
@@ -0,0 +1,93 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+ require 'isic'
4
+
5
+ # This file was generated by the `rspec --init` command. Conventionally, all
6
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
7
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
8
+ # file to always be loaded, without a need to explicitly require it in any files.
9
+ #
10
+ # Given that it is always loaded, you are encouraged to keep this file as
11
+ # light-weight as possible. Requiring heavyweight dependencies from this file
12
+ # will add to the boot time of your test suite on EVERY test run, even for an
13
+ # individual file that may not need all of that loaded. Instead, consider making
14
+ # a separate helper file that requires the additional dependencies and performs
15
+ # the additional setup, and require it from the spec files that actually need it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # The settings below are suggested to provide a good initial experience
46
+ # with RSpec, but feel free to customize to your heart's content.
47
+ =begin
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
56
+ # For more details, see:
57
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
58
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
59
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
60
+ config.disable_monkey_patching!
61
+
62
+ # This setting enables warnings. It's recommended, but in some cases may
63
+ # be too noisy due to issues in dependencies.
64
+ config.warnings = true
65
+
66
+ # Many RSpec users commonly either run the entire suite or an individual
67
+ # file, and it's useful to allow more verbose output when running an
68
+ # individual spec file.
69
+ if config.files_to_run.one?
70
+ # Use the documentation formatter for detailed output,
71
+ # unless a formatter has already been configured
72
+ # (e.g. via a command-line flag).
73
+ config.default_formatter = 'doc'
74
+ end
75
+
76
+ # Print the 10 slowest examples and example groups at the
77
+ # end of the spec run, to help surface which specs are running
78
+ # particularly slow.
79
+ config.profile_examples = 10
80
+
81
+ # Run specs in random order to surface order dependencies. If you find an
82
+ # order dependency and want to debug it, you can fix the order by providing
83
+ # the seed, which is printed after each run.
84
+ # --seed 1234
85
+ config.order = :random
86
+
87
+ # Seed global randomization in this process using the `--seed` CLI option.
88
+ # Setting this allows you to use `--seed` to deterministically reproduce
89
+ # test failures related to randomization by passing the same `--seed` value
90
+ # as the one that triggered the failure.
91
+ Kernel.srand config.seed
92
+ =end
93
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Vidal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2014-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: International Standard Industrial Classification
56
84
  email:
57
85
  - javier@javiervidal.net
@@ -60,6 +88,7 @@ extensions: []
60
88
  extra_rdoc_files: []
61
89
  files:
62
90
  - ".gitignore"
91
+ - ".rspec"
63
92
  - Gemfile
64
93
  - LICENSE.txt
65
94
  - README.md
@@ -73,6 +102,9 @@ files:
73
102
  - lib/isic/isic.rb
74
103
  - lib/isic/search.rb
75
104
  - lib/isic/version.rb
105
+ - spec/entity_spec.rb
106
+ - spec/isic_spec.rb
107
+ - spec/spec_helper.rb
76
108
  homepage: https://github.com/javiervidal/isic
77
109
  licenses:
78
110
  - MIT
@@ -97,4 +129,7 @@ rubygems_version: 2.2.2
97
129
  signing_key:
98
130
  specification_version: 4
99
131
  summary: International Standard Industrial Classification
100
- test_files: []
132
+ test_files:
133
+ - spec/entity_spec.rb
134
+ - spec/isic_spec.rb
135
+ - spec/spec_helper.rb