Class: Git
- Inherits:
-
Object
- Object
- Git
- Defined in:
- lib/git.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(file, with_commit = true) ⇒ Object
- #clean_name(f) ⇒ Object
- #commit(msg, *args) ⇒ Object
- #edit(file, with_commit = true) ⇒ Object
-
#initialize(path) ⇒ Git
constructor
A new instance of Git.
- #mv(orig, new, with_commit = true) ⇒ Object
- #rm(file, with_commit = true) ⇒ Object
Constructor Details
#initialize(path) ⇒ Git
Returns a new instance of Git.
2 3 4 |
# File 'lib/git.rb', line 2 def initialize(path) @working_path = path end |
Class Method Details
.clone(from, path, name) ⇒ Object
6 7 8 |
# File 'lib/git.rb', line 6 def self.clone(from,path,name) `cd #{path} && git clone #{from} #{name}` end |
.init(path) ⇒ Object
10 11 12 |
# File 'lib/git.rb', line 10 def self.init(path) `cd #{path} && git init` end |
Instance Method Details
#add(file, with_commit = true) ⇒ Object
19 20 21 22 |
# File 'lib/git.rb', line 19 def add(file,with_commit = true) `cd '#@working_path' && git add file` self.commit("#{clean_name(file)} Added") if with_commit end |
#clean_name(f) ⇒ Object
38 39 40 |
# File 'lib/git.rb', line 38 def clean_name(f) return f.sub(/^(.*)?\/(main|private)\/(.*)/,'\3').sub(/^@/,'') end |
#commit(msg, *args) ⇒ Object
34 35 36 |
# File 'lib/git.rb', line 34 def commit(msg,*args) `cd '#@working_path' && git commit #{args.to_s} -m '#{msg}'` end |
#edit(file, with_commit = true) ⇒ Object
24 25 26 27 |
# File 'lib/git.rb', line 24 def edit(file,with_commit = true) `cd '#@working_path' && git add file` self.commit("#{clean_name(file)} Updated") if with_commit end |
#mv(orig, new, with_commit = true) ⇒ Object
14 15 16 17 |
# File 'lib/git.rb', line 14 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 |
#rm(file, with_commit = true) ⇒ Object
29 30 31 32 |
# File 'lib/git.rb', line 29 def rm(file,with_commit=true) `cd '#@working_path' && git rm -f file` self.commit("#{clean_name(file)} Removed") if with_commit end |