merb_datamapper 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,16 +8,20 @@ PROJECT_URL = "http://merbivore.com"
8
8
  PROJECT_SUMMARY = "DataMapper plugin providing DataMapper support for Merb"
9
9
  PROJECT_DESCRIPTION = PROJECT_SUMMARY
10
10
 
11
- GEM_AUTHOR = "Jason Toy"
12
- GEM_EMAIL = "jtoy@rubynow.com"
11
+ GEM_AUTHOR = "Jason Toy"
12
+ GEM_EMAIL = "jtoy@rubynow.com"
13
13
 
14
- GEM_NAME = "merb_datamapper"
15
- PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
16
- GEM_VERSION = Merb::VERSION + PKG_BUILD
14
+ GEM_NAME = "merb_datamapper"
15
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
16
+ GEM_VERSION = Merb::VERSION + PKG_BUILD
17
17
 
18
- RELEASE_NAME = "REL #{GEM_VERSION}"
18
+ RELEASE_NAME = "REL #{GEM_VERSION}"
19
19
 
20
- GEM_DEPENDENCIES = [["dm-core", ">=0.9.5"], ["dm-migrations", ">=0.9.5"], ["merb-core", "~> #{GEM_VERSION}"]]
20
+ GEM_DEPENDENCIES = [
21
+ ["dm-core", "~> #{Merb::DM_VERSION}"],
22
+ ["dm-migrations", "~> #{Merb::DM_VERSION}"],
23
+ ["merb-core", "~> #{GEM_VERSION}"]
24
+ ]
21
25
 
22
26
  require "extlib/tasks/release"
23
27
 
@@ -7,7 +7,9 @@ class Merb::Generators::ModelGenerator
7
7
  end
8
8
 
9
9
  def after_generation
10
- STDOUT << message("Don't forget to define the model schema in your #{ Extlib::Inflection.camelize(file_name) } class")
10
+ if orm == :datamapper
11
+ STDOUT << message("Don't forget to define the model schema in your #{ Extlib::Inflection.camelize(file_name) } class")
12
+ end
11
13
  end
12
14
 
13
15
  end
@@ -14,8 +14,7 @@ end
14
14
  Merb::Generators::ResourceControllerGenerator.template :controller_datamapper, :orm => :datamapper do |t|
15
15
  t.source = File.join(File.dirname(__FILE__), "templates/resource_controller.rb")
16
16
  t.destination = File.join("app/controllers", base_path, "#{file_name}.rb")
17
-
18
- self.add_resource_route(self.plural_model)
17
+ self.add_resource_route(self.plural_model) unless skip_route_definition?
19
18
  end
20
19
 
21
20
  [:index, :show, :edit, :new].each do |view|
@@ -39,7 +39,7 @@ class <%= class_name %> < Application
39
39
  def update(id, <%= singular_model %>)
40
40
  @<%= singular_model %> = <%= model_class_name %>.get(id)
41
41
  raise NotFound unless @<%= singular_model %>
42
- if @<%= singular_model %>.update_attributes(<%= singular_model %>)
42
+ if @<%= singular_model %>.update(<%= singular_model %>)
43
43
  redirect resource(@<%= singular_model %>)
44
44
  else
45
45
  display @<%= singular_model %>, :edit
@@ -1,13 +1,16 @@
1
1
  require 'merb-core/dispatch/session'
2
- require "dm-core"
2
+
3
3
  module Merb
4
4
  class DataMapperSessionStore
5
5
  include ::DataMapper::Resource
6
6
 
7
- table_name = Merb::Plugins.config[:merb_datamapper][:session_storage_name] || 'sessions'
8
- storage_names[default_repository_name] = table_name
7
+ def self.default_repository_name
8
+ Merb::Plugins.config[:merb_datamapper][:session_repository_name]
9
+ end
10
+
11
+ storage_names[default_repository_name] = Merb::Plugins.config[:merb_datamapper][:session_storage_name]
9
12
 
10
- property :session_id, String, :size => 32, :nullable => false, :key => true
13
+ property :session_id, String, :length => 32, :nullable => false, :key => true
11
14
  property :data, Object, :default => {}, :lazy => false
12
15
  property :created_at, DateTime, :default => Proc.new { |r, p| DateTime.now }
13
16
 
@@ -31,7 +34,7 @@ module Merb
31
34
  # @param data<Object> The data to be stored in the session. Probably a hash
32
35
  def self.store_session(session_id, data)
33
36
  if session = get(session_id)
34
- session.update_attributes(:data => data)
37
+ session.update(:data => data)
35
38
  else
36
39
  create(:session_id => session_id, :data => data)
37
40
  end
@@ -44,10 +47,6 @@ module Merb
44
47
  def self.delete_session(session_id)
45
48
  all(:session_id => session_id).destroy!
46
49
  end
47
-
48
- def self.default_repository_name
49
- Merb::Plugins.config[:merb_datamapper][:session_repository_name] || :default
50
- end
51
50
  end
52
51
 
53
52
  class DataMapperSession < SessionStoreContainer
@@ -1,8 +1,7 @@
1
1
  if defined?(Merb::Plugins)
2
- dependency 'dm-core'
2
+ require 'dm-core'
3
3
 
4
4
  require File.dirname(__FILE__) / "merb" / "orms" / "data_mapper" / "connection"
5
- require File.dirname(__FILE__) / "merb" / "session" / "data_mapper_session"
6
5
  Merb::Plugins.add_rakefiles "merb_datamapper" / "merbtasks"
7
6
 
8
7
  # conditionally assign things, so as not to override previously set options.
@@ -37,7 +36,7 @@ if defined?(Merb::Plugins)
37
36
 
38
37
  # if we use a datamapper session store, require it.
39
38
  Merb.logger.verbose! "Checking if we need to use DataMapper sessions"
40
- if Merb::Config.session_stores.include?(:datamapper)
39
+ if Merb::Config.session_store == 'datamapper'
41
40
  Merb.logger.verbose! "Using DataMapper sessions"
42
41
  require File.dirname(__FILE__) / "merb" / "session" / "data_mapper_session"
43
42
  end
@@ -53,32 +52,36 @@ if defined?(Merb::Plugins)
53
52
  after LoadClasses
54
53
 
55
54
  def self.run
56
- Merb.logger.verbose! 'Merb::Orms::DataMapper::Associations block'
57
-
58
- # make sure all relationships are initialized after loading
59
- descendants = DataMapper::Resource.descendants.dup
60
- descendants.dup.each do |model|
61
- descendants.merge(model.descendants) if model.respond_to?(:descendants)
62
- end
63
- descendants.each do |model|
55
+ Merb.logger.verbose! 'Merb::Orms::DataMapper::Associations - defining lazy relationship properties'
56
+
57
+ DataMapper::Model.descendants.each do |model|
64
58
  model.relationships.each_value { |r| r.child_key }
65
59
  end
66
60
 
67
- Merb.logger.verbose! 'Merb::Orms::DataMapper::Associations complete'
61
+ Merb.logger.verbose! 'Merb::Orms::DataMapper::Associations - complete'
62
+
68
63
  end
69
64
  end
70
65
 
71
66
  if Merb::Plugins.config[:merb_datamapper][:use_repository_block]
72
- # wrap action in repository block to enable identity map
73
- class Application < Merb::Controller
74
- override! :_call_action
75
- def _call_action(*)
76
- DataMapper.repository do |r|
77
- Merb.logger.debug "In repository block #{r.name}"
78
- super
67
+
68
+ class Merb::Orms::DataMapper::IdentityMapSupport < Merb::BootLoader
69
+
70
+ after RackUpApplication
71
+
72
+ def self.run
73
+
74
+ app = Merb::Config[:app]
75
+ def app.call(env)
76
+ DataMapper.repository do |r|
77
+ Merb.logger.debug "In repository block #{r.name}"
78
+ super
79
+ end
79
80
  end
81
+
80
82
  end
81
83
  end
84
+
82
85
  end
83
86
 
84
87
  generators = File.join(File.dirname(__FILE__), 'generators')
@@ -16,17 +16,16 @@ namespace :db do
16
16
  end
17
17
  desc "Perform automigration"
18
18
  task :automigrate => :merb_env do
19
- ::DataMapper::AutoMigrator.auto_migrate
19
+ ::DataMapper.auto_migrate!
20
20
  end
21
21
  desc "Perform non destructive automigration"
22
22
  task :autoupgrade => :merb_env do
23
- ::DataMapper::AutoMigrator.auto_upgrade
23
+ ::DataMapper.auto_upgrade!
24
24
  end
25
25
 
26
26
  namespace :migrate do
27
27
  task :load => :merb_env do
28
- gem 'dm-migrations'
29
- require 'migration_runner'
28
+ require 'dm-migrations/migration_runner'
30
29
  FileList["schema/migrations/*.rb"].each do |migration|
31
30
  load migration
32
31
  end
@@ -66,7 +65,7 @@ namespace :db do
66
65
  desc "Drop the database (postgres only)"
67
66
  task :drop do
68
67
  config = Merb::Orms::DataMapper.config
69
- puts "Droping database '#{config[:database]}'"
68
+ puts "Dropping database '#{config[:database]}'"
70
69
  case config[:adapter]
71
70
  when 'postgres'
72
71
  `dropdb -U #{config[:username]} #{config[:database]}`
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb_datamapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Toy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-30 00:00:00 -07:00
12
+ date: 2009-11-03 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ">="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.5
23
+ version: "0.10"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dm-migrations
@@ -28,9 +28,9 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.5
33
+ version: "0.10"
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: merb-core
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 1.0.12
43
+ version: 1.0.13
44
44
  version:
45
45
  description: DataMapper plugin providing DataMapper support for Merb
46
46
  email: jtoy@rubynow.com
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  requirements: []
98
98
 
99
99
  rubyforge_project: merb
100
- rubygems_version: 1.3.2
100
+ rubygems_version: 1.3.5
101
101
  signing_key:
102
102
  specification_version: 3
103
103
  summary: DataMapper plugin providing DataMapper support for Merb