Class: Raykit::Conan::BuildInfo

Inherits:
Hash
  • Object
show all
Defined in:
lib/raykit/conan/buildinfo.rb

Overview

Functionality to manage a git commit

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ BuildInfo

Returns a new instance of BuildInfo.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/raykit/conan/buildinfo.rb', line 5

def initialize(filename)
  current_section = ""
  current_list = Array.new()
  File.readlines(filename).each do |line|
    #puts line
    if (line.index("[") == 0)
      if (current_section.length > 0)
        self.store(current_section, current_list)
        current_list = Array.new()
      end
      current_section = line.strip()
    else
      item = line.strip()
      if (item.length > 0)
        current_list << item
      end
    end
    #
  end
end

Instance Method Details

#copy_pdbs(dir) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/raykit/conan/buildinfo.rb', line 44

def copy_pdbs(dir)
  FileUtils.mkdir_p(dir) if !Dir.exist?(dir)
  self.pdbs.each { |pdb|
    target = "#{dir}/#{File.basename(pdb)}"
    if (!File.exist?(target))
      puts "  copying #{pdb} to #{target}"
      FileUtils.cp(pdb, "#{target}")
    end
  }
end

#pdbsObject



34
35
36
37
38
39
40
41
42
# File 'lib/raykit/conan/buildinfo.rb', line 34

def pdbs
  items = Array.new()
  self.section("[builddirs]").each { |dir|
    Dir.glob("#{dir}/**/*.pdb").sort.each { |pdb|
      items << pdb
    }
  }
  items
end

#section(name) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/raykit/conan/buildinfo.rb', line 26

def section(name)
  items = Array.new()
  if (self.has_key?(name))
    return self[name]
  end
  items
end

#source_dirs(pattern) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/raykit/conan/buildinfo.rb', line 55

def source_dirs(pattern)
  items = Array.new()
  self.section("[builddirs]").each { |dir|
    if (dir.include?(pattern))
      parts = dir.split("package/")
      if (parts.length == 2)
        items << "#{parts[0]}source"
      end
    end
  }
  items
end