spira 0.0.1.pre → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ module Spira
2
+
3
+ ##
4
+ # Spira::Types is a set of default Spira::Type classes.
5
+ #
6
+ # @see Spira::Type
7
+ # @see Spira::Types::Integer
8
+ # @see Spira::Types::Boolean
9
+ # @see Spira::Types::String
10
+ # @see Spira::Types::Float
11
+ # @see Spira::Types::Any
12
+ module Types
13
+
14
+ # No autoloading here--the associations to XSD types are made by the
15
+ # classes themselves, so we need to explicitly require them or XSD types
16
+ # will show up as not found.
17
+ require 'spira/types/integer'
18
+ require 'spira/types/boolean'
19
+ require 'spira/types/any'
20
+ require 'spira/types/string'
21
+ require 'spira/types/float'
22
+
23
+
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ module Spira::Types
2
+
3
+ ##
4
+ # This class does its best to serialize or unserialize RDF values into Ruby
5
+ # values and vice versa using RDF.rb's built-in helpers for `RDF::Literal`s.
6
+ # Its behavior is defined as 'What `RDF::Literal` does' for a given value.
7
+ #
8
+ # @see Spira::Type
9
+ # @see http://rdf.rubyforge.org/RDF/Literal.html
10
+ class Any
11
+
12
+ include Spira::Type
13
+
14
+ def self.unserialize(value)
15
+ value.object
16
+ end
17
+
18
+ def self.serialize(value)
19
+ RDF::Literal.new(value)
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ module Spira::Types
2
+
3
+ ##
4
+ # A {Spira::Type} for Boolean values. Values will be expressed as booleans
5
+ # and packaged as `XSD.boolean` `RDF::Literal`s.
6
+ #
7
+ # A {Spira::Resource} property can reference this type as
8
+ # `Spira::Types::Boolean`, `Boolean`, or `XSD.boolean`.
9
+ #
10
+ # @see Spira::Type
11
+ # @see http://rdf.rubyforge.org/RDF/Literal.html
12
+ class Boolean
13
+
14
+ include Spira::Type
15
+
16
+ def self.unserialize(value)
17
+ value.object == true
18
+ end
19
+
20
+ def self.serialize(value)
21
+ if value
22
+ RDF::Literal.new(true, :datatype => XSD.boolean)
23
+ else
24
+ RDF::Literal.new(false, :datatype => XSD.boolean)
25
+ end
26
+ end
27
+
28
+ register_alias XSD.boolean
29
+
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ module Spira::Types
2
+
3
+ ##
4
+ # A {Spira::Type} for Float values. Values will be associated with the
5
+ # `XSD.double` type.
6
+ #
7
+ # A {Spira::Resource} property can reference this type as
8
+ # `Spira::Types::Float`, `Float`, `XSD.double`, or `XSD.float`.
9
+ #
10
+ # @see Spira::Type
11
+ # @see http://rdf.rubyforge.org/RDF/Literal.html
12
+ class Float
13
+
14
+ include Spira::Type
15
+
16
+ def self.unserialize(value)
17
+ value.object.to_f
18
+ end
19
+
20
+ def self.serialize(value)
21
+ RDF::Literal.new(value.to_f, :datatype => XSD.double)
22
+ end
23
+
24
+ register_alias XSD.float
25
+ register_alias XSD.double
26
+
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ module Spira::Types
2
+
3
+ ##
4
+ # A {Spira::Type} for integer values. Values will be associated with the
5
+ # `XSD.integer` type.
6
+ #
7
+ # A {Spira::Resource} property can reference this type as
8
+ # `Spira::Types::Integer`, `Integer`, or `XSD.integer`.
9
+ #
10
+ # @see Spira::Type
11
+ # @see http://rdf.rubyforge.org/RDF/Literal.html
12
+ class Integer
13
+
14
+ include Spira::Type
15
+
16
+ def self.unserialize(value)
17
+ value.object
18
+ end
19
+
20
+ def self.serialize(value)
21
+ RDF::Literal.new(value)
22
+ end
23
+
24
+ register_alias XSD.integer
25
+
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Spira::Types
2
+
3
+ ##
4
+ # A {Spira::Type} for string values. Values will be associated with the
5
+ # `XSD.string` type with no language code.
6
+ #
7
+ # A {Spira::Resource} property can reference this type as
8
+ # `Spira::Types::String`, `String`, or `XSD.string`.
9
+ #
10
+ # @see Spira::Type
11
+ # @see http://rdf.rubyforge.org/RDF/Literal.html
12
+ class String
13
+
14
+ include Spira::Type
15
+
16
+ def self.unserialize(value)
17
+ value.object.to_s
18
+ end
19
+
20
+ def self.serialize(value)
21
+ RDF::Literal.new(value.to_s)
22
+ end
23
+
24
+ register_alias XSD.string
25
+
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ module Spira
2
+ module VERSION
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 1
6
+ EXTRA = nil
7
+
8
+ STRING = [MAJOR, MINOR, TINY].join('.')
9
+ STRING << ".#{EXTRA}" if EXTRA
10
+
11
+ ##
12
+ # @return [String]
13
+ def self.to_s() STRING end
14
+
15
+ ##
16
+ # @return [String]
17
+ def self.to_str() STRING end
18
+
19
+ ##
20
+ # @return [Array(Integer, Integer, Integer)]
21
+ def self.to_a() [MAJOR, MINOR, TINY] end
22
+ end
23
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spira
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ prerelease: false
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
8
  - 1
9
- - pre
10
- version: 0.0.1.pre
9
+ version: 0.0.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Ben Lavender
@@ -16,7 +15,7 @@ bindir:
16
15
  - bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-04-17 00:00:00 +02:00
18
+ date: 2010-05-21 00:00:00 +02:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -116,13 +115,20 @@ files:
116
115
  - README
117
116
  - UNLICENSE
118
117
  - VERSION
118
+ - lib/spira/errors.rb
119
119
  - lib/spira/resource/class_methods.rb
120
120
  - lib/spira/resource/dsl.rb
121
121
  - lib/spira/resource/instance_methods.rb
122
122
  - lib/spira/resource/validations.rb
123
123
  - lib/spira/resource.rb
124
124
  - lib/spira/type.rb
125
+ - lib/spira/types/any.rb
125
126
  - lib/spira/types/boolean.rb
127
+ - lib/spira/types/float.rb
128
+ - lib/spira/types/integer.rb
129
+ - lib/spira/types/string.rb
130
+ - lib/spira/types.rb
131
+ - lib/spira/version.rb
126
132
  - lib/spira.rb
127
133
  has_rdoc: false
128
134
  homepage: http://spira.rubyforge.org
@@ -144,13 +150,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
150
  version: 1.8.2
145
151
  required_rubygems_version: !ruby/object:Gem::Requirement
146
152
  requirements:
147
- - - ">"
153
+ - - ">="
148
154
  - !ruby/object:Gem::Version
149
155
  segments:
150
- - 1
151
- - 3
152
- - 1
153
- version: 1.3.1
156
+ - 0
157
+ version: "0"
154
158
  requirements: []
155
159
 
156
160
  rubyforge_project: spira