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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/metrojobb/category.rb +11 -3
- data/lib/metrojobb/employment_type.rb +11 -5
- data/lib/metrojobb/region.rb +11 -5
- data/lib/metrojobb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d11a14ba6fa18ac44914bc2051936cf92d98fad3
|
4
|
+
data.tar.gz: a6f5c124956818f7d2038d4fb9e77fca540e7266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd7766fa1aa678994b79cb9e23b6238072b4e7cd32b73fba1cef73c8f25880014ebb76be7ba0d9799e5cffe68864b70c01463ab3d1fadd27c59e80d65e8814a6
|
7
|
+
data.tar.gz: a2afa97441ba71e7e78d6f6e7b6ecf49b55cc72f1e66791eb9327f7736ffe5fd38913dce02f57d942d0778e0a559ab9f4776b5fad0d87149b6435c6c0abfdf24
|
data/Gemfile.lock
CHANGED
data/lib/metrojobb/category.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
42
|
+
return if self.class.id_name_map[employment_type_id]
|
37
43
|
|
38
44
|
errors.add(:employment_type_id, :inclusion)
|
39
45
|
end
|
data/lib/metrojobb/region.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
42
|
+
return if self.class.id_name_map[region_id]
|
37
43
|
|
38
44
|
errors.add(:region_id, :inclusion)
|
39
45
|
end
|
data/lib/metrojobb/version.rb
CHANGED