ill_be_back 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.ruby-gemset +0 -0
- data/.ruby-version +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +17 -1
- data/Rakefile +0 -0
- data/ill_be_back.gemspec +1 -0
- data/lib/ill_be_back.rb +12 -15
- data/lib/ill_be_back/debug_strategies/at_call.rb +15 -0
- data/lib/ill_be_back/debug_strategies/between_calls.rb +16 -0
- data/lib/ill_be_back/debug_strategies/n_times.rb +21 -0
- data/lib/ill_be_back/ext.rb +2 -0
- data/lib/ill_be_back/ext/binding.rb +8 -0
- data/lib/ill_be_back/manager.rb +26 -4
- data/lib/ill_be_back/version.rb +1 -1
- data/spec/ill_be_back/manager_spec.rb +43 -1
- data/spec/spec_helper.rb +1 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 338a23f637953dec13498b792833215f432efaf7
|
4
|
+
data.tar.gz: f63401c7881cea45c26919108935d65bd380629d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79a2d1868a3a47ccf0e2ca91ea0760418c88418be1639d0ea6d85fbbbb8d7ce069180bc0a53f82fbe8ab2edf6d4e332090b995d19f52801ea9b18e41ca45a926
|
7
|
+
data.tar.gz: c8407937849885e507aee302bb5976f5631588bfc5f7523fce77e15d4d8877e8a91b8aa865986333c2c2447ff7642ca923b2c3bfaf57929e14dc099935864df6
|
data/.gitignore
CHANGED
File without changes
|
data/.ruby-gemset
CHANGED
File without changes
|
data/.ruby-version
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Thats what IllBeBack does.
|
|
8
8
|
|
9
9
|
gem 'ill_be_back'
|
10
10
|
|
11
|
-
##
|
11
|
+
## Basic usage
|
12
12
|
|
13
13
|
require 'pry'
|
14
14
|
require 'ill_be_back'
|
@@ -31,3 +31,19 @@ Thats what IllBeBack does.
|
|
31
31
|
|
32
32
|
model.magic # stops in pry, and then prints something
|
33
33
|
model.magic # back to normallity: prints something
|
34
|
+
|
35
|
+
## Advanced usage
|
36
|
+
|
37
|
+
IllBeBack.debug { binding.pry } # stops once after 'prepare!' call
|
38
|
+
IllBeBack.debug(2.times) { binding.pry } # stops twice after 'prepare!' call
|
39
|
+
IllBeBack.debug_at_call(4) { binding.pry } # stops at 4th call after 'prepare!' call
|
40
|
+
IllBeBack.debug_between_calls(2, 4) { binding.pry } # stops at calls 2, 3 and 4 after 'prepare!' call
|
41
|
+
IllBeBack.armed? # true if 'prepare!' was called
|
42
|
+
|
43
|
+
## Ext
|
44
|
+
|
45
|
+
require 'ill_be_back/ext'
|
46
|
+
binding.prepare!
|
47
|
+
binding.armed?
|
48
|
+
binding.debug { binding.pry }
|
49
|
+
# and etc...
|
data/Rakefile
CHANGED
File without changes
|
data/ill_be_back.gemspec
CHANGED
data/lib/ill_be_back.rb
CHANGED
@@ -1,26 +1,23 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
1
3
|
require 'ill_be_back/version'
|
2
4
|
require 'ill_be_back/manager'
|
5
|
+
require 'ill_be_back/debug_strategies/n_times'
|
6
|
+
require 'ill_be_back/debug_strategies/at_call'
|
7
|
+
require 'ill_be_back/debug_strategies/between_calls'
|
3
8
|
|
4
9
|
module IllBeBack
|
5
|
-
|
10
|
+
module ClassMethods
|
11
|
+
extend Forwardable
|
12
|
+
|
13
|
+
def_delegators :manager,
|
14
|
+
:prepare!, :armed?,
|
15
|
+
:debug, :debug_at_call, :debug_within_calls
|
6
16
|
|
7
17
|
def manager
|
8
18
|
@manager ||= Manager.new
|
9
19
|
end
|
10
20
|
|
11
|
-
# core methods
|
12
|
-
|
13
|
-
def prepare!
|
14
|
-
manager.prepare!
|
15
|
-
end
|
16
|
-
|
17
|
-
def armed?
|
18
|
-
manager.armed?
|
19
|
-
end
|
20
|
-
|
21
|
-
def debug(&block)
|
22
|
-
manager.debug(&block)
|
23
|
-
end
|
24
|
-
|
25
21
|
end
|
22
|
+
extend ClassMethods
|
26
23
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module IllBeBack
|
2
|
+
module DebugStrategies
|
3
|
+
class BetweenCalls
|
4
|
+
|
5
|
+
def initialize(start_call_number, end_call_number)
|
6
|
+
@start_call_number = start_call_number
|
7
|
+
@end_call_number = end_call_number
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(stops, block)
|
11
|
+
block.call if stops >= @start_call_number && stops <= @end_call_number
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module IllBeBack
|
2
|
+
module DebugStrategies
|
3
|
+
class NTimes
|
4
|
+
|
5
|
+
def self.from_enumerator(enumerator)
|
6
|
+
count = 0
|
7
|
+
enumerator.each { count += 1 }
|
8
|
+
new(count)
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(count)
|
12
|
+
@count = count
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(stops, block)
|
16
|
+
block.call unless stops > @count
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ill_be_back/manager.rb
CHANGED
@@ -1,18 +1,40 @@
|
|
1
1
|
module IllBeBack
|
2
2
|
class Manager
|
3
3
|
|
4
|
+
def initialize
|
5
|
+
@armed = false
|
6
|
+
end
|
7
|
+
|
4
8
|
def prepare!
|
9
|
+
@stops = 0
|
5
10
|
@armed = true
|
6
11
|
end
|
7
12
|
|
8
13
|
def armed?
|
9
|
-
|
14
|
+
@armed
|
10
15
|
end
|
11
16
|
|
12
|
-
def debug(&block)
|
17
|
+
def debug(n_times_enumerator = nil, &block)
|
18
|
+
strategy = DebugStrategies::NTimes.from_enumerator(n_times_enumerator || 1.times)
|
19
|
+
handle_call_with(strategy, block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def debug_at_call(call_number, &block)
|
23
|
+
strategy = DebugStrategies::AtCall.new(call_number)
|
24
|
+
handle_call_with(strategy, block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def debug_between_calls(start_call_number, end_call_number, &block)
|
28
|
+
strategy = DebugStrategies::BetweenCalls.new(start_call_number, end_call_number)
|
29
|
+
handle_call_with(strategy, block)
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def handle_call_with(strategy, block)
|
13
35
|
return unless armed?
|
14
|
-
|
15
|
-
@
|
36
|
+
@stops += 1
|
37
|
+
strategy.call(@stops, block)
|
16
38
|
end
|
17
39
|
|
18
40
|
end
|
data/lib/ill_be_back/version.rb
CHANGED
@@ -3,7 +3,49 @@ require 'spec_helper'
|
|
3
3
|
module IllBeBack
|
4
4
|
describe Manager do
|
5
5
|
|
6
|
-
|
6
|
+
let(:binding) { double 'binding' }
|
7
|
+
|
8
|
+
it 'should not debug' do
|
9
|
+
expect(binding).not_to receive(:pry)
|
10
|
+
subject.debug { binding.fruit } # not called
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should stop once' do
|
14
|
+
expect(binding).to receive(:pry).once.with(no_args)
|
15
|
+
subject.debug { binding.fruit } # not called
|
16
|
+
subject.prepare!
|
17
|
+
subject.debug { binding.pry } # called
|
18
|
+
subject.debug { binding.fruit } # not called
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should stop twice' do
|
22
|
+
expect(binding).to receive(:pry).twice.with(no_args)
|
23
|
+
subject.debug(2.times) { binding.fruit } # not called
|
24
|
+
subject.prepare!
|
25
|
+
subject.debug(2.times) { binding.pry } # called
|
26
|
+
subject.debug(2.times) { binding.pry } # called
|
27
|
+
subject.debug(2.times) { binding.fruit } # not called
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should stop at 2nd call' do
|
31
|
+
expect(binding).to receive(:pry).once.with(no_args)
|
32
|
+
subject.prepare!
|
33
|
+
subject.debug_at_call(2) { binding.fruit } # not called
|
34
|
+
subject.debug_at_call(2) { binding.pry } # called
|
35
|
+
subject.debug_at_call(2) { binding.fruit } # not called
|
36
|
+
subject.debug_at_call(2) { binding.fruit } # not called
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should stop between 2nd and 4th calls' do
|
40
|
+
expect(binding).to receive(:pry).at_least(3).times.with(no_args)
|
41
|
+
subject.prepare!
|
42
|
+
subject.debug_between_calls(2, 4) { binding.fruit } # not called
|
43
|
+
subject.debug_between_calls(2, 4) { binding.pry } # called
|
44
|
+
subject.debug_between_calls(2, 4) { binding.pry } # called
|
45
|
+
subject.debug_between_calls(2, 4) { binding.pry } # called
|
46
|
+
subject.debug_between_calls(2, 4) { binding.fruit } # not called
|
47
|
+
subject.debug_between_calls(2, 4) { binding.fruit } # not called
|
48
|
+
end
|
7
49
|
|
8
50
|
end
|
9
51
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ill_be_back
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pablo31
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Ill Be Back Longer description
|
56
70
|
email:
|
57
71
|
- psfutn@gmail.com
|
@@ -68,6 +82,11 @@ files:
|
|
68
82
|
- Rakefile
|
69
83
|
- ill_be_back.gemspec
|
70
84
|
- lib/ill_be_back.rb
|
85
|
+
- lib/ill_be_back/debug_strategies/at_call.rb
|
86
|
+
- lib/ill_be_back/debug_strategies/between_calls.rb
|
87
|
+
- lib/ill_be_back/debug_strategies/n_times.rb
|
88
|
+
- lib/ill_be_back/ext.rb
|
89
|
+
- lib/ill_be_back/ext/binding.rb
|
71
90
|
- lib/ill_be_back/manager.rb
|
72
91
|
- lib/ill_be_back/version.rb
|
73
92
|
- spec/ill_be_back/manager_spec.rb
|