Module: Hanzo

Defined in:
lib/hanzo.rb,
lib/hanzo/cli.rb,
lib/hanzo/base.rb,
lib/hanzo/heroku.rb,
lib/hanzo/version.rb,
lib/hanzo/modules/diff.rb,
lib/hanzo/modules/config.rb,
lib/hanzo/modules/deploy.rb,
lib/hanzo/modules/console.rb,
lib/hanzo/modules/install.rb,
lib/hanzo/fetchers/environment.rb,
lib/hanzo/modules/installers/labs.rb,
lib/hanzo/modules/installers/remotes.rb

Defined Under Namespace

Modules: Fetchers, Heroku, Installers Classes: Base, CLI, Config, Console, Deploy, Diff, Install

Constant Summary collapse

VERSION =
'1.1.0'.freeze

Class Method Summary collapse

Class Method Details

._run(&blk) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/hanzo.rb', line 28

def self._run(&blk)
  if defined?(Bundler)
    ::Bundler.with_clean_env(&blk)
  else
    blk.call
  end
end

.agree(question) ⇒ Object



51
52
53
# File 'lib/hanzo.rb', line 51

def self.agree(question)
  HighLine.agree "       #{question} "
end

.ask(question, &blk) ⇒ Object



55
56
57
# File 'lib/hanzo.rb', line 55

def self.ask(question, &blk)
  HighLine.ask "-----> #{question} ", &blk
end

.configObject



59
60
61
62
63
64
65
66
# File 'lib/hanzo.rb', line 59

def self.config
  return YAML.load_file('.hanzo.yml') if File.exist?('.hanzo.yml')

  Hanzo.print 'Cannot locate .hanzo.yml'
  Hanzo.print 'For more information, please read https://github.com/mirego/hanzo'

  exit
end


36
37
38
39
40
# File 'lib/hanzo.rb', line 36

def self.print(text = '', *colors)
  colors = colors.map { |c| HighLine.const_get(c.to_s.upcase) }
  text = text.join("\n       ") if text.is_a?(Array)
  HighLine.say HighLine.color("       #{text}", *colors)
end

.run(command, fetch_output = false) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hanzo.rb', line 13

def self.run(command, fetch_output = false)
  print(command, :green)
  output = true

  _run do
    output = if fetch_output
               `#{command}`
             else
               system(command)
             end
  end

  output
end

.title(text) ⇒ Object



47
48
49
# File 'lib/hanzo.rb', line 47

def self.title(text)
  HighLine.say HighLine.color("-----> #{text}", :blue)
end

.unindent_print(text = '', *colors) ⇒ Object



42
43
44
45
# File 'lib/hanzo.rb', line 42

def self.unindent_print(text = '', *colors)
  colors = colors.map { |c| HighLine.const_get(c.to_s.upcase) }
  HighLine.say HighLine.color(text, *colors)
end