module DataKitten::Origins::Git
Git
origin module. Automatically mixed into {Dataset} for datasets that are loaded from Git
repositories.
@see Dataset
Private Class Methods
supported?(resource)
click to toggle source
# File lib/data_kitten/origins/git.rb, line 13 def self.supported?(resource) resource.to_s =~ /\A(git|https?):\/\/.*\.git\Z/ end
Public Instance Methods
change_history()
click to toggle source
A history of changes to the Dataset
, taken from the full git changelog @see Dataset#change_history
# File lib/data_kitten/origins/git.rb, line 28 def change_history @change_history ||= begin repository.log.map{|commit| commit} end end
origin()
click to toggle source
The origin type of the dataset. @return [Symbol] :git
@see Dataset#origin
# File lib/data_kitten/origins/git.rb, line 22 def origin :git end
Protected Instance Methods
load_file(path)
click to toggle source
# File lib/data_kitten/origins/git.rb, line 36 def load_file(path) # Make sure we have a working copy repository # read file File.read(File.join(working_copy_path, path)) end
Private Instance Methods
repository()
click to toggle source
# File lib/data_kitten/origins/git.rb, line 52 def repository @repository ||= begin repo = ::Git.open(working_copy_path) repo.pull("origin", "master") repo rescue ArgumentError repo = ::Git.clone(@access_url, working_copy_path) end end
working_copy_path()
click to toggle source
# File lib/data_kitten/origins/git.rb, line 45 def working_copy_path # Create holding directory FileUtils.mkdir_p(File.join(File.dirname(__FILE__), '..', '..', '..', 'tmp', 'repositories')) # generate working copy dir File.join(File.dirname(__FILE__), '..', '..', '..', 'tmp', 'repositories', @access_url.gsub('/','-')) end