class Scm::Workflow::InitRepoWorkflow

Public Class Methods

new(repo, configuration, &block) click to toggle source


# File lib/scm-workflow/workflow-init-repo.rb, line 15
def initialize(repo, configuration, &block)
  @repo = repo
  @config = repo.config
  @configuration = configuration
  @callback = block
  logger.info("asdasdsa")
end

Public Instance Methods

on_persisting_entry(new_state, event, *args) click to toggle source


# File lib/scm-workflow/workflow-init-repo.rb, line 93
def on_persisting_entry(new_state, event, *args)
  logger.info("E: Persisting configuration info")
  
  @configuration.each { |c| 
    globalEntry = c
    
    entryTitle = c.class.name.split('::').last.downcase
    c.instance_variables.each do |sv|
      begin
        entry = c.instance_variable_get(sv)
        value = entry.value unless entry.hideinput
        value = entry.value.encrypt if entry.hideinput

        @config.setValue("scm-workflow.#{entryTitle}.#{sv[1..-1]}", value)
      rescue => exception
        logger.error(exception.to_s)
      end
    end
  }

end
on_persisting_exit(new_state, event, *args) click to toggle source
# File lib/scm-workflow/workflow-init-repo.rb, line 115
def on_persisting_exit(new_state, event, *args)
  logger.info("X: Persisting configuration info done")
end
on_querying_entry(new_state, event, *args) click to toggle source


# File lib/scm-workflow/workflow-init-repo.rb, line 82
def on_querying_entry(new_state, event, *args)
  logger.info("E: Querying configuration info")
  @callback.call(@configuration)
end
on_querying_exit(new_state, event, *args) click to toggle source
# File lib/scm-workflow/workflow-init-repo.rb, line 87
def on_querying_exit(new_state, event, *args)
  logger.info("X: Querying configuration info done")
end
on_retrieving_entry(new_state, event, *args) click to toggle source


# File lib/scm-workflow/workflow-init-repo.rb, line 59
def on_retrieving_entry(new_state, event, *args)
  logger.info("E: Retrieving configuration info")
  
  @configuration.each { |c| 
    entryTitle = c.class.name.split('::').last.downcase
    c.instance_variables.each do |sv|
      begin
        entry = c.instance_variable_get(sv)
        entry.value = @config.getValue("scm-workflow.#{entryTitle}.#{sv[1..-1]}")
      rescue => exception
        # That's ok, a missing value is ok.
      end
    end
  }

end
on_retrieving_exit(new_state, event, *args) click to toggle source
# File lib/scm-workflow/workflow-init-repo.rb, line 76
def on_retrieving_exit(new_state, event, *args)
  logger.info("X: Retrieving configuration info done")
end
on_validating_entry(new_state, event, *args) click to toggle source


# File lib/scm-workflow/workflow-init-repo.rb, line 48
def on_validating_entry(new_state, event, *args)
  logger.info("E: Init worflow ready to go")
  @repoValid = @repo.repo.valid?
end
on_validating_exit(new_state, event, *args) click to toggle source
# File lib/scm-workflow/workflow-init-repo.rb, line 53
def on_validating_exit(new_state, event, *args)
  logger.info("X: Init worflow done")
end
repoIsValid?() click to toggle source
# File lib/scm-workflow/workflow-init-repo.rb, line 119
def repoIsValid?
  return @repoValid
end