nrser 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: 866f9b21a10a8770d932228f5ad747e12782a4ba
4
- data.tar.gz: bc50260a343986944cfe31e16d7d0e495360ab03
3
+ metadata.gz: bbe345fdd17d3661a6ab8424078866fca405486c
4
+ data.tar.gz: 011ea7b181ad4f101ce83a1edc9a44ea5a4728fb
5
5
  SHA512:
6
- metadata.gz: 0a77767059fb6d66420094f0e20f3fbad8e01e2cf37720df0ef0d20bd86f01193f85df842966a7f1e6fb8175b436f7abc0b5ee9cec6b802cec693ff02186cf0d
7
- data.tar.gz: 93f5875dc928e78c86206b3552c5a3b7ac7b84b5af4dff1456498cc48a56b6d62d0582420e6a20cc64115f37c4968321bf1993dec1deb38ea8b5eec6901aa90f
6
+ metadata.gz: cef54bd329af2caee3fb30220f39a57510d4a110836f86dfa7f2af744b24df8592e09f04ca27f27cbe548bb2229532e36afa2c668e2fc431ad564c4fd07b5194
7
+ data.tar.gz: 3b4f1a99cf7397b170559177ceca023b3e7b22f5bfe632a0c77f26c62c815ef488fea667b781035025ae2283258a57c391185272fbe077ecefd84a51317e02be
@@ -9,11 +9,18 @@ class Hash
9
9
  include NRSER::Ext::Tree
10
10
 
11
11
  # Short names
12
- alias_method :sym_keys!, :symbolize_keys!
13
- alias_method :sym_keys, :symbolize_keys
12
+ #
13
+ # NOTE If we use `alias_method` here it breaks subclasses that override
14
+ # `#symbolize_keys`, etc. - like {HashWithIndifferentAccess}
15
+ #
16
+ def sym_keys! *args, █ symbolize_keys! *args, █ end
17
+ def sym_keys *args, █ symbolize_keys *args, █ end
18
+
19
+ def str_keys! *args, █ stringify_keys! *args, █ end
20
+ def str_keys *args, █ stringify_keys *args, █ end
14
21
 
15
- alias_method :str_keys!, :stringify_keys!
16
- alias_method :str_keys, :stringify_keys
22
+ def to_options! *args, █ symbolize_keys! *args, █ end
23
+ def to_options *args, █ symbolize_keys *args, █ end
17
24
 
18
25
 
19
26
  # See {NRSER.bury!}
@@ -142,7 +142,7 @@ module NRSER
142
142
  count = enum.count
143
143
 
144
144
  unless count == 1
145
- message = erb binding, <<-END
145
+ message = binding.erb <<-END
146
146
  Expected enumerable to have #count == 1 but it has
147
147
 
148
148
  #count = <%= enum.count %>
@@ -132,7 +132,7 @@ module NRSER
132
132
  #
133
133
  glob = looks_globish?( rel_path ) if glob == :guess
134
134
 
135
- found = find_map( pn_from( from ).ascend ) { |dir|
135
+ found = pn_from( from ).ascend.find_map { |dir|
136
136
  path = dir / rel_path
137
137
 
138
138
  found_path = if glob
@@ -71,14 +71,19 @@ module NRSER::RSpex::ExampleGroup
71
71
  end
72
72
  end
73
73
 
74
- describe_x(
74
+ describe_x_body = if chain.empty?
75
+ body
76
+ else
77
+ -> { dive_x *chain, bind_subject: bind_subject, &body }
78
+ end
79
+
80
+ describe_x \
75
81
  NRSER::RSpex.dot_rel_path( spec_path ),
76
82
  *description,
77
83
  type: :spec_file,
78
84
  metadata: metadata,
79
- ) do
80
- dive_x *chain, bind_subject: bind_subject, &body
81
- end
85
+ &describe_x_body
86
+
82
87
  end # #describe_spec_file
83
88
 
84
89
  end # module NRSER::RSpex::ExampleGroup
@@ -18,7 +18,7 @@ module NRSER
18
18
  #
19
19
  # @return [String]
20
20
  #
21
- VERSION = '0.3.0'
21
+ VERSION = '0.3.1'
22
22
 
23
23
 
24
24
  module Version
@@ -0,0 +1,40 @@
1
+ require 'nrser/core_ext/hash'
2
+
3
+ describe_spec_file(
4
+ spec_path: __FILE__,
5
+ ) do
6
+
7
+ describe_setup "'short' transform keys methods under inheritance" do
8
+
9
+ def self.str_hash; {'x' => 1, 'y' => 2}; end
10
+ def str_hash; self.class.str_hash; end
11
+
12
+ def self.sym_hash; {x: 1, y: 2}; end
13
+ def sym_hash; self.class.sym_hash; end
14
+
15
+ [Hash, HashWithIndifferentAccess].each do |hash_class|
16
+ describe_class hash_class do
17
+ [str_hash, sym_hash].each do |source_hash|
18
+ describe "#{ described_class.name }[#{ str_hash }]" do
19
+ subject do
20
+ described_class.send :[], source_hash
21
+ end
22
+
23
+ describe_instance_method :sym_keys do
24
+ describe_called_with() do
25
+ it { is_expected.to eq subject.symbolize_keys }
26
+ end
27
+ end
28
+
29
+ describe_instance_method :str_keys do
30
+ describe_called_with() do
31
+ it { is_expected.to eq subject.stringify_keys }
32
+ end
33
+ end
34
+ end # instance str_hash
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ end # spec file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
@@ -399,6 +399,7 @@ files:
399
399
  - spec/lib/nrser/collection/map_spec.rb
400
400
  - spec/lib/nrser/core_ext/binding/erb_spec.rb
401
401
  - spec/lib/nrser/core_ext/enumerable/find_map_spec.rb
402
+ - spec/lib/nrser/core_ext/hash/short_transform_keys_spec.rb
402
403
  - spec/lib/nrser/core_ext/hash_spec.rb
403
404
  - spec/lib/nrser/errors/abstract_method_error_spec.rb
404
405
  - spec/lib/nrser/functions/enumerable/associate_spec.rb
@@ -488,6 +489,7 @@ test_files:
488
489
  - spec/lib/nrser/collection/map_spec.rb
489
490
  - spec/lib/nrser/core_ext/binding/erb_spec.rb
490
491
  - spec/lib/nrser/core_ext/enumerable/find_map_spec.rb
492
+ - spec/lib/nrser/core_ext/hash/short_transform_keys_spec.rb
491
493
  - spec/lib/nrser/core_ext/hash_spec.rb
492
494
  - spec/lib/nrser/errors/abstract_method_error_spec.rb
493
495
  - spec/lib/nrser/functions/enumerable/associate_spec.rb