finishing_moves 1.0 → 1.0.1

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: d37ca4693b6a2a3120e8ee286ab7d201e489473b
4
- data.tar.gz: 71f81d5815febb3bd3944fbd74c8ba374afd37bd
3
+ metadata.gz: 7663bab15022e6b9d9c30f6884a0d807e8ae68b5
4
+ data.tar.gz: 225ba549fa8109fabd09d95813d2c0e6e5d83cf0
5
5
  SHA512:
6
- metadata.gz: e0cdbe53527bf2fb84106d50768ef3c28e630b81ba28bdb58f1f8aaa3cda1e5792165e95127b4ceda23a49119ba8f0116369ee16a1b9d69fc750d0a294d2f93a
7
- data.tar.gz: b6afe08d894be6a022974b0859bd36d41d5de628e62be9c0df015f90e10c804d2df93fba445c06445251c015aa6d5738dfd53505cf56ffefbd4ebb8c1e7c8d48
6
+ metadata.gz: 97b0b49e565eb79d4bf2cdbcea46b37a4adc435a23832b9f0cf3c19372d75d559e6c21189931c343053819ce54cf8a136eaabb142cb52a84d5ac258fac2dffc6
7
+ data.tar.gz: 16a5d1358d8ae3e5eb1093b40053afdf015241f92b9cd7ca81eecd4abb56e97ab67771f130fceec2d8ae2d07d3fea05385e0b51c18fb85ce63692b6b3e98f144
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Finishing Moves
2
2
  [![Gem Version](https://badge.fury.io/rb/finishing_moves.svg)](https://rubygems.org/gems/finishing_moves)
3
- [![Build Status](https://travis-ci.org/BattleBrisket/rails-force-reload.svg?branch=master)](https://travis-ci.org/BattleBrisket/rails-force-reload)
3
+ [![Build Status](https://travis-ci.org/forgecrafted/finishing_moves.svg?branch=master)](https://travis-ci.org/forgecrafted/finishing_moves)
4
4
 
5
5
  Ruby includes a huge amount of default awesomeness that tackles most common development challenges. But every now and then, you find yourself performing contortions to achieve results that, honestly, **should feel more natural** given the language's design elegance. Finishing Moves is a collection of methods designed to assist in those "why is this awkward?" scenarios.
6
6
 
@@ -25,8 +25,8 @@ gem install 'finishing_moves'
25
25
  - [`Array#to_hash_values`](https://github.com/forgecrafted/finishing_moves/wiki/Array#arrayto_hash_values) :boom:
26
26
  - [`Array#to_indexed_hash`](https://github.com/forgecrafted/finishing_moves/wiki/Array#arrayto_indexed_hash)
27
27
  - [`Array#to_hash_keys`](https://github.com/forgecrafted/finishing_moves/wiki/Array#arrayto_hash_keys)
28
- - [`Array#to_sym`](https://github.com/forgecrafted/finishing_moves/wiki/Array#arrayto_sym)
29
- - [`Array#to_sym_soft`](https://github.com/forgecrafted/finishing_moves/wiki/Array#arrayto_sym_soft)
28
+ - [`Array#to_sym_strict`](https://github.com/forgecrafted/finishing_moves/wiki/Array#arrayto_sym_strict) :new:
29
+ - [`Array#to_sym_loose`](https://github.com/forgecrafted/finishing_moves/wiki/Array#arrayto_sym_loose) :new:
30
30
  - [`Enumerable#key_map`](https://github.com/forgecrafted/finishing_moves/wiki/Enumerable#enumerablekey_map) :boom:
31
31
  - [`Enumerable#key_map_reduce`](https://github.com/forgecrafted/finishing_moves/wiki/Enumerable#enumerablekey_map_reduce)
32
32
  - [`Hash#delete!`](https://github.com/forgecrafted/finishing_moves/wiki/Hash#hashdelete)
@@ -66,7 +66,7 @@ gem install 'finishing_moves'
66
66
 
67
67
  ### Ruby Version
68
68
 
69
- Tested against **`2.0.0` and above**. Probably works in `1.9.3`.
69
+ Tested against **`2.0.0` and above**.
70
70
 
71
71
  ## Development approach
72
72
 
@@ -27,29 +27,25 @@ class Array
27
27
  end
28
28
  alias_method :to_hash_as_keys, :to_hash_keys
29
29
 
30
- def to_sym
30
+ def to_sym_strict
31
31
  map { |x| x.to_sym }
32
32
  end
33
- alias_method :to_sym_hard, :to_sym
34
33
 
35
- def to_sym!
34
+ def to_sym_strict!
36
35
  map! { |x| x.to_sym }
37
36
  end
38
- alias_method :to_sym_hard!, :to_sym!
39
37
 
40
- def to_sym_soft
38
+ def to_sym_loose
41
39
  map do |x|
42
- begin
40
+ if x.respond_to?(:to_sym)
43
41
  x.to_sym
44
- rescue NoMethodError => e
42
+ else
45
43
  x
46
- rescue Exception
47
- raise
48
44
  end
49
45
  end
50
46
  end
51
47
 
52
- def to_sym_soft!
48
+ def to_sym_loose!
53
49
  map! do |x|
54
50
  begin
55
51
  x.to_sym
@@ -1,3 +1,3 @@
1
1
  module FinishingMoves
2
- VERSION = "1.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -99,45 +99,29 @@ describe Array do
99
99
  end
100
100
  end
101
101
 
102
- it '#to_sym' do
102
+ it '#to_sym_strict' do
103
103
  test = ['FOO', 'bar', :baz]
104
- expect(test.to_sym).to eq [:FOO, :bar, :baz]
104
+ expect(test.to_sym_strict).to eq [:FOO, :bar, :baz]
105
105
  expect(test).to eq ['FOO', 'bar', :baz]
106
- expect{ [1].to_sym }.to raise_error NoMethodError
107
- # FinishingMoves::FalseClass#to_sym
108
- expect([false].to_sym).to eq [:false]
106
+ expect{ [1].to_sym_strict }.to raise_error NoMethodError
109
107
  end
110
108
 
111
- it '#to_sym!' do
109
+ it '#to_sym_strict!' do
112
110
  test = ['FOO', 'bar', :baz]
113
- expect(test.to_sym!).to eq [:FOO, :bar, :baz]
111
+ expect(test.to_sym_strict!).to eq [:FOO, :bar, :baz]
114
112
  expect(test).to eq [:FOO, :bar, :baz]
115
- expect{ [1].to_sym! }.to raise_error NoMethodError
113
+ expect{ [1].to_sym_strict! }.to raise_error NoMethodError
116
114
  end
117
115
 
118
- it '#to_sym_hard' do
119
- test = ['FOO', 'bar', :baz]
120
- expect(test.to_sym_hard).to eq [:FOO, :bar, :baz]
121
- expect(test).to eq ['FOO', 'bar', :baz]
122
- expect{ [1].to_sym_hard }.to raise_error NoMethodError
123
- end
124
-
125
- it '#to_sym_hard!' do
126
- test = ['FOO', 'bar', :baz]
127
- expect(test.to_sym_hard!).to eq [:FOO, :bar, :baz]
128
- expect(test).to eq [:FOO, :bar, :baz]
129
- expect{ [1].to_sym_hard! }.to raise_error NoMethodError
130
- end
131
-
132
- it '#to_sym_soft' do
116
+ it '#to_sym_loose' do
133
117
  test = ['FOO', 'bar', :baz, 1, {bat: 'bat'}, /hay/]
134
- expect(test.to_sym_soft).to eq [:FOO, :bar, :baz, 1, {bat: 'bat'}, /hay/]
118
+ expect(test.to_sym_loose).to eq [:FOO, :bar, :baz, 1, {bat: 'bat'}, /hay/]
135
119
  expect(test).to eq ['FOO', 'bar', :baz, 1, {bat: 'bat'}, /hay/]
136
120
  end
137
121
 
138
- it '#to_sym_soft!' do
122
+ it '#to_sym_loose!' do
139
123
  test = ['FOO', 'bar', :baz, 1, {bat: 'bat'}, /hay/]
140
- expect(test.to_sym_soft!).to eq [:FOO, :bar, :baz, 1, {bat: 'bat'}, /hay/]
124
+ expect(test.to_sym_loose!).to eq [:FOO, :bar, :baz, 1, {bat: 'bat'}, /hay/]
141
125
  expect(test).to eq [:FOO, :bar, :baz, 1, {bat: 'bat'}, /hay/]
142
126
  end
143
127
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finishing_moves
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Koehl