Module: Lanes::Command
- Defined in:
- lib/lanes/command.rb,
lib/lanes/command/db.rb,
lib/lanes/command/app.rb,
lib/lanes/command/server.rb,
lib/lanes/command/update.rb,
lib/lanes/command/console.rb,
lib/lanes/command/generate.rb,
lib/lanes/command/update_model.rb,
lib/lanes/command/generate_view.rb,
lib/lanes/command/named_command.rb,
lib/lanes/command/generate_model.rb,
lib/lanes/command/generate_screen.rb,
lib/lanes/command/model_attribute.rb,
lib/lanes/command/client_model_update.rb
Defined Under Namespace
Modules: ClientModelUpdate Classes: App, Console, Db, Generate, GenerateModel, GenerateScreen, GenerateView, ModelAttribute, NamedCommand, Server, Update, UpdateModel
Class Method Summary collapse
- ._maybe_fail(should_raise) ⇒ Object
-
.load_current_extension(raise_on_fail: false) ⇒ Extension
Loads the code for the extension that the user is currently working inside.
-
.usage_from_file(file) ⇒ Object
Reads and returns the contents of a usage file.
Class Method Details
._maybe_fail(should_raise) ⇒ Object
37 38 39 40 |
# File 'lib/lanes/command.rb', line 37 def _maybe_fail(should_raise) raise Thor::Error.new("Unable to locate Lanes environment.\nDoes ./lib/*/extension.rb exist?") if should_raise return nil end |
.load_current_extension(raise_on_fail: false) ⇒ Extension
Loads the code for the extension that the user is currently working inside. The ‘lanes` command uses this to detect what actions should be taken.
Will silently swallow any exceptions that are raised when the file is required and return nil
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lanes/command.rb', line 21 def load_current_extension(raise_on_fail:false) previous = Extensions.all ext = Dir.glob("./lib/*/extension.rb").first if ext begin require(ext) rescue =>e stack = e.backtrace[0..4].join("\n") raise Thor::Error.new("Loading ./lib/*/extension.rb failed with: #{e}\n#{stack}") end Extensions.controlling else return _maybe_fail(raise_on_fail) end end |
.usage_from_file(file) ⇒ Object
Reads and returns the contents of a usage file. Used internally by commands to populate their long_desc
10 11 12 |
# File 'lib/lanes/command.rb', line 10 def usage_from_file(file) Pathname.new(__FILE__).dirname.join("command","#{file}.usage").read.gsub(/\n/,"\n\x5") end |