Class: Omnibus::BuildVersionDSL
- Inherits:
-
Object
- Object
- Omnibus::BuildVersionDSL
- Includes:
- Logging
- Defined in:
- lib/omnibus/build_version_dsl.rb
Instance Attribute Summary collapse
-
#build_version ⇒ Object
readonly
DSL to construct a build_version during the build.
-
#output_method ⇒ Object
readonly
Returns the value of attribute output_method.
-
#source_options ⇒ Object
readonly
Returns the value of attribute source_options.
-
#source_type ⇒ Object
readonly
Returns the value of attribute source_type.
Instance Method Summary collapse
-
#explain ⇒ String
Explains the build_version.
-
#initialize(version_string = nil, &block) ⇒ BuildVersionDSL
constructor
A new instance of BuildVersionDSL.
-
#output_format(output_method) ⇒ void
DSL method to set the output_format of the build_version.
-
#resolve(dependency) ⇒ void
Callback that is called by software objects to determine the version.
-
#source(source_type, source_options = {}) ⇒ void
DSL method to set the source of the build_version.
Methods included from Logging
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_version ⇒ Object
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_method ⇒ Object (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_options ⇒ Object (readonly)
Returns the value of attribute source_options.
28 29 30 |
# File 'lib/omnibus/build_version_dsl.rb', line 28 def @source_options end |
#source_type ⇒ Object (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
#explain ⇒ String
Explains the build_version. Either gives its value or gives information about how it will be constructed.
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
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.
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
52 53 54 55 |
# File 'lib/omnibus/build_version_dsl.rb', line 52 def source(source_type, = {}) @source_type = source_type @source_options = end |