Sha256: 65ebdf70758f30590c3f474886a8da2a7e4a0f85e4b7b87395e7266f8bc2786a
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
module Stack class Runner attr_accessor :configuration attr_accessor :command attr_accessor :arguments attr_accessor :generator def initialize(argv) @argv = argv @options = { } parse! end # Parse options, command and arguments def parse! options = Stack::parse! @argv @configuration = Stack::Configuration.new(options) @command = @argv.shift @arguments = @argv end # Run stack! def run! if @command.nil? @command = "generate" end if Stack::COMMANDS.include?(@command) run_command else abort "Unknown command: #{@command}. Use one of #{Stack::COMMANDS.join(", ")}." end end # Runs the specified command def run_command @generator = Stack::Generator.new(Stack::runner.configuration.source, Stack::runner.configuration.target) case self.command when /(generate|gen)/ @generator.transform! when /(server)/ # make a watcher if Stack::runner.configuration.server_watch watcher = Stack::Watcher.new(@generator) watcher.keep_alive = false watcher.observe else #@generator.transform! end # and a server server = Stack::Server.new(@generator) server.observe when /(watch)/ # setup a watcher watcher = Stack::Watcher.new(@generator) watcher.observe when /(create)/ File.open("#{Stack::runner.configuration.source}/_stack.yml", "w") { |file| YAML.dump(Stack::runner.configuration.to_hash, file) } puts "Created configuration file at '#{Stack::runner.configuration.source}/_stack.yml'" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stack-0.0.9 | lib/stack/runner.rb |
stack-0.0.8 | lib/stack/runner.rb |