Sha256: a186177035c6ba826078790fc03d69a396c2f49a62eb7aa81f36995736416d89

Contents?: true

Size: 541 Bytes

Versions: 1

Compression:

Stored size: 541 Bytes

Contents

require "platina_world/fetchers/base"

module PlatinaWorld
  module Fetcher
    class Local < Base
      CONVERT_TABLE = {
        "$HOME" => ENV["HOME"],
        "$ROOT" => "#{ENV['HOME']}/.platina_world"
      }

      private

      def valid?
        exist_resouce?
      end

      def fetch_contents
        File.read(expanded_uri)
      end

      def expanded_uri
        @expanded_uri ||= @uri.to_s.gsub(%r(\$[^/]+), CONVERT_TABLE)
      end

      def exist_resouce?
        ::File.exist?(expanded_uri)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
platina_world-0.1.5 lib/platina_world/fetchers/local.rb