schematic 0.5.6 → 0.5.7
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
CHANGED
@@ -43,6 +43,14 @@ You can include or exclude additional elements:
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
You can also change the name of the root tag:
|
47
|
+
|
48
|
+
class Post < ActiveRecord::Base
|
49
|
+
schematic do
|
50
|
+
root "blog-post"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
46
54
|
If you want to programatically include or exclude elements use:
|
47
55
|
|
48
56
|
Post#schematic_sandbox.added_elements and Post#schematic_sandbox.ignored_elements
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Schematic
|
2
2
|
module Generator
|
3
3
|
class Names
|
4
|
+
attr_accessor :root
|
4
5
|
|
5
6
|
def initialize(klass)
|
6
7
|
@klass = klass
|
@@ -11,11 +12,11 @@ module Schematic
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def element
|
14
|
-
|
15
|
+
element_name
|
15
16
|
end
|
16
17
|
|
17
18
|
def element_collection
|
18
|
-
|
19
|
+
element_name.pluralize
|
19
20
|
end
|
20
21
|
|
21
22
|
def collection_type
|
@@ -26,6 +27,11 @@ module Schematic
|
|
26
27
|
"#{element_collection}-attributes"
|
27
28
|
end
|
28
29
|
|
30
|
+
private
|
31
|
+
|
32
|
+
def element_name
|
33
|
+
(@root || type.underscore).dasherize
|
34
|
+
end
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
data/lib/schematic/version.rb
CHANGED
@@ -77,4 +77,15 @@ describe Schematic::Generator::Sandbox do
|
|
77
77
|
subject.required_elements.should include(:bar)
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
describe "setting the root" do
|
82
|
+
it "should change the root element name" do
|
83
|
+
subject.run do
|
84
|
+
root "my_new_root"
|
85
|
+
end
|
86
|
+
|
87
|
+
subject.xsd_generator.names.element.should == "my-new-root"
|
88
|
+
subject.xsd_generator.names.element_collection.should == "my-new-roots"
|
89
|
+
end
|
90
|
+
end
|
80
91
|
end
|
@@ -650,6 +650,26 @@ describe Schematic::Serializers::Xsd do
|
|
650
650
|
|
651
651
|
end
|
652
652
|
|
653
|
+
context "a model that specifies a different root element" do
|
654
|
+
with_model :ModelWithDifferentRoot do
|
655
|
+
model do
|
656
|
+
schematic do
|
657
|
+
root "my_root"
|
658
|
+
end
|
659
|
+
end
|
660
|
+
end
|
661
|
+
|
662
|
+
subject { ModelWithDifferentRoot.to_xsd }
|
663
|
+
|
664
|
+
it "should use the new root tag name" do
|
665
|
+
subject.should_not include %{"model-with-different-root"}
|
666
|
+
subject.should_not include %{"model-with-different-roots"}
|
667
|
+
subject.should include %{"my-root"}
|
668
|
+
subject.should include %{"my-roots"}
|
669
|
+
validate_xsd(subject)
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
653
673
|
end
|
654
674
|
|
655
675
|
describe "#nested_attribute_name" do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: schematic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Case Commons, LLC
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-14 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -156,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
hash:
|
159
|
+
hash: 697916379530530678
|
160
160
|
segments:
|
161
161
|
- 0
|
162
162
|
version: "0"
|
@@ -165,14 +165,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
requirements:
|
166
166
|
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
hash:
|
168
|
+
hash: 697916379530530678
|
169
169
|
segments:
|
170
170
|
- 0
|
171
171
|
version: "0"
|
172
172
|
requirements: []
|
173
173
|
|
174
174
|
rubyforge_project: schematic
|
175
|
-
rubygems_version: 1.8.
|
175
|
+
rubygems_version: 1.8.8
|
176
176
|
signing_key:
|
177
177
|
specification_version: 3
|
178
178
|
summary: Automatic XSD generation from ActiveRecord models
|