exe/pry-try in pry-try-0.3.0 vs exe/pry-try in pry-try-0.3.1

- old
+ new

@@ -23,21 +23,27 @@ gem end end end -def template_for_gems(gems) +def template_for_gems(gems, options = {}) require 'erb' @gems = gems + @inline = options[:inline] ERB.new(<<-GEMFILE, 1, "-").result +<% if @inline -%> +#!/usr/bin/env ruby + begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end - +<% else -%> +require "bundler/inline" +<% end -%> gemfile(true) do source 'https://rubygems.org' gem 'pry' <% @gems.each do |(gem, *opts)| options = opts.last.is_a?(Hash) ? opts.pop : {} @@ -46,11 +52,11 @@ <% end -%> end GEMFILE end -if ARGV.empty? || %w(-h --help).include?(ARGV.first) +if ($stdin.tty? && ARGV.empty?) || %w(-h --help).include?(ARGV.first) puts(<<-EOH) Usage: pry-try activesupport cat script.rb | pry-try @@ -81,11 +87,11 @@ require 'pry-try' puts PryTry::VERSION exit elsif %w(--inline).include?(ARGV.first) ARGV.shift - puts template_for_gems(parse_gems(ARGV)) + puts template_for_gems(parse_gems(ARGV), :inline => true) exit end @gems = parse_gems(ARGV) @@ -93,7 +99,7 @@ require 'tempfile' @script = Tempfile.new('pry-try').tap do |f| File.write(f, template_for_gems(@gems).gsub(/\n+ *(?=\S)/, ';')) end - exec %{unset BUNDLE_BIN;script=$(cat #{@script ? @script.path : ''} #{$stdin.tty? ? '' : '-'}; echo;echo '$stdin = $stdin.reopen "/dev/tty";'); printf "${script}" | pry} end +exec %{unset BUNDLE_BIN;script=$(cat #{@script ? @script.path : ''} #{$stdin.tty? ? '' : '-'}; echo;echo '$stdin = $stdin.reopen "/dev/tty";'); printf "${script}" | pry}