Class: GitDump::Tree::Builder
- Inherits:
-
PathObject
- Object
- PathObject
- GitDump::Tree::Builder
- Includes:
- Base
- Defined in:
- lib/git_dump/tree/builder.rb
Overview
Creating tree
Instance Attribute Summary
Attributes inherited from PathObject
Instance Method Summary collapse
-
#initialize(repo, dir, name) ⇒ Builder
constructor
A new instance of Builder.
- #inspect ⇒ Object
- #sha ⇒ 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, dir, name) ⇒ Builder
Returns a new instance of Builder.
12 13 14 15 |
# File 'lib/git_dump/tree/builder.rb', line 12 def initialize(repo, dir, name) super(repo, dir, name) @entries = {} end |
Instance Method Details
#inspect ⇒ Object
41 42 43 |
# File 'lib/git_dump/tree/builder.rb', line 41 def inspect "#<#{self.class} #{@entries.inspect}>" end |
#sha ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/git_dump/tree/builder.rb', line 30 def sha repo.treeify(@entries.map do |name, entry| attributes = {:name => name, :sha => entry.sha} if entry.is_a?(self.class) attributes.merge(:type => :tree) else attributes.merge(:type => :blob, :mode => entry.mode) end end) end |
#store(path, content, mode = 0o644) ⇒ Object Also known as: []=
Store data ‘content` with mode `mode` at `path` Pass `nil` as content to remove
19 20 21 |
# File 'lib/git_dump/tree/builder.rb', line 19 def store(path, content, mode = 0o644) put_at(parse_path(path), content && repo.data_sha(content), mode) end |
#store_from(path, from, mode = nil) ⇒ Object
Store data from ‘from` with mode `mode` (by default file mode) at `path`
25 26 27 28 |
# File 'lib/git_dump/tree/builder.rb', line 25 def store_from(path, from, mode = nil) mode ||= File.stat(from).mode put_at(parse_path(path), repo.path_sha(from), mode) end |