eac_ruby_utils 0.109.1 → 0.110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2b5cd79e1ec23311c26c6e444bc22ad3467fe4339414b040a6185c214f1941c
|
4
|
+
data.tar.gz: da8074cc3cdf8de32546c95088aa64bfc2b5d7bf8d56aff537de7f8d706ed077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56cdf581724ea7e15f46990e19fd70fc6b14dcc3d4d03bf995c8c15b20f615393561bf82e3008fb02a612cd1fc859dca3e6df1a397fb0383bcc721e4a805cae2
|
7
|
+
data.tar.gz: cc7a20c43187222d5c9ab0492bf45765a0d0fd6ec95a754012a61b62add8b34971a658a986034d188e15895fd4b06110dde7a597da5f6678ad072e608b199630
|
@@ -1,25 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/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.0
|
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: 2022-12-
|
11
|
+
date: 2022-12-24 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
|