mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Revert "switched valid_expression? code to using catch() technique; removed ruby_parser dependency as a result and updated Rakefile and pry.gemspec"
This reverts commit 36c1300416
.
This commit is contained in:
parent
5a38130d7e
commit
522b20f309
3 changed files with 47 additions and 27 deletions
1
Rakefile
1
Rakefile
|
@ -20,6 +20,7 @@ def apply_spec_defaults(s)
|
|||
s.executables = ["pry"]
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- test/*`.split("\n")
|
||||
s.add_dependency("ruby_parser",">=2.0.5")
|
||||
s.add_dependency("coderay",">=0.9.8")
|
||||
s.add_dependency("slop","~>1.9.0")
|
||||
s.add_dependency("method_source",">=0.6.0")
|
||||
|
|
|
@ -421,18 +421,35 @@ class Pry
|
|||
prompt_stack.size > 1 ? prompt_stack.pop : prompt
|
||||
end
|
||||
|
||||
# Determine if a string of code is a valid Ruby expression.
|
||||
# @param [String] code The code to validate.
|
||||
# @return [Boolean] Whether or not the code is a valid Ruby expression.
|
||||
# @example
|
||||
# valid_expression?("class Hello") #=> false
|
||||
# valid_expression?("class Hello; end") #=> true
|
||||
def valid_expression?(code)
|
||||
catch(:ok) do
|
||||
eval("BEGIN { throw :ok }; #{code}")
|
||||
if RUBY_VERSION =~ /1.9/ && RUBY_ENGINE == "ruby"
|
||||
require 'ripper'
|
||||
|
||||
# Determine if a string of code is a valid Ruby expression.
|
||||
# Ruby 1.9 uses Ripper, Ruby 1.8 uses RubyParser.
|
||||
# @param [String] code The code to validate.
|
||||
# @return [Boolean] Whether or not the code is a valid Ruby expression.
|
||||
# @example
|
||||
# valid_expression?("class Hello") #=> false
|
||||
# valid_expression?("class Hello; end") #=> true
|
||||
def valid_expression?(code)
|
||||
!!Ripper::SexpBuilder.new(code).parse
|
||||
end
|
||||
|
||||
else
|
||||
require 'ruby_parser'
|
||||
|
||||
# Determine if a string of code is a valid Ruby expression.
|
||||
# Ruby 1.9 uses Ripper, Ruby 1.8 uses RubyParser.
|
||||
# @param [String] code The code to validate.
|
||||
# @return [Boolean] Whether or not the code is a valid Ruby expression.
|
||||
# @example
|
||||
# valid_expression?("class Hello") #=> false
|
||||
# valid_expression?("class Hello; end") #=> true
|
||||
def valid_expression?(code)
|
||||
RubyParser.new.parse(code)
|
||||
true
|
||||
rescue Racc::ParseError, SyntaxError
|
||||
false
|
||||
end
|
||||
true
|
||||
rescue SyntaxError
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
32
pry.gemspec
32
pry.gemspec
|
@ -1,42 +1,44 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
$:.unshift File.expand_path('../lib', __FILE__)
|
||||
require 'pry/version'
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{pry}
|
||||
s.version = "0.9.4pre1"
|
||||
s.version = Pry::VERSION
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = [%q{John Mair (banisterfiend)}]
|
||||
s.date = %q{2011-08-22}
|
||||
s.description = %q{An IRB alternative and runtime developer console}
|
||||
s.description = %q{an IRB alternative and runtime developer console}
|
||||
s.email = %q{jrmair@gmail.com}
|
||||
s.executables = [%q{pry}]
|
||||
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
|
||||
s.homepage = %q{http://pry.github.com}
|
||||
s.require_paths = [%q{lib}]
|
||||
s.rubygems_version = %q{1.8.6}
|
||||
s.summary = %q{An IRB alternative and runtime developer console}
|
||||
s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/testrc}]
|
||||
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.yardopts}, %q{CHANGELOG}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
|
||||
s.homepage = %q{http://banisterfiend.wordpress.com}
|
||||
s.summary = %q{an IRB alternative and runtime developer console}
|
||||
s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/testrc}]
|
||||
|
||||
if s.respond_to? :specification_version then
|
||||
s.specification_version = 3
|
||||
|
||||
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
||||
s.add_runtime_dependency(%q<ruby_parser>, [">= 2.0.5"])
|
||||
s.add_runtime_dependency(%q<coderay>, [">= 0.9.8"])
|
||||
s.add_runtime_dependency(%q<slop>, ["~> 1.9.0"])
|
||||
s.add_runtime_dependency(%q<method_source>, [">= 0.6.0"])
|
||||
s.add_runtime_dependency(%q<slop>, ["~> 1.7.0"])
|
||||
s.add_runtime_dependency(%q<method_source>, [">= 0.4.0"])
|
||||
s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
|
||||
s.add_development_dependency(%q<open4>, ["~> 1.0.1"])
|
||||
else
|
||||
s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
|
||||
s.add_dependency(%q<coderay>, [">= 0.9.8"])
|
||||
s.add_dependency(%q<slop>, ["~> 1.9.0"])
|
||||
s.add_dependency(%q<method_source>, [">= 0.6.0"])
|
||||
s.add_dependency(%q<slop>, ["~> 1.7.0"])
|
||||
s.add_dependency(%q<method_source>, [">= 0.4.0"])
|
||||
s.add_dependency(%q<bacon>, [">= 1.1.0"])
|
||||
s.add_dependency(%q<open4>, ["~> 1.0.1"])
|
||||
end
|
||||
else
|
||||
s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
|
||||
s.add_dependency(%q<coderay>, [">= 0.9.8"])
|
||||
s.add_dependency(%q<slop>, ["~> 1.9.0"])
|
||||
s.add_dependency(%q<method_source>, [">= 0.6.0"])
|
||||
s.add_dependency(%q<slop>, ["~> 1.7.0"])
|
||||
s.add_dependency(%q<method_source>, [">= 0.4.0"])
|
||||
s.add_dependency(%q<bacon>, [">= 1.1.0"])
|
||||
s.add_dependency(%q<open4>, ["~> 1.0.1"])
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue