Class: Bard::DeployStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/bard/deploy_strategy.rb,
lib/bard/deploy_strategy/ssh.rb,
lib/bard/deploy_strategy/github_pages.rb

Direct Known Subclasses

GithubPages, SSH

Defined Under Namespace

Classes: GithubPages, SSH

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ DeployStrategy

Returns a new instance of DeployStrategy.



38
39
40
# File 'lib/bard/deploy_strategy.rb', line 38

def initialize(target)
  @target = target
end

Class Attribute Details

.strategiesObject (readonly)

Returns the value of attribute strategies.



8
9
10
# File 'lib/bard/deploy_strategy.rb', line 8

def strategies
  @strategies
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



36
37
38
# File 'lib/bard/deploy_strategy.rb', line 36

def target
  @target
end

Class Method Details

.[](name) ⇒ Object



18
19
20
# File 'lib/bard/deploy_strategy.rb', line 18

def [](name)
  strategies[name.to_sym]
end

.inherited(subclass) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/bard/deploy_strategy.rb', line 10

def inherited(subclass)
  super
  # Extract strategy name from class name
  # e.g., Bard::DeployStrategy::SSH -> :ssh
  name = extract_strategy_name(subclass)
  strategies[name] = subclass
end

Instance Method Details

#deployObject

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/bard/deploy_strategy.rb', line 42

def deploy
  raise NotImplementedError, "Subclasses must implement #deploy"
end

#run(command) ⇒ Object



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

def run(command)
  Command.run(command)
end

#run!(command) ⇒ Object

Helper methods for strategies



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

def run!(command)
  Command.run!(command)
end

#system!(command) ⇒ Object



55
56
57
58
# File 'lib/bard/deploy_strategy.rb', line 55

def system!(command)
  result = Kernel.system(command)
  raise "Command failed: #{command}" unless result
end