Class: Multisync::Catalog

Inherits:
Object
  • Object
show all
Defined in:
lib/multisync/catalog.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Catalog

Returns a new instance of Catalog.



2
3
4
# File 'lib/multisync/catalog.rb', line 2

def initialize path
  @path = File.expand_path(path)
end

Class Method Details

.default_catalog_pathObject



23
24
25
# File 'lib/multisync/catalog.rb', line 23

def self.default_catalog_path
  "~/.multisync.rb"
end

Instance Method Details

#definitionObject

top entity of definition



7
8
9
10
11
# File 'lib/multisync/catalog.rb', line 7

def definition
  @definition ||= Multisync::Definition::Entity
    .new(Multisync::Definition::Null.new, "")
    .tap { _1.instance_eval File.read(path) }
end

#pathObject

Raises:

  • (RuntimeError.new)


17
18
19
20
21
# File 'lib/multisync/catalog.rb', line 17

def path
  return @path if File.exist? @path
  sample_path = File.expand_path("../../../sample/multisync.rb", __FILE__)
  raise RuntimeError.new, "No catalog found at #{@path}. Copy sample from #{sample_path} to #{@path} and adjust to your needs."
end

#traverse(visitor) ⇒ Object



13
14
15
# File 'lib/multisync/catalog.rb', line 13

def traverse visitor
  definition.accept visitor
end