Class: Semvergen::Shell
- Inherits:
-
Object
- Object
- Semvergen::Shell
- Defined in:
- lib/semvergen/shell.rb
Instance Method Summary collapse
- #build_gem(gem_name) ⇒ Object
- #commit(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
- #push(new_version, remote_name = "origin", branch_name = "master") ⇒ 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
42 43 44 |
# File 'lib/semvergen/shell.rb', line 42 def build_gem(gem_name) execute "gem build #{gem_name}.gemspec --force" end |
#commit(version_path, new_version, commit_subject, features) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/semvergen/shell.rb', line 29 def commit(version_path, new_version, commit_subject, features) commit_body = COMMIT_MESSAGE % [new_version, commit_subject, features.join("\n")] execute "git add CHANGELOG.md" execute "git add #{version_path}" execute %Q[git commit -m "#{commit_body}"] execute %Q[git tag #{new_version} -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
46 47 48 |
# File 'lib/semvergen/shell.rb', line 46 def publish(gem_name, version, gem_server) execute "gem inabox #{gem_name}-#{version}.gem --host #{gem_server}" end |
#push(new_version, remote_name = "origin", branch_name = "master") ⇒ Object
38 39 40 |
# File 'lib/semvergen/shell.rb', line 38 def push(new_version, remote_name="origin", branch_name="master") execute "git push -q #{remote_name} #{branch_name} #{new_version}" end |