Sha256: 47bf8f8fdb71ce7e610ba24bc90ddd17bb5811e6936796b3d2205e4919721730

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

require 'dassets'

module Dassets; end
class Dassets::Runner
  UnknownCmdError = Class.new(ArgumentError)
  CmdError = Class.new(RuntimeError)
  CmdFail = Class.new(RuntimeError)

  attr_reader :cmd_name, :cmd_args, :opts

  def initialize(args, opts)
    @opts = opts
    @cmd_name = args.shift || ""
    @cmd_args = args
  end

  def run
    Dassets.init

    case @cmd_name
    when 'digest'
      require 'dassets/runner/digest_command'
      DigestCommand.new(@cmd_args).run
    when 'cache'
      require 'dassets/runner/cache_command'
      CacheCommand.new(@cmd_args.first).run
    when 'null'
      NullCommand.new.run
    else
      raise UnknownCmdError, "unknown command `#{@cmd_name}`"
    end
  end

  class NullCommand
    def run
      # if this was a real command it would do something here
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dassets-0.2.0 lib/dassets/runner.rb