dm-persevere-adapter 0.60.2 → 0.60.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/lib/dm/associations/relationship.rb +40 -0
- data/lib/dm/model.rb +1 -21
- data/lib/persevere_adapter.rb +1 -0
- metadata +16 -6
data/Rakefile
CHANGED
@@ -12,16 +12,17 @@ begin
|
|
12
12
|
gemspec.homepage = %q{http://github.com/yogo/dm-persevere-adapter}
|
13
13
|
gemspec.authors = ["Ivan R. Judson", "The Yogo Data Management Development Team" ]
|
14
14
|
gemspec.rdoc_options = ["--main", "README.txt"]
|
15
|
-
gemspec.add_dependency(%q<dm-core>, [">= 0.10.
|
15
|
+
gemspec.add_dependency(%q<dm-core>, [">= 0.10.2"])
|
16
16
|
gemspec.add_dependency(%q<extlib>)
|
17
17
|
end
|
18
18
|
|
19
19
|
Jeweler::GemcutterTasks.new
|
20
|
-
FileList['tasks/**/*.rake'].each { |task| import task }
|
21
20
|
rescue LoadError
|
22
21
|
puts "Jeweler not available. Install it with: gem install jeweler"
|
23
22
|
end
|
24
23
|
|
24
|
+
FileList['tasks/**/*.rake'].each { |task| import task }
|
25
|
+
|
25
26
|
ROOT = Pathname(__FILE__).dirname.expand_path
|
26
27
|
JRUBY = RUBY_PLATFORM =~ /java/
|
27
28
|
WINDOWS = Gem.win_platform?
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.60.
|
1
|
+
0.60.3
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module DataMapper
|
2
|
+
module Associations
|
3
|
+
class Relationship
|
4
|
+
|
5
|
+
# Prefix
|
6
|
+
# @example property.prefix
|
7
|
+
# @return [String]
|
8
|
+
# @api public
|
9
|
+
attr_accessor :prefix
|
10
|
+
|
11
|
+
def to_json_schema_hash
|
12
|
+
child = self.child_model
|
13
|
+
parent = self.parent_model
|
14
|
+
relationship_schema = {}
|
15
|
+
|
16
|
+
case self
|
17
|
+
when DataMapper::Associations::OneToMany::Relationship, DataMapper::Associations::ManyToMany::Relationship
|
18
|
+
relationship_schema = { "type" => "array",
|
19
|
+
"lazy" => true,
|
20
|
+
"optional" => true,
|
21
|
+
"items" => {"$ref" => "/Class/#{child.storage_name}"},
|
22
|
+
"minItems" => self.min
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
relationship_schema["maxItems"] = self.max if self.max != Infinity
|
27
|
+
|
28
|
+
when DataMapper::Associations::OneToOne::Relationship
|
29
|
+
relationship_schema = { "type" => { "$ref" => "/Class/#{child.storage_name}" }, "lazy" => true, "optional" => true }
|
30
|
+
when DataMapper::Associations::ManyToOne::Relationship
|
31
|
+
relationship_schema = { "type" => { "$ref" => "/Class/#{parent.storage_name}" }, "lazy" => true, "optional" => true }
|
32
|
+
end
|
33
|
+
|
34
|
+
relationship_schema.merge!("prefix" => @prefix ) unless @prefix.nil?
|
35
|
+
return relationship_schema
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/dm/model.rb
CHANGED
@@ -21,27 +21,7 @@ module DataMapper
|
|
21
21
|
# Handle relationships
|
22
22
|
relationships.each_pair do |nom,relation|
|
23
23
|
next if self.name.downcase == nom
|
24
|
-
|
25
|
-
parent = relation.parent_model
|
26
|
-
|
27
|
-
case relation
|
28
|
-
when DataMapper::Associations::OneToMany::Relationship, DataMapper::Associations::ManyToMany::Relationship
|
29
|
-
schema_hash['properties'][nom] = { "type" => "array",
|
30
|
-
"lazy" => true,
|
31
|
-
"optional" => true,
|
32
|
-
"items" => {"$ref" => "/Class/#{child.storage_name}"},
|
33
|
-
"minItems" => relation.min,
|
34
|
-
}
|
35
|
-
|
36
|
-
schema_hash['properties'][nom]["maxItems"] = relation.max if relation.max != Infinity
|
37
|
-
when DataMapper::Associations::ManyToOne::Relationship, DataMapper::Associations::OneToOne::Relationship
|
38
|
-
if self == relation.child_model
|
39
|
-
ref = "/Class/#{parent.storage_name}"
|
40
|
-
else
|
41
|
-
ref = "/Class/#{child.storage_name}"
|
42
|
-
end
|
43
|
-
schema_hash['properties'][nom] = { "type" => { "$ref" => ref }, "lazy" => true, "optional" => true }
|
44
|
-
end
|
24
|
+
schema_hash['properties'][nom] = relation.to_json_schema_hash
|
45
25
|
end
|
46
26
|
return schema_hash
|
47
27
|
end
|
data/lib/persevere_adapter.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-persevere-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 233
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 60
|
8
|
-
-
|
9
|
-
version: 0.60.
|
9
|
+
- 3
|
10
|
+
version: 0.60.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Ivan R. Judson
|
@@ -15,30 +16,34 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-06-
|
19
|
+
date: 2010-06-15 00:00:00 -06:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
23
|
name: dm-core
|
23
24
|
prerelease: false
|
24
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
27
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 51
|
28
31
|
segments:
|
29
32
|
- 0
|
30
33
|
- 10
|
31
|
-
-
|
32
|
-
version: 0.10.
|
34
|
+
- 2
|
35
|
+
version: 0.10.2
|
33
36
|
type: :runtime
|
34
37
|
version_requirements: *id001
|
35
38
|
- !ruby/object:Gem::Dependency
|
36
39
|
name: extlib
|
37
40
|
prerelease: false
|
38
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
39
43
|
requirements:
|
40
44
|
- - ">="
|
41
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
42
47
|
segments:
|
43
48
|
- 0
|
44
49
|
version: "0"
|
@@ -63,6 +68,7 @@ files:
|
|
63
68
|
- Rakefile
|
64
69
|
- VERSION
|
65
70
|
- lib/dm/associations/many_to_many.rb
|
71
|
+
- lib/dm/associations/relationship.rb
|
66
72
|
- lib/dm/model.rb
|
67
73
|
- lib/dm/property.rb
|
68
74
|
- lib/dm/query.rb
|
@@ -89,23 +95,27 @@ rdoc_options:
|
|
89
95
|
require_paths:
|
90
96
|
- lib
|
91
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
92
99
|
requirements:
|
93
100
|
- - ">="
|
94
101
|
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
95
103
|
segments:
|
96
104
|
- 0
|
97
105
|
version: "0"
|
98
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
99
108
|
requirements:
|
100
109
|
- - ">="
|
101
110
|
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
102
112
|
segments:
|
103
113
|
- 0
|
104
114
|
version: "0"
|
105
115
|
requirements: []
|
106
116
|
|
107
117
|
rubyforge_project:
|
108
|
-
rubygems_version: 1.3.
|
118
|
+
rubygems_version: 1.3.7
|
109
119
|
signing_key:
|
110
120
|
specification_version: 3
|
111
121
|
summary: A DataMapper Adapter for persevere
|