dm-rails 1.0.0.rc3 → 1.0.0

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.rc3'
4
+ DM_VERSION = '~> 1.0.0'
5
5
 
6
6
  group :runtime do
7
7
 
data/README.rdoc CHANGED
@@ -8,21 +8,14 @@ Creating new datamapper apps on rails3 from scratch is actually really easy. Lik
8
8
 
9
9
  It's really easy to go from zero gems to a working rails3 app using datamapper. All you need is the latest {rubygems}[http://docs.rubygems.org/read/chapter/3] release and {rails}[http://github.com/rails/rails]
10
10
 
11
- gem update —system # you will need rubygems-1.3.6 for the command below to work
11
+ gem update —system # you will need rubygems ~> 1.3.6 for the command below to work
12
12
  gem install rails --pre
13
13
 
14
14
  Once you have {rails}[http://github.com/rails/rails] and thus {bundler}[http://github.com/carlhuda/bundler] installed, you can bootstrap a rails master branch application with a single command. Yes! A single command. Cool.
15
15
 
16
- rails dm_rails3_app -m http://github.com/snusnu/rails-templates/raw/master/dm_rails_master.rb
17
-
18
- Now that was easy! Follow the instructions and point your browser to
19
-
20
- http://localhost:3000/people
21
-
22
- Awesome.
23
-
24
- In the future, http://github.com/snusnu/rails-templates will host a more comprehensive set of rails application templates. Currently only the above are supported but you can expect some reasonable defaults to follow soon. Things like rspec and jquery support are definitely on the list, maybe also support for {devise}[http://github.com/plataformatec/devise] and {inherited_resources}[http://github.com/josevalim/inherited_resources]. These will of course be on a pluggable basis. Nothing will be forced upon you. We heavily encourage you to build your own customized application templates and maybe send us a note if you think they could be interesting to more people.
16
+ rails dm_rails3_app -m http://datamapper.org/templates/rails.rb
25
17
 
18
+ Now that was easy! When run, the command will print some options on how to proceed with your newly generated application, to the screen.
26
19
 
27
20
  == rspec support
28
21
 
@@ -74,10 +67,6 @@ Now that was easy, wasn't it? Whenever you want to update your dependencies beca
74
67
  again and {bundler}[http://github.com/carlhuda/bundler] will go ahead and fetch the latest commits from the gems you depend on.
75
68
 
76
69
 
77
- == Minimal sample application
78
-
79
- Have a look at {datamapper_on_rails3}[http://github.com/snusnu/datamapper_on_rails3] for a very minimal sample application that was built following the previous instructions on how to build a new application from scratch.
80
-
81
70
  == Sample Gemfile
82
71
 
83
72
  Using {bundler}[http://github.com/carlhuda/bundler] it's really easy to get an app going with datamapper and rails3. Just use a Gemfile like this, and bundler will pull in everything needed to run your app. Note that you also must add any additional datamapper plugin or any other gem that you'd like to use to the Gemfile. This makes sure that bundler is able to provide a complete environment containing all required dependencies for your app.
@@ -116,21 +105,21 @@ Using {bundler}[http://github.com/carlhuda/bundler] it's really easy to get an a
116
105
  git 'git://github.com/snusnu/dm-core.git', 'branch' => 'active_support'
117
106
  git "git://github.com/snusnu/dm-more.git", 'branch' => 'active_support'
118
107
 
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'
108
+ gem 'dm-core', '~> 1.0.0'
109
+ gem 'dm-types', '~> 1.0.0'
110
+ gem 'dm-validations', '~> 1.0.0'
111
+ gem 'dm-constraints', '~> 1.0.0'
112
+ gem 'dm-aggregates', '~> 1.0.0'
113
+ gem 'dm-timestamps', '~> 1.0.0'
114
+ gem 'dm-migrations', '~> 1.0.0'
115
+ gem 'dm-observer', '~> 1.0.0'
127
116
 
128
117
  # Use this instead of git if you're working on dm-rails
129
118
  # path '/full/path/to/your/local/clone/of/dm-rails'
130
119
 
131
120
  git 'git://github.com/datamapper/dm-rails.git'
132
121
 
133
- gem 'dm-rails', '~> 1.0.0.rc3'
122
+ gem 'dm-rails', '~> 1.0.0'
134
123
 
135
124
  git 'git://github.com/rspec/rspec.git'
136
125
  git 'git://github.com/rspec/rspec-core.git'
data/Rakefile CHANGED
@@ -15,8 +15,8 @@ begin
15
15
 
16
16
  gem.rubyforge_project = 'datamapper'
17
17
 
18
- gem.add_dependency 'dm-core', '~> 1.0.0.rc3'
19
- gem.add_dependency 'dm-active_model', '~> 1.0.0.rc3'
18
+ gem.add_dependency 'dm-core', '~> 1.0.0'
19
+ gem.add_dependency 'dm-active_model', '~> 1.0.0'
20
20
  gem.add_dependency 'activesupport', '~> 3.0.0.beta3'
21
21
  gem.add_dependency 'actionpack', '~> 3.0.0.beta3'
22
22
  gem.add_dependency 'railties', '~> 3.0.0.beta3'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.rc3
1
+ 1.0.0
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.rc3"
8
+ s.version = "1.0.0"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Gamsjaeger (snusnu)", "Dan Kubb"]
12
- s.date = %q{2010-05-27}
12
+ s.date = %q{2010-06-08}
13
13
  s.description = %q{Integrate DataMapper with Rails 3}
14
14
  s.email = %q{gamsnjaga@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -64,21 +64,21 @@ Gem::Specification.new do |s|
64
64
  s.specification_version = 3
65
65
 
66
66
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
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
+ s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0"])
68
+ s.add_runtime_dependency(%q<dm-active_model>, ["~> 1.0.0"])
69
69
  s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0.beta3"])
70
70
  s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0.beta3"])
71
71
  s.add_runtime_dependency(%q<railties>, ["~> 3.0.0.beta3"])
72
72
  else
73
- s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
74
- s.add_dependency(%q<dm-active_model>, ["~> 1.0.0.rc3"])
73
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0"])
74
+ s.add_dependency(%q<dm-active_model>, ["~> 1.0.0"])
75
75
  s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta3"])
76
76
  s.add_dependency(%q<actionpack>, ["~> 3.0.0.beta3"])
77
77
  s.add_dependency(%q<railties>, ["~> 3.0.0.beta3"])
78
78
  end
79
79
  else
80
- s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
81
- s.add_dependency(%q<dm-active_model>, ["~> 1.0.0.rc3"])
80
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0"])
81
+ s.add_dependency(%q<dm-active_model>, ["~> 1.0.0"])
82
82
  s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta3"])
83
83
  s.add_dependency(%q<actionpack>, ["~> 3.0.0.beta3"])
84
84
  s.add_dependency(%q<railties>, ["~> 3.0.0.beta3"])
@@ -3,10 +3,6 @@ require 'dm-rails/storage'
3
3
 
4
4
  namespace :db do
5
5
 
6
- task :load_models => :environment do
7
- FileList["app/models/**/*.rb"].each { |model| load model }
8
- end
9
-
10
6
  desc 'Create the database, load the schema, and initialize with the seed data'
11
7
  task :setup => [ 'db:create', 'db:automigrate', 'db:seed' ]
12
8
 
@@ -46,33 +42,33 @@ namespace :db do
46
42
 
47
43
 
48
44
  desc 'Perform destructive automigration of all repositories in the current Rails.env'
49
- task :automigrate => :load_models do
45
+ task :automigrate => :environment do
50
46
  require 'dm-migrations'
51
47
  Rails::DataMapper.configuration.repositories[Rails.env].each do |repository, config|
52
48
  ::DataMapper.auto_migrate!(repository.to_sym)
53
- puts "[datamapper] Finished auto_migrate! for :#{repository} repository '#{config['database']}'"
49
+ ::DataMapper.logger.info "[datamapper] Finished auto_migrate! for :#{repository} repository '#{config['database']}'"
54
50
  end
55
51
  if Rails.env.development? && Rails::DataMapper.configuration.repositories['test']
56
52
  Rails::DataMapper.setup('test')
57
53
  Rails::DataMapper.configuration.repositories['test'].each do |repository, config|
58
54
  ::DataMapper.auto_migrate!(repository.to_sym)
59
- puts "[datamapper] Finished auto_migrate! for :#{repository} repository '#{config['database']}'"
55
+ ::DataMapper.logger.info "[datamapper] Finished auto_migrate! for :#{repository} repository '#{config['database']}'"
60
56
  end
61
57
  end
62
58
  end
63
59
 
64
60
  desc 'Perform non destructive automigration of all repositories in the current Rails.env'
65
- task :autoupgrade => :load_models do
61
+ task :autoupgrade => :environment do
66
62
  require 'dm-migrations'
67
63
  Rails::DataMapper.configuration.repositories[Rails.env].each do |repository, config|
68
64
  ::DataMapper.auto_upgrade!(repository.to_sym)
69
- puts "[datamapper] Finished auto_upgrade! for :#{repository} repository '#{config['database']}'"
65
+ ::DataMapper.logger.info "[datamapper] Finished auto_upgrade! for :#{repository} repository '#{config['database']}'"
70
66
  end
71
67
  if Rails.env.development? && Rails::DataMapper.configuration.repositories['test']
72
68
  Rails::DataMapper.setup('test')
73
69
  Rails::DataMapper.configuration.repositories['test'].each do |repository, config|
74
70
  ::DataMapper.auto_upgrade!(repository.to_sym)
75
- puts "[datamapper] Finished auto_upgrade! for :#{repository} repository '#{config['database']}'"
71
+ ::DataMapper.logger.info "[datamapper] Finished auto_upgrade! for :#{repository} repository '#{config['database']}'"
76
72
  end
77
73
  end
78
74
  end
@@ -110,14 +106,16 @@ namespace :db do
110
106
  task :create => :environment do
111
107
  require 'dm-rails/session_store'
112
108
  Rails::DataMapper::SessionStore::Session.auto_migrate!
113
- puts "Created '#{Rails::DataMapper.configurations[Rails.env]['database']}.sessions'"
109
+ database = Rails::DataMapper.configuration.repositories[Rails.env]['database']
110
+ ::DataMapper.logger.info "Created '#{database}.sessions'"
114
111
  end
115
112
 
116
113
  desc "Clear the sessions table for DataMapperStore"
117
114
  task :clear => :environment do
118
115
  require 'dm-rails/session_store'
119
116
  Rails::DataMapper::SessionStore::Session.destroy!
120
- puts "Deleted entries from '#{Rails::DataMapper.configurations[Rails.env]['database']}.sessions'"
117
+ database = Rails::DataMapper.configuration.repositories[Rails.env]['database']
118
+ ::DataMapper.logger.info "Deleted entries from '#{database}.sessions'"
121
119
  end
122
120
  end
123
121
 
@@ -1,3 +1,28 @@
1
+ require 'active_support/notifications'
2
+
3
+ # TODO This needs to be fixed upstream in active_support/notifications/instrumenter.rb
4
+ #
5
+ # We need to monkeypatch this for now, because the original implementation hardcodes the
6
+ # duration to the time elapsed between start and end of the event. The current upstream
7
+ # implementation is included here for reference:
8
+ #
9
+ # def duration
10
+ # @duration ||= 1000.0 * (@end - @time)
11
+ # end
12
+ #
13
+ # It should be safe to assume that explicitly provided duration information should be at
14
+ # least as precise as the current generic solution, if not more (as in our specific case).
15
+ #
16
+ module ActiveSupport
17
+ module Notifications
18
+ class Event
19
+ def duration
20
+ @duration ||= payload[:duration] ? (payload[:duration] / 1000.0) : 1000.0 * (@end - @time)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
1
26
  module LogListener
2
27
  def log(message)
3
28
  ActiveSupport::Notifications.instrument('sql.data_mapper',
@@ -9,7 +34,6 @@ module LogListener
9
34
  )
10
35
  super
11
36
  rescue Exception => e
12
- # TODO proper logging
13
- puts "[datamapper - ERROR] #{e.class.name}: #{e.message}: #{message.inspect}}"
37
+ ::DataMapper.logger.error "[datamapper] #{e.class.name}: #{e.message}: #{message.inspect}}"
14
38
  end
15
39
  end
@@ -1,4 +1,5 @@
1
1
  require 'dm-core'
2
+ require 'active_support/core_ext/class/attribute'
2
3
 
3
4
  # Implements DataMapper-specific session store.
4
5
 
@@ -13,18 +14,22 @@ module Rails
13
14
 
14
15
  property :id, Serial
15
16
  property :session_id, String, :required => true, :unique => true
16
- property :data, Object, :required => true, :default => ActiveSupport::Base64.encode64(Marshal.dump({}))
17
+ property :data, Object, :required => true
17
18
  property :updated_at, DateTime, :index => true
18
19
 
19
20
  def self.name
20
21
  'session'
21
22
  end
22
23
 
24
+ def data
25
+ attribute_get(:data) || {}
26
+ end
27
+
23
28
  end
24
29
 
25
30
  SESSION_RECORD_KEY = 'rack.session.record'.freeze
26
31
 
27
- cattr_accessor :session_class
32
+ class_attribute :session_class
28
33
  self.session_class = Session
29
34
 
30
35
  private
@@ -8,7 +8,7 @@ module Rails
8
8
  module DataMapper
9
9
 
10
10
  def self.setup(environment)
11
- puts "[datamapper] Setting up the #{environment.inspect} environment:"
11
+ ::DataMapper.logger.info "[datamapper] Setting up the #{environment.inspect} environment:"
12
12
  configuration.repositories[environment].each do |name, config|
13
13
  setup_with_instrumentation(name.to_sym, config)
14
14
  end
@@ -16,7 +16,7 @@ module Rails
16
16
  end
17
17
 
18
18
  def self.setup_with_instrumentation(name, options)
19
- puts "[datamapper] Setting up #{name.inspect} repository: '#{options['database']}' on #{options['adapter']}"
19
+ ::DataMapper.logger.info "[datamapper] Setting up #{name.inspect} repository: '#{options['database']}' on #{options['adapter']}"
20
20
  adapter = ::DataMapper.setup(name, options)
21
21
  adapter.extend ::DataMapper::Adapters::Benchmarking
22
22
  setup_log_listener(options['adapter'])
@@ -29,13 +29,13 @@ module Rails
29
29
  def self.setup_log_listener(adapter_name)
30
30
  adapter_name = 'sqlite3' if adapter_name == 'sqlite'
31
31
  driver_name = ActiveSupport::Inflector.camelize(adapter_name)
32
- if Object.const_defined?('DataObjects') && DataObjects.const_defined?(driver_name)
32
+
33
+ setup_do_driver(driver_name) do |driver|
33
34
  DataObjects::Connection.send(:include, LogListener)
34
35
  # FIXME Setting DataMapper::Logger.new($stdout, :off) alone won't work because the #log
35
36
  # method is currently only available in DO and needs an explicit DO Logger instantiated.
36
37
  # 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)
38
+ driver.logger = DataObjects::Logger.new($stdout, :off)
39
39
  end
40
40
  end
41
41
 
@@ -50,5 +50,23 @@ module Rails
50
50
  finalize
51
51
  end
52
52
 
53
+ class << self
54
+ private
55
+
56
+ if RUBY_VERSION < '1.9'
57
+ def setup_do_driver(driver_name)
58
+ if Object.const_defined?('DataObjects') && DataObjects.const_defined?(driver_name)
59
+ yield DataObjects.const_get(driver_name)
60
+ end
61
+ end
62
+ else
63
+ def setup_do_driver(driver_name)
64
+ if Object.const_defined?('DataObjects', false) && DataObjects.const_defined?(driver_name, false)
65
+ yield DataObjects.const_get(driver_name, false)
66
+ end
67
+ end
68
+ end
69
+ end
70
+
53
71
  end
54
72
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940572
5
- prerelease: true
4
+ hash: 23
5
+ prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
- - rc3
11
- version: 1.0.0.rc3
10
+ version: 1.0.0
12
11
  platform: ruby
13
12
  authors:
14
13
  - Martin Gamsjaeger (snusnu)
@@ -17,7 +16,7 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2010-05-27 00:00:00 -07:00
19
+ date: 2010-06-08 00:00:00 -07:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
@@ -28,13 +27,12 @@ dependencies:
28
27
  requirements:
29
28
  - - ~>
30
29
  - !ruby/object:Gem::Version
31
- hash: 977940572
30
+ hash: 23
32
31
  segments:
33
32
  - 1
34
33
  - 0
35
34
  - 0
36
- - rc3
37
- version: 1.0.0.rc3
35
+ version: 1.0.0
38
36
  type: :runtime
39
37
  version_requirements: *id001
40
38
  - !ruby/object:Gem::Dependency
@@ -45,13 +43,12 @@ dependencies:
45
43
  requirements:
46
44
  - - ~>
47
45
  - !ruby/object:Gem::Version
48
- hash: 977940572
46
+ hash: 23
49
47
  segments:
50
48
  - 1
51
49
  - 0
52
50
  - 0
53
- - rc3
54
- version: 1.0.0.rc3
51
+ version: 1.0.0
55
52
  type: :runtime
56
53
  version_requirements: *id002
57
54
  - !ruby/object:Gem::Dependency
@@ -170,14 +167,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
167
  required_rubygems_version: !ruby/object:Gem::Requirement
171
168
  none: false
172
169
  requirements:
173
- - - ">"
170
+ - - ">="
174
171
  - !ruby/object:Gem::Version
175
- hash: 25
172
+ hash: 3
176
173
  segments:
177
- - 1
178
- - 3
179
- - 1
180
- version: 1.3.1
174
+ - 0
175
+ version: "0"
181
176
  requirements: []
182
177
 
183
178
  rubyforge_project: datamapper