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

Class Method Details

.load_current_extensionExtension

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

Returns:

  • (Extension)

    extension that was loaded, nil if none was found



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lanes/command.rb', line 19

def load_current_extension
    previous = Extensions.all
    ext = Dir.glob("./lib/**/extension.rb").first
    if ext
        begin
            require(ext)
        rescue
            return nil
        end
        diff = Extensions.all - previous
        return diff.any? ? diff.first.new : nil
    else
        return nil
    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

Parameters:

  • basename (String)

    of file to read usage from



8
9
10
# File 'lib/lanes/command.rb', line 8

def usage_from_file(file)
    Pathname.new(__FILE__).dirname.join("command","#{file}.usage").read
end