cutter 0.5.4 → 0.5.5
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/lib/cutter.rb +10 -3
- data/lib/cutter/array.rb +6 -0
- data/lib/cutter/inspection.rb +27 -3
- metadata +4 -3
data/lib/cutter.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
-
require 'cutter/railtie' if defined?(Rails)
|
2
|
-
require 'cutter/inspection'
|
3
|
-
require 'cutter/stamper'
|
1
|
+
#require 'cutter/railtie' if defined?(Rails)
|
2
|
+
#require 'cutter/inspection'
|
3
|
+
#require 'cutter/stamper'
|
4
|
+
require 'cutter/array'
|
5
|
+
|
6
|
+
module Cutter
|
7
|
+
autoload :Railtie, 'cutter/railtie' if defined?(Rails)
|
8
|
+
autoload :Inspection, 'cutter/inspection'
|
9
|
+
autoload :Stamper, 'cutter/stamper'
|
10
|
+
end
|
data/lib/cutter/array.rb
ADDED
data/lib/cutter/inspection.rb
CHANGED
@@ -17,19 +17,43 @@ module Cutter
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class Object
|
20
|
-
|
20
|
+
|
21
|
+
# #inspect! may be called inside any method as 'inspect! {}' or more rigorous: 'inspect!(binding)'
|
21
22
|
# Binding is a Ruby class: http://www.ruby-doc.org/core/classes/Binding.html
|
22
23
|
|
23
|
-
def inspect!
|
24
|
+
def inspect! *options, &block
|
24
25
|
return true if Cutter::Inspection.quiet?
|
26
|
+
|
27
|
+
# Getting binding
|
28
|
+
_binding = options.first if options.first.class == Binding
|
25
29
|
raise ArgumentError, "Try inspect(binding) or inspect! {}", caller if (!block_given? && !_binding)
|
26
30
|
_binding ||= block.binding
|
27
|
-
|
31
|
+
|
32
|
+
# Want caller methods chain to be traced? - pass option :level to inspect!
|
33
|
+
options = options.extract_options!
|
34
|
+
level = options[:level]
|
35
|
+
_caller = caller
|
36
|
+
|
37
|
+
# Basic info
|
38
|
+
puts %|\nmethod: `#{eval('__method__', _binding)}'|
|
39
|
+
puts %| called from class: #{eval('self.class', _binding)}|
|
40
|
+
|
28
41
|
lvb = eval('local_variables',_binding)
|
29
42
|
puts %| variables: #{"[]" if lvb.empty?}|
|
30
43
|
lvb.map do |lv|
|
31
44
|
puts %| #{lv}: #{eval(lv.to_s, _binding)}|
|
32
45
|
end if lvb
|
46
|
+
|
47
|
+
# Caller methods chain
|
48
|
+
begin
|
49
|
+
puts %| caller methods: |
|
50
|
+
0.upto(level).each {|index|
|
51
|
+
puts %| #{_caller[index]}|
|
52
|
+
}
|
53
|
+
end if level
|
54
|
+
|
55
|
+
puts "\n"
|
56
|
+
# Yield mysterious things if they exist in block.
|
33
57
|
yield if block_given?
|
34
58
|
end
|
35
59
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- stanislaw
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-16 00:00:00 +03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -90,6 +90,7 @@ extra_rdoc_files:
|
|
90
90
|
- README.rdoc
|
91
91
|
files:
|
92
92
|
- lib/cutter.rb
|
93
|
+
- lib/cutter/array.rb
|
93
94
|
- lib/cutter/inspection.rb
|
94
95
|
- lib/cutter/railtie.rb
|
95
96
|
- lib/cutter/stamper.rb
|
@@ -109,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
110
|
requirements:
|
110
111
|
- - ">="
|
111
112
|
- !ruby/object:Gem::Version
|
112
|
-
hash: -
|
113
|
+
hash: -936352461
|
113
114
|
segments:
|
114
115
|
- 0
|
115
116
|
version: "0"
|