Sha256: ff1df056c72704ddeb5b956dac4e6bd907ec77fc30cf666095e601e8c32f9dff

Contents?: true

Size: 1019 Bytes

Versions: 3

Compression:

Stored size: 1019 Bytes

Contents

class Git
  def initialize(path)
    @working_path = path
  end

  def self.clone(from,path,name)
   `cd #{path} && git clone #{from} #{name}`
  end

  def self.init(path)
   `cd #{path} && git init`
  end

  def mv(orig,new,with_commit = true)
     `cd '#@working_path' && git mv #{orig} #{new}`
     self.commit("#{clean_name(orig)} Renamed to #{clean_name(new)}") if with_commit
  end

  def add(file,with_commit = true)
    `cd '#@working_path' && git add file`
    self.commit("#{clean_name(file)} Added") if with_commit
  end

  def edit(file,with_commit = true)
    `cd '#@working_path' && git add file`
    self.commit("#{clean_name(file)} Updated") if with_commit
  end

  def rm(file,with_commit=true)
    `cd '#@working_path' && git rm -f file`
    self.commit("#{clean_name(file)} Removed") if with_commit
  end

  def commit(msg,*args)
     `cd '#@working_path' && git commit #{args.to_s} -m '#{msg}'`
  end

  def clean_name(f)
    return f.sub(/^(.*)?\/(main|private)\/(.*)/,'\3').sub(/^@/,'')
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
wosmvp-yac-1.1.1 lib/git.rb
yac-1.1.0 lib/git.rb
yac-1.1.1 lib/git.rb