Class: Exerb::Recipe::ResourceBlock::VersionBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/exerb/recipe.rb

Overview

IconBlock

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, filename) ⇒ VersionBlock

Returns a new instance of VersionBlock.

Raises:



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/exerb/recipe.rb', line 276

def initialize(block, filename)
  @file_version_number    = self.parse_version((block.delete('file_version_number')    || "0.0.0.0"), filename)
  @product_version_number = self.parse_version((block.delete('product_version_number') || "0.0.0.0"), filename)
  @comments               = block.delete('comments')          || ""
  @company_name           = block.delete('company_name')      || ""
  @legal_copyright        = block.delete('legal_copyright')   || ""
  @legal_trademarks       = block.delete('legal_trademarks')  || ""
  @file_version           = block.delete('file_version')      || ""
  @product_version        = block.delete('product_version')   || ""
  @product_name           = block.delete('product_name')      || ""
  @file_description       = block.delete('file_description')  || ""
  @internal_name          = block.delete('internal_name')     || ""
  @original_filename      = block.delete('original_filename') || ""
  @private_build          = block.delete('private_build')     || ""
  @special_build          = block.delete('special_build')     || ""

  raise(Exerb::ExerbError, "#{filename}: unknown field in version block -- #{block.keys.join(', ')}") unless block.empty?
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def comments
  @comments
end

#company_nameObject (readonly)

Returns the value of attribute company_name.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def company_name
  @company_name
end

#file_descriptionObject (readonly)

Returns the value of attribute file_description.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def file_description
  @file_description
end

#file_versionObject (readonly)

Returns the value of attribute file_version.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def file_version
  @file_version
end

#file_version_numberObject (readonly)

Returns the value of attribute file_version_number.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def file_version_number
  @file_version_number
end

#internal_nameObject (readonly)

Returns the value of attribute internal_name.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def internal_name
  @internal_name
end

Returns the value of attribute legal_copyright.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def legal_copyright
  @legal_copyright
end

Returns the value of attribute legal_trademarks.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def legal_trademarks
  @legal_trademarks
end

#original_filenameObject (readonly)

Returns the value of attribute original_filename.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def original_filename
  @original_filename
end

#private_buildObject (readonly)

Returns the value of attribute private_build.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def private_build
  @private_build
end

#product_nameObject (readonly)

Returns the value of attribute product_name.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def product_name
  @product_name
end

#product_versionObject (readonly)

Returns the value of attribute product_version.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def product_version
  @product_version
end

#product_version_numberObject (readonly)

Returns the value of attribute product_version_number.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def product_version_number
  @product_version_number
end

#special_buildObject (readonly)

Returns the value of attribute special_build.



295
296
297
# File 'lib/exerb/recipe.rb', line 295

def special_build
  @special_build
end

Class Method Details

.analyze(blocks, filename) ⇒ Object

Raises:



300
301
302
303
304
305
# File 'lib/exerb/recipe.rb', line 300

def self.analyze(blocks, filename)
  block = blocks.delete("version")
  return nil if block.nil?
  raise(Exerb::ExerbError, "#{filename}: version block must be Hash object -- #{block.class}") unless block.kind_of?(Hash)
  return self.new(block, filename)
end

Instance Method Details

#parse_version(version, filename) ⇒ Object



307
308
309
310
311
312
313
314
315
316
# File 'lib/exerb/recipe.rb', line 307

def parse_version(version, filename)
  case version.delete(" ").tr(",", ".")
  when /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ then return [$1.to_i, $2.to_i, $3.to_i, $4.to_i]
  when /^(\d+)\.(\d+)\.(\d+)$/        then return [$1.to_i, $2.to_i, $3.to_i, 0]
  when /^(\d+)\.(\d+)$/               then return [$1.to_i, $2.to_i, 0,       0]
  when /^(\d+)$/                      then return [$1.to_i, 0,       0,       0]
  when ""                             then return [0,       0,       0,       0]
  else raise(Exerb::ExerbError, "#{filename}: invalid version format in version block -- #{version}")
  end
end