Class: Clerq::Repositories::NodeRepository
- Inherits:
-
FileRepository
- Object
- FileRepository
- Clerq::Repositories::NodeRepository
- Defined in:
- lib/clerq/repositories/node_repository.rb
Instance Attribute Summary
Attributes inherited from FileRepository
Instance Method Summary collapse
-
#assemble(on_parse: nil, on_error: nil) ⇒ Node
asseble repository nodes hierarchy.
-
#initialize(path: Dir.pwd, pattern: '*.md') ⇒ NodeRepository
constructor
A new instance of NodeRepository.
- #save(node) ⇒ Object
Methods inherited from FileRepository
Constructor Details
#initialize(path: Dir.pwd, pattern: '*.md') ⇒ NodeRepository
Returns a new instance of NodeRepository.
14 15 16 |
# File 'lib/clerq/repositories/node_repository.rb', line 14 def initialize(path: Dir.pwd, pattern: '*.md') super(path: path, pattern: pattern) end |
Instance Method Details
#assemble(on_parse: nil, on_error: nil) ⇒ Node
asseble repository nodes hierarchy
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/clerq/repositories/node_repository.rb', line 25 def assemble(on_parse: nil, on_error: nil) @node = Node.new(id: 'join', title: Clerq.title) loadn = load(on_parse: on_parse, on_error: on_error) loadn.each{|n| @node << n} subo! eqid! if @node.items.size == 1 @node = @node.items.first @node.orphan! end @node end |
#save(node) ⇒ Object
18 19 20 21 |
# File 'lib/clerq/repositories/node_repository.rb', line 18 def save(node) check! node write("#{node.id}.md", markup(node)) end |