Skip to content

Instantly share code, notes, and snippets.

@cheald

cheald/Gemfile Secret

Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheald/310096d07e6ee7118fbe to your computer and use it in GitHub Desktop.
Save cheald/310096d07e6ee7118fbe to your computer and use it in GitHub Desktop.
source "https://rubygems.org"
gem 'capistrano-jbundler', github: "cheald/capistrano-jbundler"
# bundle install --binstubs
# Amended Pathname#chop_basename
def chop_basename(path) # :nodoc:
puts "Chopping basename from #{path.inspect}"
base = File.basename(path)
puts "Base for #{path.inspect} is #{base.inspect}"
if /\A#{SEPARATOR_PAT}?\z/o =~ base
return nil
else
puts "Path is #{path}, path.rindex(base) is #{path.rindex(base).inspect} for base #{base}"
return path[0, path.rindex(base)], base
end
end
# Bundler
Chopping basename from "lib/capistrano/jbundler.rb"
Base for "lib/capistrano/jbundler.rb" is "jbundler.rb"
Path is lib/capistrano/jbundler.rb, path.rindex(base) is nil for base jbundler.rb
TypeError: no implicit conversion from nil to integer
org/jruby/RubyString.java:2932:in `[]'
/usr/local/rvm/rubies/jruby-head/lib/ruby/stdlib/pathname.rb:49:in `chop_basename'
/usr/local/rvm/rubies/jruby-head/lib/ruby/stdlib/pathname.rb:106:in `cleanpath_aggressive'
/usr/local/rvm/rubies/jruby-head/lib/ruby/stdlib/pathname.rb:92:in `cleanpath'
/usr/local/rvm/rubies/jruby-head/lib/ruby/stdlib/pathname.rb:498:in `relative_path_from'
/usr/local/rvm/gems/jruby-head@global/gems/bundler-1.9.1/lib/bundler/source/path.rb:184:in `block in generate_bin'
org/jruby/RubyArray.java:2307:in `map'
# IRB
jruby-head :001 > require 'pathname'
=> true
jruby-head :002 > Pathname.new("").send :chop_basename, "lib/capistrano/jbundler.rb"
Chopping basename from "lib/capistrano/jbundler.rb"
Base for "lib/capistrano/jbundler.rb" is "jbundler.rb"
Path is lib/capistrano/jbundler.rb, path.rindex(base) is 15 for base jbundler.rb
=> ["lib/capistrano/", "jbundler.rb"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment