Class: Tara::Archiver

Inherits:
Object
  • Object
show all
Defined in:
lib/tara/archiver.rb

Overview

Jara compatible Archiver class that makes it easy to release artiftacts using Tara and Jara.

Examples:

Release an artifact from a Rake task

task :release do
  archiver = Tara::Archiver.new
  releaser = Jara::Releaser.new('production', 'artifact-bucket', archiver: archiver)
  releaser.release
end

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Archiver

Create a new instance of Archiver with the specified configuration.

The Archiver class supports the same configuration as Tara::Archive#initialize does, with the addition of a :metadata option.

Parameters:

  • config (Hash) (defaults to: {})

Options Hash (config):

  • :app_dir (String) — default: Dir.pwd

    absolute path to the application directory.

  • :app_name (String) — default: File.basename(@config[:app_dir])

    name of the application.

  • :build_dir (String) — default: File.join(@config[:app_dir], 'build')

    the directory where the archive will be created.

  • :download_dir (String) — default: File.join(@config[:build_dir], 'downloads')

    the directory where Traveling Ruby artifacts will be downloaded.

  • :archive_name (String) — default: @config[:app_name] + '.tgz'

    name of the archive

  • :files (Array<String>) — default: %w[lib/**/*.rb]

    list of globs that will be expanded when including source files in archive. Should be relative from :app_dir.

  • :executables (Array<String>) — default: %w[bin/*]

    list of globs that will be expanded when including executables in archive. Should be relative from :app_dir.

  • :target (String) — default: linux-x86_64

    target platform that the archive will be created for. Should be one of "linux-x86", "linux-x86_64", or "osx".

  • :traveling_ruby_version (String) — default: 20150210

    release of Traveling Ruby that should be used.

  • :without_groups (Array<String>) — default: %w[development test]

    list of gem groups to exclude from the archive.

  • :metadata (Hash) — default: {}

    addidtional metadata that the published artifact will be tagged with.


43
44
45
46
# File 'lib/tara/archiver.rb', line 43

def initialize(config={})
  @config = config
  @config[:metadata] ||= {}
end

Instance Method Details

#content_typeString

Content type used by this archiver

Returns:

  • (String)

    'application/x-gzip'


68
69
70
# File 'lib/tara/archiver.rb', line 68

def content_type
  'application/x-gzip'
end

#create(options = {}) ⇒ String

Create a new archive

Returns:

  • (String)

    Path to the created archive


52
53
54
# File 'lib/tara/archiver.rb', line 52

def create(options={})
  Archive.create(@config.merge(options))
end

#extensionString

Extension used by this archiver

Returns:

  • (String)

    'tgz'


60
61
62
# File 'lib/tara/archiver.rb', line 60

def extension
  'tgz'
end

#metadataHash

Metadata that the published artifact will be tagged with.

Returns:

  • (Hash)

    Hash of key-value pairs that will be used as tags.


76
77
78
# File 'lib/tara/archiver.rb', line 76

def 
  @config[:metadata]
end