Skip to content

Commit

Permalink
allow bundler binstubs, instruct instead of Gem::LoadError, closes #2013
Browse files Browse the repository at this point in the history
  • Loading branch information
ujifgc committed Jun 8, 2016
1 parent 6745f74 commit 4fda061
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- NEW Remove RightJS, Riot, Steak support (@ujifgc)
- NEW Allow shortened mailer render calls with default mailer and message names (@ujifgc)
- FIX delegate padrino and padrino-gen to bundler binstubs

== 0.13.2 (May 9th 2016)

Expand Down
3 changes: 2 additions & 1 deletion padrino-core/bin/padrino
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
require 'bundler/setup' if %w(Gemfile .components).all? { |f| File.exist?(f) }
require 'padrino-core/cli/binstub'
Padrino.replace_with_binstub('padrino')

padrino_core_path = File.expand_path('../../lib', __FILE__)
$:.unshift(padrino_core_path) if File.directory?(padrino_core_path) && !$:.include?(padrino_core_path)
Expand Down
27 changes: 27 additions & 0 deletions padrino-core/lib/padrino-core/cli/binstub.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Padrino
##
# Replaces the current process with it's binstub.
#
def self.replace_with_binstub(executable)
begin
return if Bundler.definition.missing_specs.empty?
rescue NameError, NoMethodError
end

project_root = Dir.pwd
until project_root.empty?
break if File.file?(File.join(project_root, 'Gemfile'))
project_root = project_root.rpartition('/').first
end

if %w(Gemfile .components).all? { |file| File.file?(File.join(project_root, file)) }
binstub = File.join(project_root, 'bin', executable)
if File.file?(binstub)
exec Gem.ruby, binstub, *ARGV
else
puts 'Please run `bundler install --binstubs` from your project root to generate bundle-specific executables'
exit!
end
end
end
end
4 changes: 2 additions & 2 deletions padrino-gen/bin/padrino-gen
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require 'rubygems' unless defined?(Gem) # Useful only on --dev mode
require 'bundler/setup' if %w(Gemfile .components).all? { |f| File.exist?(f) }
require 'padrino-core/cli/binstub'
Padrino.replace_with_binstub('padrino-gen')

padrino_gen_path = File.expand_path('../../lib', __FILE__)
$:.unshift(padrino_gen_path) if File.directory?(padrino_gen_path) && !$:.include?(padrino_gen_path)
Expand Down
2 changes: 1 addition & 1 deletion padrino-gen/lib/padrino-gen/generators/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def finish_message
say "#{name} is ready for development!", :green
say '=' * 65, :green
say "$ cd #{options[:root]}/#{name}"
say "$ bundle" unless options[:bundle]
say "$ bundle --binstubs" unless options[:bundle]
say "=" * 65, :green
say
end
Expand Down

0 comments on commit 4fda061

Please sign in to comment.