Sha256: e347041e1fb7846112073c543bae38b35382a4025a3bb7608b8b52d8f4eb2f64

Contents?: true

Size: 937 Bytes

Versions: 17

Compression:

Stored size: 937 Bytes

Contents

# encoding: utf-8

module Nanoc3::Extra

  # @deprecated Create a File instance directly and use that instead.
  class FileProxy

    instance_methods.each { |m| undef_method m unless m =~ /^__/ || m.to_s == 'object_id' }

    @@deprecation_warning_shown = false

    def initialize(path)
      @path = path
    end

    def respond_to?(meth)
      File.instance_methods.any? { |m| m == meth.to_s || m == meth.to_sym }
    end

    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

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
nanoc3-3.1.9 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.8 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.7 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.6 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.2.0a3 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.5 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.4 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.2.0a2 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.3 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.2.0a1 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.2 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.1 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.0 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.0rc1 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.0b2 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.0b1 lib/nanoc3/extra/file_proxy.rb
nanoc3-3.1.0a3 lib/nanoc3/extra/file_proxy.rb