Class: Dply::Cli::Devbuild

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

Instance Method Summary collapse

Methods included from Logger

#debug?, #logger, stderr, #stderr

Constructor Details

#initialize(argv) ⇒ Devbuild

Returns a new instance of Devbuild.



13
14
15
16
# File 'lib/dply/cli/devbuild.rb', line 13

def initialize(argv)
  @argv = argv
  @options = {}
end

Instance Method Details

#clear_bundle_configObject



46
47
48
# File 'lib/dply/cli/devbuild.rb', line 46

def clear_bundle_config
  FileUtils.rm ".bundle/config" if File.exists? ".bundle/config"
end

#lockObject



42
43
44
# File 'lib/dply/cli/devbuild.rb', line 42

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

#optsObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/dply/cli/devbuild.rb', line 50

def opts
  OptionParser.new do |opts|

    opts.banner = "Usage: drake devbuild [options]"

    opts.on("-r", "--revision [REVISION]", "Specify revision") do |r|
      @options[:revision] = r
    end

    opts.on("--bundler-without [BUNDLER_WITHOUT]", "bundler --without") do |i|
      @options[:bundler_without] = i
    end

    opts.on("-i", "install pkgs") do
      @options[:install] = true
    end

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

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dply/cli/devbuild.rb', line 18

def run
  lock.acquire
  opts.parse!(@argv)
  revision = @options[:revision] || "dev"
  ENV["BUILD_NUMBER"] = revision

  build_artifacts = "tmp/build_artifacts"
  FileUtils.mkdir_p build_artifacts

  clear_bundle_config
  bundle = Bundle.new
  bundler_without = @options[:bundler_without] || "staging development test"
  bundle.install(without: bundler_without)
  bundle.clean
  util.install_pkgs(build_mode: true) if @options[:install]
  util.run :build
ensure
  clear_bundle_config
end

#utilObject



38
39
40
# File 'lib/dply/cli/devbuild.rb', line 38

def util
  @util ||= ::Dply::Util.new
end