Class: Deliver::Deliverer

Inherits:
Object
  • Object
show all
Defined in:
lib/deliver/deliverer.rb

Overview

This class will collect the deploy data from different places This will trigger:

  • Parsing the Deliverfile

  • Temporary storing all the information got from the file, until the file finished executing

  • Triggering the upload process itself using the DeliverProcess class

Defined Under Namespace

Modules: AllBlocks, ValKey

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil, hash: nil, force: false) ⇒ Deliverer

Start a new deployment process based on the given Deliverfile used for build servers. If this is set to false a PDF summary will be generated and opened

Parameters:

  • path (String) (defaults to: nil)

    The path to the Deliverfile.

  • hash (Hash) (defaults to: nil)

    You can pass a hash instead of a path to basically give all the information required (see ValKey for available options)

  • force (Bool) (defaults to: false)

    Runs a deployment without verifying any information. This can be



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/deliver/deliverer.rb', line 49

def initialize(path = nil, hash: nil, force: false)
  @deliver_process = DeliverProcess.new
  @deliver_process.deploy_information[ValKey::SKIP_PDF] = true if force

  if hash
    hash.each do |key, value|
      # we still call this interface to verify the inputs correctly
      set_new_value(key, value)
    end

    finished_executing_deliver_file
  else
    @deliver_file = Deliver::Deliverfile::Deliverfile.new(self, path)
  end

  # Do not put code here...
end

Instance Attribute Details

#deliver_fileDeliver::Deliverfile::Deliverfile

Returns A reference to the Deliverfile which is currently being used.

Returns:



11
12
13
# File 'lib/deliver/deliverer.rb', line 11

def deliver_file
  @deliver_file
end

#deliver_processDeliver::DeliverProcess

Returns The class which handels the deployment process itself.

Returns:



14
15
16
# File 'lib/deliver/deliverer.rb', line 14

def deliver_process
  @deliver_process
end

Class Method Details

.all_available_blocks_to_setHash

An array of all available blocks to be set for a deployment

Is used to verify user inputs

Returns:

  • (Hash)

    The array of symbols



99
100
101
# File 'lib/deliver/deliverer.rb', line 99

def self.all_available_blocks_to_set
  Deliverer::AllBlocks.constants.collect { |a| Deliverer::AllBlocks.const_get(a) }
end

.all_available_keys_to_setHash

An array of all available options to be set a deployment_information.

Is used to verify user inputs

Returns:

  • (Hash)

    The array of symbols



91
92
93
# File 'lib/deliver/deliverer.rb', line 91

def self.all_available_keys_to_set
  Deliverer::ValKey.constants.collect { |a| Deliverer::ValKey.const_get(a) }
end

Instance Method Details

#finished_executing_deliver_fileObject

This method will take care of the actual deployment process, after we received all information from the Deliverfile.

This method will be called from the Deliver::Deliverfile after it is finished executing the Ruby script.



108
109
110
# File 'lib/deliver/deliverer.rb', line 108

def finished_executing_deliver_file
  deliver_process.run
end

#set_new_block(key, block) ⇒ Object

Sets a new block for a specific key



83
84
85
# File 'lib/deliver/deliverer.rb', line 83

def set_new_block(key, block)
  @deliver_process.deploy_information[:blocks][key] = block
end

#set_new_value(key, value) ⇒ Object

This method is internally called from the Deliverfile DSL to set a value for a given key. This method will also verify if the key is valid.



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/deliver/deliverer.rb', line 70

def set_new_value(key, value)
  unless self.class.all_available_keys_to_set.include?key
    raise "Invalid key '#{key}', must be contained in Deliverer::ValKey.".red
  end

  if @deliver_process.deploy_information[key]      
    Helper.log.warn("You already set a value for key '#{key}'. Overwriting value '#{value}' with new value.")
  end

  @deliver_process.deploy_information[key] = value
end