array_hasher 0.1.1 → 0.1.2
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/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/README.md +5 -0
- data/lib/array_hasher/formatter.rb +3 -3
- data/lib/array_hasher/version.rb +1 -1
- 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: cf66523ac3b7dd4379f29cf3021d66033637b7bf
|
4
|
+
data.tar.gz: 27b9d366d360cbcf9d322635f538201e8adebeb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37ba57202e61fefcec97f8ab6475f0c06ccd6724d9f190cb99f6277f713273995378c3eda604f689183f8e14bb9e03361f0b432446429dd21b141abea1a532a5
|
7
|
+
data.tar.gz: e468dfad8a405605c995fa73abbe227de8b4525f1917060afa2b6f52b1770ac8ffc0c70ec20363330735831090423287224d9fa631a7099f828362ec642ecfb5
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -74,6 +74,10 @@ end
|
|
74
74
|
# {:name=>"<Your book>", :price=>1.2, :tags=>["Hehe", "Haha", "666"]}
|
75
75
|
```
|
76
76
|
|
77
|
+
### Examples
|
78
|
+
|
79
|
+
See [Here](./examples)
|
80
|
+
|
77
81
|
## Default Types
|
78
82
|
|
79
83
|
* `int` # convert string to int
|
@@ -82,6 +86,7 @@ end
|
|
82
86
|
* `time` # Time.parse(string)
|
83
87
|
* `Proc` # format the value with your proc
|
84
88
|
|
89
|
+
|
85
90
|
## Development
|
86
91
|
|
87
92
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -7,10 +7,10 @@ module ArrayHasher
|
|
7
7
|
REGEXP_EMPTY = /\A\s*\z/
|
8
8
|
|
9
9
|
TYPES = {
|
10
|
-
int: Proc.new {|v| v =~ REGEXP_EMPTY ? nil : v.gsub(/\A[^\d]+/, '').to_i },
|
11
|
-
float: Proc.new {|v| v =~ REGEXP_EMPTY ? nil : v.gsub(/\A[^\d]+/, '').to_f },
|
10
|
+
int: Proc.new {|v| (v.nil? || v =~ REGEXP_EMPTY) ? nil : v.gsub(/\A[^\d]+/, '').to_i },
|
11
|
+
float: Proc.new {|v| (v.nil? || v =~ REGEXP_EMPTY) ? nil : v.gsub(/\A[^\d]+/, '').to_f },
|
12
12
|
string: Proc.new {|v| v.to_s },
|
13
|
-
time: Proc.new {|v| Time.parse(v) }
|
13
|
+
time: Proc.new {|v| v ? Time.parse(v) : nil }
|
14
14
|
}
|
15
15
|
|
16
16
|
# cols:
|
data/lib/array_hasher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: array_hasher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiangzhi.xie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|