metrojobb 0.3.0 → 0.4.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: 9500af470a96f8234843801a10d9edb0e4882ad8
4
- data.tar.gz: 9072fdbf28436ab739feacb9b4ab9b90471384fb
3
+ metadata.gz: d11a14ba6fa18ac44914bc2051936cf92d98fad3
4
+ data.tar.gz: a6f5c124956818f7d2038d4fb9e77fca540e7266
5
5
  SHA512:
6
- metadata.gz: 811e7d4bb9c3f1ef36f9492aa4d3fddb867c17ffca915bce973ad6fab80ca0cedfec321c6f840f8f527bde30256aceb9cff3c8dfe2fba01d20f297cd521f0504
7
- data.tar.gz: 9ef6db4ecf66672eb7bab5ecc795cc9a3ab5a89b03c20e77d678f871ddc7a32128d15d7570a4ed65b5ea68cb1b1e36eec2a60fd807651e7ddab08021f92e3083
6
+ metadata.gz: cd7766fa1aa678994b79cb9e23b6238072b4e7cd32b73fba1cef73c8f25880014ebb76be7ba0d9799e5cffe68864b70c01463ab3d1fadd27c59e80d65e8814a6
7
+ data.tar.gz: a2afa97441ba71e7e78d6f6e7b6ecf49b55cc72f1e66791eb9327f7736ffe5fd38913dce02f57d942d0778e0a559ab9f4776b5fad0d87149b6435c6c0abfdf24
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metrojobb (0.2.1)
4
+ metrojobb (0.3.0)
5
5
  activemodel (~> 5.0)
6
6
  builder (~> 3.2)
7
7
 
@@ -13,12 +13,20 @@ module Metrojobb
13
13
 
14
14
  validate :validate_known_category
15
15
 
16
+ def self.names
17
+ NAME_ID_MAP.keys
18
+ end
19
+
20
+ def self.ids
21
+ NAME_ID_MAP.values
22
+ end
23
+
16
24
  def self.name_id_map
17
25
  NAME_ID_MAP
18
26
  end
19
27
 
20
28
  def self.id_name_map
21
- ID_NAME_MAP
29
+ NAME_ID_MAP.invert
22
30
  end
23
31
 
24
32
  def to_xml(builder: Builder::XmlMarkup.new(indent: DEFAULT_INDENT))
@@ -28,13 +36,13 @@ module Metrojobb
28
36
  end
29
37
 
30
38
  def category_id
31
- NAME_ID_MAP[name.presence || id.presence] ||
39
+ self.class.name_id_map[name.presence || id.presence] ||
32
40
  id.presence ||
33
41
  name.presence
34
42
  end
35
43
 
36
44
  def validate_known_category
37
- return if ID_NAME_MAP[category_id]
45
+ return if self.class.id_name_map[category_id]
38
46
 
39
47
  errors.add(:category_id, :inclusion)
40
48
  end
@@ -8,16 +8,22 @@ module Metrojobb
8
8
  File.expand_path('../../../data/employmenttypes.csv', __FILE__)
9
9
  ).to_h.invert.freeze
10
10
 
11
- ID_NAME_MAP = NAME_ID_MAP.invert.freeze
12
-
13
11
  validate :validate_known_employment_type
14
12
 
13
+ def self.names
14
+ NAME_ID_MAP.keys
15
+ end
16
+
17
+ def self.ids
18
+ NAME_ID_MAP.values
19
+ end
20
+
15
21
  def self.name_id_map
16
22
  NAME_ID_MAP
17
23
  end
18
24
 
19
25
  def self.id_name_map
20
- ID_NAME_MAP
26
+ NAME_ID_MAP.invert
21
27
  end
22
28
 
23
29
  def to_xml(builder: Builder::XmlMarkup.new(indent: DEFAULT_INDENT))
@@ -27,13 +33,13 @@ module Metrojobb
27
33
  end
28
34
 
29
35
  def employment_type_id
30
- NAME_ID_MAP[name.presence || id.presence] ||
36
+ self.class.name_id_map[name.presence || id.presence] ||
31
37
  id.presence ||
32
38
  name.presence
33
39
  end
34
40
 
35
41
  def validate_known_employment_type
36
- return if ID_NAME_MAP[employment_type_id]
42
+ return if self.class.id_name_map[employment_type_id]
37
43
 
38
44
  errors.add(:employment_type_id, :inclusion)
39
45
  end
@@ -8,16 +8,22 @@ module Metrojobb
8
8
  File.expand_path('../../../data/regions.csv', __FILE__)
9
9
  ).to_h.invert.freeze
10
10
 
11
- ID_NAME_MAP = NAME_ID_MAP.invert.freeze
12
-
13
11
  validate :validate_known_region
14
12
 
13
+ def self.names
14
+ NAME_ID_MAP.keys
15
+ end
16
+
17
+ def self.ids
18
+ NAME_ID_MAP.values
19
+ end
20
+
15
21
  def self.name_id_map
16
22
  NAME_ID_MAP
17
23
  end
18
24
 
19
25
  def self.id_name_map
20
- ID_NAME_MAP
26
+ NAME_ID_MAP.invert
21
27
  end
22
28
 
23
29
  def to_xml(builder: Builder::XmlMarkup.new(indent: DEFAULT_INDENT))
@@ -27,13 +33,13 @@ module Metrojobb
27
33
  end
28
34
 
29
35
  def region_id
30
- NAME_ID_MAP[name.presence || id.presence] ||
36
+ self.class.name_id_map[name.presence || id.presence] ||
31
37
  id.presence ||
32
38
  name.presence
33
39
  end
34
40
 
35
41
  def validate_known_region
36
- return if ID_NAME_MAP[region_id]
42
+ return if self.class.id_name_map[region_id]
37
43
 
38
44
  errors.add(:region_id, :inclusion)
39
45
  end
@@ -1,3 +1,3 @@
1
1
  module Metrojobb
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metrojobb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Burenstam