Class: Rdm::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/rdm/source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path:) ⇒ Source

Returns a new instance of Source.



4
5
6
7
8
# File 'lib/rdm/source.rb', line 4

def initialize(root_path:)
  @root_path = root_path
  @config_names = []
  @package_paths = []
end

Instance Attribute Details

#config_namesObject (readonly)

Returns the value of attribute config_names.



2
3
4
# File 'lib/rdm/source.rb', line 2

def config_names
  @config_names
end

#package_pathsObject (readonly)

Returns the value of attribute package_paths.



2
3
4
# File 'lib/rdm/source.rb', line 2

def package_paths
  @package_paths
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



2
3
4
# File 'lib/rdm/source.rb', line 2

def root_path
  @root_path
end

#setup_blockObject (readonly)

Returns the value of attribute setup_block.



2
3
4
# File 'lib/rdm/source.rb', line 2

def setup_block
  @setup_block
end

Instance Method Details

#config(config_name) ⇒ Object

Add config to list of known configs

Parameters:

  • config_name (String)

    Config name

Raises:



18
19
20
21
22
23
# File 'lib/rdm/source.rb', line 18

def config(config_name)
  config_name = config_name.to_s
  raise Rdm::Errors::ConfigExists, config_name if @config_names.include?(config_name)

  @config_names << config_name
end

#configsHash<String: Rdm::Config>

Read initialized configs

Returns:

  • (Hash<String: Rdm::Config>)

    Hash of configs by it’s name



48
49
50
# File 'lib/rdm/source.rb', line 48

def configs
  @configs || {}
end

#init_with(packages:, configs:) ⇒ Hash<String: Rdm::Package>

Init source by adding read packages and configs

Parameters:

  • value (Hash<String: Rdm::Package>)

    Hash of packages by it’s name

  • value (Hash<String: Rdm::Config>)

    Hash of configs by it’s name

Returns:

  • (Hash<String: Rdm::Package>)

    Hash of packages by it’s name



35
36
37
38
# File 'lib/rdm/source.rb', line 35

def init_with(packages:, configs:)
  @packages = packages
  @configs = configs
end

#package(package_path) ⇒ Object

Add package to list of known packages

Parameters:

  • package_path (String)

    Package path



27
28
29
# File 'lib/rdm/source.rb', line 27

def package(package_path)
  @package_paths << package_path
end

#packagesHash<String: Rdm::Package>

Read initialized packages

Returns:

  • (Hash<String: Rdm::Package>)

    Hash of packages by it’s name



42
43
44
# File 'lib/rdm/source.rb', line 42

def packages
  @packages || {}
end

#setup(&block) ⇒ Object

Set setup block for source

Parameters:

  • block (Proc)

    Setup block



12
13
14
# File 'lib/rdm/source.rb', line 12

def setup(&block)
  @setup_block = block
end