object_callbacks 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b4bd4296621d3dd1cb16c9658c57be68ca44bf8
4
- data.tar.gz: b42a83a5d4099ee1a2d81366d6f819204d2d17cd
3
+ metadata.gz: 9f90879032ff0ba9eb0606c687610c2bc2ff5b10
4
+ data.tar.gz: 6b6c30a51cd2ceab06602327431697ae791ad049
5
5
  SHA512:
6
- metadata.gz: 000d5624150fd158cb41d501e1c4dd2f6009e434a18aeb3e1b003f0f84091e00c811e8b7c5bdbc226cf80b22479ca4c26c06c60a7b86788e6fcb898894e39608
7
- data.tar.gz: 4470d2c1a788f7c1f9dfac8cd62d06fb3c93f47a40257511703f22aa3a4fcd92ed937446d55ccf60b4cf50cd2d9a78bc9aef1b182e05c0a34b0ca4fe93557b84
6
+ metadata.gz: 81fd008363e8c4f4525f88755a4feca7b2c34f0fa771050d61dcfee5f01b067cc315c23e83f637926d484f74cd6af6e5313e48725678c7d6d3347e4f7e886449
7
+ data.tar.gz: 0976bb6b2b80ae755a5231999ee8e4c5212927fcbafd55dae009748fa054849b7cc9cdeee825bf378fc35585e83857272f7da021fa26250b51468d4c623a0a12
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .ruby-version
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.3
5
+ - rbx-2.4.1
6
+ addons:
7
+ code_climate:
8
+ repo_token: 2eb7a954168cf294c4e768b51e0bab0de16e26ce45ac9a4873cd800342ae7164
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'pry'
4
+ gem 'pry', :require => nil, :platforms => [:ruby_19]
5
5
  end
6
6
 
7
+ gem "codeclimate-test-reporter", :group => :test, :require => nil, :platforms => [:ruby_19]
8
+
7
9
  gemspec
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # ObjectCallbacks
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/object_callbacks.svg)](http://badge.fury.io/rb/object_callbacks)
4
+ [![Build Status](https://travis-ci.org/raza/object_callbacks.svg)](https://travis-ci.org/raza/object_callbacks)
5
+ [![Code Climate](https://codeclimate.com/github/raza/object_callbacks/badges/gpa.svg)](https://codeclimate.com/github/raza/object_callbacks)
6
+ [![Test Coverage](https://codeclimate.com/github/raza/object_callbacks/badges/coverage.svg)](https://codeclimate.com/github/raza/object_callbacks)
4
7
 
5
8
  ActiveRecord's callbacks basic functionality, similar to BeforeFilters [**https://github.com/IDme/before_filters**] gem, with after_call and better :only, and :except clauses control.
6
9
 
@@ -32,8 +35,8 @@ class MyClass
32
35
  extend ObjectCallbacks
33
36
 
34
37
  before_call :sit_down
35
- before_call :drink_one_glass, only: [:sleep]
36
- after_call :drink_four_glasses, only: [:wake_up]
38
+ before_call :drink_one_glass, :only => [:sleep]
39
+ after_call :drink_four_glasses, :only => [:wake_up]
37
40
 
38
41
  def sleep
39
42
  puts 'Go to sleep'
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ require "rspec/core/rake_task"
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :test => :spec
7
+ task :default => :spec
@@ -3,10 +3,10 @@ require 'object_callbacks'
3
3
  class MyClass
4
4
  extend ObjectCallbacks
5
5
 
6
- before_call :before_callback_1, only: [:action1]
7
- before_call :before_callback_2, only: [:action1]
8
- before_call :before_callback_3, only: [:action1]
9
- after_call :after_call_1, only: [:action1]
6
+ before_call :before_callback_1, :only => [:action1]
7
+ before_call :before_callback_2, :only => [:action1]
8
+ before_call :before_callback_3, :only => [:action1]
9
+ after_call :after_call_1, :only => [:action1]
10
10
 
11
11
  def action1
12
12
  puts 'action1 called'
@@ -68,18 +68,18 @@ module ObjectCallbacks
68
68
  end
69
69
 
70
70
  def callbacks_for_all(callbacks)
71
- callbacks.select { |_key, value| value.empty? }.keys
71
+ callbacks.to_a.select{|key, value| value.empty?}.map(&:first)
72
72
  end
73
73
 
74
74
  def only_callbacks(callbacks, action_name)
75
- callbacks.select do |_key, value|
75
+ callbacks.to_a.select do |_key, value|
76
76
  !value[:only].nil? && value[:only].include?(action_name)
77
- end.keys
77
+ end.map(&:first)
78
78
  end
79
79
 
80
80
  def except_callbacks(callbacks, action_name)
81
- callbacks.select do |_key, value|
81
+ callbacks.to_a.select do |_key, value|
82
82
  !value[:except].nil? && !value[:except].include?(action_name)
83
- end.keys
83
+ end.map(&:first)
84
84
  end
85
85
  end
@@ -1,3 +1,3 @@
1
1
  module ObjectCallbacks
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,12 +1,12 @@
1
+ require 'spec_helper'
1
2
  require 'object_callbacks'
2
- require 'pry'
3
3
 
4
4
  class MyClass
5
5
  extend ObjectCallbacks
6
6
 
7
7
  before_call :sit_down
8
- before_call :drink_one_glass, only: [:sleep]
9
- after_call :drink_four_glasses, only: [:wake_up]
8
+ before_call :drink_one_glass, :only => [:sleep]
9
+ after_call :drink_four_glasses, :only => [:wake_up]
10
10
 
11
11
  def sleep
12
12
  'Go to sleep'
@@ -35,17 +35,17 @@ describe ObjectCallbacks do
35
35
  subject { MyClass.new }
36
36
  describe '#sleep' do
37
37
  it 'calls sit_down' do
38
- subject.should_receive(:sit_down)
38
+ expect(subject).to receive(:sit_down)
39
39
  subject.sleep
40
40
  end
41
41
 
42
42
  it 'drinks one glass' do
43
- subject.should_receive(:drink_one_glass)
43
+ expect(subject).to receive(:drink_one_glass)
44
44
  subject.sleep
45
45
  end
46
46
 
47
47
  it 'should not drink four glasses' do
48
- subject.should_not_receive(:drink_four_glasses)
48
+ expect(subject).to_not receive(:drink_four_glasses)
49
49
  subject.sleep
50
50
  end
51
51
  end
@@ -0,0 +1,13 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ if RUBY_VERSION == '1.9.3'
5
+ require 'pry'
6
+ if ENV['CODECLIMATE_REPO_TOKEN']
7
+ require "codeclimate-test-reporter"
8
+ CodeClimate::TestReporter.start
9
+ end
10
+ end
11
+
12
+ # RSpec.configure do |config|
13
+ # end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_callbacks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raza Ali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-23 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - ".travis.yml"
63
64
  - Gemfile
64
65
  - LICENSE.txt
65
66
  - README.md
@@ -68,7 +69,8 @@ files:
68
69
  - lib/object_callbacks.rb
69
70
  - lib/object_callbacks/version.rb
70
71
  - object_callbacks.gemspec
71
- - spec/before_call_spec.rb
72
+ - spec/callbacks_spec.rb
73
+ - spec/spec_helper.rb
72
74
  homepage: https://github.com/raza/object_callbacks
73
75
  licenses:
74
76
  - MIT
@@ -94,4 +96,5 @@ signing_key:
94
96
  specification_version: 4
95
97
  summary: Ruby object method callbacks
96
98
  test_files:
97
- - spec/before_call_spec.rb
99
+ - spec/callbacks_spec.rb
100
+ - spec/spec_helper.rb