rekey 0.0.3 → 1.0.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
  SHA1:
3
- metadata.gz: fa0f9ac28de18ed312d7886726801ae4eeabc6ed
4
- data.tar.gz: dfa6edfbb2dfd2313044f416e56bdeae376c3997
3
+ metadata.gz: a6c9d60055fe41b5eb0256261b47ddb024c9f59a
4
+ data.tar.gz: aa50ed7dae9056378b866e0087c47f05924864f0
5
5
  SHA512:
6
- metadata.gz: fe5cb87711746ab6717dd2e90566110841a8520dd611c88fa56b7f93734dfd36e8416f67b94fc4539a30cff793e6e583b4ece0f5529c466cd3f4327ab2be4fb1
7
- data.tar.gz: 1c1f02d4cef3e52f5d40fdad3ea2dac4299100af0971e0a361e73662e536ae7a79efc94b7d26ac9d1b75d5a42022f956263bd751b715e3a365f3acfb5e3cfe10
6
+ metadata.gz: e4d5f92fec88e352f45cb44a964e18ba305b2ebb2cc7e345e66e712382413791d30d5331499c6bbad6034260de97891b7973a550390d59593a363b3aaea077c9
7
+ data.tar.gz: 62e709ab09d097bff692620e27ba1f8f32aeb062d517b3c05f19a424d545b4cde05c4bbe33010a2aa911a25af38d1545d5b8ceb4e6fc37bf13a2a87f9e90e79e
data/lib/rekey.rb CHANGED
@@ -91,17 +91,11 @@ module Rekey
91
91
  v.send handle, v
92
92
  end
93
93
  elsif v.is_a? Array
94
- if handle.is_a? String and handle.include? '..'
95
- # properly format ranges
96
- ends = handle.split('.').reject(&:empty?).map(&:to_i)
97
- handle = Range.new(
98
- ends.first,
99
- ends.last,
100
- handle.include?('...') # exclude_end
101
- )
94
+ if handle.is_a? Regexp
95
+ v.grep handle
96
+ else
97
+ v[handle]
102
98
  end
103
-
104
- v[handle]
105
99
  elsif v.is_a? Hash
106
100
  v[handle]
107
101
  else
data/lib/rekey/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rekey
2
- VERSION = '0.0.3'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -16,28 +16,28 @@ class RekeyRangeTest < Minitest::Test
16
16
  [ 1, 2 ],
17
17
  [ 4, 5 ],
18
18
  ],
19
- @input.rekey(nil, '0..1')
19
+ @input.rekey(nil, 0..1)
20
20
  )
21
21
 
22
22
  assert_equal([
23
23
  [ 2 ],
24
24
  [ 5 ],
25
25
  ],
26
- @input.rekey(nil, '1...2')
26
+ @input.rekey(nil, 1...2)
27
27
  )
28
28
 
29
29
  assert_equal({
30
30
  [ 2 ] => @input[0],
31
31
  [ 5 ] => @input[1],
32
32
  },
33
- @input.rekey('1...2')
33
+ @input.rekey(1...2)
34
34
  )
35
35
 
36
36
  assert_equal({
37
37
  3 => [ 1, 2 ],
38
38
  6 => [ 4, 5 ],
39
39
  },
40
- @input.rekey(2, '0..1')
40
+ @input.rekey(2, 0..1)
41
41
  )
42
42
  end
43
43
 
@@ -0,0 +1,30 @@
1
+ require 'minitest/autorun'
2
+ require 'rekey'
3
+
4
+
5
+ class RekeyRegexpTest < Minitest::Test
6
+
7
+ def setup
8
+ @input = [
9
+ [ 'a', 'aa', 'b', 'ba' ],
10
+ [ 'b', 'c', 'bc' ],
11
+ ]
12
+ end
13
+
14
+ def test_stuff
15
+ assert_equal([
16
+ ['a', 'aa', 'ba'],
17
+ [],
18
+ ],
19
+ @input.rekey(nil, /a/)
20
+ )
21
+
22
+ assert_equal([
23
+ ['b', 'ba'],
24
+ ['b', 'bc'],
25
+ ],
26
+ @input.rekey(nil, /b/)
27
+ )
28
+ end
29
+
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rekey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
@@ -41,7 +41,8 @@ files:
41
41
  - test/test_array_handlers.rb
42
42
  - test/test_hash_block.rb
43
43
  - test/test_hash_handlers.rb
44
- - test/test_ranges.rb
44
+ - test/test_range.rb
45
+ - test/test_regexp.rb
45
46
  homepage: https://github.com/d1hotpep/rekey
46
47
  licenses:
47
48
  - MIT
@@ -71,4 +72,5 @@ test_files:
71
72
  - test/test_array_handlers.rb
72
73
  - test/test_hash_block.rb
73
74
  - test/test_hash_handlers.rb
74
- - test/test_ranges.rb
75
+ - test/test_range.rb
76
+ - test/test_regexp.rb