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



10
11
12
# File 'lib/nanoc/extra/file_proxy.rb', line 10

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)



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

def method_missing(sym, *args, &block)
  unless @@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



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

def freeze
end

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

Returns:

  • (Boolean)


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

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