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

Returns a new instance of BuildVersionDSL.



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

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

  if version_string
    self.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

DSL to construct a build_version during the build.



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

def build_version
  @build_version
end

#output_methodObject (readonly)

Returns the value of attribute output_method.



29
30
31
# File 'lib/omnibus/build_version_dsl.rb', line 29

def output_method
  @output_method
end

#source_optionsObject (readonly)

Returns the value of attribute source_options.



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

def source_options
  @source_options
end

#source_typeObject (readonly)

Returns the value of attribute source_type.



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

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.

Returns:

  • (String)


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

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

Parameters:

  • output_method (Symbol)

    Can be set to any method on Omnibus::BuildVersion



62
63
64
# File 'lib/omnibus/build_version_dsl.rb', line 62

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.

Parameters:



70
71
72
73
74
75
# File 'lib/omnibus/build_version_dsl.rb', line 70

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

Parameters:

  • source_type (Symbol)

    Can be set to :git or :version

  • source_options (Hash) (defaults to: {})

    Options for the given source_type.



52
53
54
55
# File 'lib/omnibus/build_version_dsl.rb', line 52

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