Module: Wordless::CLIHelper
- Included in:
- CLI
- Defined in:
- lib/wordless/cli_helper.rb
Instance Method Summary collapse
- #add_git_repo(repo, destination) ⇒ Object
- #download(url, destination) ⇒ Object
- #error(message) ⇒ Object
- #git_installed? ⇒ Boolean
- #success(message) ⇒ Object
- #unzip(file, destination) ⇒ Object
- #warning(message) ⇒ Object
Instance Method Details
#add_git_repo(repo, destination) ⇒ Object
38 39 40 |
# File 'lib/wordless/cli_helper.rb', line 38 def add_git_repo(repo, destination) run "git clone #{repo} #{destination}", :verbose => false, :capture => true end |
#download(url, destination) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wordless/cli_helper.rb', line 17 def download(url, destination) begin f = open(destination, "wb") f.write(open(url).read) ? true : false rescue false ensure f.close end end |
#error(message) ⇒ Object
5 6 7 |
# File 'lib/wordless/cli_helper.rb', line 5 def error() say , :red end |
#git_installed? ⇒ Boolean
32 33 34 35 36 |
# File 'lib/wordless/cli_helper.rb', line 32 def git_installed? # http://stackoverflow.com/questions/4597490/platform-independent-way-of-detecting-if-git-is-installed void = RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null' system "git --version >>#{void} 2>&1" end |
#success(message) ⇒ Object
9 10 11 |
# File 'lib/wordless/cli_helper.rb', line 9 def success() say , :green end |
#unzip(file, destination) ⇒ Object
28 29 30 |
# File 'lib/wordless/cli_helper.rb', line 28 def unzip(file, destination) run "unzip #{file} -d #{destination}", :verbose => false, :capture => true end |
#warning(message) ⇒ Object
13 14 15 |
# File 'lib/wordless/cli_helper.rb', line 13 def warning() say , :yellow end |