rdf-xsd 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/rdf/xsd/any_uri.rb +55 -0
  3. data/lib/rdf/xsd/date.rb +35 -5
  4. metadata +97 -162
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.7
1
+ 0.3.8
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+ require 'base64'
3
+
4
+ module RDF; class Literal
5
+ ##
6
+ # More specific sub-types of double
7
+ # Derived types
8
+ # @see http://www.w3.org/TR/xpath-functions/#datatypes
9
+
10
+ ##
11
+ # anyURI represents a Uniform Resource Identifier Reference (URI).
12
+ # An anyURI value can be absolute or relative, and may have an
13
+ # optional fragment identifier (i.e., it may be a URI Reference).
14
+ # This type should be used to specify the intention that the value fulfills
15
+ # the role of a URI as defined by [RFC 2396], as amended by [RFC 2732].
16
+ #
17
+ # @see http://www.w3.org/TR/xmlschema-2/#anyURI
18
+ # @see http://www.ietf.org/rfc/rfc2396.txt
19
+ # @see http://www.ietf.org/rfc/rfc2732.txt
20
+ class AnyURI < RDF::Literal
21
+ DATATYPE = XSD.anyURI
22
+
23
+ ##
24
+ # @param [String, Object] value
25
+ # If given a string, it will decode it as an object value.
26
+ # Otherwise, it will take the value as the object and encode to retrieve a value
27
+ # @option options [String] :lexical (nil)
28
+ def initialize(value, options = {})
29
+ super
30
+ @object = RDF::URI(value)
31
+ canonicalize! unless value.is_a?(String)
32
+ end
33
+
34
+ ##
35
+ # Converts this literal into its canonical lexical representation.
36
+ #
37
+ # @return [RDF::Literal] `self`
38
+ def canonicalize!
39
+ @string = @object.canonicalize
40
+ self
41
+ end
42
+
43
+ ##
44
+ # Returns `true` if the value adheres to the defined grammar of the
45
+ # datatype.
46
+ #
47
+ # Note: depends on implementation of Base64.strict_decode64, which may not
48
+ # be implemented for Ruby 1.8.x.
49
+ #
50
+ # @return [Boolean]
51
+ def valid?
52
+ @object.validate! rescue false
53
+ end
54
+ end
55
+ end; end #RDF::Literal
data/lib/rdf/xsd/date.rb CHANGED
@@ -11,8 +11,14 @@ module RDF; class Literal
11
11
  # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gYearMonth
12
12
  class YearMonth < RDF::Literal::Date
13
13
  DATATYPE = XSD.gYearMonth
14
- GRAMMAR = %r(\A-?\d{4,}-\d{2}((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
14
+ GRAMMAR = %r(\A(-?\d{4,}-\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
15
15
  FORMAT = '%Y-%m%Z'.freeze
16
+
17
+ def initialize(value, options = {})
18
+ @string = options.fetch(:lexical, value.to_s)
19
+ object = GRAMMAR.match(value.to_s) && ::Date.parse("#{$1}-01#{$2}")
20
+ super(object, options)
21
+ end
16
22
  end
17
23
 
18
24
  ##
@@ -23,8 +29,14 @@ module RDF; class Literal
23
29
  # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gYear
24
30
  class Year < RDF::Literal::Date
25
31
  DATATYPE = XSD.gYear
26
- GRAMMAR = %r(\A-?\d{4,}(?:(?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
32
+ GRAMMAR = %r(\A(-?\d{4,})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
27
33
  FORMAT = '%Y%Z'.freeze
34
+
35
+ def initialize(value, options = {})
36
+ @string = options.fetch(:lexical, value.to_s)
37
+ object = GRAMMAR.match(value.to_s) && ::Date.parse("#{$1}-01-01#{$2}")
38
+ super(object, options)
39
+ end
28
40
  end
29
41
 
30
42
  ##
@@ -35,8 +47,14 @@ module RDF; class Literal
35
47
  # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gMonthDay
36
48
  class MonthDay < RDF::Literal::Date
37
49
  DATATYPE = XSD.gMonthDay
38
- GRAMMAR = %r(\A\d{2}-\d{2}(?:(?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
50
+ GRAMMAR = %r(\A(\d{2}-\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
39
51
  FORMAT = '%m-%d%Z'.freeze
52
+
53
+ def initialize(value, options = {})
54
+ @string = options.fetch(:lexical, value.to_s)
55
+ object = GRAMMAR.match(value.to_s) && ::Date.parse("0000-#{$1}#{$2}")
56
+ super(object, options)
57
+ end
40
58
  end
41
59
 
42
60
  ##
@@ -47,8 +65,14 @@ module RDF; class Literal
47
65
  # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gDay
48
66
  class Day < RDF::Literal::Date
49
67
  DATATYPE = XSD.gDay
50
- GRAMMAR = %r(\A\d{2}(?:(?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
68
+ GRAMMAR = %r(\A(\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
51
69
  FORMAT = '%d%Z'.freeze
70
+
71
+ def initialize(value, options = {})
72
+ @string = options.fetch(:lexical, value.to_s)
73
+ object = GRAMMAR.match(value.to_s) && ::Date.parse("0000-01-#{$1}#{$2}")
74
+ super(object, options)
75
+ end
52
76
  end
53
77
 
54
78
  ##
@@ -58,7 +82,13 @@ module RDF; class Literal
58
82
  # @see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#gMonth
59
83
  class Month < RDF::Literal::Date
60
84
  DATATYPE = XSD.gMonth
61
- GRAMMAR = %r(\A\d{2}(?:(?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
85
+ GRAMMAR = %r(\A(\d{2})((?:[\+\-]\d{2}:\d{2})|UTC|Z)?\Z).freeze
62
86
  FORMAT = '%m%Z'.freeze
87
+
88
+ def initialize(value, options = {})
89
+ @string = options.fetch(:lexical, value.to_s)
90
+ object = GRAMMAR.match(value.to_s) && ::Date.parse("0000-#{$1}-01#{$2}")
91
+ super(object, options)
92
+ end
63
93
  end
64
94
  end; end #RDF::Literal
metadata CHANGED
@@ -1,178 +1,125 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rdf-xsd
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.8
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 7
10
- version: 0.3.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Gregg
14
9
  - Kellogg
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-05-19 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rdf
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
13
+ date: 2012-08-27 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 0.3.4
25
21
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 27
30
- segments:
31
- - 0
32
- - 3
33
- - 4
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
34
26
  version: 0.3.4
35
- type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: nokogiri
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
27
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 1
48
- - 5
49
- - 0
50
- version: 1.5.0
51
- type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: backports
28
+ name: rdf
55
29
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
65
30
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: equivalent-xml
69
- prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
31
+ - !ruby/object:Gem::Dependency
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: 3.0.0
37
+ none: false
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: 3.0.0
71
43
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 7
76
- segments:
77
- - 0
78
- - 2
79
- - 8
80
- version: 0.2.8
81
- type: :development
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
44
  name: active_support
85
45
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 7
92
- segments:
93
- - 3
94
- - 0
95
- - 0
96
- version: 3.0.0
97
46
  type: :development
98
- version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
100
- name: i18n
101
- prerelease: false
102
- requirement: &id006 !ruby/object:Gem::Requirement
47
+ - !ruby/object:Gem::Dependency
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: 0.6.0
103
53
  none: false
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: 7
108
- segments:
109
- - 0
110
- - 6
111
- - 0
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
112
58
  version: 0.6.0
113
- type: :development
114
- version_requirements: *id006
115
- - !ruby/object:Gem::Dependency
116
- name: rspec
59
+ none: false
60
+ name: i18n
117
61
  prerelease: false
118
- requirement: &id007 !ruby/object:Gem::Requirement
62
+ type: :development
63
+ - !ruby/object:Gem::Dependency
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.5.0
119
69
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 27
124
- segments:
125
- - 2
126
- - 5
127
- - 0
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
128
74
  version: 2.5.0
129
- type: :development
130
- version_requirements: *id007
131
- - !ruby/object:Gem::Dependency
132
- name: rdf-spec
75
+ none: false
76
+ name: rspec
133
77
  prerelease: false
134
- requirement: &id008 !ruby/object:Gem::Requirement
78
+ type: :development
79
+ - !ruby/object:Gem::Dependency
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: 0.3.2
135
85
  none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- hash: 23
140
- segments:
141
- - 0
142
- - 3
143
- - 2
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
144
90
  version: 0.3.2
145
- type: :development
146
- version_requirements: *id008
147
- - !ruby/object:Gem::Dependency
148
- name: yard
91
+ none: false
92
+ name: rdf-spec
149
93
  prerelease: false
150
- requirement: &id009 !ruby/object:Gem::Requirement
94
+ type: :development
95
+ - !ruby/object:Gem::Dependency
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: 0.6.0
151
101
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- hash: 7
156
- segments:
157
- - 0
158
- - 6
159
- - 0
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
160
106
  version: 0.6.0
107
+ none: false
108
+ name: yard
109
+ prerelease: false
161
110
  type: :development
162
- version_requirements: *id009
163
111
  description: Adds RDF::Literal subclasses for extended XSD datatypes.
164
112
  email: public-rdf-ruby@w3.org
165
113
  executables: []
166
-
167
114
  extensions: []
168
-
169
115
  extra_rdoc_files: []
170
-
171
- files:
116
+ files:
172
117
  - AUTHORS
173
118
  - README.markdown
174
119
  - UNLICENSE
175
120
  - VERSION
121
+ - lib/rdf/xsd.rb
122
+ - lib/rdf/xsd/any_uri.rb
176
123
  - lib/rdf/xsd/binary.rb
177
124
  - lib/rdf/xsd/date.rb
178
125
  - lib/rdf/xsd/double.rb
@@ -181,42 +128,30 @@ files:
181
128
  - lib/rdf/xsd/integer.rb
182
129
  - lib/rdf/xsd/version.rb
183
130
  - lib/rdf/xsd/xml.rb
184
- - lib/rdf/xsd.rb
185
131
  homepage: http://github.com/ruby-rdf/rdf-xsd
186
- licenses:
132
+ licenses:
187
133
  - Public Domain
188
134
  post_install_message:
189
135
  rdoc_options: []
190
-
191
- require_paths:
136
+ require_paths:
192
137
  - lib
193
- required_ruby_version: !ruby/object:Gem::Requirement
194
- none: false
195
- requirements:
196
- - - ">="
197
- - !ruby/object:Gem::Version
198
- hash: 53
199
- segments:
200
- - 1
201
- - 8
202
- - 1
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
203
142
  version: 1.8.1
204
- required_rubygems_version: !ruby/object:Gem::Requirement
205
143
  none: false
206
- requirements:
207
- - - ">="
208
- - !ruby/object:Gem::Version
209
- hash: 3
210
- segments:
211
- - 0
212
- version: "0"
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ none: false
213
150
  requirements: []
214
-
215
151
  rubyforge_project: rdf-xsd
216
- rubygems_version: 1.8.17
152
+ rubygems_version: 1.8.24
217
153
  signing_key:
218
154
  specification_version: 3
219
155
  summary: Extended XSD Datatypes for RDF.rb.
220
156
  test_files: []
221
-
222
157
  has_rdoc: false