Class: Babelyoda::Git

Inherits:
Object
  • Object
show all
Includes:
SpecificationLoader
Defined in:
lib/babelyoda/git.rb

Instance Method Summary collapse

Methods included from SpecificationLoader

#dump, included, #initialize, #method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Babelyoda::SpecificationLoader

Instance Method Details

#fetch_versions!(*filenames, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/babelyoda/git.rb', line 20

def fetch_versions!(*filenames, &block)
  Dir.mktmpdir do |dir|
    results = []
    filenames.each do |fn|
      full_fn = File.join(dir, fn)
      dirname = File.dirname(full_fn)
      FileUtils.mkdir_p dirname
      git_show(@versions[fn], full_fn)
      results << full_fn
    end
    block.call(results)
  end
end

#store_version!(filename) ⇒ Object



13
14
15
16
17
18
# File 'lib/babelyoda/git.rb', line 13

def store_version!(filename)
 versions[filename] = git_ls_sha1(filename)
  should_add = !File.exist?(versions.filename)
 versions.save!
 $logger.info "[SHA1] #{@versions[filename]} <= #{filename}"
end

#transaction(msg) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/babelyoda/git.rb', line 34

def transaction(msg)
  check_requirements!
  yield if block_given?
  if git_status.size > 0
    git_add!('.')
    git_add!('-u')
    git_commit!(msg)
  end
end

#version_exist?(filename) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/babelyoda/git.rb', line 9

def version_exist?(filename)
   versions.exist?(filename)
end