isic 1.0.2 → 1.0.3

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: 37b0a1eedfd4c4e8f4b37a9d985ae135d62c4422
4
- data.tar.gz: 1d1cb3f925b8f540b5f7b1bc2847a4ca0d59968e
3
+ metadata.gz: 22f2116c09217baebfa04f3fc5e2a8c884239218
4
+ data.tar.gz: 4fbc6075ac3ae7192dab2478a81025bad97a07ec
5
5
  SHA512:
6
- metadata.gz: c5819a3b659eb6e46791bb82be8ed87498363babe60ea95fb2fafe9485b19b9c1925ae709524e58109f1317e4e5ea5112080b815ef329e27a9dd1cad21915e52
7
- data.tar.gz: e2dff3463c9bc6a87495778fdc5c3dd8ea9df68a0fdf7536a071844bd2f741b15a490c60bb5e4a9b1b2844535f61c7adc99941355c7d88f885a556a7ef33c031
6
+ metadata.gz: 337c16d195a072740194466926cd3808be6be39d1748556c282ccea9708edad9ddd8bfad18e4d832c7a3e0ee51caa79f68a241aa30fe2091a7595d224c64456e
7
+ data.tar.gz: 6e0940c23e25de503165a235d8292d71545ff196e06798ff8872a5f1c0699b971c6b982315ab069d3d450069c906076cf55d88f1f91853bae22fa25b95dc09ea
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.1.3"
4
+ script: bundle exec rspec spec
data/README.md CHANGED
@@ -24,87 +24,100 @@ Or install it yourself as:
24
24
 
25
25
  Given an ISIC code, find its place in the hierarchy:
26
26
 
27
- > Isic::Entity.new("0891").classify
28
- {
29
- :section => { :code => "B", :description => "Mining and quarrying" },
30
- :division => { :code => "08", :description => "Other mining and quarrying" },
31
- :group => { :code => "089", :description => "Mining and quarrying n.e.c." },
32
- :class => { :code => "0891", :description => "Mining of chemical and fertilizer minerals" }
33
- }
27
+ ```ruby
28
+ > Isic::Entity.new("0891").classify
29
+ {
30
+ :section => { :code => "B", :description => "Mining and quarrying" },
31
+ :division => { :code => "08", :description => "Other mining and quarrying" },
32
+ :group => { :code => "089", :description => "Mining and quarrying n.e.c." },
33
+ :class => { :code => "0891", :description => "Mining of chemical and fertilizer minerals" }
34
+ }
35
+ ```
34
36
 
35
37
  Find all the sections:
36
38
 
37
- > Isic.sections
38
- [
39
- {:code=>"A", :description=>"Agriculture, forestry and fishing"},
40
- {:code=>"B", :description=>"Mining and quarrying"},
41
- {:code=>"C", :description=>"Manufacturing"}
42
- {:code=>"D", :description=>"Electricity, gas, steam and air conditioning supply"},
43
- {:code=>"E", :description=>"Water supply; sewerage, waste management and remediation activities"},
44
- {:code=>"F", :description=>"Construction"},
45
- {:code=>"G", :description=>"Wholesale and retail trade; repair of motor vehicles and motorcycles"},
46
- {:code=>"H", :description=>"Transportation and storage"},
47
- {:code=>"I", :description=>"Accommodation and food service activities"},
48
- {:code=>"J", :description=>"Information and communication"},
49
- {:code=>"K", :description=>"Financial and insurance activities"},
50
- {:code=>"L", :description=>"Real estate activities"},
51
- {:code=>"M", :description=>"Professional, scientific and technical activities"},
52
- {:code=>"N", :description=>"Administrative and support service activities"},
53
- {:code=>"O", :description=>"Public administration and defence; compulsory social security"},
54
- {:code=>"P", :description=>"Education"}, {:code=>"Q", :description=>"Human health and social work activities"},
55
- {:code=>"R", :description=>"Arts, entertainment and recreation"},
56
- {:code=>"S", :description=>"Other service activities"},
57
- {:code=>"T", :description=>"Activities of households as employers; undifferentiated goods- and services-producing activities of households for own use"},
58
- {:code=>"U", :description=>"Activities of extraterritorial organizations and bodies"}
59
- ]
39
+ ```ruby
40
+ > Isic.sections
41
+ [
42
+ {:code=>"A", :description=>"Agriculture, forestry and fishing"},
43
+ {:code=>"B", :description=>"Mining and quarrying"},
44
+ {:code=>"C", :description=>"Manufacturing"}
45
+ {:code=>"D", :description=>"Electricity, gas, steam and air conditioning supply"},
46
+ {:code=>"E", :description=>"Water supply; sewerage, waste management and remediation activities"},
47
+ {:code=>"F", :description=>"Construction"},
48
+ {:code=>"G", :description=>"Wholesale and retail trade; repair of motor vehicles and motorcycles"},
49
+ {:code=>"H", :description=>"Transportation and storage"},
50
+ {:code=>"I", :description=>"Accommodation and food service activities"},
51
+ {:code=>"J", :description=>"Information and communication"},
52
+ {:code=>"K", :description=>"Financial and insurance activities"},
53
+ {:code=>"L", :description=>"Real estate activities"},
54
+ {:code=>"M", :description=>"Professional, scientific and technical activities"},
55
+ {:code=>"N", :description=>"Administrative and support service activities"},
56
+ {:code=>"O", :description=>"Public administration and defence; compulsory social security"},
57
+ {:code=>"P", :description=>"Education"}, {:code=>"Q", :description=>"Human health and social work activities"},
58
+ {:code=>"R", :description=>"Arts, entertainment and recreation"},
59
+ {:code=>"S", :description=>"Other service activities"},
60
+ {:code=>"T", :description=>"Activities of households as employers; undifferentiated goods- and services-producing activities of households for own use"},
61
+ {:code=>"U", :description=>"Activities of extraterritorial organizations and bodies"}
62
+ ]
63
+ ```
60
64
 
61
65
  Find all the divisions of the "B" section:
62
66
 
63
- > Isic.divisions(section: "B")
64
- [
65
- {:code=>"05", :description=>"Mining of coal and lignite"},
66
- {:code=>"06", :description=>"Extraction of crude petroleum and natural gas"},
67
- {:code=>"07", :description=>"Mining of metal ores"},
68
- {:code=>"08", :description=>"Other mining and quarrying"},
69
- {:code=>"09", :description=>"Mining support service activities"}
70
- ]
67
+ ```ruby
68
+ > Isic.divisions(section: "B")
69
+ [
70
+ {:code=>"05", :description=>"Mining of coal and lignite"},
71
+ {:code=>"06", :description=>"Extraction of crude petroleum and natural gas"},
72
+ {:code=>"07", :description=>"Mining of metal ores"},
73
+ {:code=>"08", :description=>"Other mining and quarrying"},
74
+ {:code=>"09", :description=>"Mining support service activities"}
75
+ ]
76
+ ```
71
77
 
72
78
  Find all the groups of the "08" division:
73
79
 
74
- > Isic.groups(division: "08")
75
- [
76
- {:code=>"081", :description=>"Quarrying of stone, sand and clay"},
77
- {:code=>"089", :description=>"Mining and quarrying n.e.c."}
78
- ]
80
+ ```ruby
81
+ > Isic.groups(division: "08")
82
+ [
83
+ {:code=>"081", :description=>"Quarrying of stone, sand and clay"},
84
+ {:code=>"089", :description=>"Mining and quarrying n.e.c."}
85
+ ]
86
+ ```
79
87
 
80
88
  Find all the classes of the "089" group:
81
89
 
82
- > Isic.classes(group: "089")
83
- [
84
- {:code=>"0891", :description=>"Mining of chemical and fertilizer minerals"},
85
- {:code=>"0892", :description=>"Extraction of peat"},
86
- {:code=>"0893", :description=>"Extraction of salt"},
87
- {:code=>"0899", :description=>"Other mining and quarrying n.e.c."}
88
- ]
90
+ ```ruby
91
+ > Isic.classes(group: "089")
92
+ [
93
+ {:code=>"0891", :description=>"Mining of chemical and fertilizer minerals"},
94
+ {:code=>"0892", :description=>"Extraction of peat"},
95
+ {:code=>"0893", :description=>"Extraction of salt"},
96
+ {:code=>"0899", :description=>"Other mining and quarrying n.e.c."}
97
+ ]
98
+ ```
89
99
 
90
100
  ## Translations
91
101
 
92
102
  Descriptions are returned in English by default, but Spanish and French are supported. In any of the methods above you can specify the translation:
93
103
 
94
- > Isic::Entity.new("0891").classify(translation: :es)
95
- {
96
- :class=>{:code=>"0891", :description=>"Extracción de minerales para la fabricación de abonos y productos químicos"},
97
- :group=>{:code=>"089", :description=>"Explotación de minas y canteras n.c.p."},
98
- :division=>{:code=>"08", :description=>"Explotación de otras minas y canteras"},
99
- :section=>{:code=>"B", :description=>"Explotación de minas y canteras"}
100
- }
101
-
102
- > Isic.groups(division: "08", translation: :fr)
103
- [
104
- {:code=>"081", :description=>"Extraction de pierres, de sables et d'argiles"},
105
- {:code=>"089", :description=>"Activités extractives, n.c.a."}
106
- ]
107
-
104
+ ```ruby
105
+ > Isic::Entity.new("0891").classify(translation: :es)
106
+ {
107
+ :class=>{:code=>"0891", :description=>"Extracción de minerales para la fabricación de abonos y productos químicos"},
108
+ :group=>{:code=>"089", :description=>"Explotación de minas y canteras n.c.p."},
109
+ :division=>{:code=>"08", :description=>"Explotación de otras minas y canteras"},
110
+ :section=>{:code=>"B", :description=>"Explotación de minas y canteras"}
111
+ }
112
+ ```
113
+
114
+ ```ruby
115
+ > Isic.groups(division: "08", translation: :fr)
116
+ [
117
+ {:code=>"081", :description=>"Extraction de pierres, de sables et d'argiles"},
118
+ {:code=>"089", :description=>"Activités extractives, n.c.a."}
119
+ ]
120
+ ```
108
121
 
109
122
  ## Contributing
110
123
 
@@ -114,6 +127,13 @@ Descriptions are returned in English by default, but Spanish and French are supp
114
127
  4. Push to the branch (`git push origin my-new-feature`)
115
128
  5. Create new Pull Request
116
129
 
130
+ ## Code Status
131
+
132
+ [![Gem Version](http://img.shields.io/badge/gem-v1.0.3-blue.svg)](https://rubygems.org/gems/mic)
133
+ [![Build Status](https://travis-ci.org/javiervidal/isic.svg?branch=master)](https://travis-ci.org/javiervidal/isic)
134
+ [![Coverage Status](https://coveralls.io/repos/javiervidal/isic/badge.png?branch=master)](https://coveralls.io/r/javiervidal/isic?branch=master)
135
+ [![Code Climate](https://codeclimate.com/github/javiervidal/isic/badges/gpa.svg)](https://codeclimate.com/github/javiervidal/isic)
136
+
117
137
  ## Copyright
118
138
 
119
139
  Copyright (c) 2014 – ∞ Javier Vidal
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "awesome_print"
24
24
  spec.add_development_dependency "rspec"
25
25
  spec.add_development_dependency "simplecov"
26
+ spec.add_development_dependency "coveralls"
26
27
  end
@@ -1,4 +1,4 @@
1
- module Isic
1
+ class Isic
2
2
  class Entity
3
3
 
4
4
  def initialize(code)
@@ -1,4 +1,4 @@
1
- module Isic
1
+ class Isic
2
2
 
3
3
  DIVISIONS = {}
4
4
  DIVISIONS['A'] = %w( 01 02 03 )
@@ -41,19 +41,17 @@ module Isic
41
41
  end
42
42
 
43
43
  def groups(options = {})
44
- translation = options[:translation] || :en
45
- if options[:division] && /\d{2}/.match(options[:division])
46
- code = "#{options[:division]}\\d"
47
- Search.new(code, translation: translation).all
48
- else
49
- []
50
- end
44
+ parse(:division, 2, options)
51
45
  end
52
46
 
53
47
  def classes(options = {})
48
+ parse(:group, 3, options)
49
+ end
50
+
51
+ def parse(symbol, digits, options = {})
54
52
  translation = options[:translation] || :en
55
- if options[:group] && /\d{3}/.match(options[:group])
56
- code = "#{options[:group]}\\d"
53
+ if options[symbol] && Regexp.new("\\d{#{digits}}").match(options[symbol])
54
+ code = "#{options[symbol]}\\d"
57
55
  Search.new(code, translation: translation).all
58
56
  else
59
57
  []
@@ -62,4 +60,6 @@ module Isic
62
60
 
63
61
  end
64
62
 
63
+ private_class_method :parse
64
+
65
65
  end
@@ -1,4 +1,4 @@
1
- module Isic
1
+ class Isic
2
2
  class Search
3
3
 
4
4
  FILES = {
@@ -1,3 +1,3 @@
1
- module Isic
2
- VERSION = "1.0.2"
1
+ class Isic
2
+ VERSION = "1.0.3"
3
3
  end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe Isic::Entity do
4
+
5
+ describe '#classify' do
6
+
7
+ context 'in english' do
8
+
9
+ let(:class_classification) { Isic::Entity.new("0891").classify }
10
+ let(:group_classification) { Isic::Entity.new("089").classify }
11
+ let(:division_classification) { Isic::Entity.new("08").classify }
12
+ let(:section_classification) { Isic::Entity.new("B").classify }
13
+
14
+ it "class is classified with section, division, group and class" do
15
+ expect(class_classification).to eq({
16
+ :class => {:code => "0891", :description => "Mining of chemical and fertilizer minerals"},
17
+ :group => {:code => "089", :description => "Mining and quarrying n.e.c."},
18
+ :division => {:code => "08", :description => "Other mining and quarrying"},
19
+ :section => {:code => "B", :description => "Mining and quarrying"}
20
+ })
21
+ end
22
+
23
+ it "group is classified with section, division and group" do
24
+ expect(group_classification).to eq({
25
+ :group => {:code => "089", :description => "Mining and quarrying n.e.c."},
26
+ :division => {:code => "08", :description => "Other mining and quarrying"},
27
+ :section => {:code => "B", :description => "Mining and quarrying"}
28
+ })
29
+ end
30
+
31
+ it "division is classified with section and division" do
32
+ expect(division_classification).to eq({
33
+ :division => {:code => "08", :description => "Other mining and quarrying"},
34
+ :section => {:code => "B", :description => "Mining and quarrying"}
35
+ })
36
+ end
37
+
38
+ it "section is classified with section" do
39
+ expect(section_classification).to eq({
40
+ :section => {:code => "B", :description => "Mining and quarrying"}
41
+ })
42
+ end
43
+
44
+ end
45
+
46
+ context 'in spanish' do
47
+
48
+ let(:class_classification) { Isic::Entity.new("0891").classify(translation: :es) }
49
+
50
+ it "classifies with section, division, group and class" do
51
+ expect(class_classification).to eq({
52
+ :class => {:code => "0891", :description => "Extracción de minerales para la fabricación de abonos y productos químicos"},
53
+ :group => {:code => "089", :description => "Explotación de minas y canteras n.c.p."},
54
+ :division => {:code => "08", :description => "Explotación de otras minas y canteras"},
55
+ :section => {:code => "B", :description => "Explotación de minas y canteras"}
56
+ })
57
+ end
58
+
59
+ end
60
+
61
+ context 'in french' do
62
+
63
+ let(:class_classification) { Isic::Entity.new("0891").classify(translation: :fr) }
64
+
65
+ it "classifies with section, division, group and class" do
66
+ expect(class_classification).to eq({
67
+ :class => {:code => "0891", :description => "Extraction de minerais pour l'industrie chimique et d'engrais naturels"},
68
+ :group => {:code => "089", :description => "Activités extractives, n.c.a."},
69
+ :division => {:code => "08", :description => "Autres activités extractives"},
70
+ :section => {:code => "B", :description => "Activités extractives"}
71
+ })
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,104 @@
1
+ require 'spec_helper'
2
+
3
+ describe Isic do
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
@@ -1,93 +1,20 @@
1
1
  require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
5
+
2
6
  SimpleCov.start
7
+
3
8
  require 'isic'
4
9
 
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
10
  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.
11
+
25
12
  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
13
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
14
  end
35
15
 
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
16
  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
17
  mocks.verify_partial_doubles = true
43
18
  end
44
19
 
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
20
+ 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: 1.0.2
4
+ version: 1.0.3
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-09 00:00:00.000000000 Z
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: 'The International Standard Industrial Classification (ISIC) is a United
84
98
  Nations system for classifying economic data. The classification is based in four
85
99
  hierarchical levels: sections, divisions, groups and classes. This gem allows to
@@ -92,6 +106,7 @@ extra_rdoc_files: []
92
106
  files:
93
107
  - ".gitignore"
94
108
  - ".rspec"
109
+ - ".travis.yml"
95
110
  - Gemfile
96
111
  - LICENSE.txt
97
112
  - README.md
@@ -105,8 +120,8 @@ files:
105
120
  - lib/isic/isic.rb
106
121
  - lib/isic/search.rb
107
122
  - lib/isic/version.rb
108
- - spec/entity_spec.rb
109
- - spec/isic_spec.rb
123
+ - spec/isic/entity_spec.rb
124
+ - spec/isic/isic_spec.rb
110
125
  - spec/spec_helper.rb
111
126
  homepage: https://github.com/javiervidal/isic
112
127
  licenses:
@@ -133,6 +148,6 @@ signing_key:
133
148
  specification_version: 4
134
149
  summary: International Standard Industrial Classification
135
150
  test_files:
136
- - spec/entity_spec.rb
137
- - spec/isic_spec.rb
151
+ - spec/isic/entity_spec.rb
152
+ - spec/isic/isic_spec.rb
138
153
  - spec/spec_helper.rb
@@ -1,82 +0,0 @@
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
@@ -1,104 +0,0 @@
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