str2duck 1.3.0 → 1.3.1
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 +5 -13
- data/README.md +2 -4
- data/VERSION +1 -1
- data/files.rb +6 -7
- data/lib/str2duck/regexp.rb +2 -1
- data/str2duck.gemspec +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YzAzNDgwMmFlN2I0MmQxODFmMmQ4N2QyZmRhYzdjYmU5NmVlNThlMg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 13d262e737dd246b94d5ba61744a2f436fd8b957
|
4
|
+
data.tar.gz: 7353ed1e2ed73ce3d2b4c2052e948acc6f6d2a21
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZWI1MjQ4YzU5MWVkYjA4ZWYyMGRmOTI2NjA3N2IyYzVhZTJhNmFiMTc4Yjc0
|
11
|
-
MTFmMzEzYjY0MzFhMWU1YTM3YzhiMTlmOTAwODFlOTZkNzM2OTA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ODE1Mjk5MzA3NjZjYzhiNDEyNzFiNjhhNGMxMzRkMDA1NmYyNWExZjY5MTk1
|
14
|
-
ZGQxZTdjNzhiMTljYjAzODkxNjgwNTk1MjJmMzVmNjljN2M3NTBiOTFiMTNh
|
15
|
-
N2Y2NTZkYzI2MjFkZTgyNzlhN2E2YjZjMzgwNjI3MzNhM2VlYzA=
|
6
|
+
metadata.gz: 56a9d31455f28a6b38a142e0352f8c1287c5701c250185bc308cd09c91dbab9d0e8b8fa07b52645d11c100ab7d95962e5d2388f7c22c5580786fc46a0a9e0f24
|
7
|
+
data.tar.gz: c761bf9f825ce94193132f1acd2e4ee55c87f2d20dd4adcafc0481926211d3eac8a3d1bda47ba77450c3b44f253722c80d4222491d6c7e00e1c2e43d980cd52d
|
data/README.md
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
str2duck
|
2
2
|
========
|
3
3
|
|
4
|
-
String to Duck type parser
|
4
|
+
String(any object) to Duck type parser
|
5
5
|
It can parse int, float, time, date . datetime, booleans ,json, yaml etc from string
|
6
6
|
|
7
7
|
The main Goal for this project to give flexibility when you work on REST protocol where,
|
8
8
|
most of the obj will be sent as string.
|
9
9
|
|
10
|
-
With this you can do simeple validations like
|
10
|
+
With this you can do simeple validations in Grape like this (or anywhere)
|
11
11
|
```ruby
|
12
12
|
|
13
13
|
params['hash_obj_key'].duck.class <= Hash
|
14
|
-
|
15
14
|
```
|
16
15
|
|
17
16
|
Possible bug source, not yet been tested is the american time format.
|
@@ -28,7 +27,6 @@ Possible bug source, not yet been tested is the american time format.
|
|
28
27
|
|
29
28
|
# without sugar syntax, you can use this
|
30
29
|
Str2Duck.parse("123.123") #> Float obj
|
31
|
-
|
32
30
|
```
|
33
31
|
|
34
32
|
it is possible ot extend the Duck flexibility be require the Active Supports time extension,
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1
|
data/files.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
### Get Files from dir
|
2
2
|
begin
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module Str2Duck
|
5
|
+
@@spec_files = []
|
6
|
+
end
|
7
7
|
|
8
8
|
Dir[File.expand_path(File.join(File.dirname(__FILE__),"**","*"))].sort.uniq.each do |one_file_name|
|
9
9
|
one_file_name = File.expand_path one_file_name
|
@@ -11,11 +11,10 @@ begin
|
|
11
11
|
|
12
12
|
if !one_file_name.include?("pkg")
|
13
13
|
if !File.directory? file_name
|
14
|
-
|
14
|
+
|
15
|
+
Str2Duck.class_variable_get("@@spec_files").push file_name
|
15
16
|
STDOUT.puts file_name if $DEBUG
|
16
|
-
|
17
|
-
load one_file_name
|
18
|
-
end
|
17
|
+
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
data/lib/str2duck/regexp.rb
CHANGED
@@ -13,7 +13,8 @@ module Str2Duck
|
|
13
13
|
answer_value= nil
|
14
14
|
[
|
15
15
|
/^\w+, \d+ \w+ #{@@year} \d\d:\d\d:\d\d \+\d+$/,
|
16
|
-
/^#{@@year}-\d\d-\d\d\w\d\d:\d\d:\d\d\+\d\d:\d\d
|
16
|
+
/^#{@@year}-\d\d-\d\d\w\d\d:\d\d:\d\d\+\d\d:\d\d$/,
|
17
|
+
/\w+ \w+ \d+ #{@@year} \d+:\d+:\d+ \w+\+\d+ \(\w+\)/
|
17
18
|
].each do |regexp|
|
18
19
|
answer_value ||= obj =~ regexp
|
19
20
|
end
|
data/str2duck.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/adamluzsi/str2duck"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files =
|
17
|
+
spec.files = Str2Duck.class_variable_get("@@spec_files")
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: str2duck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: " Parse string into obj "
|
14
14
|
email:
|
15
15
|
- adamluzsi@gmail.com
|
16
16
|
executables: []
|
@@ -46,19 +46,18 @@ require_paths:
|
|
46
46
|
- lib
|
47
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
|
-
- -
|
49
|
+
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '0'
|
52
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.2.
|
59
|
+
rubygems_version: 2.2.2
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: String to Obj, Duck type parser
|
63
63
|
test_files: []
|
64
|
-
has_rdoc:
|