Class: Docman::Builders::Builder

Inherits:
Command
  • Object
show all
Defined in:
lib/docman/builders/builder.rb

Direct Known Subclasses

CopyBuilder, DirBuilder, ProviderBuilder

Constant Summary collapse

@@builders =
{}
@@build_results =
{}

Instance Attribute Summary

Attributes inherited from Command

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#add_action, #add_actions, #execute, #initialize, #perform, register_command, #replace_placeholder, #run_actions, #run_with_hooks

Methods included from Logging

#log, logger, #logger, #properties_info, #with_logging

Constructor Details

This class inherits a constructor from Docman::Command

Class Method Details

.create(params = nil, context = nil, caller = nil) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/docman/builders/builder.rb', line 11

def self.create(params = nil, context = nil, caller = nil)
  c = @@builders[params['handler']]
  if c
    c.new(params, context, caller, 'builder')
  else
    raise "Bad builder type: #{type}"
  end
end

.register_builder(name) ⇒ Object



20
21
22
# File 'lib/docman/builders/builder.rb', line 20

def self.register_builder(name)
  @@builders[name] = self
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/docman/builders/builder.rb', line 81

def changed?
  false
end

#configObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/docman/builders/builder.rb', line 24

def config
  super
  @version = nil
  environment = Application.instance.environment(@context.environment_name)

  clean_changed = environment['clean_changed'].nil? ? true : environment['clean_changed']
  add_action('before_execute', {'type' => :clean_changed}, @context) if clean_changed

  info = @context.info_file_yaml
  if info
    info['context'] = @context
    name = @context['name']
    environment['previous'] = {} if environment['previous'].nil?
    environment['previous'][name] = info
  end

  unless @context.key? 'provider'
    @context['provider'] = self['provider']
  end
  if @context['provider'] && self['target_path_id']
    self['target_path'] = @context[self['target_path_id']]
    @provider = Docman::Command.create({'type' => @context['provider'], 'target_path' => self['target_path']}, @context, self)
  end
end

#describeObject



85
86
87
# File 'lib/docman/builders/builder.rb', line 85

def describe
  "Build: #{properties_info}"
end

#prefixObject



89
90
91
# File 'lib/docman/builders/builder.rb', line 89

def prefix
  "#{@context['name']} - #{self.class.name}"
end

#validate_commandObject



49
50
51
52
# File 'lib/docman/builders/builder.rb', line 49

def validate_command
  raise "Please provide 'context'" if @context.nil?
  raise "Context should be of type 'Info'" unless @context.is_a? Docman::Info
end

#versionObject



54
55
56
# File 'lib/docman/builders/builder.rb', line 54

def version
  @version
end