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

#initialize(old_logger_do_not_use = nil) ⇒ Manifest

todo/fix: remove logger from c’tor use logutils instead



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

def initialize( old_logger_do_not_use=nil )
  if old_logger_do_not_use != nil
       puts "*** depreciated API call [Pakman::Manifest.initialize] - do NOT pass in logger; no longer required/needed; logger arg will get removed"
  end

  @manifest = []
end

Class Method Details

.load_file(old_logger_do_not_use, path) ⇒ Object



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

def self.load_file( old_logger_do_not_use, path )
  puts "*** depreciated 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



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

def self.load_file_core( old_logger_do_not_use, path )
  puts "*** depreciated 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



39
40
41
42
43
# File 'lib/pakman/manifest.rb', line 39

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

.load_file_v2(path) ⇒ Object



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

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

Instance Method Details

#eachObject



54
55
56
# File 'lib/pakman/manifest.rb', line 54

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

#load_file_core_worker(path) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/pakman/manifest.rb', line 60

def load_file_core_worker( path )
  @manifest = []

  File.open( path ).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



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/pakman/manifest.rb', line 81

def load_file_worker( path )
  filename = path
 
  puts "  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