Class: Semvergen::Shell
- Inherits:
-
Object
- Object
- Semvergen::Shell
- Defined in:
- lib/semvergen/shell.rb
Instance Method Summary collapse
- #build_gem(gem_name) ⇒ Object
- #cleanup(gem_name, version) ⇒ Object
- #commit(version_path, node_version_path, new_version, commit_subject, features) ⇒ Object
- #current_branch ⇒ Object
- #git_branch_is_tracking? ⇒ Boolean
- #git_fetch ⇒ Object
- #git_index_dirty? ⇒ Boolean
- #git_up_to_date? ⇒ Boolean
-
#initialize(execute_function = method(:system_exec).to_proc) ⇒ Shell
constructor
A new instance of Shell.
- #publish(gem_name, version, gem_server) ⇒ Object
- #publish_node_module ⇒ Object
- #push(new_version, remote_name = "origin", branch_name = current_branch) ⇒ Object
Constructor Details
#initialize(execute_function = method(:system_exec).to_proc) ⇒ Shell
Returns a new instance of Shell.
5 6 7 |
# File 'lib/semvergen/shell.rb', line 5 def initialize(execute_function = method(:system_exec).to_proc) @execute_function = execute_function end |
Instance Method Details
#build_gem(gem_name) ⇒ Object
45 46 47 |
# File 'lib/semvergen/shell.rb', line 45 def build_gem(gem_name) execute "gem build #{gem_name}.gemspec --force" end |
#cleanup(gem_name, version) ⇒ Object
61 62 63 |
# File 'lib/semvergen/shell.rb', line 61 def cleanup(gem_name, version) execute "rm #{gem_name}-#{version}.gem" end |
#commit(version_path, node_version_path, new_version, commit_subject, features) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/semvergen/shell.rb', line 29 def commit(version_path, node_version_path, new_version, commit_subject, features) commit_body = (new_version, commit_subject, features.join("\n")) execute "git add CHANGELOG.md" execute "git add #{version_path}" if node_version_path execute "git add #{node_version_path}" end execute %Q[git commit -m "#{commit_body}"] execute %Q[git tag #{new_version} -a -m "Version: #{new_version} - #{commit_subject}"] end |
#current_branch ⇒ Object
13 14 15 |
# File 'lib/semvergen/shell.rb', line 13 def current_branch execute("git symbolic-ref --short HEAD").strip end |
#git_branch_is_tracking? ⇒ Boolean
21 22 23 |
# File 'lib/semvergen/shell.rb', line 21 def git_branch_is_tracking? `git rev-list HEAD..@{u} --count` and return $?.exitstatus == 0 end |
#git_fetch ⇒ Object
17 18 19 |
# File 'lib/semvergen/shell.rb', line 17 def git_fetch `git fetch -q` end |
#git_index_dirty? ⇒ Boolean
9 10 11 |
# File 'lib/semvergen/shell.rb', line 9 def git_index_dirty? execute("git status --porcelain") =~ /^\s*(D|M|A|R|C)\s/ end |
#git_up_to_date? ⇒ Boolean
25 26 27 |
# File 'lib/semvergen/shell.rb', line 25 def git_up_to_date? `git rev-list HEAD..@{u} --count`.strip.to_i == 0 end |
#publish(gem_name, version, gem_server) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/semvergen/shell.rb', line 49 def publish(gem_name, version, gem_server) if gem_server == "rubygems.org" publish_to_rubygems(gem_name, version) else publish_to_gemserver(gem_name, version, gem_server) end end |
#publish_node_module ⇒ Object
57 58 59 |
# File 'lib/semvergen/shell.rb', line 57 def publish_node_module execute "npm publish" rescue nil end |
#push(new_version, remote_name = "origin", branch_name = current_branch) ⇒ Object
41 42 43 |
# File 'lib/semvergen/shell.rb', line 41 def push(new_version, remote_name="origin", branch_name=current_branch) execute "git push -q #{remote_name} #{branch_name} #{new_version}" end |