Module: Harrison

Defined in:
lib/harrison.rb,
lib/harrison/ssh.rb,
lib/harrison/base.rb,
lib/harrison/config.rb,
lib/harrison/deploy.rb,
lib/harrison/package.rb,
lib/harrison/version.rb,
lib/harrison/deploy/phase.rb

Defined Under Namespace

Classes: Base, Config, Deploy, Package, SSH

Constant Summary collapse

VERSION =
"0.9.5"

Class Method Summary collapse

Class Method Details

.config(opts = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/harrison.rb', line 48

def self.config(opts={})
  @@config ||= Harrison::Config.new(opts)

  if block_given?
    yield @@config
  else
    @@config
  end
end

.deploy(opts = {}) {|| ... } ⇒ Object

Yields:

  • ()


67
68
69
70
71
72
73
74
# File 'lib/harrison.rb', line 67

def self.deploy(opts={})
  @@task_runners[:deploy] ||= Harrison::Deploy.new(opts)

  # Parse options if this is the target command.
  @@task_runners[:deploy].parse(@@args.dup) if @@runner && @@runner.call == @@task_runners[:deploy]

  yield @@task_runners[:deploy]
end

.invoke(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/harrison.rb', line 17

def self.invoke(args)
  @@args = args.freeze
  @@task_runners = {
    package: nil,
    deploy: nil,
  }

  abort("No command given. Run with --help for valid commands and options.") if @@args.empty?

  # Catch root level --help
  Harrison::Base.new.parse(@@args.dup) and exit(0) if @@args[0] == '--help'

  # Find Harrisonfile.
  hf = find_harrisonfile || abort("ERROR: Could not find a Harrisonfile in this directory or any ancestor.")

  # Find the class to handle command.
  @@runner = find_runner(@@args[0]) || abort("ERROR: Unrecognized command \"#{@@args[0]}\".")

  # Eval the Harrisonfile.
  eval_script(hf)

  # Invoke command and cleanup afterwards.
  begin
    @@runner.call.run
  rescue => e
    raise e
  ensure
    @@runner.call.close
  end
end

.package(opts = {}) {|| ... } ⇒ Object

Yields:

  • ()


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

def self.package(opts={})
  @@task_runners[:package] ||= Harrison::Package.new(opts)

  # Parse options if this is the target command.
  @@task_runners[:package].parse(@@args.dup) if @@runner && @@runner.call == @@task_runners[:package]

  yield @@task_runners[:package]
end