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`.

  • :gem_executables (Array<String, String>) — default: []

    list of gem and exec name pairs which will be included as executables in archive.

  • :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.



45
46
47
48
# File 'lib/tara/archiver.rb', line 45

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

Instance Method Details

#content_typeString

Content type used by this archiver

Returns:

  • (String)

    ‘application/x-gzip’



70
71
72
# File 'lib/tara/archiver.rb', line 70

def content_type
  'application/x-gzip'
end

#create(options = {}) ⇒ String

Create a new archive

Returns:

  • (String)

    Path to the created archive



54
55
56
# File 'lib/tara/archiver.rb', line 54

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

#extensionString

Extension used by this archiver

Returns:

  • (String)

    ‘tgz’



62
63
64
# File 'lib/tara/archiver.rb', line 62

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.



78
79
80
# File 'lib/tara/archiver.rb', line 78

def 
  @config[:metadata]
end