Hello community, here is the log from the commit of package rubygem-pry for openSUSE:Factory checked in at 2017-11-18 00:21:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-pry (Old) and /work/SRC/openSUSE:Factory/.rubygem-pry.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-pry" Sat Nov 18 00:21:36 2017 rev:20 rq:542641 version:0.11.3 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-pry/rubygem-pry.changes 2017-10-23 16:53:32.247995010 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-pry.new/rubygem-pry.changes 2017-11-18 00:21:40.674274695 +0100 @@ -1,0 +2,20 @@ +Fri Nov 17 09:38:37 UTC 2017 - [email protected] + +- updated to version 0.11.3 + + # Features + + - Deprecate Pry::Command#text. Please use black(), white(), etc directly instead (as you would with helper functions from BaseHelpers and CommandHelpers) + - Add Pry::Testable, an improved modular replacement for PryTestHelpers. breaking change. + - Add a new category module: "Pry::Platform". Loosely related to #1668 below. + - Add mac_osx? and linux? utility functions to Pry::Helpers::BaseHelpers. + - Add utility functions for drawing colorised text on a colorised background. + + # Bug fixes + + - Fix a case of infinite recursion in Pry::Method::WeirdMethodLocator#find_method_in_superclass that users of the Hanami web framework experienced and reported since 2015. + - Fix a bug where Method objects were not returned for setters inherited from a default (Pry::Config::Default). Eg, this is no longer an error: + - Do not capture unused Proc objects in Text helper methods no_color and no_paging, for performance reasons. Improve the documentation of both methods. + - Fix String#pp output color. + +------------------------------------------------------------------- Old: ---- pry-0.11.2.gem New: ---- pry-0.11.3.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-pry.spec ++++++ --- /var/tmp/diff_new_pack.TJvye8/_old 2017-11-18 00:21:41.522243821 +0100 +++ /var/tmp/diff_new_pack.TJvye8/_new 2017-11-18 00:21:41.526243675 +0100 @@ -24,7 +24,7 @@ # Name: rubygem-pry -Version: 0.11.2 +Version: 0.11.3 Release: 0 %define mod_name pry %define mod_full_name %{mod_name}-%{version} ++++++ pry-0.11.2.gem -> pry-0.11.3.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2017-10-18 23:40:15.000000000 +0200 +++ new/CHANGELOG.md 2017-11-14 15:06:19.000000000 +0100 @@ -1,3 +1,49 @@ +### HEAD + +#### Features + +* Add Pry::Testable, an improved modular replacement for PryTestHelpers. + **breaking change**. + +See pull request [#1679](https://github.com/pry/pry/pull/1679). + +* Add a new category module: "Pry::Platform". Loosely related to #1668 below. + +See pull request [#1670](https://github.com/pry/pry/pull/1670) + +* Add `mac_osx?` and `linux?` utility functions to Pry::Helpers::BaseHelpers. + +See pull request [#1668](https://github.com/pry/pry/pull/1668). + +* Add utility functions for drawing colorised text on a colorised background. + +See pull request [#1673](https://github.com/pry/pry/pull/1673). + +#### Bug fixes + +* Fix a case of infinite recursion in `Pry::Method::WeirdMethodLocator#find_method_in_superclass` + that users of the [Hanami](http://hanamirb.org/) web framework experienced and + reported since 2015. + +See pull request [#1639](https://github.com/pry/pry/pull/1689). + +* Fix a bug where Method objects were not returned for setters inherited + from a default (Pry::Config::Default). Eg, this is no longer an error: + + pry(main)> d = Pry::Config.from_hash({}, Pry::Config::Default.new) + pry(main)> d.method(:exception_whitelist=) # Error + +See pull request [#1688](https://github.com/pry/pry/pull/1688). + +* Do not capture unused Proc objects in Text helper methods `no_color` and `no_paging`, + for performance reasons. Improve the documentation of both methods. + +See pull request [#1691](https://github.com/pry/pry/pull/1691). + +* Fix `String#pp` output color. + +See pull request [#1674](https://github.com/pry/pry/pull/1674). + ### 0.11.0 * Add alias 'whereami[?!]+' for 'whereami' command. ([#1597](https://github.com/pry/pry/pull/1597)) @@ -47,7 +93,6 @@ * Move to rspec for testing (from bacon) * Clean up ruby warnings - ### 0.10.0 #### Features Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/color_printer.rb new/lib/pry/color_printer.rb --- old/lib/pry/color_printer.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/color_printer.rb 2017-11-14 15:06:19.000000000 +0100 @@ -34,7 +34,7 @@ if String === obj # Avoid calling Ruby 2.4+ String#pretty_print that prints multiline # Strings prettier - Object.instance_method(:pretty_print).bind(obj).call + text(obj.inspect) else super end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/commands/whereami.rb new/lib/pry/commands/whereami.rb --- old/lib/pry/commands/whereami.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/commands/whereami.rb 2017-11-14 15:06:19.000000000 +0100 @@ -193,5 +193,5 @@ Pry::Commands.add_command(Pry::Command::Whereami) Pry::Commands.alias_command '@', 'whereami' - Pry::Commands.alias_command /whereami[!?]+/, 'whereami' + Pry::Commands.alias_command(/whereami[!?]+/, 'whereami') end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/config/behavior.rb new/lib/pry/config/behavior.rb --- old/lib/pry/config/behavior.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/config/behavior.rb 2017-11-14 15:06:19.000000000 +0100 @@ -188,6 +188,7 @@ end def respond_to_missing?(key, include_all=false) + key = key.to_s.chomp(ASSIGNMENT) key?(key) or @default.respond_to?(key) or super(key, include_all) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/config/default.rb new/lib/pry/config/default.rb --- old/lib/pry/config/default.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/config/default.rb 2017-11-14 15:06:19.000000000 +0100 @@ -58,8 +58,8 @@ true }, should_trap_interrupts: proc { - Pry::Helpers::BaseHelpers.jruby? - }, # TODO: Pry::Platform.jruby? + Pry::Platform.jruby? + }, disable_auto_reload: proc { false }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/helpers/base_helpers.rb new/lib/pry/helpers/base_helpers.rb --- old/lib/pry/helpers/base_helpers.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/helpers/base_helpers.rb 2017-11-14 15:06:19.000000000 +0100 @@ -1,109 +1,71 @@ -class Pry - module Helpers +module Pry::Helpers; end +module Pry::Helpers::BaseHelpers + include Pry::Platform + extend self + + def silence_warnings + old_verbose = $VERBOSE + $VERBOSE = nil + begin + yield + ensure + $VERBOSE = old_verbose + end + end + + # Acts like send but ignores any methods defined below Object or Class in the + # inheritance hierarchy. + # This is required to introspect methods on objects like Net::HTTP::Get that + # have overridden the `method` method. + def safe_send(obj, method, *args, &block) + (Module === obj ? Module : Object).instance_method(method).bind(obj).call(*args, &block) + end + public :safe_send + + def find_command(name, set = Pry::Commands) + command_match = set.find do |_, command| + (listing = command.options[:listing]) == name && listing != nil + end + command_match.last if command_match + end + + def not_a_real_file?(file) + file =~ /^(\(.*\))$|^<.*>$/ || file =~ /__unknown__/ || file == "" || file == "-e" + end - module BaseHelpers + def command_dependencies_met?(options) + return true if !options[:requires_gem] + Array(options[:requires_gem]).all? do |g| + Pry::Rubygem.installed?(g) + end + end - module_function + def use_ansi_codes? + windows_ansi? || ENV['TERM'] && ENV['TERM'] != "dumb" + end + + def colorize_code(code) + CodeRay.scan(code, :ruby).term + end + + def highlight(string, regexp, highlight_color=:bright_yellow) + string.gsub(regexp) { |match| "<#{highlight_color}>#{match}</#{highlight_color}>" } + end + + # formatting + def heading(text) + text = "#{text}\n--" + "\e[1m#{text}\e[0m" + end - def silence_warnings - old_verbose = $VERBOSE - $VERBOSE = nil - begin - yield - ensure - $VERBOSE = old_verbose - end - end - - # Acts like send but ignores any methods defined below Object or Class in the - # inheritance hierarchy. - # This is required to introspect methods on objects like Net::HTTP::Get that - # have overridden the `method` method. - def safe_send(obj, method, *args, &block) - (Module === obj ? Module : Object).instance_method(method).bind(obj).call(*args, &block) - end - public :safe_send - - def find_command(name, set = Pry::Commands) - command_match = set.find do |_, command| - (listing = command.options[:listing]) == name && listing != nil - end - command_match.last if command_match - end - - def not_a_real_file?(file) - file =~ /^(\(.*\))$|^<.*>$/ || file =~ /__unknown__/ || file == "" || file == "-e" - end - - def command_dependencies_met?(options) - return true if !options[:requires_gem] - Array(options[:requires_gem]).all? do |g| - Rubygem.installed?(g) - end - end - - def use_ansi_codes? - windows_ansi? || ENV['TERM'] && ENV['TERM'] != "dumb" - end - - def colorize_code(code) - CodeRay.scan(code, :ruby).term - end - - def highlight(string, regexp, highlight_color=:bright_yellow) - string.gsub(regexp) { |match| "<#{highlight_color}>#{match}</#{highlight_color}>" } - end - - # formatting - def heading(text) - text = "#{text}\n--" - "\e[1m#{text}\e[0m" - end - - # have fun on the Windows platform. - def windows? - RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ - end - - # are we able to use ansi on windows? - def windows_ansi? - defined?(Win32::Console) || ENV['ANSICON'] || (windows? && mri_2?) - end - - def jruby? - RbConfig::CONFIG['ruby_install_name'] == 'jruby' - end - - def jruby_19? - jruby? && RbConfig::CONFIG['ruby_version'] == '1.9' - end - - def rbx? - RbConfig::CONFIG['ruby_install_name'] == 'rbx' - end - - def mri? - RbConfig::CONFIG['ruby_install_name'] == 'ruby' - end - - def mri_19? - mri? && RUBY_VERSION =~ /^1\.9/ - end - - def mri_2? - mri? && RUBY_VERSION =~ /^2/ - end - - # Send the given text through the best available pager (if Pry.config.pager is - # enabled). Infers where to send the output if used as a mixin. - # DEPRECATED. - def stagger_output(text, out = nil) - if defined?(_pry_) && _pry_ - _pry_.pager.page text - else - Pry.new.pager.page text - end - end + # Send the given text through the best available pager (if Pry.config.pager is + # enabled). Infers where to send the output if used as a mixin. + # DEPRECATED. + def stagger_output(text, out = nil) + if defined?(_pry_) && _pry_ + _pry_.pager.page text + else + Pry.new.pager.page text end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/helpers/text.rb new/lib/pry/helpers/text.rb --- old/lib/pry/helpers/text.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/helpers/text.rb 2017-11-14 15:06:19.000000000 +0100 @@ -24,6 +24,16 @@ define_method "bright_#{color}" do |text| "\033[1;#{30+value}m#{text}\033[0m" end + + COLORS.each_pair do |bg_color, bg_value| + define_method "#{color}_on_#{bg_color}" do |text| + "\033[0;#{30 + value};#{40 + bg_value}m#{text}\033[0m" + end + + define_method "bright_#{color}_on_#{bg_color}" do |text| + "\033[1;#{30 + value};#{40 + bg_value}m#{text}\033[0m" + end + end end # Remove any color codes from _text_. @@ -52,10 +62,13 @@ end alias_method :bright_default, :bold - # Executes the block with `Pry.config.color` set to false. + # # @yield + # Yields a block with color turned off. + # # @return [void] - def no_color(&block) + # + def no_color boolean = Pry.config.color Pry.config.color = false yield @@ -63,10 +76,13 @@ Pry.config.color = boolean end - # Executes the block with `Pry.config.pager` set to false. + # # @yield + # Yields a block with paging turned off. + # # @return [void] - def no_pager(&block) + # + def no_pager boolean = Pry.config.pager Pry.config.pager = false yield @@ -98,4 +114,3 @@ end end end - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/method/weird_method_locator.rb new/lib/pry/method/weird_method_locator.rb --- old/lib/pry/method/weird_method_locator.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/method/weird_method_locator.rb 2017-11-14 15:06:19.000000000 +0100 @@ -26,13 +26,17 @@ # @param [Binding] b # @return [Boolean] def normal_method?(method, b) - method && (method.source_file && method.source_range rescue false) && - File.expand_path(method.source_file) == File.expand_path(b.eval('__FILE__')) && - method.source_range.include?(b.eval('__LINE__')) + if method and method.source_file and method.source_range + binding_file, binding_line = b.eval('__FILE__'), b.eval('__LINE__') + File.expand_path(method.source_file) == File.expand_path(binding_file) and + method.source_range.include?(binding_line) + end + rescue + false end def weird_method?(method, b) - !normal_method?(method, b) + not normal_method?(method, b) end end @@ -61,6 +65,11 @@ private + def skip_superclass_search? + target_mod = @target.eval('self').class + target_mod.ancestors.take_while {|mod| mod != target_mod }.any? + end + def normal_method?(method) self.class.normal_method?(method, target) end @@ -98,7 +107,9 @@ # superclass method. def find_method_in_superclass guess = method - + if skip_superclass_search? + return guess + end while guess # needs rescue if this is a Disowned method or a C method or something... # TODO: Fix up the exception handling so we don't need a bare rescue diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/platform.rb new/lib/pry/platform.rb --- old/lib/pry/platform.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/pry/platform.rb 2017-11-14 15:06:19.000000000 +0100 @@ -0,0 +1,93 @@ +module Pry::Platform + extend self + + # + # @return [Boolean] + # Returns true if Pry is running on Mac OSX. + # + # @note + # Queries RbConfig::CONFIG['host_os'] with a best guess. + # + def mac_osx? + !!(RbConfig::CONFIG['host_os'] =~ /\Adarwin/i) + end + + # + # @return [Boolean] + # Returns true if Pry is running on Linux. + # + # @note + # Queries RbConfig::CONFIG['host_os'] with a best guess. + # + def linux? + !!(RbConfig::CONFIG['host_os'] =~ /linux/i) + end + + # + # @return [Boolean] + # Returns true if Pry is running on Windows. + # + # @note + # Queries RbConfig::CONFIG['host_os'] with a best guess. + # + def windows? + !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) + end + + # + # @return [Boolean] + # Returns true when Pry is running on Windows with ANSI support. + # + def windows_ansi? + return false if not windows? + !!(defined?(Win32::Console) or ENV['ANSICON'] or mri_2?) + end + + # + # @return [Boolean] + # Returns true when Pry is being run from JRuby. + # + def jruby? + RbConfig::CONFIG['ruby_install_name'] == 'jruby' + end + + # + # @return [Boolean] + # Returns true when Pry is being run from JRuby in 1.9 mode. + # + def jruby_19? + jruby? and RbConfig::CONFIG['ruby_version'] == '1.9' + end + + # + # @return [Boolean] + # Returns true when Pry is being run from Rubinius. + # + def rbx? + RbConfig::CONFIG['ruby_install_name'] == 'rbx' + end + + # + # @return [Boolean] + # Returns true when Pry is being run from MRI (CRuby). + # + def mri? + RbConfig::CONFIG['ruby_install_name'] == 'ruby' + end + + # + # @return [Boolean] + # Returns true when Pry is being run from MRI v1.9+ (CRuby). + # + def mri_19? + !!(mri? and RUBY_VERSION =~ /\A1\.9/) + end + + # + # @return [Boolean] + # Returns true when Pry is being run from MRI v2+ (CRuby). + # + def mri_2? + !!(mri? and RUBY_VERSION =~ /\A2/) + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/test/helper.rb new/lib/pry/test/helper.rb --- old/lib/pry/test/helper.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/test/helper.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,179 +0,0 @@ -require 'pry' - -# in case the tests call reset_defaults, ensure we reset them to -# amended (test friendly) values -class << Pry - alias_method :orig_reset_defaults, :reset_defaults - def reset_defaults - orig_reset_defaults - - Pry.config.color = false - Pry.config.pager = false - Pry.config.should_load_rc = false - Pry.config.should_load_local_rc= false - Pry.config.should_load_plugins = false - Pry.config.history.should_load = false - Pry.config.history.should_save = false - Pry.config.correct_indent = false - Pry.config.hooks = Pry::Hooks.new - Pry.config.collision_warning = false - end -end -Pry.reset_defaults - -# A global space for storing temporary state during tests. - -module PryTestHelpers - - module_function - - # inject a variable into a binding - def inject_var(name, value, b) - Pry.current[:pry_local] = value - b.eval("#{name} = ::Pry.current[:pry_local]") - ensure - Pry.current[:pry_local] = nil - end - - def constant_scope(*names) - names.each do |name| - Object.remove_const name if Object.const_defined?(name) - end - - yield - ensure - names.each do |name| - Object.remove_const name if Object.const_defined?(name) - end - end - - # Open a temp file and yield it to the block, closing it after - # @return [String] The path of the temp file - def temp_file(ext='.rb') - file = Tempfile.new(['pry', ext]) - yield file - ensure - file.close(true) if file - File.unlink("#{file.path}c") if File.exist?("#{file.path}c") # rbx - end - - def unindent(*args) - Pry::Helpers::CommandHelpers.unindent(*args) - end - - def mock_command(cmd, args=[], opts={}) - output = StringIO.new - pry = Pry.new(output: output) - ret = cmd.new(opts.merge(pry_instance: pry, :output => output)).call_safely(*args) - Struct.new(:output, :return).new(output.string, ret) - end - - def mock_exception(*mock_backtrace) - StandardError.new.tap do |e| - e.define_singleton_method(:backtrace) { mock_backtrace } - end - end - - def inner_scope - catch(:inner_scope) do - yield ->{ throw(:inner_scope, self) } - end - end -end - -def pry_tester(*args, &block) - if args.length == 0 || args[0].is_a?(Hash) - args.unshift(Pry.toplevel_binding) - end - - PryTester.new(*args).tap do |t| - (class << t; self; end).class_eval(&block) if block - end -end - -def pry_eval(*eval_strs) - if eval_strs.first.is_a? String - binding = Pry.toplevel_binding - else - binding = Pry.binding_for(eval_strs.shift) - end - - pry_tester(binding).eval(*eval_strs) -end - -class PryTester - extend Pry::Forwardable - - attr_reader :pry, :out - - def_delegators :@pry, :eval_string, :eval_string= - - def initialize(target = TOPLEVEL_BINDING, options = {}) - @pry = Pry.new(options.merge(:target => target)) - @history = options[:history] - - @pry.inject_sticky_locals! - reset_output - end - - def eval(*strs) - reset_output - result = nil - - strs.flatten.each do |str| - # Check for space prefix. See #1369. - if str !~ /^\s\S/ - str = "#{str.strip}\n" - end - @history.push str if @history - - if @pry.process_command(str) - result = last_command_result_or_output - else - result = @pry.evaluate_ruby(str) - end - end - - result - end - - def push(*lines) - Array(lines).flatten.each do |line| - @pry.eval(line) - end - end - - def push_binding(context) - @pry.push_binding context - end - - def last_output - @out.string if @out - end - - def process_command(command_str) - @pry.process_command(command_str) or raise "Not a valid command" - last_command_result_or_output - end - - def last_command_result - result = Pry.current[:pry_cmd_result] - result.retval if result - end - - protected - - def last_command_result_or_output - result = last_command_result - if result != Pry::Command::VOID_VALUE - result - else - last_output - end - end - - def reset_output - @out = StringIO.new - @pry.output = @out - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/testable/evalable.rb new/lib/pry/testable/evalable.rb --- old/lib/pry/testable/evalable.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/pry/testable/evalable.rb 2017-11-14 15:06:19.000000000 +0100 @@ -0,0 +1,15 @@ +module Pry::Testable::Evalable + def pry_tester(*args, &block) + if args.length == 0 || args[0].is_a?(Hash) + args.unshift(Pry.toplevel_binding) + end + Pry::Testable::PryTester.new(*args).tap do |t| + t.singleton_class.class_eval(&block) if block + end + end + + def pry_eval(*eval_strs) + b = String === eval_strs.first ? Pry.toplevel_binding : Pry.binding_for(eval_strs.shift) + pry_tester(b).eval(*eval_strs) + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/testable/mockable.rb new/lib/pry/testable/mockable.rb --- old/lib/pry/testable/mockable.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/pry/testable/mockable.rb 2017-11-14 15:06:19.000000000 +0100 @@ -0,0 +1,14 @@ +module Pry::Testable::Mockable + def mock_command(cmd, args=[], opts={}) + output = StringIO.new + pry = Pry.new(output: output) + ret = cmd.new(opts.merge(pry_instance: pry, :output => output)).call_safely(*args) + Struct.new(:output, :return).new(output.string, ret) + end + + def mock_exception(*mock_backtrace) + StandardError.new.tap do |e| + e.define_singleton_method(:backtrace) { mock_backtrace } + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/testable/pry_tester.rb new/lib/pry/testable/pry_tester.rb --- old/lib/pry/testable/pry_tester.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/pry/testable/pry_tester.rb 2017-11-14 15:06:19.000000000 +0100 @@ -0,0 +1,73 @@ +class Pry::Testable::PryTester + extend Pry::Forwardable + attr_reader :pry, :out + def_delegators :@pry, :eval_string, :eval_string= + + def initialize(target = TOPLEVEL_BINDING, options = {}) + @pry = Pry.new(options.merge(:target => target)) + @history = options[:history] + @pry.inject_sticky_locals! + reset_output + end + + def eval(*strs) + reset_output + result = nil + + strs.flatten.each do |str| + # Check for space prefix. See #1369. + if str !~ /^\s\S/ + str = "#{str.strip}\n" + end + @history.push str if @history + + if @pry.process_command(str) + result = last_command_result_or_output + else + result = @pry.evaluate_ruby(str) + end + end + + result + end + + def push(*lines) + Array(lines).flatten.each do |line| + @pry.eval(line) + end + end + + def push_binding(context) + @pry.push_binding context + end + + def last_output + @out.string if @out + end + + def process_command(command_str) + @pry.process_command(command_str) or raise "Not a valid command" + last_command_result_or_output + end + + def last_command_result + result = Pry.current[:pry_cmd_result] + result.retval if result + end + + protected + + def last_command_result_or_output + result = last_command_result + if result != Pry::Command::VOID_VALUE + result + else + last_output + end + end + + def reset_output + @out = StringIO.new + @pry.output = @out + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/testable/utility.rb new/lib/pry/testable/utility.rb --- old/lib/pry/testable/utility.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/pry/testable/utility.rb 2017-11-14 15:06:19.000000000 +0100 @@ -0,0 +1,26 @@ +module Pry::Testable::Utility + # + # Creates a Tempfile then unlinks it after the block has yielded. + # + # @yieldparam [String] file + # The path of the temp file + # + # @return [void] + # + def temp_file(ext='.rb') + file = Tempfile.open(['pry', ext]) + yield file + ensure + file.close(true) if file + end + + def unindent(*args) + Pry::Helpers::CommandHelpers.unindent(*args) + end + + def inner_scope + catch(:inner_scope) do + yield ->{ throw(:inner_scope, self) } + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/testable/variables.rb new/lib/pry/testable/variables.rb --- old/lib/pry/testable/variables.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/pry/testable/variables.rb 2017-11-14 15:06:19.000000000 +0100 @@ -0,0 +1,46 @@ +module Pry::Testable::Variables + # + # @example + # temporary_constants(:Foo, :Bar) do + # Foo = Class.new(RuntimeError) + # Bar = Class.new(RuntimeError) + # end + # Foo # => NameError + # Bar # => NameError + # + # @param [Array<Symbol>] *names + # An array of constant names that be defined by a block, + # and removed by this method afterwards. + # + # @return [void] + # + def temporary_constants(*names) + names.each do |name| + Object.remove_const name if Object.const_defined?(name) + end + yield + ensure + names.each do |name| + Object.remove_const name if Object.const_defined?(name) + end + end + + # + # @param [String] name + # The name of a variable. + # + # @param [String] value + # Its value. + # + # @param [Binding] b + # The binding object to insert a variable into. + # + # @return [void] + # + def insert_variable(name, value, b) + Pry.current[:pry_local] = value + b.eval("#{name} = ::Pry.current[:pry_local]") + ensure + Pry.current[:pry_local] = nil + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/testable.rb new/lib/pry/testable.rb --- old/lib/pry/testable.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/pry/testable.rb 2017-11-14 15:06:19.000000000 +0100 @@ -0,0 +1,70 @@ +# good idea ??? +# if you're testing pry plugin you should require pry by yourself, no? +require 'pry' if not defined?(Pry) + +module Pry::Testable + extend self + require_relative "testable/pry_tester" + require_relative "testable/evalable" + require_relative "testable/mockable" + require_relative "testable/variables" + require_relative "testable/utility" + + # + # When {Pry::Testable} is included into another module or class, + # the following modules are also included: {Pry::Testable::Mockable}, + # {Pry::Testable::Evalable}, {Pry::Testable::Variables}, and + # {Pry::Testable::Utility}. + # + # @note + # Each of the included modules mentioned above may also be used + # standalone or in a pick-and-mix fashion. + # + # @param [Module] mod + # A class or module. + # + # @return [void] + # + def self.included(mod) + mod.module_eval do + include Pry::Testable::Mockable + include Pry::Testable::Evalable + include Pry::Testable::Variables + include Pry::Testable::Utility + end + end + + TEST_DEFAULTS = { + color: false, + pager: false, + should_load_rc: false, + should_load_local_rc: false, + correct_indent: false, + collison_warning: false, + history: { + should_load: false, + should_save: false + } + } + private_constant :TEST_DEFAULTS + + # + # Sets various configuration options that make Pry optimal for a test + # environment, see source code for complete details. + # + # @return [void] + # + def self.set_testenv_variables + Pry.config = Pry::Config.from_hash(TEST_DEFAULTS, Pry::Config::Default.new) + Pry.config.hooks = Pry::Hooks.new + end + + # + # Reset the Pry configuration to their default values. + # + # @return [void] + # + def self.unset_testenv_variables + Pry.config = Pry::Config.from_hash({}, Pry::Config::Default.new) + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry/version.rb new/lib/pry/version.rb --- old/lib/pry/version.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry/version.rb 2017-11-14 15:06:19.000000000 +0100 @@ -1,3 +1,3 @@ class Pry - VERSION = "0.11.2" + VERSION = "0.11.3" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/pry.rb new/lib/pry.rb --- old/lib/pry.rb 2017-10-18 23:40:15.000000000 +0200 +++ new/lib/pry.rb 2017-11-14 15:06:19.000000000 +0100 @@ -5,6 +5,7 @@ require 'pry/forwardable' require 'pry/input_lock' require 'pry/exceptions' +require 'pry/platform' require 'pry/helpers/base_helpers' require 'pry/hooks' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2017-10-18 23:40:15.000000000 +0200 +++ new/metadata 2017-11-14 15:06:19.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: pry version: !ruby/object:Gem::Version - version: 0.11.2 + version: 0.11.3 platform: ruby authors: - John Mair (banisterfiend) @@ -10,7 +10,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2017-10-18 00:00:00.000000000 Z +date: 2017-11-14 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: coderay @@ -185,6 +185,7 @@ - lib/pry/object_path.rb - lib/pry/output.rb - lib/pry/pager.rb +- lib/pry/platform.rb - lib/pry/plugins.rb - lib/pry/prompt.rb - lib/pry/pry_class.rb @@ -198,7 +199,12 @@ - lib/pry/slop/commands.rb - lib/pry/slop/option.rb - lib/pry/terminal.rb -- lib/pry/test/helper.rb +- lib/pry/testable.rb +- lib/pry/testable/evalable.rb +- lib/pry/testable/mockable.rb +- lib/pry/testable/pry_tester.rb +- lib/pry/testable/utility.rb +- lib/pry/testable/variables.rb - lib/pry/version.rb - lib/pry/wrapped_module.rb - lib/pry/wrapped_module/candidate.rb @@ -222,7 +228,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.5.1 +rubygems_version: 2.6.13 signing_key: specification_version: 4 summary: An IRB alternative and runtime developer console
