Class: Semvergen::Release

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/semvergen/release.rb

Instance Method Summary collapse

Constructor Details

#initialize(interface, version_file, node_version_file, change_log_file, shell, gem_name, gem_server, notifier) ⇒ Release

Returns a new instance of Release.



9
10
11
12
13
14
15
16
17
18
# File 'lib/semvergen/release.rb', line 9

def initialize(interface, version_file, node_version_file, change_log_file, shell, gem_name, gem_server, notifier)
  @interface = interface
  @version_file = version_file
  @node_version_file = node_version_file
  @change_log_file = change_log_file
  @shell = shell
  @gem_name = gem_name
  @gem_server = gem_server
  @notifier = notifier
end

Instance Method Details

#run!(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/semvergen/release.rb', line 20

def run!(options={})
  if agree("Release? ")
    if @gem_server == "rubygems.org" && !File.exist?(File.expand_path("~/.gem/credentials"))
      @interface.fail_exit("Could not find rubygems.org credentials file at ~/.gem/credentials. Please make sure this file exists and that it has the correct credentials before continuing.")
    end
    say "Found gemspec: #{color(@gem_name, :green)}"
    newline

    say color("Building gem: ")
    @shell.build_gem(@gem_name)
    say color("OK", :green, :bold)

    say color("Publishing: ")
    @shell.publish(@gem_name, @version_file.version, @gem_server)
    say color("OK", :green, :bold)

    if @node_version_file
      say color("Publishing to NPM: ")
      if @shell.publish_node_module.nil?
        say color("Error: npm CLI not found! Please ensure that 'npm publish' runs successfully", :underline, :red)
      end
    end

    features = options[:features] || gem_features
    @notifier.gem_published(@gem_name, gem_version, features.join("\n"))

    @shell.cleanup(@gem_name, gem_version) rescue say color("Unable to cleanup", :red)
  end
end