merb_datamapper 1.1.0.pre → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/merb_datamapper.rb +67 -69
- data/lib/merb_datamapper/version.rb +1 -1
- metadata +46 -21
data/Rakefile
CHANGED
data/lib/merb_datamapper.rb
CHANGED
@@ -1,102 +1,100 @@
|
|
1
|
-
|
1
|
+
require "merb-core"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require "dm-core"
|
4
|
+
require "merb_datamapper/connection"
|
5
5
|
|
6
|
-
|
6
|
+
Merb::Plugins.add_rakefiles "merb_datamapper" / "merbtasks"
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
# conditionally assign things, so as not to override previously set options.
|
9
|
+
# This is most relevent for :use_repository_block, which is used later in this file.
|
10
|
+
unless Merb::Plugins.config[:merb_datamapper].has_key?(:use_repository_block)
|
11
|
+
Merb::Plugins.config[:merb_datamapper][:use_repository_block] = true
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
unless Merb::Plugins.config[:merb_datamapper].has_key?(:session_storage_name)
|
15
|
+
Merb::Plugins.config[:merb_datamapper][:session_storage_name] = 'sessions'
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
unless Merb::Plugins.config[:merb_datamapper].has_key?(:session_repository_name)
|
19
|
+
Merb::Plugins.config[:merb_datamapper][:session_repository_name] = :default
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
module DataMapper
|
23
|
+
module Resource
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
# actionorm compliance
|
26
|
+
alias new_record? new?
|
27
27
|
|
28
|
-
end
|
29
28
|
end
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def self.run
|
35
|
-
Merb.logger.verbose! "Merb::Orms::DataMapper::Connect block."
|
36
|
-
|
37
|
-
# check for the presence of database.yml
|
38
|
-
if File.file?(Merb.dir_for(:config) / "database.yml")
|
39
|
-
# if we have it, connect
|
40
|
-
Merb::Orms::DataMapper.connect
|
41
|
-
else
|
42
|
-
# assume we'll be told at some point
|
43
|
-
Merb.logger.info "No database.yml file found in #{Merb.dir_for(:config)}, assuming database connection(s) established in the environment file in #{Merb.dir_for(:config)}/environments"
|
44
|
-
end
|
31
|
+
class Merb::Orms::DataMapper::Connect < Merb::BootLoader
|
32
|
+
after BeforeAppLoads
|
45
33
|
|
46
|
-
|
47
|
-
|
48
|
-
if Merb::Config.session_store == 'datamapper'
|
49
|
-
Merb.logger.verbose! "Using DataMapper sessions"
|
50
|
-
require 'merb_datamapper/data_mapper_session'
|
51
|
-
end
|
34
|
+
def self.run
|
35
|
+
Merb.logger.verbose! "Merb::Orms::DataMapper::Connect block."
|
52
36
|
|
53
|
-
|
54
|
-
|
37
|
+
# check for the presence of database.yml
|
38
|
+
if File.file?(Merb.dir_for(:config) / "database.yml")
|
39
|
+
# if we have it, connect
|
40
|
+
Merb::Orms::DataMapper.connect
|
41
|
+
else
|
42
|
+
# assume we'll be told at some point
|
43
|
+
Merb.logger.info "No database.yml file found in #{Merb.dir_for(:config)}, assuming database connection(s) established in the environment file in #{Merb.dir_for(:config)}/environments"
|
44
|
+
end
|
55
45
|
|
56
|
-
|
46
|
+
# if we use a datamapper session store, require it.
|
47
|
+
Merb.logger.verbose! "Checking if we need to use DataMapper sessions"
|
48
|
+
if Merb::Config.session_store == 'datamapper'
|
49
|
+
Merb.logger.verbose! "Using DataMapper sessions"
|
50
|
+
require "merb_datamapper/data_mapper_session"
|
57
51
|
end
|
58
|
-
end
|
59
52
|
|
60
|
-
|
61
|
-
|
53
|
+
# take advantage of the fact #id returns the key of the model, unless #id is a property
|
54
|
+
Merb::Router.root_behavior = Merb::Router.root_behavior.identify(DataMapper::Resource => :id)
|
62
55
|
|
63
|
-
|
56
|
+
Merb.logger.verbose! "Merb::Orms::DataMapper::Connect complete"
|
57
|
+
end
|
58
|
+
end
|
64
59
|
|
65
|
-
|
60
|
+
class Merb::Orms::DataMapper::Associations < Merb::BootLoader
|
61
|
+
after LoadClasses
|
66
62
|
|
67
|
-
|
68
|
-
model.relationships.each_value { |r| r.child_key }
|
69
|
-
end
|
63
|
+
def self.run
|
70
64
|
|
71
|
-
|
65
|
+
Merb.logger.verbose! 'Merb::Orms::DataMapper::Associations - defining lazy relationship properties'
|
72
66
|
|
67
|
+
DataMapper::Model.descendants.each do |model|
|
68
|
+
model.relationships.each_value { |r| r.child_key }
|
73
69
|
end
|
70
|
+
|
71
|
+
Merb.logger.verbose! 'Merb::Orms::DataMapper::Associations - complete'
|
72
|
+
|
74
73
|
end
|
74
|
+
end
|
75
75
|
|
76
|
-
|
76
|
+
if Merb::Plugins.config[:merb_datamapper][:use_repository_block]
|
77
77
|
|
78
|
-
|
78
|
+
class Merb::Orms::DataMapper::IdentityMapSupport < Merb::BootLoader
|
79
79
|
|
80
|
-
|
80
|
+
after RackUpApplication
|
81
81
|
|
82
|
-
|
82
|
+
def self.run
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
84
|
+
app = Merb::Config[:app]
|
85
|
+
def app.call(env)
|
86
|
+
DataMapper.repository do |r|
|
87
|
+
Merb.logger.debug "In repository block #{r.name}"
|
88
|
+
super
|
90
89
|
end
|
91
|
-
|
92
90
|
end
|
93
|
-
end
|
94
91
|
|
92
|
+
end
|
95
93
|
end
|
96
94
|
|
97
|
-
generators = File.join(File.dirname(__FILE__), 'generators')
|
98
|
-
Merb.add_generators generators / 'data_mapper_model'
|
99
|
-
Merb.add_generators generators / 'data_mapper_resource_controller'
|
100
|
-
Merb.add_generators generators / 'data_mapper_migration'
|
101
|
-
|
102
95
|
end
|
96
|
+
|
97
|
+
generators = File.join(File.dirname(__FILE__), 'generators')
|
98
|
+
Merb.add_generators generators / 'data_mapper_model'
|
99
|
+
Merb.add_generators generators / 'data_mapper_resource_controller'
|
100
|
+
Merb.add_generators generators / 'data_mapper_migration'
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb_datamapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: true
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- rc1
|
10
|
+
version: 1.1.0.rc1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Jason Toy
|
@@ -9,49 +15,64 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-03-15 00:00:00 +00:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: merb-core
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
25
|
requirements:
|
21
26
|
- - "="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- pre
|
23
33
|
version: 1.1.0.pre
|
24
|
-
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: dm-core
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
40
|
requirements:
|
31
41
|
- - ~>
|
32
42
|
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 10
|
33
46
|
version: "0.10"
|
34
|
-
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
35
49
|
- !ruby/object:Gem::Dependency
|
36
50
|
name: dm-migrations
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
53
|
requirements:
|
41
54
|
- - ~>
|
42
55
|
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
- 10
|
43
59
|
version: "0.10"
|
44
|
-
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
45
62
|
- !ruby/object:Gem::Dependency
|
46
63
|
name: rspec
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
66
|
requirements:
|
51
67
|
- - ">="
|
52
68
|
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 1
|
71
|
+
- 2
|
72
|
+
- 9
|
53
73
|
version: 1.2.9
|
54
|
-
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
55
76
|
description: Merb plugin that provides support for datamapper
|
56
77
|
email: jtoy@rubynow.com
|
57
78
|
executables: []
|
@@ -107,18 +128,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
128
|
requirements:
|
108
129
|
- - ">="
|
109
130
|
- !ruby/object:Gem::Version
|
131
|
+
segments:
|
132
|
+
- 0
|
110
133
|
version: "0"
|
111
|
-
version:
|
112
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
135
|
requirements:
|
114
136
|
- - ">"
|
115
137
|
- !ruby/object:Gem::Version
|
138
|
+
segments:
|
139
|
+
- 1
|
140
|
+
- 3
|
141
|
+
- 1
|
116
142
|
version: 1.3.1
|
117
|
-
version:
|
118
143
|
requirements: []
|
119
144
|
|
120
145
|
rubyforge_project:
|
121
|
-
rubygems_version: 1.3.
|
146
|
+
rubygems_version: 1.3.6
|
122
147
|
signing_key:
|
123
148
|
specification_version: 3
|
124
149
|
summary: Merb plugin that allows you to use datamapper with your merb app
|