dm-rails 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  DATAMAPPER = 'git://github.com/datamapper'
4
- DM_VERSION = '~> 1.0.0.rc2'
4
+ DM_VERSION = '~> 1.0.0.rc3'
5
5
 
6
6
  group :runtime do
7
7
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2010 The dm-rails team
1
+ Copyright (c) 2010-2010 The dm-rails team
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -116,21 +116,21 @@ Using {bundler}[http://github.com/carlhuda/bundler] it's really easy to get an a
116
116
  git 'git://github.com/snusnu/dm-core.git', 'branch' => 'active_support'
117
117
  git "git://github.com/snusnu/dm-more.git", 'branch' => 'active_support'
118
118
 
119
- gem 'dm-core', '~> 1.0.0.rc2'
120
- gem 'dm-types', '~> 1.0.0.rc2'
121
- gem 'dm-validations', '~> 1.0.0.rc2'
122
- gem 'dm-constraints', '~> 1.0.0.rc2'
123
- gem 'dm-aggregates', '~> 1.0.0.rc2'
124
- gem 'dm-timestamps', '~> 1.0.0.rc2'
125
- gem 'dm-migrations', '~> 1.0.0.rc2'
126
- gem 'dm-observer', '~> 1.0.0.rc2'
119
+ gem 'dm-core', '~> 1.0.0.rc3'
120
+ gem 'dm-types', '~> 1.0.0.rc3'
121
+ gem 'dm-validations', '~> 1.0.0.rc3'
122
+ gem 'dm-constraints', '~> 1.0.0.rc3'
123
+ gem 'dm-aggregates', '~> 1.0.0.rc3'
124
+ gem 'dm-timestamps', '~> 1.0.0.rc3'
125
+ gem 'dm-migrations', '~> 1.0.0.rc3'
126
+ gem 'dm-observer', '~> 1.0.0.rc3'
127
127
 
128
128
  # Use this instead of git if you're working on dm-rails
129
129
  # path '/full/path/to/your/local/clone/of/dm-rails'
130
130
 
131
131
  git 'git://github.com/datamapper/dm-rails.git'
132
132
 
133
- gem 'dm-rails', '~> 1.0.0.rc2'
133
+ gem 'dm-rails', '~> 1.0.0.rc3'
134
134
 
135
135
  git 'git://github.com/rspec/rspec.git'
136
136
  git 'git://github.com/rspec/rspec-core.git'
@@ -503,4 +503,4 @@ Thx to all contributors, every patch, big or small is very much appreciated!
503
503
 
504
504
  == Copyright
505
505
 
506
- Copyright (c) 2009-2010 The dm-rails team. See {LICENSE}[http://github.com/datamapper/dm-rails/blob/master/LICENSE] for details.
506
+ Copyright (c) 2010-2010 The dm-rails team. See {LICENSE}[http://github.com/datamapper/dm-rails/blob/master/LICENSE] for details.
data/Rakefile CHANGED
@@ -2,30 +2,29 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  begin
5
-
5
+ gem 'jeweler', '~> 1.4'
6
6
  require 'jeweler'
7
7
 
8
8
  Jeweler::Tasks.new do |gem|
9
-
10
9
  gem.name = 'dm-rails'
11
10
  gem.summary = 'Use DataMapper with Rails 3'
12
11
  gem.description = 'Integrate DataMapper with Rails 3'
13
12
  gem.email = 'gamsnjaga@gmail.com'
14
- gem.homepage = 'http://github.com/datamapper/dm-rails'
13
+ gem.homepage = 'http://github.com/datamapper/%s' % gem.name
15
14
  gem.authors = [ 'Martin Gamsjaeger (snusnu)', 'Dan Kubb' ]
16
15
 
17
- gem.add_dependency 'dm-core', '~> 1.0.0.rc2'
18
- gem.add_dependency 'dm-active_model', '~> 1.0.0.rc2'
16
+ gem.rubyforge_project = 'datamapper'
19
17
 
20
- gem.add_dependency 'activesupport', '~> 3.0.0.beta3'
21
- gem.add_dependency 'actionpack', '~> 3.0.0.beta3'
22
- gem.add_dependency 'railties', '~> 3.0.0.beta3'
18
+ gem.add_dependency 'dm-core', '~> 1.0.0.rc3'
19
+ gem.add_dependency 'dm-active_model', '~> 1.0.0.rc3'
20
+ gem.add_dependency 'activesupport', '~> 3.0.0.beta3'
21
+ gem.add_dependency 'actionpack', '~> 3.0.0.beta3'
22
+ gem.add_dependency 'railties', '~> 3.0.0.beta3'
23
23
  end
24
24
 
25
25
  Jeweler::GemcutterTasks.new
26
26
 
27
27
  FileList['tasks/**/*.rake'].each { |task| import task }
28
-
29
28
  rescue LoadError
30
29
  puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
31
30
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.rc2
1
+ 1.0.0.rc3
data/dm-rails.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dm-rails}
8
- s.version = "1.0.0.rc2"
8
+ s.version = "1.0.0.rc3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Gamsjaeger (snusnu)", "Dan Kubb"]
12
- s.date = %q{2010-05-19}
12
+ s.date = %q{2010-05-27}
13
13
  s.description = %q{Integrate DataMapper with Rails 3}
14
14
  s.email = %q{gamsnjaga@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/dm-rails/railties/controller_runtime.rb",
34
34
  "lib/dm-rails/railties/database.rake",
35
35
  "lib/dm-rails/railties/i18n_support.rb",
36
+ "lib/dm-rails/railties/log_listener.rb",
36
37
  "lib/dm-rails/railties/log_subscriber.rb",
37
38
  "lib/dm-rails/session_store.rb",
38
39
  "lib/dm-rails/setup.rb",
@@ -54,6 +55,7 @@ Gem::Specification.new do |s|
54
55
  s.homepage = %q{http://github.com/datamapper/dm-rails}
55
56
  s.rdoc_options = ["--charset=UTF-8"]
56
57
  s.require_paths = ["lib"]
58
+ s.rubyforge_project = %q{datamapper}
57
59
  s.rubygems_version = %q{1.3.7}
58
60
  s.summary = %q{Use DataMapper with Rails 3}
59
61
 
@@ -62,21 +64,21 @@ Gem::Specification.new do |s|
62
64
  s.specification_version = 3
63
65
 
64
66
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
65
- s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
66
- s.add_runtime_dependency(%q<dm-active_model>, ["~> 1.0.0.rc2"])
67
+ s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
68
+ s.add_runtime_dependency(%q<dm-active_model>, ["~> 1.0.0.rc3"])
67
69
  s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0.beta3"])
68
70
  s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0.beta3"])
69
71
  s.add_runtime_dependency(%q<railties>, ["~> 3.0.0.beta3"])
70
72
  else
71
- s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
72
- s.add_dependency(%q<dm-active_model>, ["~> 1.0.0.rc2"])
73
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
74
+ s.add_dependency(%q<dm-active_model>, ["~> 1.0.0.rc3"])
73
75
  s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta3"])
74
76
  s.add_dependency(%q<actionpack>, ["~> 3.0.0.beta3"])
75
77
  s.add_dependency(%q<railties>, ["~> 3.0.0.beta3"])
76
78
  end
77
79
  else
78
- s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
79
- s.add_dependency(%q<dm-active_model>, ["~> 1.0.0.rc2"])
80
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
81
+ s.add_dependency(%q<dm-active_model>, ["~> 1.0.0.rc3"])
80
82
  s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta3"])
81
83
  s.add_dependency(%q<actionpack>, ["~> 3.0.0.beta3"])
82
84
  s.add_dependency(%q<railties>, ["~> 3.0.0.beta3"])
@@ -116,7 +116,7 @@ namespace :db do
116
116
  desc "Clear the sessions table for DataMapperStore"
117
117
  task :clear => :environment do
118
118
  require 'dm-rails/session_store'
119
- Rails::DataMapper::SessionStore::Session.all.destroy!
119
+ Rails::DataMapper::SessionStore::Session.destroy!
120
120
  puts "Deleted entries from '#{Rails::DataMapper.configurations[Rails.env]['database']}.sessions'"
121
121
  end
122
122
  end
@@ -0,0 +1,15 @@
1
+ module LogListener
2
+ def log(message)
3
+ ActiveSupport::Notifications.instrument('sql.data_mapper',
4
+ :name => 'SQL',
5
+ :sql => message.query, # TODO think about changing the key to :query
6
+ :start => message.start,
7
+ :duration => message.duration,
8
+ :connection_id => self.object_id
9
+ )
10
+ super
11
+ rescue Exception => e
12
+ # TODO proper logging
13
+ puts "[datamapper - ERROR] #{e.class.name}: #{e.message}: #{message.inspect}}"
14
+ end
15
+ end
@@ -3,6 +3,11 @@ module DataMapper
3
3
 
4
4
  class LogSubscriber < Rails::LogSubscriber
5
5
 
6
+ def initialize
7
+ super
8
+ @odd_or_even = false
9
+ end
10
+
6
11
  def sql(event)
7
12
  name = '%s (%.1fms)' % [event.payload[:name], event.duration]
8
13
  sql = event.payload[:sql].squeeze(' ')
@@ -12,9 +12,9 @@ module Rails
12
12
  include ::DataMapper::Resource
13
13
 
14
14
  property :id, Serial
15
- property :session_id, String, :required => true, :unique => true, :unique_index => true
15
+ property :session_id, String, :required => true, :unique => true
16
16
  property :data, Object, :required => true, :default => ActiveSupport::Base64.encode64(Marshal.dump({}))
17
- property :updated_at, DateTime, :required => false, :index => true
17
+ property :updated_at, DateTime, :index => true
18
18
 
19
19
  def self.name
20
20
  'session'
@@ -1,6 +1,7 @@
1
1
  require 'active_support/core_ext/hash/except'
2
2
 
3
3
  require 'dm-rails/configuration'
4
+ require 'dm-rails/railties/log_listener'
4
5
  require 'dm-rails/railties/benchmarking_mixin'
5
6
 
6
7
  module Rails
@@ -11,30 +12,42 @@ module Rails
11
12
  configuration.repositories[environment].each do |name, config|
12
13
  setup_with_instrumentation(name.to_sym, config)
13
14
  end
14
- initialize_foreign_keys
15
- end
16
-
17
- def self.setup_logger(logger)
18
- ::DataMapper.logger = logger
15
+ finalize
19
16
  end
20
17
 
21
18
  def self.setup_with_instrumentation(name, options)
22
19
  puts "[datamapper] Setting up #{name.inspect} repository: '#{options['database']}' on #{options['adapter']}"
23
20
  adapter = ::DataMapper.setup(name, options)
24
21
  adapter.extend ::DataMapper::Adapters::Benchmarking
22
+ setup_log_listener(options['adapter'])
23
+ end
24
+
25
+ def self.setup_logger(logger)
26
+ ::DataMapper.logger = logger
25
27
  end
26
28
 
27
- def self.initialize_foreign_keys
28
- ::DataMapper::Model.descendants.each do |model|
29
- model.relationships.each_value { |r| r.child_key }
29
+ def self.setup_log_listener(adapter_name)
30
+ adapter_name = 'sqlite3' if adapter_name == 'sqlite'
31
+ driver_name = ActiveSupport::Inflector.camelize(adapter_name)
32
+ if Object.const_defined?('DataObjects') && DataObjects.const_defined?(driver_name)
33
+ DataObjects::Connection.send(:include, LogListener)
34
+ # FIXME Setting DataMapper::Logger.new($stdout, :off) alone won't work because the #log
35
+ # method is currently only available in DO and needs an explicit DO Logger instantiated.
36
+ # We turn the logger :off because ActiveSupport::Notifications handles displaying log messages
37
+ do_driver = DataObjects.const_get(driver_name)
38
+ do_driver.logger = DataObjects::Logger.new($stdout, :off)
30
39
  end
31
40
  end
32
41
 
42
+ def self.finalize
43
+ ::DataMapper.finalize
44
+ end
45
+
33
46
  def self.preload_models(app)
34
47
  app.config.paths.app.models.each do |path|
35
48
  Dir.glob("#{path}/**/*.rb").sort.each { |file| require_dependency file }
36
49
  end
37
- initialize_foreign_keys
50
+ finalize
38
51
  end
39
52
 
40
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940575
4
+ hash: 977940572
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
- - rc2
11
- version: 1.0.0.rc2
10
+ - rc3
11
+ version: 1.0.0.rc3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Martin Gamsjaeger (snusnu)
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-05-19 00:00:00 -07:00
20
+ date: 2010-05-27 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -28,13 +28,13 @@ dependencies:
28
28
  requirements:
29
29
  - - ~>
30
30
  - !ruby/object:Gem::Version
31
- hash: 977940575
31
+ hash: 977940572
32
32
  segments:
33
33
  - 1
34
34
  - 0
35
35
  - 0
36
- - rc2
37
- version: 1.0.0.rc2
36
+ - rc3
37
+ version: 1.0.0.rc3
38
38
  type: :runtime
39
39
  version_requirements: *id001
40
40
  - !ruby/object:Gem::Dependency
@@ -45,13 +45,13 @@ dependencies:
45
45
  requirements:
46
46
  - - ~>
47
47
  - !ruby/object:Gem::Version
48
- hash: 977940575
48
+ hash: 977940572
49
49
  segments:
50
50
  - 1
51
51
  - 0
52
52
  - 0
53
- - rc2
54
- version: 1.0.0.rc2
53
+ - rc3
54
+ version: 1.0.0.rc3
55
55
  type: :runtime
56
56
  version_requirements: *id002
57
57
  - !ruby/object:Gem::Dependency
@@ -131,6 +131,7 @@ files:
131
131
  - lib/dm-rails/railties/controller_runtime.rb
132
132
  - lib/dm-rails/railties/database.rake
133
133
  - lib/dm-rails/railties/i18n_support.rb
134
+ - lib/dm-rails/railties/log_listener.rb
134
135
  - lib/dm-rails/railties/log_subscriber.rb
135
136
  - lib/dm-rails/session_store.rb
136
137
  - lib/dm-rails/setup.rb
@@ -179,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
180
  version: 1.3.1
180
181
  requirements: []
181
182
 
182
- rubyforge_project:
183
+ rubyforge_project: datamapper
183
184
  rubygems_version: 1.3.7
184
185
  signing_key:
185
186
  specification_version: 3