Sha256: 0c1aef9a95b05f5adad52f5cb0741954e901035271f0b6fd69740f6963fd9ebf

Contents?: true

Size: 905 Bytes

Versions: 4

Compression:

Stored size: 905 Bytes

Contents

module ZendeskAppsSupport

  class AppFile

    attr_reader :relative_path
    attr_reader :absolute_path

    def initialize(package, relative_path)
      @relative_path = relative_path
      @file = File.new(package.root.join(relative_path))
      @absolute_path = File.absolute_path @file.path
    end

    def read
      File.read @file.path
    end

    def =~(regex)
      @relative_path =~ regex
    end

    alias_method :to_s, :relative_path

    def method_missing(sym, *args, &block)
      if @file.respond_to?(sym)
        @file.call(sym, *args, &block)
      else
        super
      end
    end

    # Unless Ruby 1.9
    def respond_to?(sym, include_private = false)
      @file.respond_to?(sym, include_private) || super
    end

    # If Ruby 1.9
    def respond_to_missing?(sym, include_private = false)
      @file.respond_to_missing?(sym, include_private) || super
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zendesk_apps_support-1.12.0 lib/zendesk_apps_support/app_file.rb
zendesk_apps_support-1.11.0 lib/zendesk_apps_support/app_file.rb
zendesk_apps_support-1.10.0 lib/zendesk_apps_support/app_file.rb
zendesk_apps_support-1.9.0 lib/zendesk_apps_support/app_file.rb