Class: Palimpsest::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/palimpsest/component.rb

Overview

Use this class to store parts of your project in a location separate from the normal installed location.

For example, put custom templates in components/my_app/templates which might later be installed to apps/my_app/templates.

This is useful when apps/my_app is a separate project with its own repository loaded using External.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_path: '', install_path: '') ⇒ Component

Returns a new instance of Component.



20
21
22
23
# File 'lib/palimpsest/component.rb', line 20

def initialize source_path: '', install_path: ''
  self.source_path = source_path
  self.install_path = install_path
end

Instance Attribute Details

#install_pathString

Returns install path for component.

Returns:

  • (String)

    install path for component



18
# File 'lib/palimpsest/component.rb', line 18

attr_accessor :source_path, :install_path

#source_pathString

Returns source path for component.

Returns:

  • (String)

    source path for component



18
19
20
# File 'lib/palimpsest/component.rb', line 18

def source_path
  @source_path
end

Instance Method Details

#installObject

Installs files in #source_path to #install_path



26
27
28
29
30
31
# File 'lib/palimpsest/component.rb', line 26

def install
  fail RuntimeError if source_path.empty?
  fail RuntimeError if install_path.empty?
  FileUtils.mkdir_p install_path
  FileUtils.mv Dir["#{source_path}/*"], install_path
end