Class: Yuzu::Command::Base

Inherits:
Object show all
Includes:
Uploader
Defined in:
lib/yuzu/commands/base.rb

Overview

The Base class for all commands provides methods for coordinating the Updater, which manages the files to be updated and the actual update commands, and the Uploader, which takes care of turning update operations into service calls via FTP, S3, etc.

Direct Known Subclasses

PublicationCommand, Watch

Constant Summary

Constants included from Uploader

Uploader::ENDC, Uploader::GREEN

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, config) ⇒ Base

Returns a new instance of Base.



21
22
23
24
# File 'lib/yuzu/commands/base.rb', line 21

def initialize(args, config)
  @args = args
  @config = config
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



19
20
21
# File 'lib/yuzu/commands/base.rb', line 19

def args
  @args
end

Class Method Details

.help(method) ⇒ Object



53
54
# File 'lib/yuzu/commands/base.rb', line 53

def self.help(method)
end

.requires_config?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/yuzu/commands/base.rb', line 56

def self.requires_config?
  true
end

.service_overrideObject

This method enables a command to override the configuration’s selected publication service. Some commands work only locally, such as preview, or don’t have a publication method involved.



49
50
51
# File 'lib/yuzu/commands/base.rb', line 49

def self.service_override
  nil
end

.shell(cmd) ⇒ Object



26
27
28
# File 'lib/yuzu/commands/base.rb', line 26

def self.shell(cmd)
  FileUtils.cd(Dir.pwd) {|d| return `#{cmd}`}
end

Instance Method Details

#updaterObject



30
31
32
# File 'lib/yuzu/commands/base.rb', line 30

def updater
  @updater ||= Yuzu::Core::Updater.new(uploader, @config)
end

#uploaderObject



34
35
36
# File 'lib/yuzu/commands/base.rb', line 34

def uploader
  @uploader ||= UploadManager.new(uploader_config, self.class.service_override)
end

#uploader_configObject



38
39
40
41
42
43
44
45
# File 'lib/yuzu/commands/base.rb', line 38

def uploader_config
  options = {
    :connection => @config.connection,
    :verbose? => @config.verbose?
  }
  config_hash = @config.services.merge(options)
  UploaderConfig.new(config_hash)
end