Sha256: d269efa2aeb65d9bbb5864f5336ab0565a6e6f4eaab0a119a6af08ab8674b79a

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

module Palimpsest

  # 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 {Palimpsest::External}.
  class Component

    # @!attribute source_path
    #   @return [String] source path for component
    #
    # @!attribute install_path
    #   @return [String] install path for component
    attr_accessor :source_path, :install_path

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

    # Installs files in {#source_path} to {#install_path}
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
palimpsest-0.2.0 lib/palimpsest/component.rb
palimpsest-0.1.1 lib/palimpsest/component.rb
palimpsest-0.1.0 lib/palimpsest/component.rb