duck_puncher 0.1.2 → 0.2.0
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 +4 -4
- data/README.md +1 -0
- data/lib/duck_puncher/array.rb +7 -2
- data/lib/duck_puncher/version.rb +1 -1
- data/test/duck_puncher/array_test.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dd7bb9b78276814a980391bcd2aaa484842651c
|
4
|
+
data.tar.gz: 0a9daa1a7e6938ca3ea25fa7326779bb9771142a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da795cdef2c5829430ec572287444c7a05edb6e60c1fd46627f68c701131d9ae911c4a5bff539d178e6ae335d0a9993259a392c57db7b1812f98a45be4cb8c0d
|
7
|
+
data.tar.gz: db4675a9f8804cc8e4465d1cf38ac7995a7e4a38370c66502dbb0d61fdac9883cc0d22d21b8d856d281f04ab5bcb444d426e8a1b5eef911cffe5ba756ad778f3
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
Currently have the following punches in our repertoire:
|
4
4
|
|
5
5
|
* Array#m - alias for `map(&:)`, usage: `[1].m(:succ)`
|
6
|
+
* Array#get - usage: `[].methods.get('ty?') #=> [:empty?]`
|
6
7
|
* Hash#seek - usage: `{a: 1, b: {c: 2}}.seek(:b, :c) #=> 2`
|
7
8
|
* Numeric#to_currency - usage: `25.245.to_currency #=> '25.25'`
|
8
9
|
* Numeric#to_duration - usage `10_000.to_duration #=> '2 h 46 min'`
|
data/lib/duck_puncher/array.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
module DuckPuncher
|
2
2
|
module Array
|
3
3
|
def m(method_name)
|
4
|
-
|
4
|
+
map(&method_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def get(regex_or_str)
|
8
|
+
regex = regex_or_str.is_a?(Regexp) ? regex_or_str : Regexp.new(Regexp.escape(regex_or_str))
|
9
|
+
select { |x| x.to_s =~ regex }
|
5
10
|
end
|
6
11
|
end
|
7
12
|
end
|
8
13
|
|
9
|
-
Array.send(:include, DuckPuncher::Array)
|
14
|
+
Array.send(:include, DuckPuncher::Array)
|
data/lib/duck_puncher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duck_puncher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.4.6
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Duck punches Ruby
|