Module: Jax::ScriptLoader
- Defined in:
- lib/jax/script_loader.rb
Class Method Summary collapse
-
.check_for_common_commands ⇒ Object
if necessary, invoke a command common to both Rails and non-Rails apps returns true if a command was invoked.
- .friendly_help_message ⇒ Object
- .invoke! ⇒ Object
- .recursively_find_path(relative_path, path = File.expand_path(".")) ⇒ Object
- .ruby(*args) ⇒ Object
Class Method Details
.check_for_common_commands ⇒ Object
if necessary, invoke a command common to both Rails and non-Rails apps returns true if a command was invoked
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jax/script_loader.rb', line 34 def check_for_common_commands case ARGV[0].to_s.downcase when 'plugin' require File.("../config/environment", File.dirname(@rails_or_jax)) require 'jax' Jax::PluginManager.start ARGV[1..-1] true else false end end |
.friendly_help_message ⇒ Object
46 47 48 49 |
# File 'lib/jax/script_loader.rb', line 46 def puts "Not in a Jax or Rails application." puts "Try `jax new [app-name]` or `rails new [app-name]` instead." end |
.invoke! ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jax/script_loader.rb', line 8 def invoke! @rails_or_jax = recursively_find_path("script/rails") || recursively_find_path("script/jax") if @rails_or_jax if ARGV[0] && ARGV[0][/^(g|generate|destroy)$/] if ARGV.length > 1 ARGV[1] = "jax:#{ARGV[1]}" else ARGV[1] = "jax" end end return if check_for_common_commands ruby @rails_or_jax, *ARGV end if ARGV.shift == 'new' require 'generators/jax/all' return Jax::Generators::ApplicationGenerator.start end end |
.recursively_find_path(relative_path, path = File.expand_path(".")) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jax/script_loader.rb', line 51 def recursively_find_path(relative_path, path = File.(".")) full_path = File.join(path, relative_path) if File.file?(full_path) full_path else new_path = File.dirname(path) return false if new_path == path # root recursively_find_path relative_path, new_path end end |
.ruby(*args) ⇒ Object
62 63 64 65 |
# File 'lib/jax/script_loader.rb', line 62 def ruby(*args) ruby = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"] exec *[ ruby, *args ] end |