schematic 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -23,6 +23,14 @@ Then run:
23
23
 
24
24
  Post.to_xsd => (a bunch of xml)
25
25
 
26
+ Validations will automatically add restrictions to the XSD for fields. If a validation has a conditional
27
+ if or unless option it will be skipped. However if you wish to force the inclusion of the validation in
28
+ the XSD you can set: { :xsd => { :include => true } } in the options e.g.
29
+
30
+ class Post < ActiveRecord::Base
31
+ validates :category, :inclusion => { :in => ["foo", "bar"], :xsd => { :include => true } }, :if => lambda { ... }
32
+ end
33
+
26
34
  You can include additional elements by defining a ".xsd_methods" on your class:
27
35
 
28
36
  class Post < ActiveRecord::Base
@@ -1,3 +1,3 @@
1
1
  module Schematic
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
@@ -10,18 +10,22 @@ describe Schematic::Generator::Restrictions::Enumeration do
10
10
  t.string "title"
11
11
  t.string "should_be_skipped"
12
12
  t.string "should_also_be_skipped"
13
+ t.string "and_also_be_skipped"
13
14
  t.boolean "active"
14
15
  t.string "options"
15
16
  t.integer "force_enumeration"
17
+ t.integer "skip_enumeration"
16
18
  end
17
19
 
18
20
  model do
19
21
  validates :title, :inclusion => { :in => ["a", "b", "c"] }
20
22
  validates :should_be_skipped, :inclusion => ["a", "b", "c"], :if => lambda { false }
21
23
  validates :should_also_be_skipped, :inclusion => ["a", "b", "c"], :unless => lambda { false }
24
+ validates :and_also_be_skipped, :inclusion => ["a", "b", "c"], :if => lambda { true}, :unless => lambda { false }
22
25
  validates :active, :inclusion => { :in => [true, false] }
23
26
  validates :options, :inclusion => { :in => lambda { |f| ["some valid attribute"] } }
24
27
  validates :force_enumeration, :inclusion => { :in => [1, 2], :xsd => { :include => true} }, :if => lambda { false }
28
+ validates :skip_enumeration, :inclusion => { :in => [1, 2], :xsd => { :include => false} }, :if => lambda { true }
25
29
  end
26
30
  end
27
31
 
@@ -31,7 +35,14 @@ describe Schematic::Generator::Restrictions::Enumeration do
31
35
  lambda {
32
36
  validate_xml_against_xsd(xml, subject)
33
37
  }.should raise_error
34
- valid_instance = EnumerationModel.new(:title => "a", :should_be_skipped => "a", :should_also_be_skipped => "a", :active => true, :options => "some valid attribute", :force_enumeration => 2)
38
+ valid_instance = EnumerationModel.new(:title => "a",
39
+ :should_be_skipped => "a",
40
+ :should_also_be_skipped => "a",
41
+ :and_also_be_skipped => "a",
42
+ :active => true,
43
+ :options => "some valid attribute",
44
+ :force_enumeration => 2,
45
+ :skip_enumeration => 2)
35
46
  xml = [valid_instance].to_xml
36
47
  lambda {
37
48
  validate_xml_against_xsd(xml, subject)
@@ -68,6 +79,14 @@ describe Schematic::Generator::Restrictions::Enumeration do
68
79
  </xs:simpleContent>
69
80
  </xs:complexType>
70
81
  </xs:element>
82
+ <xs:element name="and-also-be-skipped" minOccurs="0" maxOccurs="1">
83
+ <xs:complexType>
84
+ <xs:simpleContent>
85
+ <xs:restriction base="String">
86
+ </xs:restriction>
87
+ </xs:simpleContent>
88
+ </xs:complexType>
89
+ </xs:element>
71
90
  <xs:element name="active" minOccurs="0" maxOccurs="1">
72
91
  <xs:complexType>
73
92
  <xs:simpleContent>
@@ -94,6 +113,14 @@ describe Schematic::Generator::Restrictions::Enumeration do
94
113
  </xs:simpleContent>
95
114
  </xs:complexType>
96
115
  </xs:element>
116
+ <xs:element name="skip-enumeration" minOccurs="0" maxOccurs="1">
117
+ <xs:complexType>
118
+ <xs:simpleContent>
119
+ <xs:restriction base="Integer">
120
+ </xs:restriction>
121
+ </xs:simpleContent>
122
+ </xs:complexType>
123
+ </xs:element>
97
124
  XML
98
125
  end
99
126
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: schematic
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.7
5
+ version: 0.3.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Case Commons, LLC
@@ -154,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - ">="
156
156
  - !ruby/object:Gem::Version
157
- hash: -1535622649516995802
157
+ hash: 3119055094098631503
158
158
  segments:
159
159
  - 0
160
160
  version: "0"
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
- hash: -1535622649516995802
166
+ hash: 3119055094098631503
167
167
  segments:
168
168
  - 0
169
169
  version: "0"