str2duck 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDU2ZTU1M2Y1YjIwYzRjY2I5OTM2MWY4ZDcyY2I2NDAyMDU2M2EzZg==
4
+ NDJiMGI1NTkyMzY3NjAwNDBiOGU5OTk3NjE2NDQ3ZDZkOTBlNTllOQ==
5
5
  data.tar.gz: !binary |-
6
- NjU5ODJlMTA2MDM0MTA2NjYwOTQ2NDA2NjMxZjIwN2YxZWNlYTQzMg==
6
+ YzAzNDgwMmFlN2I0MmQxODFmMmQ4N2QyZmRhYzdjYmU5NmVlNThlMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjUxNDM2Y2M2M2QyMjBjNjMzOTUzYjA5NDFkMGUwNjRkZTRlNzRiMzZmOGU3
10
- YWQzODNiZDEzMjhlYTEwZDcxNzYwZGUxYTNiMDhiNGY2YWFjNzU3MjY0YjFh
11
- YjllMDc5N2YwMWE1ZDJhNjk3ZDgyNmM2OWJkYmRiNGZhZDE1OWI=
9
+ OWRmNTllODdlMDE1YjBhMjE3YmI2ODBmNDYxMTMxN2VhMDZiZjI1YWJkOTY0
10
+ ZWI1MjQ4YzU5MWVkYjA4ZWYyMGRmOTI2NjA3N2IyYzVhZTJhNmFiMTc4Yjc0
11
+ MTFmMzEzYjY0MzFhMWU1YTM3YzhiMTlmOTAwODFlOTZkNzM2OTA=
12
12
  data.tar.gz: !binary |-
13
- ZmMyYjAzOWE2N2Y2ZTg2Mjc3NjM3ZDA0NmMyYjc4YjU1NDE4MmY3NmNhOGU3
14
- ZTk5MzY0YWQ0YzYyZjRiMGI3ZThlOGZhNTI4NGQ5MjU2ODFiZGVhZjhiMjQ0
15
- OTYwZTViNWU3MGJhZGI4YjJjNDhiNGJlOWI5MWU5YThjZGQyODc=
13
+ ODE1Mjk5MzA3NjZjYzhiNDEyNzFiNjhhNGMxMzRkMDA1NmYyNWExZjY5MTk1
14
+ ZGQxZTdjNzhiMTljYjAzODkxNjgwNTk1MjJmMzVmNjljN2M3NTBiOTFiMTNh
15
+ N2Y2NTZkYzI2MjFkZTgyNzlhN2E2YjZjMzgwNjI3MzNhM2VlYzA=
data/README.md CHANGED
@@ -62,5 +62,20 @@ If you dont want one or more parser to be active on parse, you can simply config
62
62
 
63
63
  ```
64
64
 
65
+ Now it has a new object syntax sugar patch that allow you to call the duck methods on any class if you not sure,
66
+ is the obj there is instance of anything but String or not
67
+ ```ruby
68
+ puts 123.duck.class
69
+ #Fixnum
70
+
71
+ puts ["hello","world"].duck.class
72
+ #Array
73
+
74
+ puts '{"hello":"world"}'.duck.class
75
+ #Hash
76
+
77
+ puts "hello: world".duck.class
78
+ #Hash
79
+ ```
65
80
 
66
81
  Happy parsing!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
data/examples/test.rb CHANGED
@@ -1,4 +1,11 @@
1
1
  require_relative "../lib/str2duck"
2
2
 
3
+ puts 123.duck.class
4
+ puts ["hello","world"].duck.class
5
+ puts '{"hello":"world"}'.duck.class
6
+ puts "hello: world".duck.class,"","---"
7
+
8
+
3
9
  Str2Duck::Config.yaml = false
4
- puts Str2Duck::Config.list
10
+ puts Str2Duck::Config.list,"","---"
11
+ puts "hello: world".duck.class
@@ -0,0 +1,28 @@
1
+ module Str2Duck
2
+
3
+ module MPatch
4
+
5
+ module Object
6
+
7
+ def duck(self_obj= self)
8
+ if self_obj.class <= String
9
+ Str2Duck::MPatch::String.duck(self_obj)
10
+ else
11
+ return self_obj
12
+ end
13
+ end
14
+
15
+ alias :to_duck :duck
16
+
17
+ self.instance_methods.each do |symbol|
18
+ module_function symbol
19
+ public symbol
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
28
+ Object.__send__( :include, Str2Duck::MPatch::Object )
@@ -0,0 +1,23 @@
1
+ module Str2Duck
2
+
3
+ module MPatch
4
+
5
+ module String
6
+
7
+ def duck(self_obj= self)
8
+ Str2Duck.parse(self_obj)
9
+ end
10
+ alias :to_duck :duck
11
+
12
+ self.instance_methods.each do |symbol|
13
+ module_function symbol
14
+ public symbol
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+
23
+ String.__send__( :include, Str2Duck::MPatch::String )
data/lib/str2duck.rb CHANGED
@@ -7,4 +7,6 @@ require File.join File.dirname(__FILE__),'str2duck','format'
7
7
  require File.join File.dirname(__FILE__),'str2duck','config'
8
8
 
9
9
  require File.join File.dirname(__FILE__),'str2duck','parser'
10
- require File.join File.dirname(__FILE__),'str2duck','string'
10
+
11
+ require File.join File.dirname(__FILE__),'str2duck','mpatch','string'
12
+ require File.join File.dirname(__FILE__),'str2duck','mpatch','object'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: str2duck
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
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-03-02 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ! ' Parse string into obj '
14
14
  email:
@@ -30,9 +30,10 @@ files:
30
30
  - lib/str2duck.rb
31
31
  - lib/str2duck/config.rb
32
32
  - lib/str2duck/format.rb
33
+ - lib/str2duck/mpatch/object.rb
34
+ - lib/str2duck/mpatch/string.rb
33
35
  - lib/str2duck/parser.rb
34
36
  - lib/str2duck/regexp.rb
35
- - lib/str2duck/string.rb
36
37
  - lib/str2duck/support.rb
37
38
  - str2duck.gemspec
38
39
  homepage: https://github.com/adamluzsi/str2duck
@@ -1,8 +0,0 @@
1
- class String
2
-
3
- def duck
4
- Str2Duck.parse(self)
5
- end
6
- alias :to_duck :duck
7
-
8
- end