module DataKitten::Hosts::Gist

Gist host module. Automatically mixed into {Dataset} for datasets that are loaded from Gist.

@see Dataset

Private Class Methods

supported?(uri) click to toggle source
# File lib/data_kitten/hosts/gist.rb, line 13
def self.supported?(uri)
  uri =~ /\A(git|https?):\/\/gist\.github\.com\//
end

Public Instance Methods

gist_path(path = '') click to toggle source

Helper for generating Gist URLs

@param path [String] The path to append to the Gist base URL.

@return [String] The supplied path with the Gist base URL prepended

@example

dataset = Dataset.new('git://gist.github.com/5633865.git')
dataset.gist_path           # => 'https://gist.github.com/5633865'
dataset.gist_path('download') # => 'https://gist.github.com/5633865/download'
# File lib/data_kitten/hosts/gist.rb, line 36
def gist_path(path = '')
  "https://gist.github.com/#{gist_repository_name}/#{path}"
end
host() click to toggle source

Where the dataset is hosted. @return [Symbol] :gist @see Dataset#host

# File lib/data_kitten/hosts/gist.rb, line 22
def host
  :gist
end

Private Instance Methods

gist_repository_name() click to toggle source
# File lib/data_kitten/hosts/gist.rb, line 42
def gist_repository_name
  @gist_repository_name ||= uri.split('/')[-1].split('.')[0]
end