dm-rails 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +69 -55
- data/VERSION +2 -1
- data/dm-rails.gemspec +1 -1
- data/lib/dm-rails/railties/database.rake +6 -4
- data/lib/dm-rails/storage.rb +2 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -6,9 +6,10 @@ Creating new datamapper apps on rails3 from scratch is actually really easy. The
|
|
6
6
|
|
7
7
|
== Generating a new application from scratch
|
8
8
|
|
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]
|
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, {bundler}[http://gembundler.com] and {rails}[http://github.com/rails/rails]
|
10
10
|
|
11
11
|
gem update —system # you will need rubygems ~> 1.3.6 for the command below to work
|
12
|
+
gem install bundler --pre (optional, rails will likely pull in a current version)
|
12
13
|
gem install rails --pre
|
13
14
|
|
14
15
|
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.
|
@@ -19,37 +20,61 @@ When run, the command will print out some options on how to proceed with your ne
|
|
19
20
|
|
20
21
|
== rspec support
|
21
22
|
|
22
|
-
|
23
|
+
I haven't yet tested rspec support extensively, but the basics are working after a few modifications to the spec/spec_helper.rb file that the necessary
|
23
24
|
|
24
|
-
|
25
|
-
adapter: mysql
|
26
|
-
username: root
|
27
|
-
password:
|
28
|
-
host: localhost
|
25
|
+
rails generate rspec:install
|
29
26
|
|
30
|
-
|
31
|
-
database: dm_rails3_app_development
|
32
|
-
<<: *defaults
|
27
|
+
gives us. First you need to uncomment/remove a seemingly invalid rspec configuration option that gets set by default, and you also should turn off transactional_fixtures at least for now. It's pretty common to run `DataMapper.auto_migrate!` before all specs too. My spec_helper.rb file currently looks like the following, and model specs run fine.
|
33
28
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# username: the_user
|
40
|
-
# password: secrets
|
41
|
-
# host: localhost
|
42
|
-
# repo2:
|
43
|
-
# ...
|
29
|
+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
30
|
+
# from the project root directory.
|
31
|
+
ENV["RAILS_ENV"] ||= 'test'
|
32
|
+
require File.expand_path("../../config/environment", __FILE__)
|
33
|
+
require 'rspec/rails'
|
44
34
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
# Requires supporting files with custom matchers and macros, etc,
|
36
|
+
# in ./support/ and its subdirectories.
|
37
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
38
|
+
|
39
|
+
RSpec.configure do |config|
|
40
|
+
# == Mock Framework
|
41
|
+
#
|
42
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
43
|
+
#
|
44
|
+
# config.mock_with :mocha
|
45
|
+
# config.mock_with :flexmock
|
46
|
+
# config.mock_with :rr
|
47
|
+
config.mock_with :rspec
|
48
|
+
|
49
|
+
config.before(:all) { DataMapper.auto_migrate! }
|
51
50
|
|
52
|
-
|
51
|
+
# I can't find that option when looking at current rspec-core source
|
52
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
53
|
+
|
54
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
55
|
+
# examples within a transaction, comment the following line or assign false
|
56
|
+
# instead of true.
|
57
|
+
# config.use_transactional_fixtures = true
|
58
|
+
end
|
59
|
+
|
60
|
+
With this in place, running
|
61
|
+
|
62
|
+
./bin/rake spec
|
63
|
+
./bin/rake spec:models
|
64
|
+
...
|
65
|
+
|
66
|
+
should work fine. In order to have ./bin/rake available, the bundle needs to be installed with
|
67
|
+
|
68
|
+
bundle install --binstubs
|
69
|
+
|
70
|
+
If you haven't done so for whatever reason, use
|
71
|
+
|
72
|
+
bundle exec rake spec
|
73
|
+
bundle exec rake spec:models
|
74
|
+
|
75
|
+
instead.
|
76
|
+
|
77
|
+
You may have noticed that rspec is included into both the `:development` and `:test` groups in the Gemfile the application template generated. I couldn't find another way to make it so that the above mentioned way of running the specs work. If rspec is not included into the `:development` group, rails must be informed explicitly about the environment it should run in, by prefixing the above rake commands with `RAILS_ENV=test`.
|
53
78
|
|
54
79
|
== Developing dm-rails
|
55
80
|
|
@@ -71,19 +96,17 @@ Using {bundler}[http://github.com/carlhuda/bundler] it's really easy to get an a
|
|
71
96
|
|
72
97
|
source 'http://rubygems.org'
|
73
98
|
|
74
|
-
RAILS_VERSION = '~> 3.0.0.
|
75
|
-
|
99
|
+
RAILS_VERSION = '~> 3.0.0.rc'
|
76
100
|
DM_VERSION = '~> 1.0.0'
|
77
|
-
|
78
|
-
RSPEC_VERSION = '~> 2.0.0.beta.11'
|
101
|
+
RSPEC_VERSION = '~> 2.0.0.beta.19'
|
79
102
|
|
80
103
|
gem 'activesupport', RAILS_VERSION, :require => 'active_support'
|
81
104
|
gem 'actionpack', RAILS_VERSION, :require => 'action_pack'
|
82
105
|
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
|
83
106
|
gem 'railties', RAILS_VERSION, :require => 'rails'
|
84
107
|
|
85
|
-
gem 'dm-rails',
|
86
|
-
gem 'dm
|
108
|
+
gem 'dm-rails', DM_VERSION # !NOTE! 1.0.2 will be released soon
|
109
|
+
gem 'dm-sqlite-adapter', DM_VERSION
|
87
110
|
|
88
111
|
# You can use any of the other available database adapters.
|
89
112
|
# This is only a small excerpt of the list of all available adapters
|
@@ -111,32 +134,23 @@ Using {bundler}[http://github.com/carlhuda/bundler] it's really easy to get an a
|
|
111
134
|
|
112
135
|
group(:test) do
|
113
136
|
|
114
|
-
gem 'rspec', RSPEC_VERSION
|
115
|
-
gem 'rspec-core', RSPEC_VERSION, :require => 'rspec/core'
|
116
|
-
gem 'rspec-expectations', RSPEC_VERSION, :require => 'rspec/expectations'
|
117
|
-
gem 'rspec-mocks', RSPEC_VERSION, :require => 'rspec/mocks'
|
118
137
|
gem 'rspec-rails', RSPEC_VERSION
|
119
138
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
139
|
+
# To get a detailed overview about what queries get issued and how long they take
|
140
|
+
# have a look at rails_metrics. Once you bundled it, you can run
|
141
|
+
#
|
142
|
+
# rails g rails_metrics Metric
|
143
|
+
# rake db:automigrate
|
144
|
+
#
|
145
|
+
# to generate a model that stores the metrics. You can access them by visiting
|
146
|
+
#
|
147
|
+
# /rails_metrics
|
148
|
+
#
|
149
|
+
# in your rails application.
|
130
150
|
|
131
|
-
|
132
|
-
gem 'dm-do-adapter', DM_VERSION
|
133
|
-
gem 'dm-active_model', DM_VERSION
|
134
|
-
|
135
|
-
|
136
|
-
# Uncomment this line if you want to see application specific metric data
|
137
|
-
|
138
|
-
# gem 'rails_metrics', '~> 0.1', :git => 'git://github.com/engineyard/rails_metrics'
|
151
|
+
# gem 'rails_metrics', '~> 0.1', :git => 'git://github.com/engineyard/rails_metrics'
|
139
152
|
|
153
|
+
end
|
140
154
|
|
141
155
|
|
142
156
|
== Sample database.yml files
|
data/VERSION
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
2
|
+
|
data/dm-rails.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-rails}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
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"]
|
@@ -42,8 +42,9 @@ namespace :db do
|
|
42
42
|
task :automigrate => :environment do
|
43
43
|
require 'dm-migrations'
|
44
44
|
Rails::DataMapper.configuration.repositories[Rails.env].each do |repository, config|
|
45
|
+
::DataMapper.setup(repository.to_sym, config)
|
45
46
|
::DataMapper.auto_migrate!(repository.to_sym)
|
46
|
-
|
47
|
+
puts "[datamapper] Finished auto_migrate! for :#{repository} repository '#{config['database']}'"
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
@@ -51,8 +52,9 @@ namespace :db do
|
|
51
52
|
task :autoupgrade => :environment do
|
52
53
|
require 'dm-migrations'
|
53
54
|
Rails::DataMapper.configuration.repositories[Rails.env].each do |repository, config|
|
55
|
+
::DataMapper.setup(repository.to_sym, config)
|
54
56
|
::DataMapper.auto_upgrade!(repository.to_sym)
|
55
|
-
|
57
|
+
puts "[datamapper] Finished auto_upgrade! for :#{repository} repository '#{config['database']}'"
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
@@ -90,7 +92,7 @@ namespace :db do
|
|
90
92
|
require 'dm-rails/session_store'
|
91
93
|
Rails::DataMapper::SessionStore::Session.auto_migrate!
|
92
94
|
database = Rails::DataMapper.configuration.repositories[Rails.env]['database']
|
93
|
-
|
95
|
+
puts "Created '#{database}.sessions'"
|
94
96
|
end
|
95
97
|
|
96
98
|
desc "Clear the sessions table for DataMapperStore"
|
@@ -98,7 +100,7 @@ namespace :db do
|
|
98
100
|
require 'dm-rails/session_store'
|
99
101
|
Rails::DataMapper::SessionStore::Session.destroy!
|
100
102
|
database = Rails::DataMapper.configuration.repositories[Rails.env]['database']
|
101
|
-
|
103
|
+
puts "Deleted entries from '#{database}.sessions'"
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
data/lib/dm-rails/storage.rb
CHANGED
@@ -95,7 +95,8 @@ module Rails
|
|
95
95
|
class Sqlite < Storage
|
96
96
|
def _create
|
97
97
|
return if in_memory?
|
98
|
-
|
98
|
+
# TODO don't to_s the path once a do_sqlite3 gem supports it
|
99
|
+
::DataMapper.setup(name, config.merge('database' => path.to_s))
|
99
100
|
end
|
100
101
|
|
101
102
|
def _drop
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Martin Gamsjaeger (snusnu)
|