dm-transactions 1.0.0.rc2 → 1.0.0.rc3

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/Gemfile CHANGED
@@ -71,7 +71,7 @@
71
71
  source 'http://rubygems.org'
72
72
 
73
73
  DATAMAPPER = 'git://github.com/datamapper'
74
- DM_VERSION = '~> 1.0.0.rc2'
74
+ DM_VERSION = '~> 1.0.0.rc3'
75
75
  DO_VERSION = '~> 0.10.3'
76
76
 
77
77
  group :runtime do # Runtime dependencies (as in the gemspec)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 snusnu
1
+ Copyright (c) 2010 snusnu
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/Rakefile CHANGED
@@ -2,27 +2,27 @@ 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
- gem.name = "dm-transactions"
10
- gem.summary = %Q{Adds transaction support to datamapper}
11
- gem.description = %Q{Makes transaction support available for adapters that support them}
12
- gem.email = "gamsnjaga@gmail.com"
13
- gem.homepage = "http://github.com/datamapper/dm-transactions"
14
- gem.authors = ["Dirkjan Bussink (dbussink)", "Dan Kubb (dkubb)"]
9
+ gem.name = 'dm-transactions'
10
+ gem.summary = 'Adds transaction support to datamapper'
11
+ gem.description = 'Makes transaction support available for adapters that support them'
12
+ gem.email = 'gamsnjaga@gmail.com'
13
+ gem.homepage = 'http://github.com/datamapper/%s' % gem.name
14
+ gem.authors = [ 'Dirkjan Bussink (dbussink)', 'Dan Kubb (dkubb)' ]
15
15
 
16
- gem.add_dependency 'dm-core', '~> 1.0.0.rc2'
16
+ gem.rubyforge_project = 'datamapper'
17
17
 
18
- gem.add_development_dependency 'rspec', '~> 1.3'
18
+ gem.add_dependency 'dm-core', '~> 1.0.0.rc3'
19
19
 
20
+ gem.add_development_dependency 'rspec', '~> 1.3'
20
21
  end
21
22
 
22
23
  Jeweler::GemcutterTasks.new
23
24
 
24
25
  FileList['tasks/**/*.rake'].each { |task| import task }
25
-
26
26
  rescue LoadError
27
27
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
28
28
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.rc2
1
+ 1.0.0.rc3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dm-transactions}
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 = ["Dirkjan Bussink (dbussink)", "Dan Kubb (dkubb)"]
12
- s.date = %q{2010-05-19}
12
+ s.date = %q{2010-05-27}
13
13
  s.description = %q{Makes transaction support available for adapters that support them}
14
14
  s.email = %q{gamsnjaga@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
49
49
  s.homepage = %q{http://github.com/datamapper/dm-transactions}
50
50
  s.rdoc_options = ["--charset=UTF-8"]
51
51
  s.require_paths = ["lib"]
52
+ s.rubyforge_project = %q{datamapper}
52
53
  s.rubygems_version = %q{1.3.7}
53
54
  s.summary = %q{Adds transaction support to datamapper}
54
55
  s.test_files = [
@@ -64,14 +65,14 @@ Gem::Specification.new do |s|
64
65
  s.specification_version = 3
65
66
 
66
67
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
67
- s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
68
+ s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
68
69
  s.add_development_dependency(%q<rspec>, ["~> 1.3"])
69
70
  else
70
- s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
71
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
71
72
  s.add_dependency(%q<rspec>, ["~> 1.3"])
72
73
  end
73
74
  else
74
- s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
75
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
75
76
  s.add_dependency(%q<rspec>, ["~> 1.3"])
76
77
  end
77
78
  end
@@ -75,7 +75,8 @@ module DataMapper
75
75
 
76
76
  # @api private
77
77
  def transactions
78
- Thread.current[:dm_transactions] ||= []
78
+ Thread.current[:dm_transactions] ||= {}
79
+ Thread.current[:dm_transactions][object_id] ||= []
79
80
  end
80
81
 
81
82
  # Retrieve the current connection for this Adapter.
@@ -390,10 +390,10 @@ module DataMapper
390
390
 
391
391
  def self.include_transaction_api
392
392
  [ :Repository, :Model, :Resource ].each do |name|
393
- DataMapper.const_get(name).send(:include, Transaction.const_get(name))
393
+ DataMapper.const_get(name).send(:include, const_get(name))
394
394
  end
395
- DataMapper::Repository.adapters.values.each do |adapter|
396
- Adapters.include_transaction_api(ActiveSupport::Inflector.demodulize(adapter.class.name))
395
+ Adapters::AbstractAdapter.descendants.each do |adapter_class|
396
+ Adapters.include_transaction_api(ActiveSupport::Inflector.demodulize(adapter_class.name))
397
397
  end
398
398
  end
399
399
 
@@ -401,23 +401,22 @@ module DataMapper
401
401
 
402
402
  module Adapters
403
403
 
404
- class << self
405
-
406
- def include_transaction_api(const_name)
407
- require transaction_extensions(const_name)
404
+ def self.include_transaction_api(const_name)
405
+ require transaction_extensions(const_name)
406
+ if Transaction.const_defined?(const_name)
408
407
  adapter = const_get(const_name)
409
- if DataMapper::Transaction.const_defined?(const_name)
410
- adapter.send(:include, transaction_module(const_name))
411
- end
412
- rescue LoadError
413
- # Silently ignore the fact that no adapter extensions could be required
414
- # This means that the adapter in use doesn't support transactions
408
+ adapter.send(:include, transaction_module(const_name))
415
409
  end
410
+ rescue LoadError
411
+ # Silently ignore the fact that no adapter extensions could be required
412
+ # This means that the adapter in use doesn't support transactions
413
+ end
416
414
 
417
- def transaction_module(const_name)
418
- DataMapper::Transaction.const_get(const_name)
419
- end
415
+ def self.transaction_module(const_name)
416
+ Transaction.const_get(const_name)
417
+ end
420
418
 
419
+ class << self
421
420
  private
422
421
 
423
422
  # @api private
@@ -1,15 +1,13 @@
1
1
  require 'spec'
2
2
  require 'isolated/require_spec'
3
3
  require 'dm-core/spec/setup'
4
- require 'dm-core/spec/lib/adapter_helpers'
5
4
 
6
5
  # To really test this behavior, this spec needs to be run in isolation and not
7
6
  # as part of the typical rake spec run, which requires dm-transactions upfront
8
7
 
9
- if %w[postgres mysql sqlite oracle sqlserver].include?(ENV['ADAPTER'])
8
+ if %w[ postgres mysql sqlite oracle sqlserver ].include?(ENV['ADAPTER'])
10
9
 
11
10
  describe "require 'dm-transactions after calling DataMapper.setup" do
12
- extend DataMapper::Spec::Adapters::Helpers
13
11
 
14
12
  before(:all) do
15
13
  @adapter = DataMapper::Spec.adapter
@@ -1,15 +1,13 @@
1
1
  require 'spec'
2
2
  require 'isolated/require_spec'
3
3
  require 'dm-core/spec/setup'
4
- require 'dm-core/spec/lib/adapter_helpers'
5
4
 
6
5
  # To really test this behavior, this spec needs to be run in isolation and not
7
6
  # as part of the typical rake spec run, which requires dm-transactions upfront
8
7
 
9
- if %w[postgres mysql sqlite oracle sqlserver].include?(ENV['ADAPTER'])
8
+ if %w[ postgres mysql sqlite oracle sqlserver ].include?(ENV['ADAPTER'])
10
9
 
11
10
  describe "require 'dm-transactions' before calling DataMapper.setup" do
12
- extend DataMapper::Spec::Adapters::Helpers
13
11
 
14
12
  before(:all) do
15
13
  require 'dm-transactions'
@@ -1,15 +1,15 @@
1
1
  shared_examples_for "require 'dm-transactions'" do
2
2
 
3
- %w[Repository Model Resource].each do |name|
3
+ %w[ Repository Model Resource ].each do |name|
4
4
  it "should include the transaction api in DataMapper::#{name}" do
5
- (DataMapper.const_get(name) < DataMapper::Transaction.const_get(name)).should be_true
5
+ (DataMapper.const_get(name) < DataMapper::Transaction.const_get(name)).should be(true)
6
6
  end
7
7
  end
8
8
 
9
9
  it "should include the transaction api into the adapter" do
10
- @adapter.respond_to?(:push_transaction ).should be_true
11
- @adapter.respond_to?(:pop_transaction ).should be_true
12
- @adapter.respond_to?(:current_transaction).should be_true
10
+ @adapter.respond_to?(:push_transaction ).should be(true)
11
+ @adapter.respond_to?(:pop_transaction ).should be(true)
12
+ @adapter.respond_to?(:current_transaction).should be(true)
13
13
  end
14
14
 
15
15
  end
@@ -93,10 +93,18 @@ describe DataMapper::Resource, 'Transactions' do
93
93
  it_should_behave_like 'A Resource supporting Strategic Eager Loading'
94
94
  end
95
95
 
96
- supported_by :postgres, :mysql, :sqlite3, :oracle, :sqlserver do
97
- describe '#transaction' do
96
+ describe '#transaction' do
97
+ before :all do
98
+ class ::Author
99
+ include DataMapper::Resource
100
+
101
+ property :name, String, :key => true
102
+ end
103
+ end
104
+
105
+ supported_by :postgres, :mysql, :sqlite, :oracle, :sqlserver do
98
106
  before do
99
- @user_model.all.destroy!
107
+ @user_model.destroy!
100
108
  end
101
109
 
102
110
  it 'should have access to resources presisted before the transaction' do
@@ -134,8 +142,8 @@ describe DataMapper::Resource, 'Transactions' do
134
142
  @txn = nil
135
143
 
136
144
  def doit
137
- @user_model.transaction do
138
- @txn = Thread.current[:dm_transactions].last
145
+ @user_model.transaction do |transaction|
146
+ @txn = transaction
139
147
  return
140
148
  end
141
149
  end
@@ -148,6 +156,33 @@ describe DataMapper::Resource, 'Transactions' do
148
156
  it 'should return the last statement in the transaction block' do
149
157
  @user_model.transaction { 1 }.should == 1
150
158
  end
159
+
160
+ with_alternate_adapter do
161
+ before :all do
162
+ class ::Article
163
+ include DataMapper::Resource
164
+
165
+ def self.default_repository_name
166
+ :alternate
167
+ end
168
+
169
+ property :title, String, :key => true
170
+ end
171
+
172
+ DataMapper.auto_migrate!(:alternate)
173
+ end
174
+
175
+ it 'should work with other repositories' do
176
+ expect {
177
+ DataMapper.repository.transaction.commit do
178
+ Author.create(:name => 'Dan Kubb')
179
+
180
+ # save a resource to another repository
181
+ Article.create(:title => 'DataMapper Rocks!')
182
+ end
183
+ }.should_not raise_error
184
+ end
185
+ end
151
186
  end
152
187
  end
153
188
  end
data/spec/rcov.opts CHANGED
@@ -1,4 +1,4 @@
1
- --exclude "spec"
1
+ --exclude "spec,^/"
2
2
  --sort coverage
3
3
  --callsites
4
4
  --xrefs
data/tasks/spec.rake CHANGED
@@ -35,4 +35,7 @@ rescue LoadError
35
35
  end
36
36
  end
37
37
 
38
+ task :spec => :check_dependencies
39
+ task :rcov => :check_dependencies
40
+
38
41
  task :default => :spec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-transactions
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
  - Dirkjan Bussink (dbussink)
@@ -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
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: 1.3.1
122
122
  requirements: []
123
123
 
124
- rubyforge_project:
124
+ rubyforge_project: datamapper
125
125
  rubygems_version: 1.3.7
126
126
  signing_key:
127
127
  specification_version: 3