Class: BuildMaster::JavaManifest

Inherits:
Object
  • Object
show all
Defined in:
lib/buildmaster/project/java_manifest.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest_file) ⇒ JavaManifest

Returns a new instance of JavaManifest.



3
4
5
# File 'lib/buildmaster/project/java_manifest.rb', line 3

def initialize(manifest_file)
  @manifest_file = manifest_file
end

Class Method Details

.from_file(manifest_file) ⇒ Object



7
8
9
# File 'lib/buildmaster/project/java_manifest.rb', line 7

def JavaManifest::from_file(manifest_file)
  return JavaManifest.new(manifest_file)
end

Instance Method Details

#increase_buildObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/buildmaster/project/java_manifest.rb', line 25

def increase_build
  content = ""
  number = nil
  build = nil
  @manifest_file.foreach do |line|
    name_value = NameValue.parse(line)
    if (name_value.name== "Implementation-Version")
      number = name_value.value
      content = content + line
    elsif (name_value.name == "Implementation-Build")
      build = name_value.value.to_i + 1
      content = content + "Implementation-Build: #{build}\n"
    else
      content = content + line
    end
  end
  @manifest_file.write do |file|
    file.printf(content)
  end
  return Version.new(number, build)
end

#versionObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/buildmaster/project/java_manifest.rb', line 11

def version
  number = nil
  build = nil
  @manifest_file.foreach do |line|
    name_value = NameValue.parse(line)
    if (name_value.name== "Implementation-Version")
      number = name_value.value
    elsif (name_value.name == "Implementation-Build")
      build = name_value.value
    end
  end
  return Version.new(number, build.to_i)
end