eac_ruby_utils 0.97.0 → 0.100.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: 7853f73c30655f3f5e800a0e60f84b3eb3e8a6fd2f0da0707c276968c70ab3dd
4
- data.tar.gz: b8edeff03332dd10516e607326deb826e39ca8813f88374f82b6cfa2bccb82d2
3
+ metadata.gz: e6f852b958cf7ed8f6f05d3860d738de716c1c5a7456917b4705abf4ab78b546
4
+ data.tar.gz: ea80e22f5fec3c6d5958a544a348790a01491490dc0f75ac98d8d59b88955122
5
5
  SHA512:
6
- metadata.gz: fa551ee55bfa9ab6557aedbc68169181f3cadc46a64e0be42b174e6b992690d8697c5ff73d3abea682e500b3878078fe6a89a9cd7e145ea26d62f64b253f692c
7
- data.tar.gz: 269956e80320b4ab1a471715effda782c75e4c0a9b7a4673176af48ea5a531bf9b3d78d7d0d258d6b17b489bf9626541c1e6c6610a7ffe6fae952e5537b392b0
6
+ metadata.gz: 9b9be95919c93a7b3800d726bb52055c9ecfe92b422601af67cc7ad50bbd0a6602d0d92d120759ad408661201040512545286fc376832031f594e46ea1d7d121
7
+ data.tar.gz: 50674addc08d99c21ffcd2160a8beeb0418f49bd1bd6b2a815544179495b8fce3b4e33fb98074ab530a8def5052db2022048d758943afff3ade8855a3d6bc512
@@ -29,8 +29,16 @@ module EacRubyUtils
29
29
  @values.values.map(&:value)
30
30
  end
31
31
 
32
+ def values_with_blank
33
+ [blank_value.value] + values
34
+ end
35
+
32
36
  def options
33
- @values.values.map { |v| [v.label, v.value] }
37
+ @values.values.map(&:to_option)
38
+ end
39
+
40
+ def options_with_blank
41
+ [blank_value.to_option] + options
34
42
  end
35
43
 
36
44
  def method_missing(name, *args, &block)
@@ -30,6 +30,11 @@ module EacRubyUtils
30
30
  translate('description')
31
31
  end
32
32
 
33
+ # @return [Array] A two-item array in format `[label, value]`.
34
+ def to_option
35
+ [label, value]
36
+ end
37
+
33
38
  def translation_required?
34
39
  @translation_required
35
40
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'addressable'
4
+
5
+ module Addressable
6
+ class URI
7
+ # @return [ActiveSupport:HashWithIndifferentAccess]
8
+ def hash_query_values
9
+ (query_values || {}).with_indifferent_access
10
+ end
11
+
12
+ def query_value(*args)
13
+ if args.count == 1
14
+ query_value_get(*args)
15
+ elsif args.count == 2
16
+ query_value_set(*args)
17
+ else
18
+ raise ::ArgumentError, "#{object.class}.#{__method__}: wrong number of arguments" \
19
+ " (given #{args.count}, expected 1..2)"
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def query_value_get(name)
26
+ hash_query_values[name]
27
+ end
28
+
29
+ def query_value_set(name, value)
30
+ new_query_values = hash_query_values
31
+ new_query_values[name] = value
32
+ self.query_values = new_query_values
33
+
34
+ self
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub __FILE__
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub __FILE__
@@ -1,18 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Object
4
- def pretty_debug
4
+ def pretty_debug(options = {})
5
+ print_debug_title(options)
6
+
5
7
  STDERR.write(pretty_inspect)
6
8
 
7
9
  self
8
10
  end
9
11
 
10
- def print_debug
12
+ def print_debug(options = {})
13
+ print_debug_title(options)
11
14
  STDERR.write(to_debug + "\n")
12
15
 
13
16
  self
14
17
  end
15
18
 
19
+ def print_debug_title(title)
20
+ if title.is_a?(::Hash)
21
+ return unless title[:title]
22
+
23
+ title = title[:title]
24
+ end
25
+ char = '='
26
+ STDERR.write(char * (4 + title.length) + "\n")
27
+ STDERR.write("#{char} #{title} #{char}\n")
28
+ STDERR.write(char * (4 + title.length) + "\n")
29
+ end
30
+
16
31
  def to_debug
17
32
  "|#{::Object.instance_method(:to_s).bind(self).call}|#{self}|"
18
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.97.0'
4
+ VERSION = '0.100.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.97.0
4
+ version: 0.100.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-08-02 00:00:00.000000000 Z
11
+ date: 2022-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -182,6 +182,9 @@ files:
182
182
  - lib/eac_ruby_utils/options_consumer.rb
183
183
  - lib/eac_ruby_utils/patch.rb
184
184
  - lib/eac_ruby_utils/patches.rb
185
+ - lib/eac_ruby_utils/patches/addressable.rb
186
+ - lib/eac_ruby_utils/patches/addressable/uri.rb
187
+ - lib/eac_ruby_utils/patches/addressable/uri/query_value.rb
185
188
  - lib/eac_ruby_utils/patches/class.rb
186
189
  - lib/eac_ruby_utils/patches/class/abstract.rb
187
190
  - lib/eac_ruby_utils/patches/class/common_constructor.rb