callback_skipper 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1,5 @@
1
+ rvm use ree-1.8.7-2011.03@callback_skipper --create
2
+ if ! command -v bundle ; then
3
+ gem install bundler
4
+ bundle
5
+ fi
data/CONTRIBUTORS.txt ADDED
@@ -0,0 +1,4 @@
1
+ Ryan Sonnek - Original Author
2
+
3
+ Complete list of contributors:
4
+ https://github.com/wireframe/callback_skipper/contributors
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in callback_skipper.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Ryan Sonnek
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # callback_skipper
2
+
3
+ Programatically Skip ActiveRecord Callbacks
4
+
5
+ ## Features
6
+ * easily skip callbacks
7
+ * useful for unit testing to skip long running processes
8
+
9
+ ## Installation
10
+
11
+ gem 'callback_skipper'
12
+
13
+ ## Usage
14
+
15
+ ```ruby
16
+ class Foo < ActiveRecord::Base
17
+ after_create :do_something_expensive
18
+ end
19
+
20
+ foo = Foo.new
21
+ foo.skip_callback :save, :after, :do_something_expensive
22
+ foo.save!
23
+ ```
24
+ ### Example: FactoryGirl Usage
25
+
26
+ https://github.com/thoughtbot/factory_girl
27
+ ```ruby
28
+ # spec/factories/foo_factory.rb
29
+ Factory.define :foo do |f|
30
+ f.after_build do |o|
31
+ o.skip_callback :save, :after, :do_something_expensive
32
+ end
33
+ end
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ * Fork the project
39
+ * Fix the issue
40
+ * Add unit tests
41
+ * Submit pull request on github
42
+
43
+ See CONTRIBUTORS.txt for list of project contributors
44
+
45
+ ## Copyright
46
+
47
+ Copyright (c) 2011 Ryan Sonnek. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "callback_skipper/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "callback_skipper"
7
+ s.version = CallbackSkipper::VERSION
8
+ s.authors = ["Ryan Sonnek"]
9
+ s.email = ["ryan@codecrate.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Skip ActiveRecord callbacks}
12
+ s.description = %q{programatically skip ActiveRecord callbacks}
13
+
14
+ s.rubyforge_project = "callback_skipper"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here
22
+ s.add_runtime_dependency 'activerecord', ['>= 3.0']
23
+ s.add_development_dependency "rake", ["0.9.2.2"]
24
+ end
@@ -0,0 +1,3 @@
1
+ module CallbackSkipper
2
+ VERSION = "0.3.0"
3
+ end
@@ -0,0 +1,13 @@
1
+ require "callback_skipper/version"
2
+
3
+ module CallbackSkipper
4
+ extend ActiveSupport::Concern
5
+ module InstanceMethods
6
+ def skip_callback(*args)
7
+ instance = self
8
+ args << {:if => lambda { self == instance }}
9
+ self.class.skip_callback *args
10
+ end
11
+ end
12
+ end
13
+ ActiveRecord::Base.send :include, CallbackSkipper
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: callback_skipper
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
+ platform: ruby
12
+ authors:
13
+ - Ryan Sonnek
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-22 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activerecord
22
+ prerelease: false
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ version: "3.0"
33
+ requirement: *id001
34
+ type: :runtime
35
+ - !ruby/object:Gem::Dependency
36
+ name: rake
37
+ prerelease: false
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ hash: 11
44
+ segments:
45
+ - 0
46
+ - 9
47
+ - 2
48
+ - 2
49
+ version: 0.9.2.2
50
+ requirement: *id002
51
+ type: :development
52
+ description: programatically skip ActiveRecord callbacks
53
+ email:
54
+ - ryan@codecrate.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files: []
60
+
61
+ files:
62
+ - .gitignore
63
+ - .rvmrc
64
+ - CONTRIBUTORS.txt
65
+ - Gemfile
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - callback_skipper.gemspec
70
+ - lib/callback_skipper.rb
71
+ - lib/callback_skipper/version.rb
72
+ homepage: ""
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project: callback_skipper
101
+ rubygems_version: 1.8.5
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Skip ActiveRecord callbacks
105
+ test_files: []
106
+