trace_spy 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
  SHA256:
3
- metadata.gz: 3831d476b8d255dbec62c68b430fbd5733a8ff9a517c16d61a5be2ccac842a59
4
- data.tar.gz: 4247e3304fd6cb2ef1e81187e1a29e8457ca4225c6414d5a171aed34775739ca
3
+ metadata.gz: f438d726a80168f12bdf852bc190fb9c30dde90a12b3cb9fd63b9a650a209acc
4
+ data.tar.gz: a2096afab270481c50c3d0ba58bdbbe8b372bb2ebcb31e9d55c1fc352bd631a4
5
5
  SHA512:
6
- metadata.gz: 69c58ab72a6908eee036ecebbae4ee3b1337ef6d8baa921d2d885bc017781a86fa5ea09a4892b6a575b9d82e4190c8785c43b8af9825543e71c2c5c0208b4b9a
7
- data.tar.gz: 3226f8d53fd8cceb8403bfda5f90a5cfa3938d77c71bfbdcb5f131098e55fee9642492bd60028fb78d42cceb78423abbc5aedfa368328ea36957b020c953764c
6
+ metadata.gz: 3a8fa257ab7856e95835a6761772e78e09ee2df6f1dd080ea973216036d17c8a5480d9a9bbc587182c7ef2ad16b14e4d7b88b8659613d60d8bf09ef3ecb823ac
7
+ data.tar.gz: 1ab33f532bc2baaf669e943ebbf70a42c211a0a77ffcbc31b6bb9e37fa0ce2048f70edd1467bbb45dd28df06124536e32aa01d57ab3716869ccc0ea7f6b6ecb6
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ trace_spy (0.0.2)
5
+ qo (~> 0.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ any (0.1.0)
11
+ coderay (1.1.2)
12
+ diff-lcs (1.3)
13
+ ffi (1.10.0)
14
+ formatador (0.2.5)
15
+ guard (2.15.0)
16
+ formatador (>= 0.2.4)
17
+ listen (>= 2.7, < 4.0)
18
+ lumberjack (>= 1.0.12, < 2.0)
19
+ nenv (~> 0.1)
20
+ notiffany (~> 0.0)
21
+ pry (>= 0.9.12)
22
+ shellany (~> 0.0)
23
+ thor (>= 0.18.1)
24
+ guard-compat (1.2.1)
25
+ guard-rspec (4.7.3)
26
+ guard (~> 2.1)
27
+ guard-compat (~> 1.1)
28
+ rspec (>= 2.99.0, < 4.0)
29
+ listen (3.1.5)
30
+ rb-fsevent (~> 0.9, >= 0.9.4)
31
+ rb-inotify (~> 0.9, >= 0.9.7)
32
+ ruby_dep (~> 1.2)
33
+ lumberjack (1.0.13)
34
+ method_source (0.9.2)
35
+ nenv (0.3.0)
36
+ notiffany (0.1.1)
37
+ nenv (~> 0.1)
38
+ shellany (~> 0.0)
39
+ pry (0.12.2)
40
+ coderay (~> 1.1.0)
41
+ method_source (~> 0.9.0)
42
+ qo (0.5.0)
43
+ any (= 0.1.0)
44
+ rake (10.5.0)
45
+ rb-fsevent (0.10.3)
46
+ rb-inotify (0.10.0)
47
+ ffi (~> 1.0)
48
+ rspec (3.8.0)
49
+ rspec-core (~> 3.8.0)
50
+ rspec-expectations (~> 3.8.0)
51
+ rspec-mocks (~> 3.8.0)
52
+ rspec-core (3.8.0)
53
+ rspec-support (~> 3.8.0)
54
+ rspec-expectations (3.8.2)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.8.0)
57
+ rspec-mocks (3.8.0)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.8.0)
60
+ rspec-support (3.8.0)
61
+ ruby_dep (1.5.0)
62
+ shellany (0.0.1)
63
+ thor (0.20.3)
64
+
65
+ PLATFORMS
66
+ ruby
67
+
68
+ DEPENDENCIES
69
+ bundler (~> 1.17)
70
+ guard-rspec (~> 4.0)
71
+ rake (~> 10.0)
72
+ rspec (~> 3.0)
73
+ trace_spy!
74
+
75
+ BUNDLED WITH
76
+ 1.17.2
data/README.md CHANGED
@@ -63,26 +63,37 @@ testing_spy = TraceSpy::Method.new(:testing) do |spy|
63
63
  end
64
64
  end
65
65
 
66
- testing_spy.enable
67
- # => false
66
+ # If you want to manually enable/disable the trace, use:
67
+ #
68
+ # testing_spy.enable
69
+ # testing_spy.disable
70
+ #
71
+ # Otherwise, use:
72
+
73
+ # Outside of this block, the trace is inactive:
74
+ testing_spy.with_tracing do
75
+ p testing(1, 2, 3)
76
+ # My args were 1, 2, 3: {:a=>1, :b=>2, :c=>3}
77
+ # I got an even return: 6
78
+ # => 6
79
+
80
+ p testing(21, 2, 3) rescue 'nope'
81
+ # I encountered an error: heck
82
+ # => 'nope'
83
+
84
+ p testing(*%w(foo bar baz))
85
+ # Oh hey! You called me with strings: {:a=>"foo", :b=>"bar", :c=>"baz"}
86
+ # Strings in, Strings out no?: foobarbaz
87
+ # => 'foobarbaz'
88
+
89
+ p testing(1, 2, 4)
90
+ # I saw d was a local in here!: {:a=>1, :b=>2, :c=>4, :d=>5}
91
+ # => 7
92
+ end
68
93
 
69
- p testing(1, 2, 3)
70
- # My args were 1, 2, 3: {:a=>1, :b=>2, :c=>3}
71
- # I got an even return: 6
94
+ # Back to normal
95
+ testing(1, 2, 3)
72
96
  # => 6
73
-
74
- p testing(21, 2, 3) rescue 'nope'
75
- # I encountered an error: heck
76
- # => 'nope'
77
-
78
- p testing(*%w(foo bar baz))
79
- # Oh hey! You called me with strings: {:a=>"foo", :b=>"bar", :c=>"baz"}
80
- # Strings in, Strings out no?: foobarbaz
81
- # => 'foobarbaz'
82
-
83
- p testing(1, 2, 4)
84
- # I saw d was a local in here!: {:a=>1, :b=>2, :c=>4, :d=>5}
85
- # => 7
86
97
  ```
87
98
 
88
99
  ## Installation
@@ -65,6 +65,37 @@ module TraceSpy
65
65
  yield(self) if block_given?
66
66
  end
67
67
 
68
+ # Allows to run a block of code in the context of a tracer with the
69
+ # convenient side-effect of not having to remember to turn it off
70
+ # afterwards.
71
+ #
72
+ # Tracer will only be active within the block, and will be disabled
73
+ # afterwards
74
+ #
75
+ # @since 0.0.3
76
+ #
77
+ # @example
78
+ # The tracer will only be active within the block:
79
+ #
80
+ # ```ruby
81
+ # tracer.with_tracing do
82
+ # # tasks
83
+ # end
84
+ # ```
85
+ #
86
+ # @param &traced_function [Proc]
87
+ # Function to execute with tracing enabled
88
+ #
89
+ # @return [TrueClass]
90
+ # Result of disabling the tracer
91
+ def with_tracing(&traced_function)
92
+ self.enable
93
+
94
+ yield
95
+
96
+ self.disable
97
+ end
98
+
68
99
  # Creates a Spy on function arguments
69
100
  #
70
101
  # @since 0.0.1
@@ -1,3 +1,3 @@
1
1
  module TraceSpy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "bundler", "~> 1.17"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "guard-rspec", "~> 4.0"
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trace_spy
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
  - Brandon Weaver
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
69
83
  description:
70
84
  email:
71
85
  - keystonelemur@gmail.com
@@ -78,6 +92,7 @@ files:
78
92
  - ".travis.yml"
79
93
  - CODE_OF_CONDUCT.md
80
94
  - Gemfile
95
+ - Gemfile.lock
81
96
  - LICENSE.txt
82
97
  - README.md
83
98
  - Rakefile