Module: Bookshop::ScriptBookshopLoader
- Defined in:
- lib/bookshop/script_bookshop_loader.rb
Overview
Checks to see if we are in a bookshop application
Constant Summary collapse
- RUBY =
File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"]
- SCRIPT_BOOKSHOP =
File.join('script', 'bookshop')
Class Method Summary collapse
- .exec_script_bookshop! ⇒ Object
- .in_bookshop_application? ⇒ Boolean
- .in_bookshop_application_subdirectory?(path = Pathname.new(Dir.pwd)) ⇒ Boolean
Class Method Details
.exec_script_bookshop! ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bookshop/script_bookshop_loader.rb', line 9 def self.exec_script_bookshop! cwd = Dir.pwd return unless in_bookshop_application? || in_bookshop_application_subdirectory? exec RUBY, SCRIPT_BOOKSHOP, *ARGV if in_bookshop_application? Dir.chdir("..") do # Recurse in a chdir block: if the search fails we want to be sure # the application is generated in the original working directory. exec_script_bookshop! unless cwd == Dir.pwd end rescue SystemCallError # could not chdir, no problem just return end |
.in_bookshop_application? ⇒ Boolean
22 23 24 |
# File 'lib/bookshop/script_bookshop_loader.rb', line 22 def self.in_bookshop_application? File.exists?(SCRIPT_BOOKSHOP) end |
.in_bookshop_application_subdirectory?(path = Pathname.new(Dir.pwd)) ⇒ Boolean
26 27 28 |
# File 'lib/bookshop/script_bookshop_loader.rb', line 26 def self.in_bookshop_application_subdirectory?(path = Pathname.new(Dir.pwd)) File.exists?(File.join(path, SCRIPT_BOOKSHOP)) || !path.root? && in_bookshop_application_subdirectory?(path.parent) end |