super-smart-mod 0.0.1

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.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/pry-0.16.0/CHANGELOG.md +1211 -0
  3. data/pry-0.16.0/LICENSE +25 -0
  4. data/pry-0.16.0/README.md +469 -0
  5. data/pry-0.16.0/bin/pry +13 -0
  6. data/pry-0.16.0/lib/pry/basic_object.rb +10 -0
  7. data/pry-0.16.0/lib/pry/block_command.rb +22 -0
  8. data/pry-0.16.0/lib/pry/class_command.rb +194 -0
  9. data/pry-0.16.0/lib/pry/cli.rb +211 -0
  10. data/pry-0.16.0/lib/pry/code/code_file.rb +114 -0
  11. data/pry-0.16.0/lib/pry/code/code_range.rb +73 -0
  12. data/pry-0.16.0/lib/pry/code/loc.rb +105 -0
  13. data/pry-0.16.0/lib/pry/code.rb +357 -0
  14. data/pry-0.16.0/lib/pry/code_object.rb +197 -0
  15. data/pry-0.16.0/lib/pry/color_printer.rb +66 -0
  16. data/pry-0.16.0/lib/pry/command.rb +520 -0
  17. data/pry-0.16.0/lib/pry/command_set.rb +418 -0
  18. data/pry-0.16.0/lib/pry/command_state.rb +36 -0
  19. data/pry-0.16.0/lib/pry/commands/amend_line.rb +103 -0
  20. data/pry-0.16.0/lib/pry/commands/bang.rb +24 -0
  21. data/pry-0.16.0/lib/pry/commands/bang_pry.rb +21 -0
  22. data/pry-0.16.0/lib/pry/commands/cat/abstract_formatter.rb +32 -0
  23. data/pry-0.16.0/lib/pry/commands/cat/exception_formatter.rb +90 -0
  24. data/pry-0.16.0/lib/pry/commands/cat/file_formatter.rb +77 -0
  25. data/pry-0.16.0/lib/pry/commands/cat/input_expression_formatter.rb +48 -0
  26. data/pry-0.16.0/lib/pry/commands/cat.rb +70 -0
  27. data/pry-0.16.0/lib/pry/commands/cd.rb +48 -0
  28. data/pry-0.16.0/lib/pry/commands/change_inspector.rb +34 -0
  29. data/pry-0.16.0/lib/pry/commands/change_prompt.rb +51 -0
  30. data/pry-0.16.0/lib/pry/commands/clear_screen.rb +20 -0
  31. data/pry-0.16.0/lib/pry/commands/code_collector.rb +182 -0
  32. data/pry-0.16.0/lib/pry/commands/disable_pry.rb +31 -0
  33. data/pry-0.16.0/lib/pry/commands/easter_eggs.rb +101 -0
  34. data/pry-0.16.0/lib/pry/commands/edit/exception_patcher.rb +29 -0
  35. data/pry-0.16.0/lib/pry/commands/edit/file_and_line_locator.rb +47 -0
  36. data/pry-0.16.0/lib/pry/commands/edit.rb +225 -0
  37. data/pry-0.16.0/lib/pry/commands/exit.rb +47 -0
  38. data/pry-0.16.0/lib/pry/commands/exit_all.rb +33 -0
  39. data/pry-0.16.0/lib/pry/commands/exit_program.rb +27 -0
  40. data/pry-0.16.0/lib/pry/commands/find_method.rb +199 -0
  41. data/pry-0.16.0/lib/pry/commands/fix_indent.rb +23 -0
  42. data/pry-0.16.0/lib/pry/commands/help.rb +171 -0
  43. data/pry-0.16.0/lib/pry/commands/hist.rb +182 -0
  44. data/pry-0.16.0/lib/pry/commands/import_set.rb +27 -0
  45. data/pry-0.16.0/lib/pry/commands/jump_to.rb +33 -0
  46. data/pry-0.16.0/lib/pry/commands/list_inspectors.rb +42 -0
  47. data/pry-0.16.0/lib/pry/commands/ls/config.rb +54 -0
  48. data/pry-0.16.0/lib/pry/commands/ls/constants.rb +75 -0
  49. data/pry-0.16.0/lib/pry/commands/ls/formatter.rb +55 -0
  50. data/pry-0.16.0/lib/pry/commands/ls/globals.rb +50 -0
  51. data/pry-0.16.0/lib/pry/commands/ls/grep.rb +23 -0
  52. data/pry-0.16.0/lib/pry/commands/ls/instance_vars.rb +40 -0
  53. data/pry-0.16.0/lib/pry/commands/ls/interrogatable.rb +24 -0
  54. data/pry-0.16.0/lib/pry/commands/ls/jruby_hacks.rb +55 -0
  55. data/pry-0.16.0/lib/pry/commands/ls/local_names.rb +37 -0
  56. data/pry-0.16.0/lib/pry/commands/ls/local_vars.rb +47 -0
  57. data/pry-0.16.0/lib/pry/commands/ls/ls_entity.rb +65 -0
  58. data/pry-0.16.0/lib/pry/commands/ls/methods.rb +55 -0
  59. data/pry-0.16.0/lib/pry/commands/ls/methods_helper.rb +50 -0
  60. data/pry-0.16.0/lib/pry/commands/ls/self_methods.rb +34 -0
  61. data/pry-0.16.0/lib/pry/commands/ls.rb +114 -0
  62. data/pry-0.16.0/lib/pry/commands/nesting.rb +29 -0
  63. data/pry-0.16.0/lib/pry/commands/play.rb +113 -0
  64. data/pry-0.16.0/lib/pry/commands/pry_backtrace.rb +30 -0
  65. data/pry-0.16.0/lib/pry/commands/pry_version.rb +21 -0
  66. data/pry-0.16.0/lib/pry/commands/raise_up.rb +38 -0
  67. data/pry-0.16.0/lib/pry/commands/reload_code.rb +74 -0
  68. data/pry-0.16.0/lib/pry/commands/reset.rb +22 -0
  69. data/pry-0.16.0/lib/pry/commands/ri.rb +75 -0
  70. data/pry-0.16.0/lib/pry/commands/save_file.rb +63 -0
  71. data/pry-0.16.0/lib/pry/commands/shell_command.rb +75 -0
  72. data/pry-0.16.0/lib/pry/commands/shell_mode.rb +30 -0
  73. data/pry-0.16.0/lib/pry/commands/show_doc.rb +84 -0
  74. data/pry-0.16.0/lib/pry/commands/show_info.rb +234 -0
  75. data/pry-0.16.0/lib/pry/commands/show_input.rb +22 -0
  76. data/pry-0.16.0/lib/pry/commands/show_source.rb +57 -0
  77. data/pry-0.16.0/lib/pry/commands/stat.rb +44 -0
  78. data/pry-0.16.0/lib/pry/commands/switch_to.rb +29 -0
  79. data/pry-0.16.0/lib/pry/commands/toggle_color.rb +28 -0
  80. data/pry-0.16.0/lib/pry/commands/watch_expression/expression.rb +43 -0
  81. data/pry-0.16.0/lib/pry/commands/watch_expression.rb +108 -0
  82. data/pry-0.16.0/lib/pry/commands/whereami.rb +205 -0
  83. data/pry-0.16.0/lib/pry/commands/wtf.rb +95 -0
  84. data/pry-0.16.0/lib/pry/config/attributable.rb +22 -0
  85. data/pry-0.16.0/lib/pry/config/lazy_value.rb +29 -0
  86. data/pry-0.16.0/lib/pry/config/memoized_value.rb +34 -0
  87. data/pry-0.16.0/lib/pry/config/value.rb +24 -0
  88. data/pry-0.16.0/lib/pry/config.rb +321 -0
  89. data/pry-0.16.0/lib/pry/control_d_handler.rb +28 -0
  90. data/pry-0.16.0/lib/pry/core_extensions.rb +144 -0
  91. data/pry-0.16.0/lib/pry/editor.rb +157 -0
  92. data/pry-0.16.0/lib/pry/env.rb +18 -0
  93. data/pry-0.16.0/lib/pry/exception_handler.rb +48 -0
  94. data/pry-0.16.0/lib/pry/exceptions.rb +73 -0
  95. data/pry-0.16.0/lib/pry/forwardable.rb +27 -0
  96. data/pry-0.16.0/lib/pry/helpers/base_helpers.rb +71 -0
  97. data/pry-0.16.0/lib/pry/helpers/command_helpers.rb +146 -0
  98. data/pry-0.16.0/lib/pry/helpers/documentation_helpers.rb +84 -0
  99. data/pry-0.16.0/lib/pry/helpers/options_helpers.rb +34 -0
  100. data/pry-0.16.0/lib/pry/helpers/platform.rb +55 -0
  101. data/pry-0.16.0/lib/pry/helpers/table.rb +121 -0
  102. data/pry-0.16.0/lib/pry/helpers/text.rb +118 -0
  103. data/pry-0.16.0/lib/pry/helpers.rb +8 -0
  104. data/pry-0.16.0/lib/pry/history.rb +153 -0
  105. data/pry-0.16.0/lib/pry/hooks.rb +180 -0
  106. data/pry-0.16.0/lib/pry/indent.rb +414 -0
  107. data/pry-0.16.0/lib/pry/input/simple_stdio.rb +13 -0
  108. data/pry-0.16.0/lib/pry/input_completer.rb +283 -0
  109. data/pry-0.16.0/lib/pry/input_lock.rb +129 -0
  110. data/pry-0.16.0/lib/pry/inspector.rb +39 -0
  111. data/pry-0.16.0/lib/pry/last_exception.rb +61 -0
  112. data/pry-0.16.0/lib/pry/method/disowned.rb +67 -0
  113. data/pry-0.16.0/lib/pry/method/patcher.rb +131 -0
  114. data/pry-0.16.0/lib/pry/method/weird_method_locator.rb +222 -0
  115. data/pry-0.16.0/lib/pry/method.rb +599 -0
  116. data/pry-0.16.0/lib/pry/object_path.rb +91 -0
  117. data/pry-0.16.0/lib/pry/output.rb +136 -0
  118. data/pry-0.16.0/lib/pry/pager.rb +249 -0
  119. data/pry-0.16.0/lib/pry/prompt.rb +214 -0
  120. data/pry-0.16.0/lib/pry/pry_class.rb +371 -0
  121. data/pry-0.16.0/lib/pry/pry_instance.rb +663 -0
  122. data/pry-0.16.0/lib/pry/repl.rb +326 -0
  123. data/pry-0.16.0/lib/pry/repl_file_loader.rb +79 -0
  124. data/pry-0.16.0/lib/pry/ring.rb +89 -0
  125. data/pry-0.16.0/lib/pry/slop/LICENSE +20 -0
  126. data/pry-0.16.0/lib/pry/slop/commands.rb +190 -0
  127. data/pry-0.16.0/lib/pry/slop/option.rb +210 -0
  128. data/pry-0.16.0/lib/pry/slop.rb +672 -0
  129. data/pry-0.16.0/lib/pry/syntax_highlighter.rb +26 -0
  130. data/pry-0.16.0/lib/pry/system_command_handler.rb +17 -0
  131. data/pry-0.16.0/lib/pry/testable/evalable.rb +24 -0
  132. data/pry-0.16.0/lib/pry/testable/mockable.rb +22 -0
  133. data/pry-0.16.0/lib/pry/testable/pry_tester.rb +88 -0
  134. data/pry-0.16.0/lib/pry/testable/utility.rb +34 -0
  135. data/pry-0.16.0/lib/pry/testable/variables.rb +52 -0
  136. data/pry-0.16.0/lib/pry/testable.rb +68 -0
  137. data/pry-0.16.0/lib/pry/version.rb +5 -0
  138. data/pry-0.16.0/lib/pry/warning.rb +20 -0
  139. data/pry-0.16.0/lib/pry/wrapped_module/candidate.rb +145 -0
  140. data/pry-0.16.0/lib/pry/wrapped_module.rb +382 -0
  141. data/pry-0.16.0/lib/pry.rb +148 -0
  142. data/super-smart-mod.gemspec +12 -0
  143. metadata +182 -0
@@ -0,0 +1,205 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'method_source'
4
+
5
+ class Pry
6
+ class Command
7
+ class Whereami < Pry::ClassCommand
8
+ def initialize(*)
9
+ super
10
+
11
+ @method_code = nil
12
+ end
13
+
14
+ class << self
15
+ attr_accessor :method_size_cutoff
16
+ end
17
+
18
+ @method_size_cutoff = 30
19
+
20
+ match 'whereami'
21
+ description 'Show code surrounding the current context.'
22
+ group 'Context'
23
+
24
+ banner <<-'BANNER'
25
+ Usage: whereami [-qn] [LINES]
26
+
27
+ Describe the current location. If you use `binding.pry` inside a method then
28
+ whereami will print out the source for that method.
29
+
30
+ If a number is passed, then LINES lines before and after the current line will be
31
+ shown instead of the method itself.
32
+
33
+ The `-q` flag can be used to suppress error messages in the case that there's
34
+ no code to show. This is used by pry in the default before_session hook to show
35
+ you when you arrive at a `binding.pry`.
36
+
37
+ The `-n` flag can be used to hide line numbers so that code can be copy/pasted
38
+ effectively.
39
+
40
+ When pry was started on an Object and there is no associated method, whereami
41
+ will instead output a brief description of the current object.
42
+ BANNER
43
+
44
+ def setup
45
+ if target.respond_to?(:source_location)
46
+ file, @line = target.source_location
47
+ @file = expand_path(file)
48
+ else
49
+ @file = expand_path(target.eval('__FILE__'))
50
+ @line = target.eval('__LINE__')
51
+ end
52
+ @method = Pry::Method.from_binding(target)
53
+ end
54
+
55
+ def options(opt)
56
+ opt.on :q, :quiet, "Don't display anything in case of an error"
57
+ opt.on :n, :"no-line-numbers", "Do not display line numbers"
58
+ opt.on :m, :method, "Show the complete source for the current method."
59
+ opt.on :c, :class, "Show the complete source for the current class or module."
60
+ opt.on :f, :file, "Show the complete source for the current file."
61
+ end
62
+
63
+ def code
64
+ @code ||= if opts.present?(:m)
65
+ method_code || raise(CommandError, "Cannot find method code.")
66
+ elsif opts.present?(:c)
67
+ class_code || raise(CommandError, "Cannot find class code.")
68
+ elsif opts.present?(:f)
69
+ Pry::Code.from_file(@file)
70
+ elsif args.any?
71
+ code_window
72
+ else
73
+ default_code
74
+ end
75
+ end
76
+
77
+ def code?
78
+ !!code
79
+ rescue MethodSource::SourceNotFoundError
80
+ false
81
+ end
82
+
83
+ def bad_option_combination?
84
+ [opts.present?(:m), opts.present?(:f),
85
+ opts.present?(:c), args.any?].count(true) > 1
86
+ end
87
+
88
+ def location
89
+ "#{@file}:#{@line} #{@method && @method.name_with_owner}"
90
+ end
91
+
92
+ def process
93
+ if bad_option_combination?
94
+ raise CommandError, "Only one of -m, -c, -f, and LINES may be specified."
95
+ end
96
+
97
+ return if nothing_to_do?
98
+
99
+ if internal_binding?(target)
100
+ handle_internal_binding
101
+ return
102
+ end
103
+
104
+ set_file_and_dir_locals(@file)
105
+
106
+ pretty_code = code.with_line_numbers(use_line_numbers?)
107
+ .with_marker(marker)
108
+ .highlighted
109
+ pry_instance.pager.page(
110
+ "\n#{bold('From:')} #{location}:\n\n" + pretty_code + "\n"
111
+ )
112
+ end
113
+
114
+ private
115
+
116
+ def nothing_to_do?
117
+ opts.quiet? && (internal_binding?(target) || !code?)
118
+ end
119
+
120
+ def use_line_numbers?
121
+ !opts.present?(:n)
122
+ end
123
+
124
+ def marker
125
+ !opts.present?(:n) && @line
126
+ end
127
+
128
+ def top_level?
129
+ target_self == Pry.main
130
+ end
131
+
132
+ def handle_internal_binding
133
+ if top_level?
134
+ output.puts "At the top level."
135
+ else
136
+ output.puts "Inside #{Pry.view_clip(target_self)}."
137
+ end
138
+ end
139
+
140
+ def small_method?
141
+ @method.source_range.count < self.class.method_size_cutoff
142
+ end
143
+
144
+ def default_code
145
+ if method_code && small_method?
146
+ method_code
147
+ else
148
+ code_window
149
+ end
150
+ end
151
+
152
+ def code_window
153
+ Pry::Code.from_file(@file).around(@line, window_size)
154
+ end
155
+
156
+ def method_code
157
+ return @method_code if @method_code
158
+
159
+ @method_code = Pry::Code.from_method(@method) if valid_method?
160
+ end
161
+
162
+ # This either returns the `target_self`
163
+ # or it returns the class of `target_self` if `target_self` is not a class.
164
+ # @return [Pry::WrappedModule]
165
+ def target_class
166
+ return Pry::WrappedModule(target_self) if target_self.is_a?(Module)
167
+
168
+ Pry::WrappedModule(target_self.class)
169
+ end
170
+
171
+ def class_code
172
+ @class_code ||=
173
+ begin
174
+ mod = @method ? Pry::WrappedModule(@method.owner) : target_class
175
+ idx = mod.candidates.find_index { |v| expand_path(v.source_file) == @file }
176
+ idx && Pry::Code.from_module(mod, idx)
177
+ end
178
+ end
179
+
180
+ def valid_method?
181
+ @method && @method.source? && expand_path(@method.source_file) == @file &&
182
+ @method.source_range.include?(@line)
183
+ end
184
+
185
+ def expand_path(filename)
186
+ return unless filename
187
+ return filename if Pry.eval_path == filename
188
+
189
+ File.expand_path(filename)
190
+ end
191
+
192
+ def window_size
193
+ if args.empty?
194
+ pry_instance.config.default_window_size
195
+ else
196
+ args.first.to_i
197
+ end
198
+ end
199
+ end
200
+
201
+ Pry::Commands.add_command(Pry::Command::Whereami)
202
+ Pry::Commands.alias_command '@', 'whereami'
203
+ Pry::Commands.alias_command(/whereami[!?]+/, 'whereami')
204
+ end
205
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Pry
4
+ class Command
5
+ class Wtf < Pry::ClassCommand
6
+ match(/wtf([?!]*)/)
7
+ group 'Context'
8
+ description 'Show the backtrace of the most recent exception.'
9
+ options listing: 'wtf?'
10
+
11
+ banner <<-'BANNER'
12
+ Usage: wtf[?|!]
13
+
14
+ Shows a few lines of the backtrace of the most recent exception (also available
15
+ as `_ex_.backtrace`). If you want to see more lines, add more question marks or
16
+ exclamation marks.
17
+
18
+ wtf?
19
+ wtf?!???!?!?
20
+
21
+ # To see the entire backtrace, pass the `-v` or `--verbose` flag.
22
+ wtf -v
23
+ BANNER
24
+
25
+ RUBY_FRAME_PATTERN = /\A(?<file>(.+)):(?<line>(\d+))/.freeze
26
+
27
+ def options(opt)
28
+ opt.on :v, :verbose, "Show the full backtrace"
29
+ opt.on :c, :code, "Show code corresponding to the backtrace frame"
30
+ end
31
+
32
+ def process
33
+ unless pry_instance.last_exception
34
+ raise Pry::CommandError, "No most-recent exception"
35
+ end
36
+
37
+ text = ''.dup
38
+ unwind_exceptions.each_with_index do |exception, i|
39
+ title = (i == 0 ? 'Exception' : 'Caused by')
40
+ text << format_header(title, exception)
41
+ text << format_backtrace(exception.backtrace)
42
+ end
43
+ output.puts(text)
44
+ end
45
+
46
+ private
47
+
48
+ def unwind_exceptions
49
+ exception_list = []
50
+ exception = pry_instance.last_exception
51
+
52
+ while exception
53
+ exception_list << exception
54
+ exception = (exception.cause if exception.respond_to?(:cause))
55
+ end
56
+
57
+ exception_list
58
+ end
59
+
60
+ def format_header(title, exception)
61
+ "#{bold(title + ':')} #{exception.class}: #{exception}\n--\n"
62
+ end
63
+
64
+ def format_backtrace(backtrace)
65
+ lines = trim_backtrace(backtrace).map do |frame|
66
+ next frame unless opts.code?
67
+
68
+ match = frame.match(RUBY_FRAME_PATTERN)
69
+ code = read_line(match[:file], match[:line].to_i)
70
+ [bold(frame), code].join("\n")
71
+ end
72
+
73
+ Pry::Code.new(lines.compact, 0, :text).with_line_numbers.to_s
74
+ end
75
+
76
+ def trim_backtrace(backtrace)
77
+ return backtrace if opts.verbose?
78
+
79
+ size_of_backtrace = [captures[0].size, 0.5].max * 10
80
+ backtrace.first(size_of_backtrace)
81
+ end
82
+
83
+ def read_line(file, line)
84
+ File.open(file, 'r') do |f|
85
+ (line - 1).times { f.gets }
86
+ f.gets
87
+ end
88
+ rescue Errno::ENOENT
89
+ nil
90
+ end
91
+ end
92
+
93
+ Pry::Commands.add_command(Pry::Command::Wtf)
94
+ end
95
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Pry
4
+ class Config
5
+ # Attributable provides the ability to create "attribute"
6
+ # accessors. Attribute accessors create a standard "attr_writer" and a
7
+ # customised "attr_reader". This reader is Proc-aware (lazy).
8
+ #
9
+ # @since v0.13.0
10
+ # @api private
11
+ module Attributable
12
+ def attribute(attr_name)
13
+ define_method(attr_name) do
14
+ value = Config::Value.new(instance_variable_get("@#{attr_name}"))
15
+ value.call
16
+ end
17
+
18
+ attr_writer(attr_name)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Pry
4
+ class Config
5
+ # LazyValue is a Proc (block) wrapper. It is meant to be used as a
6
+ # configuration value. Subsequent `#call` calls always evaluate the given
7
+ # block.
8
+ #
9
+ # @example
10
+ # num = 19
11
+ # value = Pry::Config::LazyValue.new { num += 1 }
12
+ # value.foo # => 20
13
+ # value.foo # => 21
14
+ # value.foo # => 22
15
+ #
16
+ # @api private
17
+ # @since v0.13.0
18
+ # @see Pry::Config::MemoizedValue
19
+ class LazyValue
20
+ def initialize(&block)
21
+ @block = block
22
+ end
23
+
24
+ def call
25
+ @block.call
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Pry
4
+ class Config
5
+ # MemoizedValue is a Proc (block) wrapper. It is meant to be used as a
6
+ # configuration value. Subsequent `#call` calls return the same memoized
7
+ # result.
8
+ #
9
+ # @example
10
+ # num = 19
11
+ # value = Pry::Config::MemoizedValue.new { num += 1 }
12
+ # value.call # => 20
13
+ # value.call # => 20
14
+ # value.call # => 20
15
+ #
16
+ # @api private
17
+ # @since v0.13.0
18
+ # @see Pry::Config::LazyValue
19
+ class MemoizedValue
20
+ def initialize(&block)
21
+ @block = block
22
+ @called = false
23
+ @call = nil
24
+ end
25
+
26
+ def call
27
+ return @call if @called
28
+
29
+ @called = true
30
+ @call = @block.call
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Pry
4
+ class Config
5
+ # Value holds a value for the given attribute and decides how it should
6
+ # be read. Procs get called, other values are returned as is.
7
+ #
8
+ # @since v0.13.0
9
+ # @api private
10
+ class Value
11
+ def initialize(value)
12
+ @value = value
13
+ end
14
+
15
+ def call
16
+ unless [Config::MemoizedValue, Config::LazyValue].include?(@value.class)
17
+ return @value
18
+ end
19
+
20
+ @value.call
21
+ end
22
+ end
23
+ end
24
+ end