Class: Dply::Cli::Build

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/dply/cli/build.rb

Instance Method Summary collapse

Methods included from Logger

#debug?, #logger, stderr, #stderr

Constructor Details

#initialize(argv) ⇒ Build

Returns a new instance of Build.



12
13
14
# File 'lib/dply/cli/build.rb', line 12

def initialize(argv)
  @argv = argv
end

Instance Method Details

#buildObject



22
23
24
# File 'lib/dply/cli/build.rb', line 22

def build
  @build ||= ::Dply::Build.new(config)
end

#configObject



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

def config
  @config ||= BuildConfig.build("#{Dir.pwd}/build.rb")
end

#lockObject



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

def lock
  @lock ||= Lock.new(Dir.pwd)
end

#optsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/dply/cli/build.rb', line 34

def opts
  OptionParser.new do |opts|

    opts.banner = "Usage: drake build [options] [target]"

    opts.on("-b", "--branch [BRANCH]" , "Specify git branch") do |b|
      config.branch = b
    end

    opts.on("-r", "--revision [REVISION]", "Specify revision") do |r|
      config.revision = r
      ENV["BUILD_NUMBER"] = r.to_s
    end

    opts.on("--no-pull", "Enable/disable git pull") do |e|
      config.no_pull = true
    end

    opts.on("--skip-git", "Disable git") do |e|
      config.git = false
    end

    opts.on("-h", "--help", "Help") do
      puts opts
      exit
    end
  end
end

#runObject



16
17
18
19
20
# File 'lib/dply/cli/build.rb', line 16

def run
  lock.acquire
  opts.parse!(@argv)
  build.run
end