eac_ruby_utils 0.35.0 → 0.36.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
  SHA256:
3
- metadata.gz: 3edd773afcebdd9c7f6af74230428101cfd4afc0e18c2311ace07c45764db8ce
4
- data.tar.gz: fee5141ecfb6aa6d457d842b0cbafe42abbcb2da5a88cdc873dce82f647459e7
3
+ metadata.gz: 5ba02fdc9d6fb66a14fbaf450133ad2ff83c8e0950ffa48bd8a26dcd217162be
4
+ data.tar.gz: 8720f2d7da61a357a578c8005079739c127a3afb464e7a83b32516f2c81f34db
5
5
  SHA512:
6
- metadata.gz: 94629883aff72c800948b4de4f102434a642771a18603971b689311eae89fba38c5729601a1075c8bdb949fd0c85540be846a6b1745fa7247092432e244b111d
7
- data.tar.gz: 91b1694cde13eaa0621f0ccc847267d3ad7e6656d927cdcdd5b4f21673a1398f99929ed06e368d4b1e49e6d4738ab86139d032436e6bd6a706fcc821cbf27526
6
+ metadata.gz: 6fa38e552ff8a9f8808614aa67e55eb5a50b837891f0bcd3d6e909bea3ba739307c661a7754f91b048bb600be23fa6ce049d487d6d098931073a54fb70128f00
7
+ data.tar.gz: 68156f1fc6a1bab01b5524d4568aed52e3361cb46d3306aec17f82da80400c8802b2f8e65f78252de5271160b4fcf5b1eb689d73d21e9f82b95bcdf93ac4b7a4
@@ -12,6 +12,10 @@ module EacRubyUtils
12
12
  apply_constants
13
13
  end
14
14
 
15
+ def each_value(&block)
16
+ values.each(&block)
17
+ end
18
+
15
19
  def values
16
20
  @values.values.map(&:value)
17
21
  end
@@ -4,6 +4,7 @@ require 'active_support/hash_with_indifferent_access'
4
4
  require 'active_support/core_ext/string/inflections'
5
5
  require_relative 'integer_list'
6
6
  require_relative 'string_list'
7
+ require_relative 'symbol_list'
7
8
 
8
9
  module EacRubyUtils
9
10
  module Listable
@@ -14,18 +15,10 @@ module EacRubyUtils
14
15
  @source = source
15
16
  end
16
17
 
17
- def add_integer(item, *labels)
18
- check_acts_as_listable_new_item(item)
19
- acts_as_listable_items[item] = ::EacRubyUtils::Listable::IntegerList.new(
20
- self, item, labels
21
- )
22
- end
23
-
24
- def add_string(item, *labels)
25
- check_acts_as_listable_new_item(item)
26
- acts_as_listable_items[item] = ::EacRubyUtils::Listable::StringList.new(
27
- self, item, labels
28
- )
18
+ %w[integer string symbol].each do |list_type|
19
+ define_method "add_#{list_type}" do |item, *labels|
20
+ add(::EacRubyUtils::Listable.const_get("#{list_type}_list".camelize), item, labels)
21
+ end
29
22
  end
30
23
 
31
24
  def method_missing(name, *args, &block)
@@ -43,6 +36,11 @@ module EacRubyUtils
43
36
 
44
37
  private
45
38
 
39
+ def add(list_class, item, labels)
40
+ check_acts_as_listable_new_item(item)
41
+ acts_as_listable_items[item] = list_class.new(self, item, labels)
42
+ end
43
+
46
44
  def check_acts_as_listable_new_item(item)
47
45
  return unless acts_as_listable_items.key?(item)
48
46
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'list'
4
+
5
+ module EacRubyUtils
6
+ module Listable
7
+ class SymbolList < ::EacRubyUtils::Listable::List
8
+ protected
9
+
10
+ def parse_labels(labels)
11
+ if labels.first.is_a?(Hash)
12
+ Hash[labels.first.map { |k, v| [k.to_sym, v.to_sym] }]
13
+ else
14
+ Hash[labels.map { |v| [v.to_sym, v.to_sym] }]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.35.0'
4
+ VERSION = '0.36.0'
5
5
  end
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.35.0
4
+ version: 0.36.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: 2020-06-01 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -155,6 +155,7 @@ files:
155
155
  - lib/eac_ruby_utils/listable/list.rb
156
156
  - lib/eac_ruby_utils/listable/lists.rb
157
157
  - lib/eac_ruby_utils/listable/string_list.rb
158
+ - lib/eac_ruby_utils/listable/symbol_list.rb
158
159
  - lib/eac_ruby_utils/listable/value.rb
159
160
  - lib/eac_ruby_utils/on_clean_ruby_environment.rb
160
161
  - lib/eac_ruby_utils/options_consumer.rb