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.3.0"

Class Method Summary collapse

Class Method Details

.config(opts = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/harrison.rb', line 43

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

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

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

Yields:

  • ()


62
63
64
65
66
67
68
69
# File 'lib/harrison.rb', line 62

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



12
13
14
15
16
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
# File 'lib/harrison.rb', line 12

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:

  • ()


53
54
55
56
57
58
59
60
# File 'lib/harrison.rb', line 53

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