Class: Multisync::Catalog

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

Defined Under Namespace

Classes: Filter, List

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Catalog

Returns a new instance of Catalog.



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

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

Instance Attribute Details

#definitionObject (readonly)

top entity of definition



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

def definition
  @definition
end

Class Method Details

.default_catalog_pathObject



37
38
39
# File 'lib/multisync/catalog.rb', line 37

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

Instance Method Details

#filter(sets) ⇒ Object



25
26
27
28
29
# File 'lib/multisync/catalog.rb', line 25

def filter sets
  catalog_filter = Multisync::Catalog::Filter.new sets
  definition.accept(catalog_filter)
  catalog_filter.result
end

#listObject



19
20
21
22
23
# File 'lib/multisync/catalog.rb', line 19

def list
  catalog_list = Multisync::Catalog::List.new
  definition.accept(catalog_list)
  catalog_list.result
end

#pathObject

Raises:

  • (RuntimeError.new)


31
32
33
34
35
# File 'lib/multisync/catalog.rb', line 31

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