Class: Pakman::Manifest

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/pakman/manifest.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManifest

Returns a new instance of Manifest.



10
11
12
# File 'lib/pakman/manifest.rb', line 10

def initialize()
  @manifest = []
end

Class Method Details

.load_file(old_logger_do_not_use, path) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/pakman/manifest.rb', line 22

def self.load_file( old_logger_do_not_use, path )
  puts "*** deprecated API call [Pakman::Manifest.load_file] - do NOT pass in logger; no longer required/needed; logger arg will get removed"

  obj = self.new
  obj.load_file_worker( path )
  obj
end

.load_file_core(old_logger_do_not_use, path) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/pakman/manifest.rb', line 14

def self.load_file_core( old_logger_do_not_use, path )
  puts "*** deprecated API call [Pakman::Manifest.load_file_core] - do NOT pass in logger; no longer required/needed; logger arg will get removed"

  obj = self.new
  obj.load_file_core_worker( path )
  obj
end

.load_file_core_v2(path) ⇒ Object



31
32
33
34
35
# File 'lib/pakman/manifest.rb', line 31

def self.load_file_core_v2( path )
  obj = self.new
  obj.load_file_core_worker( path )
  obj
end

.load_file_v2(path) ⇒ Object



37
38
39
40
41
# File 'lib/pakman/manifest.rb', line 37

def self.load_file_v2( path )
  obj = self.new
  obj.load_file_worker( path )
  obj
end

Instance Method Details

#eachObject



46
47
48
# File 'lib/pakman/manifest.rb', line 46

def each
  @manifest.each { |ary| yield ary }
end

#load_file_core_worker(path) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/pakman/manifest.rb', line 52

def load_file_core_worker( path )
  @manifest = []

  File.open( path, 'r:bom|utf-8' ).readlines.each_with_index do |line,i|
    case line
    when /^\s*$/
      # skip empty lines
    when /^\s*#.*$/
      # skip comment lines
    else
      logger.debug "line #{i+1}: #{line.strip}"
      values = line.strip.split( /[ <,+]+/ )

      # add source for shortcuts (assumes relative path; if not issue warning/error)
      values << values[0] if values.size == 1

      @manifest << values
    end
  end
end

#load_file_worker(path) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/pakman/manifest.rb', line 73

def load_file_worker( path )
  filename = path

  logger.info "  Loading template manifest #{filename}..."
  load_file_core_worker( filename )

  # post-processing
  # normalize all source paths (1..-1) /make full path/add template dir

  templatesdir = File.dirname( path )
  logger.debug "templatesdir=#{templatesdir}"

  @manifest.each do |values|
    (1..values.size-1).each do |i|
      values[i] = "#{templatesdir}/#{values[i]}"
      logger.debug "  path[#{i}]=>#{values[i]}<"
    end
  end
end