Class: ZAssets::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/zassets/cli.rb

Constant Summary collapse

ACTIONS =
%w(build serve)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, stdout = $stdout) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
13
# File 'lib/zassets/cli.rb', line 9

def initialize(args, stdout = $stdout)
  @stdout = stdout
  @action = :build
  args_parse! args
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



7
8
9
# File 'lib/zassets/cli.rb', line 7

def action
  @action
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/zassets/cli.rb', line 7

def options
  @options
end

Instance Method Details

#builderObject



28
29
30
# File 'lib/zassets/cli.rb', line 28

def builder
  @builder ||= Builder.new config
end

#configObject



15
16
17
# File 'lib/zassets/cli.rb', line 15

def config
  @config ||= Config.new @options
end

#runObject



19
20
21
22
23
24
25
26
# File 'lib/zassets/cli.rb', line 19

def run
  case @action
  when :serve
    server.run
  when :build
    builder.build
  end
end

#serverObject



32
33
34
# File 'lib/zassets/cli.rb', line 32

def server
  @server ||= Server.new config
end