ar_after_transaction 0.2.1 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -5
- data/Gemfile.lock +26 -24
- data/Rakefile +18 -17
- data/Readme.md +9 -1
- data/ar_after_transaction.gemspec +8 -47
- data/lib/ar_after_transaction.rb +2 -4
- data/lib/ar_after_transaction/version.rb +3 -0
- data/spec/ar_after_transaction_spec.rb +5 -1
- data/spec/spec_helper.rb +4 -4
- metadata +33 -56
- data/VERSION +0 -1
data/Gemfile
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
gem 'activerecord', '~>2', :require => 'active_record'
|
4
|
-
|
5
3
|
group :dev do
|
6
4
|
gem 'rake'
|
7
5
|
gem 'rspec', '~>2'
|
8
|
-
gem 'jeweler'
|
9
6
|
gem 'mysql'
|
10
|
-
gem '
|
11
|
-
end
|
7
|
+
gem 'activerecord', '~>3', :require => 'active_record'
|
8
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,37 +1,39 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
activesupport (=
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
activemodel (3.1.3)
|
5
|
+
activesupport (= 3.1.3)
|
6
|
+
builder (~> 3.0.0)
|
7
|
+
i18n (~> 0.6)
|
8
|
+
activerecord (3.1.3)
|
9
|
+
activemodel (= 3.1.3)
|
10
|
+
activesupport (= 3.1.3)
|
11
|
+
arel (~> 2.2.1)
|
12
|
+
tzinfo (~> 0.3.29)
|
13
|
+
activesupport (3.1.3)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
arel (2.2.1)
|
16
|
+
builder (3.0.0)
|
17
|
+
diff-lcs (1.1.3)
|
18
|
+
i18n (0.6.0)
|
19
|
+
multi_json (1.0.4)
|
15
20
|
mysql (2.8.1)
|
16
|
-
rake (0.
|
17
|
-
rspec (2.
|
18
|
-
rspec-core (~> 2.
|
19
|
-
rspec-expectations (~> 2.
|
20
|
-
rspec-mocks (~> 2.
|
21
|
-
rspec-core (2.
|
22
|
-
rspec-expectations (2.
|
21
|
+
rake (0.9.2.2)
|
22
|
+
rspec (2.8.0)
|
23
|
+
rspec-core (~> 2.8.0)
|
24
|
+
rspec-expectations (~> 2.8.0)
|
25
|
+
rspec-mocks (~> 2.8.0)
|
26
|
+
rspec-core (2.8.0)
|
27
|
+
rspec-expectations (2.8.0)
|
23
28
|
diff-lcs (~> 1.1.2)
|
24
|
-
rspec-mocks (2.
|
25
|
-
|
26
|
-
json_pure (>= 1.1.7)
|
29
|
+
rspec-mocks (2.8.0)
|
30
|
+
tzinfo (0.3.31)
|
27
31
|
|
28
32
|
PLATFORMS
|
29
33
|
ruby
|
30
34
|
|
31
35
|
DEPENDENCIES
|
32
|
-
activerecord (~>
|
33
|
-
activesupport
|
34
|
-
jeweler
|
36
|
+
activerecord (~> 3)
|
35
37
|
mysql
|
36
38
|
rake
|
37
39
|
rspec (~> 2)
|
data/Rakefile
CHANGED
@@ -1,23 +1,24 @@
|
|
1
|
-
require '
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
|
3
|
-
task :
|
3
|
+
task :spec do
|
4
|
+
sh "rspec spec"
|
5
|
+
end
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
task :default do
|
8
|
+
sh "RAILS='~>2' && (bundle || bundle install) && bundle exec rake spec"
|
9
|
+
sh "RAILS='~>3' && (bundle || bundle install) && bundle exec rake spec"
|
7
10
|
end
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
rule /^version:bump:.*/ do |t|
|
13
|
+
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
|
14
|
+
index = ['major', 'minor','patch'].index(t.name.split(':').last)
|
15
|
+
file = 'lib/youtube_search/version.rb'
|
16
|
+
|
17
|
+
version_file = File.read(file)
|
18
|
+
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
|
19
|
+
version_parts[index] = version_parts[index].to_i + 1
|
20
|
+
new_version = version_parts * '.'
|
21
|
+
File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
|
19
22
|
|
20
|
-
|
21
|
-
rescue LoadError
|
22
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
23
|
+
sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
|
23
24
|
end
|
data/Readme.md
CHANGED
@@ -57,6 +57,14 @@ If you use transactional fixtures you should change it in test mode.
|
|
57
57
|
...
|
58
58
|
end
|
59
59
|
|
60
|
+
Alternative
|
61
|
+
===========
|
62
|
+
[after_commit](https://github.com/freelancing-god/after_commit)<br/>
|
63
|
+
+ threadsafe<br/>
|
64
|
+
+ more fine-grained callacks<br/>
|
65
|
+
- no instant `after_transaction do` support<br/>
|
66
|
+
- more complex<br/>
|
67
|
+
|
60
68
|
Authors
|
61
69
|
=======
|
62
70
|
[Original idea and code](https://rails.lighthouseapp.com/projects/8994/tickets/2991-after-transaction-patch) from [Jamis Buck](http://weblog.jamisbuck.org/) (post by Jeremy Kemper)
|
@@ -67,4 +75,4 @@ Authors
|
|
67
75
|
|
68
76
|
[Michael Grosser](http://grosser.it)<br/>
|
69
77
|
michael@grosser.it<br/>
|
70
|
-
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
78
|
+
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
@@ -1,50 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
require 'ar_after_transaction/version'
|
5
3
|
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.
|
8
|
-
s.version = "0.2.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
|
+
Gem::Specification.new "ar_after_transaction", ARAfterTransaction::VERSION do |s|
|
5
|
+
s.summary = "Execute irreversible actions only when transactions are not rolled back"
|
11
6
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.files =
|
15
|
-
|
16
|
-
"Gemfile.lock",
|
17
|
-
"Rakefile",
|
18
|
-
"Readme.md",
|
19
|
-
"VERSION",
|
20
|
-
"ar_after_transaction.gemspec",
|
21
|
-
"init.rb",
|
22
|
-
"lib/ar_after_transaction.rb",
|
23
|
-
"spec/ar_after_transaction_spec.rb",
|
24
|
-
"spec/setup_database.rb",
|
25
|
-
"spec/spec_helper.rb"
|
26
|
-
]
|
27
|
-
s.homepage = %q{http://github.com/grosser/ar_after_transaction}
|
28
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
29
|
-
s.require_paths = ["lib"]
|
30
|
-
s.rubygems_version = %q{1.4.2}
|
31
|
-
s.summary = %q{Execute irreversible actions only when transactions are not rolled back}
|
32
|
-
s.test_files = [
|
33
|
-
"spec/setup_database.rb",
|
34
|
-
"spec/spec_helper.rb",
|
35
|
-
"spec/ar_after_transaction_spec.rb"
|
36
|
-
]
|
37
|
-
|
38
|
-
if s.respond_to? :specification_version then
|
39
|
-
s.specification_version = 3
|
40
|
-
|
41
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
-
s.add_runtime_dependency(%q<activerecord>, [">= 0"])
|
43
|
-
else
|
44
|
-
s.add_dependency(%q<activerecord>, [">= 0"])
|
45
|
-
end
|
46
|
-
else
|
47
|
-
s.add_dependency(%q<activerecord>, [">= 0"])
|
48
|
-
end
|
7
|
+
s.email = "michael@grosser.it"
|
8
|
+
s.homepage = "http://github.com/grosser/ar_after_transaction"
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.add_runtime_dependency "activerecord"
|
49
11
|
end
|
50
|
-
|
data/lib/ar_after_transaction.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
|
3
3
|
module ARAfterTransaction
|
4
|
-
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
5
|
-
|
6
4
|
def self.included(base)
|
7
5
|
base.extend(ClassMethods)
|
8
6
|
end
|
@@ -10,9 +8,9 @@ module ARAfterTransaction
|
|
10
8
|
module ClassMethods
|
11
9
|
@@after_transaction_callbacks = []
|
12
10
|
|
13
|
-
def transaction(&block)
|
11
|
+
def transaction(*args, &block)
|
14
12
|
clean = true
|
15
|
-
super
|
13
|
+
super
|
16
14
|
rescue Exception
|
17
15
|
clean = false
|
18
16
|
raise
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
2
|
|
3
3
|
class AnExpectedError < Exception
|
4
4
|
end
|
@@ -99,6 +99,10 @@ describe ARAfterTransaction do
|
|
99
99
|
User.test_stack.should == [:normal, :normal]
|
100
100
|
end
|
101
101
|
|
102
|
+
it "does not crash with additional options" do
|
103
|
+
User.transaction(:requires_new => true){}
|
104
|
+
end
|
105
|
+
|
102
106
|
describe :normally_open_transactions do
|
103
107
|
it "uses 0 by default" do
|
104
108
|
User.normally_open_transactions.should == 0
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH << "lib"
|
3
|
-
require "init"
|
4
|
-
require "spec/setup_database"
|
1
|
+
current = File.dirname(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH << "#{current}/lib"
|
3
|
+
require "#{current}/init"
|
4
|
+
require "#{current}/spec/setup_database"
|
metadata
CHANGED
@@ -1,92 +1,69 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar_after_transaction
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 0.2.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Michael Grosser
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-01-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activerecord
|
16
|
+
requirement: &73628820 !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
prerelease: false
|
32
|
-
version_requirements: *id001
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *73628820
|
35
25
|
description:
|
36
26
|
email: michael@grosser.it
|
37
27
|
executables: []
|
38
|
-
|
39
28
|
extensions: []
|
40
|
-
|
41
29
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
30
|
+
files:
|
44
31
|
- Gemfile
|
45
32
|
- Gemfile.lock
|
46
33
|
- Rakefile
|
47
34
|
- Readme.md
|
48
|
-
- VERSION
|
49
35
|
- ar_after_transaction.gemspec
|
50
36
|
- init.rb
|
51
37
|
- lib/ar_after_transaction.rb
|
38
|
+
- lib/ar_after_transaction/version.rb
|
52
39
|
- spec/ar_after_transaction_spec.rb
|
53
40
|
- spec/setup_database.rb
|
54
41
|
- spec/spec_helper.rb
|
55
|
-
has_rdoc: true
|
56
42
|
homepage: http://github.com/grosser/ar_after_transaction
|
57
43
|
licenses: []
|
58
|
-
|
59
44
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
|
62
|
-
require_paths:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
63
47
|
- lib
|
64
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
49
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
segments:
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
segments:
|
71
55
|
- 0
|
72
|
-
|
73
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
hash: 297393871
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
58
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
version: "0"
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
82
63
|
requirements: []
|
83
|
-
|
84
64
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.
|
65
|
+
rubygems_version: 1.8.10
|
86
66
|
signing_key:
|
87
67
|
specification_version: 3
|
88
68
|
summary: Execute irreversible actions only when transactions are not rolled back
|
89
|
-
test_files:
|
90
|
-
- spec/setup_database.rb
|
91
|
-
- spec/spec_helper.rb
|
92
|
-
- spec/ar_after_transaction_spec.rb
|
69
|
+
test_files: []
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.1
|