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.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/fpm/fry/source/patched.rb', line 110

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.exist?(options[:file])
      raise ArgumentError, "File doesn't exist: #{options[:file]}"
    end
    options
  end
  if @inner.respond_to? :logger
    @logger = @inner.logger
  else
    @logger = Cabin::Channel.get
  end
end

Instance Attribute Details

#innerObject (readonly)

Returns the value of attribute inner.



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

def inner
  @inner
end

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

#patchesObject (readonly)

Returns the value of attribute patches.



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

def patches
  @patches
end

Class Method Details

.decorate(options) ⇒ Object



137
138
139
140
141
142
143
144
# File 'lib/fpm/fry/source/patched.rb', line 137

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



133
134
135
# File 'lib/fpm/fry/source/patched.rb', line 133

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