Module: Hookify::Helpers
- Included in:
- Command, Command::Base
- Defined in:
- lib/hookify/helpers.rb
Instance Method Summary collapse
- #display(msg, newline = true) ⇒ Object
- #error(msg) ⇒ Object
- #executable(path) ⇒ Object
- #home_directory ⇒ Object
- #hooks_directory ⇒ Object
- #running_on_a_mac? ⇒ Boolean
- #running_on_windows? ⇒ Boolean
Instance Method Details
#display(msg, newline = true) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/hookify/helpers.rb', line 23 def display(msg, newline=true) if newline puts(msg) else print(msg) STDOUT.flush end end |
#error(msg) ⇒ Object
32 33 34 35 |
# File 'lib/hookify/helpers.rb', line 32 def error(msg) STDERR.puts(msg) # exit 1 end |
#executable(path) ⇒ Object
19 20 21 |
# File 'lib/hookify/helpers.rb', line 19 def executable(path) FileUtils.chmod(0755, path) end |
#home_directory ⇒ Object
7 8 9 |
# File 'lib/hookify/helpers.rb', line 7 def home_directory running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME'] end |
#hooks_directory ⇒ Object
3 4 5 |
# File 'lib/hookify/helpers.rb', line 3 def hooks_directory ".git/hooks" end |
#running_on_a_mac? ⇒ Boolean
15 16 17 |
# File 'lib/hookify/helpers.rb', line 15 def running_on_a_mac? RUBY_PLATFORM =~ /-darwin\d/ end |
#running_on_windows? ⇒ Boolean
11 12 13 |
# File 'lib/hookify/helpers.rb', line 11 def running_on_windows? RUBY_PLATFORM =~ /mswin32|mingw32/ end |