Class: Omnibus::BuildVersionDSL

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/omnibus/build_version_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included

Constructor Details

#initialize(version_string = nil, &block) ⇒ BuildVersionDSL


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/omnibus/build_version_dsl.rb', line 29

def initialize(version_string = nil, &block)
  @build_version = nil
  @source_type = nil
  @source_options = nil
  @output_method = nil

  if version_string
    @build_version = version_string
  elsif block_given?
    instance_eval(&block)
    construct_build_version unless from_dependency?
  else
    raise "Please give me the build_version or tell me how to construct it"
  end
end

Instance Attribute Details

#build_versionObject (readonly)

DSL to construct a build_version during the build.


24
25
26
# File 'lib/omnibus/build_version_dsl.rb', line 24

def build_version
  @build_version
end

#output_methodObject (readonly)

Returns the value of attribute output_method


27
28
29
# File 'lib/omnibus/build_version_dsl.rb', line 27

def output_method
  @output_method
end

#source_optionsObject (readonly)

Returns the value of attribute source_options


26
27
28
# File 'lib/omnibus/build_version_dsl.rb', line 26

def source_options
  @source_options
end

#source_typeObject (readonly)

Returns the value of attribute source_type


25
26
27
# File 'lib/omnibus/build_version_dsl.rb', line 25

def source_type
  @source_type
end

Instance Method Details

#explainString

Explains the build_version. Either gives its value or gives information about how it will be constructed.


79
80
81
82
83
84
85
86
87
88
89
# File 'lib/omnibus/build_version_dsl.rb', line 79

def explain
  if build_version
    "Build Version: #{@build_version}"
  else
    if from_dependency?
      "Build Version will be determined from software '#{version_dependency}'"
    else
      "Build Version is not determined yet."
    end
  end
end

#output_format(output_method) ⇒ void

This method returns an undefined value.

DSL method to set the output_format of the build_version. Only honored

when source_type is set to :git

60
61
62
# File 'lib/omnibus/build_version_dsl.rb', line 60

def output_format(output_method)
  @output_method = output_method
end

#resolve(dependency) ⇒ void

This method returns an undefined value.

Callback that is called by software objects to determine the version.


68
69
70
71
72
73
# File 'lib/omnibus/build_version_dsl.rb', line 68

def resolve(dependency)
  if from_dependency? && version_dependency == dependency.name
    construct_build_version(dependency)
    log.info(log_key) { "Build Version is set to '#{build_version}'" }
  end
end

#source(source_type, source_options = {}) ⇒ void

This method returns an undefined value.

DSL method to set the source of the build_version


50
51
52
53
# File 'lib/omnibus/build_version_dsl.rb', line 50

def source(source_type, source_options = {})
  @source_type = source_type
  @source_options = source_options
end