Class: Rake::Delphi::BDSVersionInfo

Inherits:
ProjectVersionInfo show all
Defined in:
lib/rake/delphi/projectinfo.rb

Direct Known Subclasses

RAD2007VersionInfo

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ProjectVersionInfo

#[], #method_missing

Constructor Details

#initialize(task) ⇒ BDSVersionInfo

Returns a new instance of BDSVersionInfo.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rake/delphi/projectinfo.rb', line 33

def initialize(task)
    super(task)
    versioninfo = get_versioninfo_tag(@content)
    # no need to continue if no version info file
    return unless versioninfo
    ['Delphi.Personality', 'VersionInfoKeys', 'VersionInfoKeys'].each do |key|
      versioninfo = versioninfo[key]
      # test version info file validity
      # no need to continue if file not valid
      return unless versioninfo
    end
    use_encode = String.new.respond_to?(:encode)
    encoding = self.class.encoding
    if encoding && ! use_encode
        require 'iconv'
        iconv = Iconv.new(encoding, 'UTF-8')
    end
    versioninfo.each do |v|
        cv = v['content']
        cv = (use_encode ? cv.encode(encoding, 'UTF-8') : iconv.iconv(cv)) if cv && encoding
        @info[v['Name'].to_sym] = cv
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rake::Delphi::ProjectVersionInfo

Class Method Details

.encodingObject



61
62
63
64
# File 'lib/rake/delphi/projectinfo.rb', line 61

def self.encoding
    # override to set your own encoding
    nil
end

Instance Method Details

#_extObject



75
76
77
# File 'lib/rake/delphi/projectinfo.rb', line 75

def _ext
    return 'bdsproj'
end

#do_getcontentObject



66
67
68
69
70
71
72
73
# File 'lib/rake/delphi/projectinfo.rb', line 66

def do_getcontent
    if File.exists?(@file)
        @content = XmlSimple.xml_in(@file, :ForceArray => false)
    else
        warn "WARNING! Version info file #{@file} does not exists"
        super
    end
end

#get_versioninfo_tag(content) ⇒ Object



57
58
59
# File 'lib/rake/delphi/projectinfo.rb', line 57

def get_versioninfo_tag(content)
    return content
end