Class: RSFServices::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/rsf_services.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj, package, debug: false) ⇒ Package

Returns a new instance of Package.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rsf_services.rb', line 30

def initialize(obj, package, debug: false)

  
  puts 'inside Package#initialize' if debug
  
  @obj, @package, @debug = obj, package, debug

  @url = File.join(@obj.package_basepath, package + '.rsf')
  
  puts 'before Rexle' if @debug
  puts '@url: ' + @url.inspect if @debug
  
  s, _ = RXFHelper.read(@url)
  puts 's: ' + s.inspect if @debug
  
  doc = Rexle.new  s
  puts 'before xpath' if @debug
  
  a = doc.root.xpath 'job/attribute::id'
  
  a.each do |attr|
    
    method_name = attr.value.gsub('-','_') 

    define_singleton_method method_name.to_sym do |*args|
      run_job method_name, args
    end

  end

end