aromat 0.5.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aromat/dclone.rb +9 -6
- data/lib/aromat/nstr.rb +2 -1
- data/lib/aromat/pad.rb +4 -4
- data/lib/aromat/sym_keys.rb +4 -4
- data/lib/aromat/try.rb +5 -1
- data/lib/aromat/version.rb +1 -1
- data/lib/aromat.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 709297778b3caa94ab4766f212c03a69b0b157b0
|
4
|
+
data.tar.gz: 6aaa9cf511abf07e3bf7272bbed89aec34a0bf6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16464baf14f57fe5fca36633f883fc211cbaf96e0d6aa79be8ec37d3c5348657ff1b54b6dfa14936d90ea2f6e2a0263a00507586b151c29f692923f287d14285
|
7
|
+
data.tar.gz: eac91efd63c038c1821e97ec7eee800eb0996b9f57df6db980876422f3f4f28edb019a2ec15c2304c9581e65289fe89c7e73f6e6e769fefbc240b85a607bbac8
|
data/lib/aromat/dclone.rb
CHANGED
@@ -7,18 +7,21 @@ module Aromat
|
|
7
7
|
# Dclone Module
|
8
8
|
module Dclone
|
9
9
|
|
10
|
-
# Base Clone
|
11
|
-
# Clone the object if possible
|
10
|
+
# Base Clone:
|
11
|
+
# Clone the object if possible.
|
12
|
+
# @param [Object] e Any object
|
13
|
+
# @return [Object] A clone of e
|
12
14
|
def self.base_clone e
|
13
15
|
e.clone rescue e
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
19
|
+
|
17
20
|
# Monkey-patch Array Class
|
18
21
|
class Array
|
19
22
|
|
20
|
-
# Deep-Clone
|
21
|
-
# Recursively clones every level of the Array
|
23
|
+
# Deep-Clone:
|
24
|
+
# Recursively clones every level of the Array.
|
22
25
|
# @return [Array] A copy of the original array where each element has been clone'd
|
23
26
|
def dclone
|
24
27
|
collect { |a| a.respond_to?(:dclone) ? a.dclone : Aromat::Dclone.base_clone(a) }
|
@@ -28,8 +31,8 @@ end
|
|
28
31
|
# Monkey-patch Hash Class
|
29
32
|
class Hash
|
30
33
|
|
31
|
-
# Deep-Clone
|
32
|
-
# Recursively clones every level of the Hash
|
34
|
+
# Deep-Clone:
|
35
|
+
# Recursively clones every level of the Hash.
|
33
36
|
# @return [Hash] A copy of the original hash where each element has been clone'd
|
34
37
|
def dclone
|
35
38
|
Hash[*(inject([]) { |a, e| a + e }.collect { |e| e.respond_to?(:dclone) ? e.dclone : Aromat::Dclone.base_clone(e) })]
|
data/lib/aromat/nstr.rb
CHANGED
data/lib/aromat/pad.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
# Monkey-patch String Class
|
5
5
|
class String
|
6
6
|
|
7
|
-
# Right-Pad
|
8
|
-
# Right-Pads a String to a given length using a given filler
|
7
|
+
# Right-Pad:
|
8
|
+
# Right-Pads a String to a given length using a given filler.
|
9
9
|
# @param [Fixnum] size
|
10
10
|
# @param [String] fill
|
11
11
|
# @return [String] A copy of the original String, padded to [size] with [fill]
|
@@ -15,8 +15,8 @@ class String
|
|
15
15
|
s.slice 0, size
|
16
16
|
end
|
17
17
|
|
18
|
-
# Left-Pad
|
19
|
-
# Left-Pads a String to a given length using a given filler
|
18
|
+
# Left-Pad:
|
19
|
+
# Left-Pads a String to a given length using a given filler.
|
20
20
|
# @param [Fixnum] size
|
21
21
|
# @param [String] fill
|
22
22
|
# @return [String] A copy of the original String, padded to [size] with [fill]
|
data/lib/aromat/sym_keys.rb
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
# Monkey-patch Array Class
|
5
5
|
class Array
|
6
6
|
|
7
|
-
# Symbolize Keys
|
8
|
-
# Recursively symbolizes hash keys
|
7
|
+
# Symbolize Keys:
|
8
|
+
# Recursively symbolizes hash keys.
|
9
9
|
# @return [Array] A copy of the original array where each element has had its keys recursively symbolized
|
10
10
|
def sym_keys
|
11
11
|
collect { |e| e.respond_to?(:sym_keys) ? e.sym_keys : e }
|
@@ -15,8 +15,8 @@ end
|
|
15
15
|
# Monkey-patch Hash Class
|
16
16
|
class Hash
|
17
17
|
|
18
|
-
# Symbolize Keys
|
19
|
-
# Recursively symbolizes hash keys
|
18
|
+
# Symbolize Keys:
|
19
|
+
# Recursively symbolizes hash keys.
|
20
20
|
# @return [Hash] A copy of the original hash where each element has had its keys recursively symbolized
|
21
21
|
def sym_keys
|
22
22
|
Hash[*(inject([]) { |a, e| (a << (e[0].respond_to?(:to_sym) ? e[0].to_sym : e[0])) << (e[1].respond_to?(:sym_keys) ? e[1].sym_keys : e[1]) })]
|
data/lib/aromat/try.rb
CHANGED
@@ -4,7 +4,11 @@
|
|
4
4
|
# Monkey-patch Object Class
|
5
5
|
class Object
|
6
6
|
|
7
|
-
# Try
|
7
|
+
# Try:
|
8
|
+
# Call a method if possible, do nothing otherwise.
|
9
|
+
# @param [Symbol] meth Method name
|
10
|
+
# @param [Array] args Method arguments
|
11
|
+
# @param [Object] block Method block
|
8
12
|
def try meth, *args, &block
|
9
13
|
return nil unless respond_to? meth
|
10
14
|
send meth.to_sym, *args, &block
|
data/lib/aromat/version.rb
CHANGED
data/lib/aromat.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aromat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eresse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|