Sha256: 6d497235075e7c78cfc77f578ad4b74b4c81748bae9c188b0b8dcafed4a4587e

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

require 'dply/logger'
require 'dply/lock'
require 'dply/tasks'
require 'fileutils'

module Dply
  module Cli
    class Devbuild

      include Logger

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

      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
        tasks.install_pkgs(build_mode: true, use_yum: @options[:use_yum])
        tasks.build "app:build"
      ensure
        clear_bundle_config
      end

      def tasks
        @tasks ||= ::Dply::Tasks.new
      end

      def lock
        @lock ||= ::Dply::Lock.new
      end

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

      def opts
        OptionParser.new do |opts|

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

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

          opts.on("--use-yum", "use yum to install packages") do |e|
            @options[:use_yum] = true
          end

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

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dply-0.2.19 lib/dply/cli/devbuild.rb
dply-0.2.18 lib/dply/cli/devbuild.rb
dply-0.2.17 lib/dply/cli/devbuild.rb
dply-0.2.16 lib/dply/cli/devbuild.rb
dply-0.2.15 lib/dply/cli/devbuild.rb
dply-0.2.14 lib/dply/cli/devbuild.rb
dply-0.2.13 lib/dply/cli/devbuild.rb