Class: Nanoc::Extra::FileProxy Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/extra/file_proxy.rb

Overview

Deprecated.

Create a File instance directly and use that instead.

Constant Summary

@@deprecation_warning_shown =
false

Instance Method Summary (collapse)

Constructor Details

- (FileProxy) initialize(path)

Returns a new instance of FileProxy



12
13
14
# File 'lib/nanoc/extra/file_proxy.rb', line 12

def initialize(path)
  @path = path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(sym, *args, &block)



23
24
25
26
27
28
29
30
# File 'lib/nanoc/extra/file_proxy.rb', line 23

def method_missing(sym, *args, &block)
  if !@@deprecation_warning_shown
    $stderr.puts 'WARNING: The :file attribute is deprecated and will be removed in a future version of nanoc. Instead of using this :file attribute, consider manually creating a File object when it’s needed, using the :content_filename, :meta_filename or :filename attributes.'
    @@deprecation_warning_shown = true
  end

  File.open(@path, 'r') { |io| io.__send__(sym, *args, &block) }
end

Instance Method Details

- (Object) freeze



16
17
# File 'lib/nanoc/extra/file_proxy.rb', line 16

def freeze
end

- (Boolean) respond_to?(meth, include_all = false)

Returns:

  • (Boolean)


19
20
21
# File 'lib/nanoc/extra/file_proxy.rb', line 19

def respond_to?(meth, include_all = false)
  file_instance_methods.include?(meth.to_sym)
end