Class: Utopia::Components
- Inherits:
-
Object
- Object
- Utopia::Components
- Defined in:
- lib/utopia/components.rb
Overview
Installs JavaScript packages from node_modules into the public components directory. Package contents are copied from dist when it exists, otherwise from the package root.
By default, the complete source directory is installed. Projects can limit an individual package to a set of files using utopia.components in their package.json file.
Instance Attribute Summary collapse
-
#package_root ⇒ Object
readonly
Returns the value of attribute package_root.
Instance Method Summary collapse
-
#initialize(root) ⇒ Components
constructor
Initialize a component installer for the given project root.
- #The directory containing the installed JavaScript packages.=(directorycontainingtheinstalledJavaScriptpackages. = (value)) ⇒ Object
-
#update(package_names) ⇒ Object
Update the specified packages in the public components directory.
Constructor Details
#initialize(root) ⇒ Components
Initialize a component installer for the given project root.
18 19 20 21 22 23 24 |
# File 'lib/utopia/components.rb', line 18 def initialize(root) @root = Pathname.new(root) @package_root = @root + "node_modules" @install_root = @root + "public/_components" @configuration = load_configuration end |
Instance Attribute Details
#package_root ⇒ Object (readonly)
Returns the value of attribute package_root.
27 28 29 |
# File 'lib/utopia/components.rb', line 27 def package_root @package_root end |
Instance Method Details
#The directory containing the installed JavaScript packages.=(directorycontainingtheinstalledJavaScriptpackages. = (value)) ⇒ Object
27 |
# File 'lib/utopia/components.rb', line 27 attr :package_root |
#update(package_names) ⇒ Object
Update the specified packages in the public components directory.
32 33 34 35 36 37 38 39 40 |
# File 'lib/utopia/components.rb', line 32 def update(package_names) (@package_root).each do |package_path| package_name = package_path.relative_path_from(@package_root).to_s if package_names.include?(package_name) install(package_name, package_path) end end end |