class Emeril::Releaser

Tags a git commit with a version string and (optionally) pushes the cookbook to the Community Site.

@author Fletcher Nichol <fnichol@nichol.ca>

Constants

DEFAULT_CATEGORY

Attributes

category[R]
git_tagger[R]
logger[R]
metadata[R]
publish_to_supermarket[R]
publisher[R]
source_path[R]
tag_prefix[R]

Public Class Methods

new(options = {}) click to toggle source

Creates a new instance.

@param [Hash] options configuration for a releaser @option options [Logger] an optional logger instance @option options [String] source_path the path to a git repository @option options [Hash] metadata a hash of cookbook metadata @option options [String] category a Community Site category for the

cookbook

@option options [GitTagger] git_tagger a git tagger @option options [Publisher] publisher a publisher @option options [Boolean] publish_to_community a boolean which

controls if the cookbook will published on the Community Site, now
the Supermarket site (the default is to publish)

@option options [Boolean] publish_to_supermarket a boolean which

controls if the cookbook will published on the Supermarket site (the
default is to publish)

@raise [ArgumentError] if any required options are not set

# File lib/emeril/releaser.rb, line 34
def initialize(options = {})
  @logger = options[:logger]
  @tag_prefix = options[:tag_prefix]
  @source_path = options.fetch(:source_path, Dir.pwd)
  @metadata = options.fetch(:metadata) { default_metadata }
  @category = options.fetch(:category) { default_category }
  @git_tagger = options.fetch(:git_tagger) { default_git_tagger }
  @publish_to_supermarket = options.fetch(
    :publish_to_supermarket,
    options.fetch(:publish_to_community, true)
  )
  setup_publisher(options.fetch(:publisher, nil))
end

Public Instance Methods

run() click to toggle source

Tags and releases a cookbook.

# File lib/emeril/releaser.rb, line 50
def run
  git_tagger.run
  publisher.run if publish_to_supermarket
end

Private Instance Methods

default_category() click to toggle source
# File lib/emeril/releaser.rb, line 91
def default_category
  Category.for_cookbook(metadata[:name]) || "Other"
end
default_git_tagger() click to toggle source
# File lib/emeril/releaser.rb, line 67
def default_git_tagger
  GitTagger.new(
    :logger => logger,
    :source_path => source_path,
    :version => metadata[:version],
    :tag_prefix => tag_prefix
  )
end
default_metadata() click to toggle source
# File lib/emeril/releaser.rb, line 62
def default_metadata
  metadata_file = File.expand_path(File.join(source_path, "metadata.rb"))
  MetadataChopper.new(metadata_file)
end
default_publisher() click to toggle source
# File lib/emeril/releaser.rb, line 76
def default_publisher
  Publisher.new(
    :logger => logger,
    :source_path => source_path,
    :name => metadata[:name],
    :category => category
  )
end
setup_publisher(publisher) click to toggle source
# File lib/emeril/releaser.rb, line 85
def setup_publisher(publisher)
  return unless publish_to_supermarket

  @publisher = publisher || default_publisher
end