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 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 'activesupport', :require => 'active_support'
11
- end
7
+ gem 'activerecord', '~>3', :require => 'active_record'
8
+ end
@@ -1,37 +1,39 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activerecord (2.3.9)
5
- activesupport (= 2.3.9)
6
- activesupport (2.3.9)
7
- diff-lcs (1.1.2)
8
- gemcutter (0.6.1)
9
- git (1.2.5)
10
- jeweler (1.4.0)
11
- gemcutter (>= 0.1.0)
12
- git (>= 1.2.5)
13
- rubyforge (>= 2.0.0)
14
- json_pure (1.4.6)
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.8.7)
17
- rspec (2.5.0)
18
- rspec-core (~> 2.5.0)
19
- rspec-expectations (~> 2.5.0)
20
- rspec-mocks (~> 2.5.0)
21
- rspec-core (2.5.1)
22
- rspec-expectations (2.5.0)
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.5.0)
25
- rubyforge (2.0.4)
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 (~> 2)
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 'rspec/core/rake_task'
1
+ require 'bundler/gem_tasks'
2
2
 
3
- task :default => :spec
3
+ task :spec do
4
+ sh "rspec spec"
5
+ end
4
6
 
5
- RSpec::Core::RakeTask.new do |t|
6
- t.rspec_opts = ['--color']
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
- begin
10
- require 'jeweler'
11
- Jeweler::Tasks.new do |gem|
12
- gem.name = 'ar_after_transaction'
13
- gem.summary = "Execute irreversible actions only when transactions are not rolled back"
14
- gem.email = "michael@grosser.it"
15
- gem.homepage = "http://github.com/grosser/#{gem.name}"
16
- gem.authors = ["Michael Grosser"]
17
- gem.add_dependency ['activerecord']
18
- end
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
- Jeweler::GemcutterTasks.new
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
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
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.name = %q{ar_after_transaction}
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.date = %q{2011-02-18}
13
- s.email = %q{michael@grosser.it}
14
- s.files = [
15
- "Gemfile",
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
-
@@ -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(&block)
13
+ super
16
14
  rescue Exception
17
15
  clean = false
18
16
  raise
@@ -0,0 +1,3 @@
1
+ module ARAfterTransaction
2
+ VERSION = Version = '0.2.4'
3
+ end
@@ -1,4 +1,4 @@
1
- require "spec/spec_helper"
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
@@ -1,4 +1,4 @@
1
- require 'rubygems'
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
- hash: 21
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
- date: 2011-02-18 00:00:00 +01:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
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
- hash: 3
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
- name: activerecord
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
- - --charset=UTF-8
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
- hash: 3
70
- segments:
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ segments:
71
55
  - 0
72
- version: "0"
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
- hash: 3
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.4.2
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