class Paperwork::CLI

command line interface for paperwork

Constants

CONFIG_FILE

Attributes

config[RW]

Public Instance Methods

build() click to toggle source
# File lib/paperwork/cli.rb, line 27
def build
    build_internal "build"
end
rebuild() click to toggle source
# File lib/paperwork/cli.rb, line 38
def rebuild
    build_internal "rebuild"
end
server() click to toggle source
# File lib/paperwork/cli.rb, line 44
def server
    build_internal "server"
end

Protected Instance Methods

build_internal(task) click to toggle source
# File lib/paperwork/cli.rb, line 50
def build_internal(task)
    setup_config
    setup_tasks
    invoke_tasks task
end
invoke_tasks(target) click to toggle source
# File lib/paperwork/cli.rb, line 78
def invoke_tasks(target)
    Rake::Task["paperwork:#{self.config["name"]}:set_verbose"].invoke if options[:verbose]
    Rake::Task["paperwork:#{self.config["name"]}:#{target}"].invoke
end
setup_config() click to toggle source
# File lib/paperwork/cli.rb, line 56
def setup_config
    unless File.exist?(CONFIG_FILE)
        raise Exception.new(
            "#{CONFIG_FILE} not found. You need to create a configuration file first."
        )
    end

    yaml = YAML.load_file(CONFIG_FILE)
    self.config = yaml["config"]
    self.config["sources"] << CONFIG_FILE

    return unless self.config.nil?

    raise Exception.new(
        "No 'config' found in #{CONFIG_FILE}. You need to describe the build setup in a 'config' section first."
    )
end
setup_tasks() click to toggle source
# File lib/paperwork/cli.rb, line 74
def setup_tasks
    paperwork self.config["name"], sources: self.config["sources"]
end