Class: Palimpsest::Component
- Inherits:
-
Object
- Object
- Palimpsest::Component
- 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
-
#install_path ⇒ String
Install path for component.
-
#source_path ⇒ String
Source path for component.
Instance Method Summary collapse
-
#initialize(source_path: '', install_path: '') ⇒ Component
constructor
A new instance of Component.
-
#install ⇒ Object
Installs files in #source_path to #install_path.
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_path ⇒ String
Returns install path for component.
18 |
# File 'lib/palimpsest/component.rb', line 18 attr_accessor :source_path, :install_path |
#source_path ⇒ String
Returns source path for component.
18 19 20 |
# File 'lib/palimpsest/component.rb', line 18 def source_path @source_path end |
Instance Method Details
#install ⇒ Object
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 |