Class: RCS::Deploy::Me
- Inherits:
-
Object
- Object
- RCS::Deploy::Me
- Defined in:
- lib/rcs-common/deploy.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #ask(question, yes_no: true, choices: %w[y n])) ⇒ Object
-
#initialize ⇒ Me
constructor
A new instance of Me.
- #pending_changes? ⇒ Boolean
- #run(cmd, opts = {}) ⇒ Object
Constructor Details
#initialize ⇒ Me
Returns a new instance of Me.
13 14 15 16 17 18 |
# File 'lib/rcs-common/deploy.rb', line 13 def initialize @path ||= File.(Dir.pwd) raise "Missing rakefile" unless File.exists?("#{@path}/Rakefile") raise "Not in a git repo" unless Dir.exists?("#{@path}/.git") end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/rcs-common/deploy.rb', line 11 def path @path end |
Instance Method Details
#ask(question, yes_no: true, choices: %w[y n])) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rcs-common/deploy.rb', line 29 def ask(question, yes_no: true, choices: %w[y n]) print("#{question} (#{choices.join(', ')}): ") begin answer = STDIN.readline.strip.downcase yes_no ? (answer == 'y' or answer == 'yes') : answer rescue Interrupt puts "\nBye" exit end end |
#pending_changes? ⇒ Boolean
25 26 27 |
# File 'lib/rcs-common/deploy.rb', line 25 def pending_changes? run("cd \"#{path}\" && git status", trap: true) !~ /nothing to commit, working directory clean/ end |
#run(cmd, opts = {}) ⇒ Object
20 21 22 23 |
# File 'lib/rcs-common/deploy.rb', line 20 def run(cmd, opts = {}) puts "executing: #{cmd}" opts[:trap] ? `#{cmd}` : Kernel.system(cmd) end |