core_extend 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/core_extend/hash.rb +11 -0
- data/lib/core_extend/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: cdb6632c532b262ea6976650cc341af53e79bcbd
|
4
|
+
data.tar.gz: 9c6cfa8db19971d88157eaff985563bccbec0af9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96db84e0dbb7b155c709c38e1e84fc13a90d2650c561e0d5b54199d29b3316b1a16de9b5abdd3104c4633ad31f21138ca7968b10e1fa7e1a1b7c91eadfd87af7
|
7
|
+
data.tar.gz: 69d5b80723482b0b444b9f634584a9933ed749dc7d4460d498069482cdeba018592d9180cb0efb72047270f6262dd163e5b5838dbf9a6b026d14aa07cf28f5cf
|
data/README.md
CHANGED
@@ -87,7 +87,12 @@ puts h.to_yaml
|
|
87
87
|
#=>:appName: 哈哈
|
88
88
|
#=>:package: com.xxx.yyy
|
89
89
|
```
|
90
|
-
|
90
|
+
###kv_join
|
91
|
+
```ruby
|
92
|
+
h = {:order => {"name" => "柳溪测试。。。", "phone" => "15101043867", "shipping_province" => "山东省", "shipping_city" => "枣庄市", "shipping_district" => "峄城区", "shipping_address" => "afsadfsd", "shipping_charge" => 9, "delivery_vendor" => "圆通", "pay_type" => "0", "comment" => "", "line_items_attributes" => {7174875524045 => {"product_id" => "69ec4fcb3450ebd81be117f1bd2df0f4", "product_prop_id" => "76b1b27af67021fe71001c9630056c7b", "quantity" => 1, "sale_price" => "169.0"}}}, :api_key => "dd432da4", :device_id => "20160602175425344_common"}
|
93
|
+
h.kv_join('=)
|
94
|
+
#=>name=柳溪测试。。。phone=15101043867shipping_province=山东省shipping_city=枣庄市shipping_district=峄城区shipping_address=afsadfsdshipping_charge=9delivery_vendor=圆通pay_type=0comment=product_id=69ec4fcb3450ebd81be117f1bd2df0f4product_prop_id=76b1b27af67021fe71001c9630056c7bquantity=1sale_price=169.0api_key=dd432da4device_id=20160602175425344_common
|
95
|
+
```
|
91
96
|
|
92
97
|
## Development
|
93
98
|
|
data/lib/core_extend/hash.rb
CHANGED
@@ -8,4 +8,15 @@ class Hash
|
|
8
8
|
# end
|
9
9
|
# end
|
10
10
|
# end
|
11
|
+
|
12
|
+
def kv_join(s)
|
13
|
+
self.map do |k, v|
|
14
|
+
if v.is_a?(Hash)
|
15
|
+
# When upload a file, make tempfile and other params out of hash.
|
16
|
+
v.key?('tempfile') ? "#{k}=#{v['filename']}" : v.kv_join(s)
|
17
|
+
else
|
18
|
+
"#{k}#{s}#{v}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
11
22
|
end
|
data/lib/core_extend/version.rb
CHANGED