masterplan 0.3.1 → 0.4.0
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/README.rdoc +7 -2
- data/VERSION +1 -1
- data/lib/masterplan.rb +3 -0
- data/masterplan.gemspec +3 -4
- data/spec/masterplan_spec.rb +69 -15
- metadata +17 -17
data/README.rdoc
CHANGED
@@ -150,11 +150,16 @@ Note that for the moment, schemes, i.e. the outermost object, can only be hashes
|
|
150
150
|
|
151
151
|
== Installation
|
152
152
|
|
153
|
-
|
153
|
+
(sudo) gem install masterplan
|
154
|
+
|
155
|
+
Or, install latest version from Github with bundler by adding this to your Gemfile:
|
154
156
|
|
155
157
|
gem 'masterplan', :git => 'git://github.com/traveliq/masterplan.git'
|
156
158
|
|
157
|
-
|
159
|
+
== Dependencies
|
160
|
+
|
161
|
+
You'll need ActiveSupport, but that should be handled automatically.
|
162
|
+
Under Ruby 1.9.x, however, you need the test-unit gem. It works for us with test-unit 1.2.3.
|
158
163
|
|
159
164
|
== Authors
|
160
165
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/masterplan.rb
CHANGED
data/masterplan.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{masterplan}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Martin Tepper"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-09}
|
13
13
|
s.description = %q{Masterplan is a library for comparing Ruby data structures against predefined templates - like XML Schema without the XML. Please see the README on github for more information.}
|
14
14
|
s.email = %q{developer@traveliq.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.homepage = %q{http://github.com/traveliq/masterplan}
|
38
38
|
s.licenses = ["MIT"]
|
39
39
|
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version = %q{1.
|
40
|
+
s.rubygems_version = %q{1.5.0}
|
41
41
|
s.summary = %q{Masterplan is a library for comparing Ruby data structures against predefined templates - like XML Schema without the XML.}
|
42
42
|
s.test_files = [
|
43
43
|
"spec/masterplan_spec.rb",
|
@@ -45,7 +45,6 @@ Gem::Specification.new do |s|
|
|
45
45
|
]
|
46
46
|
|
47
47
|
if s.respond_to? :specification_version then
|
48
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
48
|
s.specification_version = 3
|
50
49
|
|
51
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/spec/masterplan_spec.rb
CHANGED
@@ -10,17 +10,28 @@ describe "Masterplan" do
|
|
10
10
|
{
|
11
11
|
"name" => "Mast",
|
12
12
|
"length" => rule(12.3, :allow_nil => true),
|
13
|
-
"material" => rule("wood", :included_in => ['wood', 'steel', 'human'])
|
13
|
+
"material" => rule("wood", :included_in => ['wood', 'steel', 'human']),
|
14
|
+
"scream" => rule("AAAAAAH", :matches => /[A-Z]/),
|
14
15
|
},
|
15
16
|
{
|
16
17
|
"name" => "Rudder",
|
17
18
|
"length" => nil,
|
18
|
-
"material" => "steel"
|
19
|
+
"material" => "steel",
|
20
|
+
"scream" => "HAAAAAARGH"
|
19
21
|
}
|
20
22
|
]
|
21
23
|
}
|
22
24
|
})
|
23
25
|
end
|
26
|
+
|
27
|
+
def test_value_and_expect(testee, *error_and_descripton)
|
28
|
+
lambda do
|
29
|
+
Masterplan.compare(
|
30
|
+
:scheme => @scheme,
|
31
|
+
:to => testee
|
32
|
+
)
|
33
|
+
end.should raise_error(*error_and_descripton)
|
34
|
+
end
|
24
35
|
|
25
36
|
describe "Testing with #compare" do
|
26
37
|
|
@@ -32,29 +43,72 @@ describe "Masterplan" do
|
|
32
43
|
:parts => [
|
33
44
|
:name => "Thingy",
|
34
45
|
:length => 1.0,
|
35
|
-
:material => "human"
|
46
|
+
:material => "human",
|
47
|
+
:scream => "UUUUUUUUH"
|
36
48
|
]
|
37
49
|
}
|
38
50
|
}
|
39
51
|
).should be_true
|
40
52
|
end
|
53
|
+
|
41
54
|
it "complains if a key is missing" do
|
55
|
+
test_value_and_expect(
|
56
|
+
{ :tank => {} },
|
57
|
+
Masterplan::FailedError, /expected: ship*\n*received: tank/
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "complains if not given a Masterplan::Document" do
|
42
62
|
lambda do
|
43
63
|
Masterplan.compare(
|
44
|
-
:scheme =>
|
45
|
-
:to => {
|
46
|
-
:tank => {}
|
47
|
-
}
|
64
|
+
:scheme => {},
|
65
|
+
:to => {}
|
48
66
|
)
|
49
|
-
end.should raise_error(
|
67
|
+
end.should raise_error(ArgumentError, /scheme needs to be a Masterplan::Document/)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "complains if there are extra keys" do
|
71
|
+
test_value_and_expect(
|
72
|
+
{ :ship => {}, :boat => {} },
|
73
|
+
Masterplan::FailedError, /expected: ship*\n*received: boat,ship/
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "complains if a value is of the wrong class" do
|
78
|
+
test_value_and_expect(
|
79
|
+
{ :ship => [] },
|
80
|
+
Masterplan::FailedError, /value at 'root'=>'ship' \(Array\) is not a Hash/
|
81
|
+
)
|
50
82
|
end
|
51
|
-
|
52
|
-
it "complains if
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
83
|
+
|
84
|
+
it "complains if a value is nil" do
|
85
|
+
test_value_and_expect(
|
86
|
+
{ :ship => {:parts => [{:name => nil, :length => 1.0, :material => "wood", :scream => "BLEEEEERGH"}]} },
|
87
|
+
Masterplan::FailedError, /value at 'root'=>'ship'=>'parts'=>'0'=>'name' \(NilClass\) is not a String/
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "does not complain if a value is nil and the rule allows nil" do
|
92
|
+
Masterplan.compare(
|
93
|
+
:scheme => @scheme,
|
94
|
+
:to => { :ship => {:parts => [{:name => "haha", :length => nil, :material => "wood", :scream => "UUUUAUAUAUAH"}]} }
|
95
|
+
).should == true
|
96
|
+
end
|
97
|
+
|
98
|
+
it "complains if a value does not match the regexp rule" do
|
99
|
+
test_value_and_expect(
|
100
|
+
{ :ship => {:parts => [{:name => "thing", :length => 1.0, :material => "wood", :scream => "omai !"}]} },
|
101
|
+
Masterplan::FailedError, /value at 'root'=>'ship'=>'parts'=>'0'=>'scream' "omai !" \(String\) does not match \/\[A-Z\]\//
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "complains if a value is not included in the rule list" do
|
106
|
+
test_value_and_expect(
|
107
|
+
{ :ship => {:parts => [{:name => "thing", :length => 1.0, :material => "socks", :scream => "GRAGRAGR"}]} },
|
108
|
+
Masterplan::FailedError, /value at 'root'=>'ship'=>'parts'=>'0'=>'material' "socks" \(String\) is not one of \["wood", "steel", "human"\]/
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
58
112
|
it "checks all values of value arrays, but only against the first array value of the scheme"
|
59
113
|
it "checks all array values one-to-one if the compare_each rule is used"
|
60
114
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: masterplan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Martin Tepper
|
@@ -15,10 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-09 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
name: activesupport
|
22
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
24
|
none: false
|
24
25
|
requirements:
|
@@ -30,11 +31,11 @@ dependencies:
|
|
30
31
|
- 3
|
31
32
|
- 5
|
32
33
|
version: 2.3.5
|
33
|
-
requirement: *id001
|
34
34
|
prerelease: false
|
35
35
|
type: :runtime
|
36
|
-
|
36
|
+
requirement: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
38
39
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
@@ -46,11 +47,11 @@ dependencies:
|
|
46
47
|
- 3
|
47
48
|
- 0
|
48
49
|
version: 2.3.0
|
49
|
-
requirement: *id002
|
50
50
|
prerelease: false
|
51
51
|
type: :development
|
52
|
-
|
52
|
+
requirement: *id002
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
54
55
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
56
|
none: false
|
56
57
|
requirements:
|
@@ -62,11 +63,11 @@ dependencies:
|
|
62
63
|
- 0
|
63
64
|
- 0
|
64
65
|
version: 1.0.0
|
65
|
-
requirement: *id003
|
66
66
|
prerelease: false
|
67
67
|
type: :development
|
68
|
-
|
68
|
+
requirement: *id003
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
+
name: jeweler
|
70
71
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
71
72
|
none: false
|
72
73
|
requirements:
|
@@ -78,11 +79,11 @@ dependencies:
|
|
78
79
|
- 5
|
79
80
|
- 2
|
80
81
|
version: 1.5.2
|
81
|
-
requirement: *id004
|
82
82
|
prerelease: false
|
83
83
|
type: :development
|
84
|
-
|
84
|
+
requirement: *id004
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
|
+
name: rcov
|
86
87
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
87
88
|
none: false
|
88
89
|
requirements:
|
@@ -92,10 +93,9 @@ dependencies:
|
|
92
93
|
segments:
|
93
94
|
- 0
|
94
95
|
version: "0"
|
95
|
-
requirement: *id005
|
96
96
|
prerelease: false
|
97
97
|
type: :development
|
98
|
-
|
98
|
+
requirement: *id005
|
99
99
|
description: Masterplan is a library for comparing Ruby data structures against predefined templates - like XML Schema without the XML. Please see the README on github for more information.
|
100
100
|
email: developer@traveliq.net
|
101
101
|
executables: []
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
requirements: []
|
153
153
|
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.
|
155
|
+
rubygems_version: 1.5.0
|
156
156
|
signing_key:
|
157
157
|
specification_version: 3
|
158
158
|
summary: Masterplan is a library for comparing Ruby data structures against predefined templates - like XML Schema without the XML.
|