Class: FPM::Fry::Source::Patched

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/fpm/fry/source/patched.rb

Defined Under Namespace

Classes: Cache

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inner, options = {}) ⇒ Patched

Returns a new instance of Patched.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/fpm/fry/source/patched.rb', line 85

def initialize( inner , options = {})
  @inner = inner
  @patches = Array(options[:patches]).map do |file|
    if file.kind_of? String
      options = {file: file}
    elsif file.kind_of? Hash
      options = file.dup
    else
      raise ArgumentError, "Expected a Hash or a String, got #{file.inspect}"
    end
    options[:file] = File.expand_path(options[:file])
    if !File.exists?(options[:file])
      raise ArgumentError, "File doesn't exist: #{options[:file]}"
    end
    options
  end
end

Instance Attribute Details

#innerObject (readonly)

Returns the value of attribute inner.



79
80
81
# File 'lib/fpm/fry/source/patched.rb', line 79

def inner
  @inner
end

Class Method Details

.decorate(options) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/fpm/fry/source/patched.rb', line 107

def self.decorate(options)
  if options.key?(:patches) && Array(options[:patches]).size > 0
    p = options.delete(:patches)
    return new( yield(options), patches: p )
  else
    return yield options
  end
end

Instance Method Details

#build_cache(tmpdir) ⇒ Object



103
104
105
# File 'lib/fpm/fry/source/patched.rb', line 103

def build_cache(tmpdir)
  Cache.new(self,tmpdir)
end