Skip to content

Commit

Permalink
Support :publish_to_supermarket option in Releaser.
Browse files Browse the repository at this point in the history
Note that the former option (`:publish_to_community`) will continue to
work for previously set up Rakefiles and Thorfiles.
  • Loading branch information
fnichol committed Aug 6, 2014
1 parent c2baf85 commit 354f8d6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
15 changes: 10 additions & 5 deletions lib/emeril/releaser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class Releaser
# @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 (the
# 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
#
Expand All @@ -36,23 +39,25 @@ def initialize(options = {})
@metadata = options.fetch(:metadata) { default_metadata }
@category = options.fetch(:category) { default_category }
@git_tagger = options.fetch(:git_tagger) { default_git_tagger }
@publish_to_community = options.fetch(:publish_to_community) { true }
setup_publisher(options.fetch(:publisher, nil)) if publish_to_community
@publish_to_supermarket = options.fetch(:publish_to_supermarket) do
options.fetch(:publish_to_community, true)
end
setup_publisher(options.fetch(:publisher, nil)) if publish_to_supermarket
end

# Tags and releases a cookbook.
#
def run
git_tagger.run
publisher.run if publish_to_community
publisher.run if publish_to_supermarket
end

private

DEFAULT_CATEGORY = "Other".freeze

attr_reader :logger, :tag_prefix, :source_path, :metadata,
:category, :git_tagger, :publisher, :publish_to_community
:category, :git_tagger, :publisher, :publish_to_supermarket

def default_metadata
metadata_file = File.expand_path(File.join(source_path, "metadata.rb"))
Expand Down
14 changes: 7 additions & 7 deletions spec/integration/skip_publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

VCR.use_cassette("new_release") do
Emeril::Releaser.new(
:logger => logger,
:source_path => cookbook_path,
:publish_to_community => false
:logger => logger,
:source_path => cookbook_path,
:publish_to_supermarket => false
).run
end

Expand All @@ -48,10 +48,10 @@

VCR.use_cassette("new_release") do
Emeril::Releaser.new(
:logger => logger,
:source_path => cookbook_path,
:publish_to_community => false,
:tag_prefix => "release-"
:logger => logger,
:source_path => cookbook_path,
:publish_to_supermarket => false,
:tag_prefix => "release-"
).run
end

Expand Down
29 changes: 29 additions & 0 deletions spec/unit/emeril/releaser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@
)
end

it "does not call Publisher when disabling supermarket publishing" do
Emeril::Publisher.expects(:new).never

Emeril::Releaser.new(
:source_path => source_path,
:metadata => metadata,
:category => category,
:publish_to_supermarket => false
)
end

it "disables the git version tag prefix" do
Emeril::GitTagger.expects(:new).with do |opts|
opts[:tag_prefix] == false
Expand Down Expand Up @@ -150,6 +161,24 @@
releaser.run
end

describe "when disabling supermarket site publishing" do

it "does not call #run on publisher" do
releaser = Emeril::Releaser.new(
:metadata => metadata,
:category => category,
:git_tagger => git_tagger,
:publisher => publisher,
:publish_to_supermarket => false
)
publisher.unstub(:run)
publisher.expects(:run).never

releaser.run
end

end

describe "when disabling community site publishing" do

it "does not call #run on publisher" do
Expand Down

0 comments on commit 354f8d6

Please sign in to comment.