Class: Bookbinder::Commands::BuildAndPushTarball

Inherits:
Object
  • Object
show all
Includes:
Naming
Defined in:
lib/bookbinder/commands/build_and_push_tarball.rb

Instance Method Summary collapse

Methods included from Naming

#command_for?, #command_type, #flag?

Constructor Details

#initialize(streams, configuration_fetcher) ⇒ BuildAndPushTarball

Returns a new instance of BuildAndPushTarball.



8
9
10
11
# File 'lib/bookbinder/commands/build_and_push_tarball.rb', line 8

def initialize(streams, configuration_fetcher)
  @success = streams[:success]
  @configuration_fetcher = configuration_fetcher
end

Instance Method Details

#run(_) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bookbinder/commands/build_and_push_tarball.rb', line 20

def run(_)
  config = configuration_fetcher.fetch_config
  aws_credentials = configuration_fetcher.fetch_credentials[:aws]
  archive = Deploy::Archive.new(key: aws_credentials.access_key, secret: aws_credentials.secret_key)
  result = archive.create_and_upload_tarball(
    build_number: ENV.fetch('BUILD_NUMBER', Time.now.strftime("%Y%m%d_%H%M")),
    bucket: aws_credentials.green_builds_bucket,
    namespace: Ingest::DestinationDirectory.new(config.book_repo)
  )
  success.puts(result.reason)
  0
end

#usageObject



15
16
17
18
# File 'lib/bookbinder/commands/build_and_push_tarball.rb', line 15

def usage
  [command_name,
   "Create a tarball from the final_app directory and push to the S3 bucket specified in your credentials.yml"]
end