Class: GitDump::Version::Builder
- Inherits:
-
Object
- Object
- GitDump::Version::Builder
- Includes:
- Base
- Defined in:
- lib/git_dump/version/builder.rb
Overview
Creating version
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
-
#commit(options = {}) ⇒ Object
Create commit and tag it, returns Version instance Options: :time - set version time (tag and commit) :tags - list of strings to associate with this version :annotation - tag message :description - commit message :keep_identity - don’t override identity with “git_dump gitdump@hostname”.
-
#initialize(repo) ⇒ Builder
constructor
A new instance of Builder.
- #inspect ⇒ Object
-
#store(path, content, mode = 0o644) ⇒ Object
(also: #[]=)
Store data ‘content` with mode `mode` at `path` Pass `nil` as content to remove.
-
#store_from(path, from, mode = nil) ⇒ Object
Store data from ‘from` with mode `mode` (by default file mode) at `path`.
Methods included from Base
Constructor Details
#initialize(repo) ⇒ Builder
Returns a new instance of Builder.
14 15 16 17 18 19 |
# File 'lib/git_dump/version/builder.rb', line 14 def initialize(repo) fail ArgumentError, 'Expected Repo' unless repo.is_a?(Repo) @repo = repo @tree = Tree::Builder.new(repo, nil, nil) end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
13 14 15 |
# File 'lib/git_dump/version/builder.rb', line 13 def repo @repo end |
Instance Method Details
#commit(options = {}) ⇒ Object
Create commit and tag it, returns Version instance Options:
:time - set version time (tag and commit)
:tags - list of strings to associate with this version
:annotation - tag
:description - commit
:keep_identity - don't override identity with "git_dump
gitdump@hostname“
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/git_dump/version/builder.rb', line 41 def commit( = {}) = {:time => Time.now}.merge() base = {:time => [:time]} unless [:keep_identity] base[:name] = 'git_dump' base[:email] = "git_dump@#{GitDump.hostname}" end commit_sha = repo.commit(tree.sha, base.merge({ :message => [:description], })) tag_name = repo.tag(commit_sha, name_parts(), base.merge({ :message => [:annotation], })) repo.gc(:auto => true) Version.by_id(repo, tag_name) end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/git_dump/version/builder.rb', line 63 def inspect "#<#{self.class} tree=#{tree.inspect}>" end |
#store(path, content, mode = 0o644) ⇒ Object Also known as: []=
Store data ‘content` with mode `mode` at `path` Pass `nil` as content to remove
23 24 25 |
# File 'lib/git_dump/version/builder.rb', line 23 def store(path, content, mode = 0o644) tree.store(path, content, mode) end |
#store_from(path, from, mode = nil) ⇒ Object
Store data from ‘from` with mode `mode` (by default file mode) at `path`
29 30 31 |
# File 'lib/git_dump/version/builder.rb', line 29 def store_from(path, from, mode = nil) tree.store_from(path, from, mode) end |