eac_ruby_utils 0.109.1 → 0.110.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 290ef6d02ac4c1937fbafee4fc646fc344dbaecd4a290cb3fc400f6d053cf7a7
|
4
|
+
data.tar.gz: 71bb0f660a223254f4644d6f16667a1c7fdd990f2a5b8c97dfaf260028c47bc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7e8fc8a029e673628315be510e4f5e49b67fd5ae3819715e2b1e32e0ae9e414ae813844d434b5238ea95e5fa04af9fb9a70c4eb35df4f996c775dfed623a338
|
7
|
+
data.tar.gz: 66978244be21e8d56b99209fd9e888555df5760d4ac0b72aec780aecc9a49f9f8fd743b42465f7f387d16bd0fa3ccfab8b5fd95d3063cd0a87f37f54d4892a48
|
@@ -1,25 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/patches/class/common_constructor'
|
3
4
|
require 'eac_ruby_utils/inflector'
|
4
5
|
|
5
6
|
module EacRubyUtils
|
6
7
|
module Listable
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
def initialize(list, value, key, translation_required = true)
|
11
|
-
@list = list
|
12
|
-
@value = value
|
13
|
-
@key = key
|
14
|
-
@translation_required = translation_required
|
15
|
-
end
|
8
|
+
class Item
|
9
|
+
common_constructor :list, :value, :key, :translation_required, default: [true]
|
16
10
|
|
17
11
|
def to_s
|
18
|
-
"I: #{
|
12
|
+
"I: #{list.item}, V: #{value}, K: #{key}"
|
19
13
|
end
|
20
14
|
|
21
15
|
def constant_name
|
22
|
-
::EacRubyUtils::Inflector.variableize("#{
|
16
|
+
::EacRubyUtils::Inflector.variableize("#{list.item}_#{key}").upcase
|
23
17
|
end
|
24
18
|
|
25
19
|
def label
|
@@ -36,13 +30,13 @@ module EacRubyUtils
|
|
36
30
|
end
|
37
31
|
|
38
32
|
def translation_required?
|
39
|
-
|
33
|
+
translation_required
|
40
34
|
end
|
41
35
|
|
42
36
|
private
|
43
37
|
|
44
38
|
def translate(translate_key)
|
45
|
-
full_translate_key = "#{
|
39
|
+
full_translate_key = "#{list.i18n_key}.#{key}.#{translate_key}"
|
46
40
|
if !::I18n.exists?(full_translate_key) && !translation_required?
|
47
41
|
''
|
48
42
|
else
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/listable/
|
3
|
+
require 'eac_ruby_utils/listable/item'
|
4
4
|
|
5
5
|
module EacRubyUtils
|
6
6
|
module Listable
|
@@ -18,13 +18,23 @@ module EacRubyUtils
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def blank_value
|
21
|
-
@blank_value ||= ::EacRubyUtils::Listable::
|
21
|
+
@blank_value ||= ::EacRubyUtils::Listable::Item.new(self, BLANK_VALUE, BLANK_KEY, false)
|
22
22
|
end
|
23
23
|
|
24
24
|
def each_value(&block)
|
25
25
|
values.each(&block)
|
26
26
|
end
|
27
27
|
|
28
|
+
# @return [EacRubyUtils::Listable::Item, nil]
|
29
|
+
def item_by_value(value)
|
30
|
+
@values.values.find { |item| item.value == value }
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [EacRubyUtils::Listable::Item]
|
34
|
+
def item_by_value!(value)
|
35
|
+
item_by_value(value) || raise(::KeyError, "Value not found: #{value}")
|
36
|
+
end
|
37
|
+
|
28
38
|
def values
|
29
39
|
@values.values.map(&:value)
|
30
40
|
end
|
@@ -59,7 +69,7 @@ module EacRubyUtils
|
|
59
69
|
"eac_ruby_utils.listable.#{class_i18n_key}.#{item}"
|
60
70
|
end
|
61
71
|
|
62
|
-
# @return [EacRubyUtils::Listable::
|
72
|
+
# @return [EacRubyUtils::Listable::Item, nil]
|
63
73
|
def instance_value(instance)
|
64
74
|
v = instance.send(item)
|
65
75
|
return blank_value if v.blank?
|
@@ -109,7 +119,7 @@ module EacRubyUtils
|
|
109
119
|
def build_values(labels)
|
110
120
|
vs = {}
|
111
121
|
parse_labels(labels).each do |value, key|
|
112
|
-
v =
|
122
|
+
v = ::EacRubyUtils::Listable::Item.new(self, value, key)
|
113
123
|
vs[v.value] = v
|
114
124
|
end
|
115
125
|
vs
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_ruby_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.110.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -197,11 +197,11 @@ files:
|
|
197
197
|
- lib/eac_ruby_utils/listable/class_methods.rb
|
198
198
|
- lib/eac_ruby_utils/listable/instance_methods.rb
|
199
199
|
- lib/eac_ruby_utils/listable/integer_list.rb
|
200
|
+
- lib/eac_ruby_utils/listable/item.rb
|
200
201
|
- lib/eac_ruby_utils/listable/list.rb
|
201
202
|
- lib/eac_ruby_utils/listable/lists.rb
|
202
203
|
- lib/eac_ruby_utils/listable/string_list.rb
|
203
204
|
- lib/eac_ruby_utils/listable/symbol_list.rb
|
204
|
-
- lib/eac_ruby_utils/listable/value.rb
|
205
205
|
- lib/eac_ruby_utils/local_time_zone.rb
|
206
206
|
- lib/eac_ruby_utils/locales.rb
|
207
207
|
- lib/eac_ruby_utils/locales/from_all_gems.rb
|
@@ -258,6 +258,7 @@ files:
|
|
258
258
|
- lib/eac_ruby_utils/patches/object/to_pathname.rb
|
259
259
|
- lib/eac_ruby_utils/patches/object/to_uri.rb
|
260
260
|
- lib/eac_ruby_utils/patches/pathname.rb
|
261
|
+
- lib/eac_ruby_utils/patches/pathname/assert_parent.rb
|
261
262
|
- lib/eac_ruby_utils/patches/pathname/basename_noext.rb
|
262
263
|
- lib/eac_ruby_utils/patches/pathname/basename_sub.rb
|
263
264
|
- lib/eac_ruby_utils/patches/pathname/if_exist.rb
|