spectifly 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Spectifly
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -7,11 +7,17 @@ module Spectifly
7
7
 
8
8
  def to_xsd(builder = nil)
9
9
  builder ||= ::Builder::XmlMarkup.new(:indent => 2)
10
- attributes['type'] = "#{Spectifly::Support.lower_camelize(type)}Type"
11
- attributes['minOccurs'] = '0' unless required? && relationship != 'belongs_to'
10
+ if relationship == 'belongs_to'
11
+ attributes['name'] = "#{name}Id"
12
+ attributes['type'] = "xs:string"
13
+ else
14
+ attributes['name'] = name
15
+ attributes['type'] = "#{Spectifly::Support.lower_camelize(type)}Type"
16
+ attributes['minOccurs'] = '0' unless required?
17
+ end
12
18
  attributes['maxOccurs'] = 'unbounded' if multiple?
13
19
  block = embedded_block
14
- builder.xs :element, { :name => name }.merge(attributes), &block
20
+ builder.xs :element, attributes, &block
15
21
  end
16
22
 
17
23
  def embedded_block
@@ -28,4 +34,4 @@ module Spectifly
28
34
  end
29
35
  end
30
36
  end
31
- end
37
+ end
@@ -24,6 +24,13 @@ module Spectifly
24
24
  end
25
25
  end
26
26
 
27
+ def types
28
+ [
29
+ fields.map(&:type) +
30
+ associations.select { |a| a.relationship != 'belongs_to' }.map(&:type)
31
+ ].flatten.compact.uniq
32
+ end
33
+
27
34
  def build(xml = nil)
28
35
  xml ||= ::Builder::XmlMarkup.new(:indent => 2)
29
36
  xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
@@ -34,10 +41,12 @@ module Spectifly
34
41
  unless utilized_extended_types.empty?
35
42
  xml.xs :include, 'schemaLocation' => "extended.xsd"
36
43
  end
37
- xml.xs :element, :name => Spectifly::Support.camelize(root), :type => root_type
44
+ xml.xs :element,
45
+ :name => Spectifly::Support.camelize(root),
46
+ :type => root_type
38
47
  build_type(xml)
39
48
  end
40
49
  end
41
50
  end
42
51
  end
43
- end
52
+ end
@@ -1,6 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
3
- <xs:include schemaLocation="group.xsd"/>
4
3
  <xs:include schemaLocation="extended.xsd"/>
5
4
  <xs:element name="Individual" type="individualType"/>
6
5
  <xs:complexType name="individualType">
@@ -37,7 +36,7 @@
37
36
  <xs:documentation>Whether or not this individual is pickled</xs:documentation>
38
37
  </xs:annotation>
39
38
  </xs:element>
40
- <xs:element name="Party" type="groupType" minOccurs="0">
39
+ <xs:element name="PartyId" type="xs:string">
41
40
  <xs:annotation>
42
41
  <xs:documentation>Which funtime party this individual happy with is</xs:documentation>
43
42
  </xs:annotation>
@@ -1,6 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
3
- <xs:include schemaLocation="group.xsd"/>
4
3
  <xs:include schemaLocation="extended.xsd"/>
5
4
  <xs:element name="Individual" type="individualType"/>
6
5
  <xs:complexType name="individualType">
@@ -25,7 +24,7 @@
25
24
  <xs:documentation>Whether or not this individual is pickled</xs:documentation>
26
25
  </xs:annotation>
27
26
  </xs:element>
28
- <xs:element name="Party" type="groupType" minOccurs="0">
27
+ <xs:element name="PartyId" type="xs:string">
29
28
  <xs:annotation>
30
29
  <xs:documentation>Which funtime party this individual happy with is</xs:documentation>
31
30
  </xs:annotation>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectifly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-01 00:00:00.000000000 Z
12
+ date: 2013-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -207,12 +207,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
207
  - - ! '>='
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
+ segments:
211
+ - 0
212
+ hash: 2137149722934303799
210
213
  required_rubygems_version: !ruby/object:Gem::Requirement
211
214
  none: false
212
215
  requirements:
213
216
  - - ! '>='
214
217
  - !ruby/object:Gem::Version
215
218
  version: '0'
219
+ segments:
220
+ - 0
221
+ hash: 2137149722934303799
216
222
  requirements: []
217
223
  rubyforge_project:
218
224
  rubygems_version: 1.8.23
@@ -248,4 +254,3 @@ test_files:
248
254
  - spec/spectifly/xsd/field_spec.rb
249
255
  - spec/spectifly/xsd/types_spec.rb
250
256
  - spec/support/path_helper.rb
251
- has_rdoc: