Class: Grancher
- Inherits:
-
Object
- Object
- Grancher
- Defined in:
- lib/grancher.rb,
lib/grancher/task.rb
Defined Under Namespace
Classes: Task
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#directories ⇒ Object
readonly
Returns the value of attribute directories.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#gash ⇒ Object
readonly
Returns our Gash-object.
-
#message ⇒ Object
Returns the value of attribute message.
-
#push_to ⇒ Object
Returns the value of attribute push_to.
-
#refspec ⇒ Object
Returns the value of attribute refspec.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
-
#commit(message = nil) ⇒ Object
Commits the changes.
-
#directory(from, to = nil) ⇒ Object
Stores the directory
from
atto
. -
#file(from, to = nil) ⇒ Object
Stores the file
from
atto
. -
#initialize(&blk) ⇒ Grancher
constructor
A new instance of Grancher.
-
#keep(*files) ⇒ Object
Keeps the files (or directories) given.
-
#keep_all ⇒ Object
Keep all the files in the branch.
-
#push ⇒ Object
Pushes the branch to the remote.
-
#tag(tag, tag_msg = "", commit = nil) ⇒ Object
Tag the most recent checked-out commit.
Constructor Details
#initialize(&blk) ⇒ Grancher
Returns a new instance of Grancher.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/grancher.rb', line 82 def initialize(&blk) @directories = {} @files = {} @keep = [] @repo = '.' = 'Updated files.' = [] if block_given? if blk.arity == 1 blk.call(self) else self.instance_eval(&blk) end end end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
79 80 81 |
# File 'lib/grancher.rb', line 79 def branch @branch end |
#directories ⇒ Object (readonly)
Returns the value of attribute directories.
80 81 82 |
# File 'lib/grancher.rb', line 80 def directories @directories end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
80 81 82 |
# File 'lib/grancher.rb', line 80 def files @files end |
#gash ⇒ Object (readonly)
Returns our Gash-object
99 100 101 |
# File 'lib/grancher.rb', line 99 def gash @gash end |
#message ⇒ Object
Returns the value of attribute message.
79 80 81 |
# File 'lib/grancher.rb', line 79 def end |
#push_to ⇒ Object
Returns the value of attribute push_to.
79 80 81 |
# File 'lib/grancher.rb', line 79 def push_to @push_to end |
#refspec ⇒ Object
Returns the value of attribute refspec.
79 80 81 |
# File 'lib/grancher.rb', line 79 def refspec @refspec end |
#repo ⇒ Object
Returns the value of attribute repo.
79 80 81 |
# File 'lib/grancher.rb', line 79 def repo @repo end |
#tags ⇒ Object
Returns the value of attribute tags.
79 80 81 |
# File 'lib/grancher.rb', line 79 def end |
Instance Method Details
#commit(message = nil) ⇒ Object
Commits the changes.
159 160 161 162 163 164 165 166 167 |
# File 'lib/grancher.rb', line 159 def commit( = nil) old_keys = gash.keys build if gash.keys.sort == old_keys.sort gash.commit( || ()) else gash.commit( || (), :force => true) end end |
#directory(from, to = nil) ⇒ Object
Stores the directory from
at to
.
104 105 106 |
# File 'lib/grancher.rb', line 104 def directory(from, to = nil) @directories[from.chomp('/')] = to end |
#file(from, to = nil) ⇒ Object
Stores the file from
at to
.
109 110 111 |
# File 'lib/grancher.rb', line 109 def file(from, to = nil) @files[from] = to end |
#keep(*files) ⇒ Object
Keeps the files (or directories) given.
114 115 116 |
# File 'lib/grancher.rb', line 114 def keep(*files) @keep.concat(files.flatten) end |
#keep_all ⇒ Object
Keep all the files in the branch.
119 120 121 |
# File 'lib/grancher.rb', line 119 def keep_all @keep_all = true end |
#push ⇒ Object
Pushes the branch to the remote.
150 151 152 153 154 155 156 |
# File 'lib/grancher.rb', line 150 def push if .empty? gash.send(:git, 'push', @push_to, @refspec) else gash.send(:git, 'push', '--tags', @push_to, @refspec) end end |
#tag(tag, tag_msg = "", commit = nil) ⇒ Object
Tag the most recent checked-out commit
140 141 142 143 144 145 146 147 |
# File 'lib/grancher.rb', line 140 def tag(tag, tag_msg="", commit=nil) << tag if commit gash.send(:git, 'tag', '-f', '-a', '-m', tag_msg, tag, commit) else gash.send(:git, 'tag', '-f', '-a', '-m', tag_msg, tag) end end |