cuba-tools 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cce7b5e2cadb366537a2f2ee3f434325d2cff99
4
- data.tar.gz: 744fd4deb1be24eb3e80b315f5c8e42ec0874210
3
+ metadata.gz: b6851d42438fa529615b93252c0cad46c1c572d5
4
+ data.tar.gz: 2a76b364bd7ccb343ac9404788c5aa37b8b322bf
5
5
  SHA512:
6
- metadata.gz: 1a31abad8618284431d5f499f2f63cfa0ea142d6076b4b9e15825841a3900d19f4e98624bf8116c4749e3312309bac9358405c53454c81f10a0d16ecd7f12c1c
7
- data.tar.gz: 9d1c792660a5a0f8758a9d23aebaee2019aa6e90b80a964161f801a0dec141cf75f877e9d530ac8e9d72bc78982cd0a1f468c7f7f9ae894879e37a7c98c1e6de
6
+ metadata.gz: 62d6433bbb4c7d7afc4cc38e39a8753c09d86d2315d3520cca53b9a1e7e445ecd4957b7f1f30a7326bf41c3bbe5b88928549237c46b4e20684ba9549a7d71efb
7
+ data.tar.gz: a746f38ba3eb38fd3279f46d054dcbb9aad5d117d35cf070f123c2311262e1803a71b81d70e1cb072544ecb1f30e32f1caeb2d88d758ae8b8c45012e6e487516
data/cuba-tools.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "cuba-tools"
7
- spec.version = "0.0.6"
7
+ spec.version = "0.0.7"
8
8
  spec.authors = ["cj"]
9
9
  spec.email = ["cjlazell@gmail.com"]
10
10
  spec.description = %q{Contains a group of tools to extend cuba}
@@ -22,26 +22,27 @@ class Object
22
22
  end
23
23
 
24
24
  class DeepOpenStruct < OpenStruct
25
- def initialize(hash=nil)
25
+ def initialize hash = nil
26
26
 
27
27
  @table = {}
28
28
  @hash_table = {}
29
29
 
30
+ hash = [hash] unless hash.is_a? Hash
31
+
30
32
  if hash
31
33
  hash.each do |k,v|
32
34
 
33
- if v.is_a?(Array)
34
- other = Array.new()
35
+ if v.is_a? Array
36
+ @table[k.to_sym] ||= []
37
+
35
38
  v.each { | entry |
36
- other.push(self.class.new(entry))
39
+ @table[k.to_sym] << entry
37
40
  }
38
- v = other
41
+ else
42
+ @table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
43
+ @hash_table[k.to_sym] = v
44
+ new_ostruct_member(k)
39
45
  end
40
-
41
- @table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
42
- @hash_table[k.to_sym] = v
43
- new_ostruct_member(k)
44
-
45
46
  end
46
47
  end
47
48
  end
@@ -0,0 +1,24 @@
1
+ require_relative '../cutest_helper'
2
+ require 'cuba/tools/inflectors'
3
+
4
+ setup do
5
+ {
6
+ "widget_event" => "submit_note",
7
+ "widget_name" => "claim_note",
8
+ "claim_id" => "11242",
9
+ "_method" => "post",
10
+ "_csrf" => "AO6VtRx4gTbVvyppffF7ZF6P/tFG4aI+VnDcXXI7Ps0=",
11
+ "claim_note" => {
12
+ "claim_id" => "11242",
13
+ "comment" => "",
14
+ "permission" => "public",
15
+ "recipient_ids" => ["2416"]
16
+ }
17
+ }
18
+ end
19
+
20
+ scope "inflectors" do
21
+ test "#to_deep_ostruct" do |params|
22
+ assert params.to_deep_ostruct.claim_note.recipient_ids.is_a? Array
23
+ end
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuba-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-23 00:00:00.000000000 Z
11
+ date: 2014-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cuba
@@ -180,6 +180,7 @@ files:
180
180
  - test/dummy/app/widgets/some_widget/_some_partial.slim
181
181
  - test/dummy/app/widgets/some_widget/display.slim
182
182
  - test/dummy/app/widgets/some_widget/some_state.slim
183
+ - test/tools/inflectors_test.rb
183
184
  - test/tools/widget_test.rb
184
185
  homepage: ''
185
186
  licenses:
@@ -212,5 +213,5 @@ test_files:
212
213
  - test/dummy/app/widgets/some_widget/_some_partial.slim
213
214
  - test/dummy/app/widgets/some_widget/display.slim
214
215
  - test/dummy/app/widgets/some_widget/some_state.slim
216
+ - test/tools/inflectors_test.rb
215
217
  - test/tools/widget_test.rb
216
- has_rdoc: