whoopee-cushion 1.0.0 → 1.0.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +20 -28
- data/lib/whoopee_cushion/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0ad2fa7eab93bd1c26e8da9052519db870d3e4
|
4
|
+
data.tar.gz: 1f023f5709c3fb97dea08bbe5d2dfbc67200e91a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f42fccf1155a87cde3ce979dc8d32c9a731b874eb01b786cc0457efa4a20fb72a5b4789be48241c710d176eb75176d6962ab864089028380561aa38715d58c0
|
7
|
+
data.tar.gz: 4e57ca1ca97900f00879f7fb66c791dfd63e0be8030ba0bed1ceadfca58e5593cbc458454fd55af0077e124f9bf00b3a3ce9eb66832855419cefcc7ccbf2ce6f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -18,57 +18,49 @@ because it uses Ruby's faster Struct objects under the hood.
|
|
18
18
|
Setup
|
19
19
|
=====
|
20
20
|
|
21
|
-
`
|
22
|
-
gem install whoopee-cushion
|
23
|
-
`
|
21
|
+
`gem install whoopee-cushion`
|
24
22
|
|
25
23
|
or
|
26
24
|
|
27
|
-
`
|
28
|
-
gem "whoopee-cushion"
|
29
|
-
`
|
25
|
+
`gem "whoopee-cushion"`
|
30
26
|
|
31
27
|
in your Gemfile.
|
32
28
|
|
33
29
|
In your Ruby code:
|
34
30
|
|
35
|
-
`
|
36
|
-
require 'whoopee_cushion'
|
37
|
-
`
|
31
|
+
`require 'whoopee_cushion'`
|
38
32
|
|
39
33
|
then
|
40
34
|
|
41
|
-
`
|
42
|
-
hash = {:a => 1, :CamelCase => 2, :c => 3, :d => { :e => 4, :f => [1,2,3,4,5]}}
|
35
|
+
`hash = {:a => 1, :CamelCase => 2, :c => 3, :d => { :e => 4, :f => [1,2,3,4,5]}}`
|
43
36
|
|
44
|
-
obj = WhoopeeCushion::Inflate.from_hash(hash)
|
37
|
+
`obj = WhoopeeCushion::Inflate.from_hash(hash)`
|
45
38
|
|
46
|
-
puts obj.a
|
47
|
-
|
48
|
-
puts obj.
|
49
|
-
|
39
|
+
`puts obj.a`
|
40
|
+
|
41
|
+
`puts obj.camel_case`
|
42
|
+
|
43
|
+
`puts obj.d.f.first`
|
50
44
|
|
51
45
|
You can also go straight from JSON, or turn off the automatic camel case conversion:
|
52
46
|
|
53
|
-
`
|
54
|
-
json = '{"CamelCase": "no", "json": "yes"}'
|
47
|
+
`json = '{"CamelCase": "no", "json": "yes"}'`
|
55
48
|
|
56
|
-
obj = WhoopeeCushion::Inflate.from_json(json, :convert_keys => false)
|
49
|
+
`obj = WhoopeeCushion::Inflate.from_json(json, :convert_keys => false)`
|
57
50
|
|
58
|
-
puts obj.CamelCase
|
59
|
-
`
|
51
|
+
`puts obj.CamelCase`
|
60
52
|
|
61
53
|
If you want to carry out your own string conversion, use a lambda:
|
62
54
|
|
63
|
-
`
|
64
|
-
|
55
|
+
`hash = {:a => 1, :CamelCase => 2, :c => 3, :d => { :e => 4, :f => [1,2,3,4,5]}}`
|
56
|
+
|
57
|
+
`obj = WhoopeeCushion::Inflate.from_hash(hash, :convert_keys => lambda {|s| '#{s}_foo'})`
|
58
|
+
|
59
|
+
`puts obj.a_foo`
|
65
60
|
|
66
|
-
obj
|
61
|
+
`puts obj.CamelCase_foo`
|
67
62
|
|
68
|
-
puts obj.
|
69
|
-
puts obj.CamelCase_foo
|
70
|
-
puts obj.d_foo.f_foo.first
|
71
|
-
`
|
63
|
+
`puts obj.d_foo.f_foo.first`
|
72
64
|
|
73
65
|
Performance
|
74
66
|
===========
|