Sha256: a2919cb22f18e0a7e05adb1659d4e46e36126980650cf6d400cca5fd78208050

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

module Lanes
    module Command
        class << self

            # Reads and returns the contents of a usage file.  Used
            # internally by commands to populate their long_desc
            # @param [String] basename of file to read usage from
            def usage_from_file(file)
                Pathname.new(__FILE__).dirname.join("command","#{file}.usage").read
            end

            # 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
            #
            # @return [Extension] extension that was loaded, nil if none was found
            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

        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lanes-0.0.5 lib/lanes/command.rb