Class: ZAssets::CLI

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

Constant Summary collapse

ACTIONS =
%w[build serve].freeze

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



26
27
28
# File 'lib/zassets/cli.rb', line 26

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
# File 'lib/zassets/cli.rb', line 19

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

#serverObject



30
31
32
# File 'lib/zassets/cli.rb', line 30

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