binding-debug 0.2.0 → 0.3.0

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: 4dc80b554de30e00e748016f0e0f46bef5acfc7157249560465850b8816fd46c
4
- data.tar.gz: 4113961c5ed661c20c882c346b4ad88acf6b82e7c2b2d319bf22b5b516dc2633
3
+ metadata.gz: 7e0251b77cd35210d2c9320b8320507842f280102046baf5a7ee17954372be4e
4
+ data.tar.gz: 5a33a5870f093f2cd7fae013d45bcfcf12c7d05b5ac2cc6d651e0bf5d7ba4c25
5
5
  SHA512:
6
- metadata.gz: 0c324146dca90da0221e1961678fee5a4266775fcdb6d69495c65f70703672a34159d825e89a57c1be708618db9191bb2c465fe674eeba4a489b9b0d265f0a4c
7
- data.tar.gz: 2ff101b9ad0c26d294645c8b1cdf796e55524b42e81ae5d01001622fa1c3a53aaf0075261e4275782dce6210bad97af0aecd65084709ec467d56addc1fb45e4f
6
+ metadata.gz: '092c6941d2066486851bbc829e26201f437e1c9ab9298377b63846d80262e50089fd56038619be54d21849965dd4d7bab9e98e4c478fe80530c53ce82ed443e8'
7
+ data.tar.gz: 8d741ab842ac0b1038e44d4bc27211159da7b6716b296a8e2b78a55a0d6396acd06345267315ffe9640137693538a7f5bf14406576b1b5b4150188b1dc92668a
data/README.md CHANGED
@@ -37,14 +37,14 @@ end
37
37
 
38
38
  hoge = 42
39
39
  p binding.debug "hoge"
40
- # => "hoge : 42"
40
+ # => "hoge # => 42"
41
41
  p binding.debug %{ hoge }
42
42
 
43
43
  binding.p "hoge"
44
- # => "hoge : 42"
44
+ # => "hoge # => 42"
45
45
 
46
46
  binding.puts "hoge"
47
- # output: "hoge : 42"
47
+ # output: "hoge # => 42"
48
48
 
49
49
  # with format
50
50
  p binding.debug("hoge"){ |name, value| "#{name} - #{value}" }
@@ -56,7 +56,7 @@ p binding.debug("hoge"){ |name, value| "#{name} - #{value}" }
56
56
  #######################################
57
57
 
58
58
  binding.p "plus(1, 2)"
59
- # => "plus 1, 2 : 3"
59
+ # => "plus 1, 2 # => 3"
60
60
 
61
61
 
62
62
  #######################################
@@ -71,10 +71,10 @@ binding.puts %{
71
71
  foo.class.name
72
72
  }
73
73
  # output:
74
- # foo.to_s.upcase : HOMU
75
- # plus 1, 2 : 3
76
- # (0..20).to_a : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
77
- # foo.class.name : String
74
+ # foo.to_s.upcase # => HOMU
75
+ # plus 1, 2 # => 3
76
+ # (0..20).to_a # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
77
+ # foo.class.name # => String
78
78
  ```
79
79
 
80
80
  ### `puts` with blocks
@@ -98,10 +98,10 @@ puts {
98
98
  foo.class.name
99
99
  }
100
100
  # output:
101
- # foo.to_s.upcase : HOMU
102
- # plus 1, 2 : 3
103
- # (0..20).to_a : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
104
- # foo.class.name : String
101
+ # foo.to_s.upcase # => HOMU
102
+ # plus 1, 2 # => 3
103
+ # (0..20).to_a # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
104
+ # foo.class.name # => String
105
105
  ```
106
106
 
107
107
  Supported `Kernel.#p` , `Kernel.#pp`.
@@ -120,12 +120,17 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/osyo-m
120
120
 
121
121
  ## Release Note
122
122
 
123
+ #### 0.3.0
124
+
125
+ * Fix return values
126
+ * Change default format `expr : result` to `expr # => result`
127
+
123
128
  #### 0.2.0
124
129
 
125
130
  * Add `BindingDebug::Formats`
126
131
  * Add `Binding#pp`
127
132
  * Add with block in `Kernle.#puts` `Kernle.#p` `Kernle.#pp`
128
- * e.g `puts { value } # => "value : #{value}"`
133
+ * e.g `puts { value } # => "value # => #{value}"`
129
134
 
130
135
  #### 0.1.0
131
136
 
@@ -20,8 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_dependency "binding_of_caller"
24
-
25
23
  spec.add_development_dependency "bundler"
26
24
  spec.add_development_dependency "rake"
27
25
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -1,5 +1,4 @@
1
1
  require "binding/debug/version"
2
- require "binding_of_caller"
3
2
  require "pp"
4
3
 
5
4
  module BindingDebug
@@ -7,7 +6,7 @@ module BindingDebug
7
6
  module_function
8
7
 
9
8
  def default
10
- proc { |name, value| "#{name} : #{value}" }
9
+ proc { |name, value| "#{name} # => #{value}" }
11
10
  end
12
11
 
13
12
  def inspect formatter = default
@@ -34,14 +33,22 @@ module BindingDebug
34
33
 
35
34
  def p expr, &block
36
35
  block ||= Formats.default
37
- puts(expr){ |name, value| block.call name, value.inspect }
38
- expr
36
+ result = nil
37
+ puts(expr){ |name, value|
38
+ result = value; block.call name, value.inspect
39
+ }
40
+ result
39
41
  end
40
42
 
41
43
  def pp expr, &block
42
44
  block ||= Formats.default
43
- puts(expr){ |name, value| block.call name, value.pretty_inspect }
44
- expr
45
+ result = nil
46
+ puts(expr){ |name, value|
47
+ result = value
48
+ # MEMO: Remove \n in eol.
49
+ block.call name, value.pretty_inspect.rstrip
50
+ }
51
+ result
45
52
  end
46
53
 
47
54
  def puts expr, &block
@@ -117,17 +124,17 @@ module BindingDebug
117
124
 
118
125
  def puts(*args, &block)
119
126
  return super(*args) if block.nil?
120
- binding.of_caller(1).puts block.body
127
+ block.binding.puts block.body
121
128
  end
122
129
 
123
130
  def p(*args, &block)
124
131
  return super(*args) if block.nil?
125
- binding.of_caller(1).p block.body
132
+ block.binding.p block.body
126
133
  end
127
134
 
128
135
  def pp(*args, &block)
129
136
  return super(*args) if block.nil?
130
- binding.of_caller(1).pp block.body
137
+ block.binding.pp block.body
131
138
  end
132
139
  end
133
140
  end
@@ -1,3 +1,3 @@
1
1
  module BindingDebug
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binding-debug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - manga_osyo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2020-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: binding_of_caller
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -91,7 +77,7 @@ files:
91
77
  homepage: https://github.com/osyo-manga/gem-binding-debug
92
78
  licenses: []
93
79
  metadata: {}
94
- post_install_message:
80
+ post_install_message:
95
81
  rdoc_options: []
96
82
  require_paths:
97
83
  - lib
@@ -106,8 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
92
  - !ruby/object:Gem::Version
107
93
  version: '0'
108
94
  requirements: []
109
- rubygems_version: 3.1.2
110
- signing_key:
95
+ rubygems_version: 3.2.0.rc.1
96
+ signing_key:
111
97
  specification_version: 4
112
98
  summary: 'Debug output. `name : value`'
113
99
  test_files: []