execute_with_rescue 0.0.1 → 0.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/.travis.yml CHANGED
@@ -1,13 +1,25 @@
1
+ # Send builds to container-based infrastructure
2
+ # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
3
+ sudo: false
1
4
  language: ruby
2
5
  cache:
3
- - bundler
6
+ - bundler
4
7
  rvm:
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.0
8
- - 2.1.1
8
+ - 2.1.10
9
+ - 2.2.6
10
+ - 2.3.3
11
+ - ruby-head
9
12
  gemfile:
10
- - gemfiles/rails_3_2.gemfile
11
13
  - gemfiles/rails_4_0.gemfile
12
14
  - gemfiles/rails_4_1.gemfile
15
+ - gemfiles/rails_4_2.gemfile
16
+ matrix:
17
+ fast_finish: true
18
+ allow_failures:
19
+ - rvm: ruby-head
20
+ include:
21
+ - rvm: 2.3.3
22
+ gemfile: gemfiles/rails_5_0.gemfile
23
+ - rvm: ruby-head
24
+ gemfile: gemfiles/rails_5_0.gemfile
13
25
 
data/Appraisals CHANGED
@@ -1,11 +1,20 @@
1
- appraise "rails-3-2" do
2
- gem "activesupport", "3.2.17"
1
+ appraise "rails_4_0" do
2
+ version = "~> 4.0.12"
3
+ gem "activesupport", version
3
4
  end
4
5
 
5
- appraise "rails-4-0" do
6
- gem "activesupport", "4.0.4"
6
+ appraise "rails_4_1" do
7
+ version = "~> 4.1.8"
8
+ gem "activesupport", version
7
9
  end
8
10
 
9
- appraise "rails-4-1" do
10
- gem "activesupport", "4.1.0.rc1"
11
+ appraise "rails_4_2" do
12
+ version = "~> 4.2.0"
13
+ gem "activesupport", version
11
14
  end
15
+
16
+ appraise "rails_5_0" do
17
+ version = "~> 5.0.0"
18
+ gem "activesupport", version
19
+ end
20
+
data/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
- ### Changelog
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+
6
+ ## [Unreleased]
7
+
8
+ ### Added
9
+
10
+ - Nothing
11
+
12
+ ### Changed
13
+
14
+ - Nothing
15
+
16
+ ### Fixed
17
+
18
+ - Nothing
19
+
20
+
21
+ ## [0.0.2] - 2016-12-23
22
+
23
+ ### Changed
24
+
25
+ - Add support for AR 5.0.x
26
+ - Drop support for AR 3.x
27
+ - Drop support for Ruby < 2.1
28
+
29
+
30
+ ## 0.0.1 - 2014-03-26
31
+
32
+ ### Added
33
+
34
+ - Initial Release
35
+
36
+
37
+ [0.0.2]: https://github.com/AssetSync/asset_sync/compare/v0.0.2...HEAD
38
+ [Unreleased]: https://github.com/AssetSync/asset_sync/compare/v0.0.1...v0.0.2
2
39
 
3
40
 
4
- - **0.0.1**
5
- - Initail Release
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in execute_with_rescue.gemspec
3
+ # Specify your gem"s dependencies in execute_with_rescue.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -10,17 +10,13 @@ Calling `airbrake` manually sometimes is the best option, but not all the time.
10
10
  I might release another gem for that airbrake adapter.
11
11
 
12
12
 
13
- ## Support
14
- ===========
15
- Tested against:
16
- - Active Support of version `3.2`, `4.0` and `4.1` (pre-3.2 got wrong dependency & I don't want to support)
17
- - MRI `1.9.3`, `2.0.0`, `2.1.0`, `2.1.1`
18
-
19
- [![Build Status](http://img.shields.io/travis/PikachuEXE/execute_with_rescue.svg)](https://travis-ci.org/PikachuEXE/execute_with_rescue)
20
- [![Gem Version](http://img.shields.io/gem/v/execute_with_rescue.svg)](http://badge.fury.io/rb/execute_with_rescue)
21
- [![Dependency Status](http://img.shields.io/gemnasium/PikachuEXE/execute_with_rescue.svg)](https://gemnasium.com/PikachuEXE/execute_with_rescue)
22
- [![Coverage Status](http://img.shields.io/coveralls/PikachuEXE/execute_with_rescue.svg)](https://coveralls.io/r/PikachuEXE/execute_with_rescue)
23
- [![Code Climate](http://img.shields.io/codeclimate/github/PikachuEXE/execute_with_rescue.svg)](https://codeclimate.com/github/PikachuEXE/execute_with_rescue)
13
+ ## Status
14
+
15
+ [![Build Status](http://img.shields.io/travis/PikachuEXE/execute_with_rescue.svg?style=flat-square)](https://travis-ci.org/PikachuEXE/execute_with_rescue)
16
+ [![Gem Version](http://img.shields.io/gem/v/execute_with_rescue.svg?style=flat-square)](http://badge.fury.io/rb/execute_with_rescue)
17
+ [![Dependency Status](http://img.shields.io/gemnasium/PikachuEXE/execute_with_rescue.svg?style=flat-square)](https://gemnasium.com/PikachuEXE/execute_with_rescue)
18
+ [![Coverage Status](http://img.shields.io/coveralls/PikachuEXE/execute_with_rescue.svg?style=flat-square)](https://coveralls.io/r/PikachuEXE/execute_with_rescue)
19
+ [![Code Climate](http://img.shields.io/codeclimate/github/PikachuEXE/execute_with_rescue.svg?style=flat-square)](https://codeclimate.com/github/PikachuEXE/execute_with_rescue)
24
20
 
25
21
 
26
22
  ## Installation
data/Rakefile CHANGED
@@ -1,16 +1,18 @@
1
- require "bundler/gem_tasks"
2
- require "rubygems"
3
- require "bundler/setup"
4
-
5
- require "rspec/core/rake_task"
6
1
  require "appraisal"
2
+ require "bundler"
3
+ require "rspec/core/rake_task"
4
+ require "rubocop/rake_task"
5
+
6
+ Bundler::GemHelper.install_tasks
7
7
 
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
+ RuboCop::RakeTask.new(:rubocop)
11
+
10
12
  if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
11
13
  task :default do
12
- sh "rake appraisal:install && rake appraisal spec"
14
+ sh "appraisal install && rake appraisal spec"
13
15
  end
14
16
  else
15
- task :default => :spec
17
+ task default: [:spec]
16
18
  end
@@ -1,18 +1,21 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'execute_with_rescue/version'
4
+ require "execute_with_rescue/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "execute_with_rescue"
8
8
  spec.version = ExecuteWithRescue::VERSION
9
9
  spec.authors = ["PikachuEXE"]
10
10
  spec.email = ["pikachuexe@gmail.com"]
11
- spec.summary = %q{Execute code without writting rescue in methods with before and after hooks. You can also create some extensions yourself.}
12
- spec.description = <<-DESC
13
- Saves your from writing `begin...rescue...ensure...end` everywhere.
14
- This assumes you know how to use `rescue_from` not just within a controller.
15
- DESC
11
+ spec.summary = <<-SUMMARY
12
+ Execute code without writting rescue in methods with before and after hooks.
13
+ You can also create some extensions yourself.
14
+ SUMMARY
15
+ spec.description = <<-DESC
16
+ Saves your from writing `begin...rescue...ensure...end` everywhere.
17
+ This assumes you know how to use `rescue_from` not just within a controller.
18
+ DESC
16
19
  spec.homepage = "http://github.com/PikachuEXE/execute_with_rescue"
17
20
  spec.license = "MIT"
18
21
 
@@ -21,16 +24,18 @@ Gem::Specification.new do |spec|
21
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
25
  spec.require_paths = ["lib"]
23
26
 
24
- spec.add_dependency "activesupport", ">= 3.2.0", "< 5.0.0"
27
+ spec.add_dependency "activesupport", ">= 4.0.0", "< 5.1.0"
25
28
 
26
29
  spec.add_development_dependency "bundler", "~> 1.5"
27
- spec.add_development_dependency "rake"
28
- spec.add_development_dependency "appraisal", ">= 0.5.2"
29
- spec.add_development_dependency "rspec", "~> 2.14.0"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "appraisal", "~> 2.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "rspec-its", "~> 1.0"
30
34
  spec.add_development_dependency "coveralls", ">= 0.7"
31
35
  spec.add_development_dependency "gem-release", ">= 0.7"
36
+ spec.add_development_dependency "rubocop", "~> 0.30"
32
37
 
33
- spec.required_ruby_version = ">= 1.9.3"
38
+ spec.required_ruby_version = ">= 2.1.0"
34
39
 
35
40
  spec.required_rubygems_version = ">= 1.4.0"
36
41
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "4.0.4"
5
+ gem "activesupport", "~> 4.0.12"
6
6
 
7
- gemspec :path=>"../"
7
+ gemspec :path => "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "4.1.0.rc1"
5
+ gem "activesupport", "~> 4.1.8"
6
6
 
7
- gemspec :path=>"../"
7
+ gemspec :path => "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "3.2.17"
5
+ gem "activesupport", "~> 4.2.0"
6
6
 
7
- gemspec :path=>"../"
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 5.0.0"
6
+
7
+ gemspec :path => "../"
@@ -1,8 +1,8 @@
1
- require 'active_support/concern'
2
- require 'active_support/rescuable'
3
- require 'active_support/core_ext/class/attribute'
1
+ require "active_support/concern"
2
+ require "active_support/rescuable"
3
+ require "active_support/core_ext/class/attribute"
4
4
 
5
- require 'execute_with_rescue/errors'
5
+ require "execute_with_rescue/errors"
6
6
 
7
7
  module ExecuteWithRescue
8
8
  module Mixins
@@ -13,13 +13,17 @@ module ExecuteWithRescue
13
13
  include ActiveSupport::Rescuable
14
14
 
15
15
  # Use active support or inheritance will be broken
16
- class_attribute :_execute_with_rescue_before_hooks,
17
- instance_reader: true,
18
- instance_writer: false
16
+ class_attribute(
17
+ :_execute_with_rescue_before_hooks,
18
+ instance_reader: true,
19
+ instance_writer: false,
20
+ )
19
21
  self._execute_with_rescue_before_hooks = []
20
- class_attribute :_execute_with_rescue_after_hooks,
21
- instance_reader: true,
22
- instance_writer: false
22
+ class_attribute(
23
+ :_execute_with_rescue_after_hooks,
24
+ instance_reader: true,
25
+ instance_writer: false,
26
+ )
23
27
  self._execute_with_rescue_after_hooks = []
24
28
 
25
29
  class << self
@@ -45,14 +49,16 @@ module ExecuteWithRescue
45
49
  # Must use setter to avoid changing parent setting
46
50
  self._execute_with_rescue_before_hooks =
47
51
  [
48
- self._execute_with_rescue_before_hooks,
52
+ _execute_with_rescue_before_hooks,
49
53
  # Add method names first, block later
50
54
  method_names,
51
55
  block,
52
56
  ].flatten.compact
53
57
  end
54
- alias_method :add_execute_with_rescue_before_hook,
55
- :add_execute_with_rescue_before_hooks
58
+ alias_method(
59
+ :add_execute_with_rescue_before_hook,
60
+ :add_execute_with_rescue_before_hooks,
61
+ )
56
62
 
57
63
  # Pass method names or/and a block to be executed after yield
58
64
  # Similar to add_execute_with_rescue_before_hooks
@@ -64,23 +70,25 @@ module ExecuteWithRescue
64
70
  # Must use setter to avoid changing parent setting
65
71
  self._execute_with_rescue_after_hooks =
66
72
  [
67
- self._execute_with_rescue_after_hooks,
73
+ _execute_with_rescue_after_hooks,
68
74
  # Add method names first, block later
69
75
  method_names,
70
76
  block,
71
77
  ].flatten.compact
72
78
  end
73
- alias_method :add_execute_with_rescue_after_hook,
74
- :add_execute_with_rescue_after_hooks
79
+ alias_method(
80
+ :add_execute_with_rescue_after_hook,
81
+ :add_execute_with_rescue_after_hooks,
82
+ )
75
83
 
76
- # @private
84
+ # @api private
77
85
  # @discuss
78
86
  # Should this moved into another module?
79
87
  # (without being mixed in)
80
88
  def _validate_execute_with_rescue_hook!(method_names, block)
81
- raise ArgumentError if (method_names.empty? && block.nil?)
82
- raise ExecuteWithRescue::Errors::UnsupportedHookValue unless
83
- method_names.all?{|m| m.is_a?(Symbol)}
89
+ fail ArgumentError if method_names.empty? && block.nil?
90
+ fail ExecuteWithRescue::Errors::UnsupportedHookValue unless
91
+ method_names.all? { |m| m.is_a?(Symbol) }
84
92
  end
85
93
  end
86
94
  end
@@ -91,7 +99,7 @@ module ExecuteWithRescue
91
99
  # after you have call `rescue_from` at class level
92
100
  # This saves you from typing:
93
101
  # ```
94
- # being
102
+ # begin
95
103
  # # Some code that might cause exception
96
104
  # rescue
97
105
  # rescue_with_handler(exception) || raise
@@ -102,6 +110,8 @@ module ExecuteWithRescue
102
110
  # You can use `alias_method` to create a shorter alias, I use `execute`
103
111
  # But some gem might use that name already, so be careful
104
112
  #
113
+ # @api
114
+ #
105
115
  # @param block [Proc]
106
116
  # a block to be executed
107
117
  #
@@ -129,44 +139,46 @@ module ExecuteWithRescue
129
139
  _run_execute_with_rescue_before_hooks
130
140
  yield
131
141
  rescue Exception => exception
132
- rescue_with_handler(exception) || raise
142
+ rescue_with_handler(exception) || fail
133
143
  ensure
134
144
  _run_execute_with_rescue_after_hooks
135
145
  end
136
146
 
137
- # @private
147
+ # @api private
138
148
  def _run_execute_with_rescue_before_hooks
139
149
  _execute_with_rescue_before_hooks.each do |before_hook|
140
150
  _run_execute_with_rescue_hook(before_hook)
141
151
  end
142
152
  end
143
153
 
144
- # @private
154
+ # @api private
145
155
  def _run_execute_with_rescue_after_hooks
146
- _execute_with_rescue_after_hooks.reverse.each do |after_hook|
156
+ _execute_with_rescue_after_hooks.reverse_each do |after_hook|
147
157
  _run_execute_with_rescue_hook(after_hook)
148
158
  end
149
159
  end
150
160
 
151
- # @private
161
+ # @api private
152
162
  def _run_execute_with_rescue_hook(method_name_or_block)
153
163
  case method_name_or_block
154
164
  when Symbol
155
- begin
156
- self.send(method_name_or_block)
157
- rescue NoMethodError
158
- raise ExecuteWithRescue::Errors::NoHookMethod,
159
- "method `#{method_name_or_block}` does not exists"
160
- end
161
- # block are converted to Proc as argument
165
+ _run_execute_with_rescue_hook_with_symbol(method_name_or_block)
162
166
  when Proc
167
+ # block are converted to Proc as argument
163
168
  instance_eval(&method_name_or_block)
164
169
  else
165
170
  # This should not happen unless someone tamper the class attribute
166
171
  # without using the provided methods
167
- raise ExecuteWithRescue::Errors::UnsupportedHookValue
172
+ fail ExecuteWithRescue::Errors::UnsupportedHookValue
168
173
  end
169
174
  end
175
+
176
+ def _run_execute_with_rescue_hook_with_symbol(method_name)
177
+ send(method_name)
178
+ rescue NoMethodError
179
+ fail ExecuteWithRescue::Errors::NoHookMethod,
180
+ "method `#{method_name}` does not exists"
181
+ end
170
182
  end
171
183
  end
172
184
  end
@@ -1,3 +1,3 @@
1
1
  module ExecuteWithRescue
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,6 +1,6 @@
1
- require 'execute_with_rescue/version'
2
- require 'execute_with_rescue/errors'
3
- require 'execute_with_rescue/mixins/core'
1
+ require "execute_with_rescue/version"
2
+ require "execute_with_rescue/errors"
3
+ require "execute_with_rescue/mixins/core"
4
4
 
5
5
  module ExecuteWithRescue
6
6
  end