winch 0.0.2 → 0.0.3
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.
- data/Manifest.txt +2 -2
- data/lib/winch/base.rb +22 -14
- data/lib/winch.rb +2 -3
- metadata +3 -3
data/Manifest.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
History.txt
|
2
2
|
Manifest.txt
|
3
3
|
PostInstall.txt
|
4
|
-
README.rdoc
|
5
4
|
Rakefile
|
5
|
+
README.rdoc
|
6
6
|
lib/active_resource_boot/base.rb
|
7
7
|
lib/winch/base.rb
|
8
8
|
lib/winch.rb
|
@@ -11,4 +11,4 @@ script/destroy
|
|
11
11
|
script/generate
|
12
12
|
spec/spec.opts
|
13
13
|
spec/spec_helper.rb
|
14
|
-
spec/winch_spec.rb
|
14
|
+
spec/winch_spec.rb
|
data/lib/winch/base.rb
CHANGED
@@ -2,7 +2,7 @@ module Winch::Base
|
|
2
2
|
module ClassMethods
|
3
3
|
def must_have(name, options={})
|
4
4
|
#Either :default, or :faux can be anything including false and '', just not nil
|
5
|
-
raise "%s can have either a default or a faux value, but not both." % name unless options.values_at(:default, :faux).
|
5
|
+
raise "%s can have either a default or a faux value, but not both." % name unless options.values_at(:default, :faux).select { |v| !v.nil? }.length == 1
|
6
6
|
|
7
7
|
self.must_haves = (self.must_haves || []).push(options.merge(:name => name))
|
8
8
|
end
|
@@ -23,20 +23,28 @@ module Winch::Base
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
def preform_type_check
|
28
|
-
@broken_attributes = (@broken_attributes || []) + attributes.keys.collect do |name|
|
29
|
-
if attributes[name].kind_of?(ActiveResource::Base) && !attributes[name].well_typed?
|
30
|
-
attributes[name].broken_attributes.collect { |a| "%s.%s" % [name, a] }
|
31
|
-
elsif attributes[name].kind_of?(Array)
|
32
|
-
attributes[name].to_enum(:each_with_index).collect do |node, index|
|
33
|
-
node.broken_attributes.collect { |a| "%s[%s].%s" % [name, index, a] } unless node.well_typed?
|
34
|
-
end
|
35
|
-
else
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
end.flatten.compact
|
39
26
|
|
27
|
+
def find_broken_in_active_resource(name, node)
|
28
|
+
@broken_attributes += node.broken_attributes.collect { |a| "%s.%s" % [name, a] } unless node.well_typed?
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_broken_in_collection(name, node)
|
32
|
+
node.each_with_index do |child_node, index|
|
33
|
+
find_broken_in_node("%s[%s]" % [name, index], child_node)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def find_broken_in_node(name, node)
|
38
|
+
if node.kind_of?(ActiveResource::Base)
|
39
|
+
find_broken_in_active_resource(name, node)
|
40
|
+
elsif node.kind_of?(Array)
|
41
|
+
find_broken_in_collection(name, node)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def preform_type_check
|
46
|
+
@broken_attributes ||= []
|
47
|
+
attributes.keys.each { |name| find_broken_in_node(name, attributes[name]) }
|
40
48
|
@well_typed = @broken_attributes.blank?
|
41
49
|
end
|
42
50
|
end
|
data/lib/winch.rb
CHANGED
@@ -5,9 +5,8 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
5
5
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
6
6
|
|
7
7
|
module Winch
|
8
|
-
VERSION = '0.0.
|
9
|
-
|
10
|
-
autoload :Base, 'winch/base'
|
8
|
+
VERSION = '0.0.3' unless defined?(Winch::VERSION)
|
11
9
|
end
|
12
10
|
|
11
|
+
require 'winch/base'
|
13
12
|
require 'active_resource_boot/base'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: winch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vanson Samuel
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-16 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -47,8 +47,8 @@ files:
|
|
47
47
|
- History.txt
|
48
48
|
- Manifest.txt
|
49
49
|
- PostInstall.txt
|
50
|
-
- README.rdoc
|
51
50
|
- Rakefile
|
51
|
+
- README.rdoc
|
52
52
|
- lib/active_resource_boot/base.rb
|
53
53
|
- lib/winch/base.rb
|
54
54
|
- lib/winch.rb
|