Class: Utopia::Components
- Inherits:
-
Object
- Object
- Utopia::Components
- Defined in:
- lib/utopia/components.rb
Overview
Installs JavaScript packages 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 25 26 27 28 29 |
# File 'lib/utopia/components.rb', line 18 def initialize(root) @root = Pathname.new(root) @package_root = @root + "node_modules" # This is a legacy path: unless @package_root.directory? @package_root = @root + "lib/components" end @install_root = @root + "public/_components" @configuration = load_configuration end |
Instance Attribute Details
#package_root ⇒ Object (readonly)
Returns the value of attribute package_root.
32 33 34 |
# File 'lib/utopia/components.rb', line 32 def package_root @package_root end |
Instance Method Details
#The directory containing the installed JavaScript packages.=(directorycontainingtheinstalledJavaScriptpackages. = (value)) ⇒ Object
32 |
# File 'lib/utopia/components.rb', line 32 attr :package_root |
#update(package_names) ⇒ Object
Update the specified packages in the public components directory.
37 38 39 40 41 42 43 44 45 |
# File 'lib/utopia/components.rb', line 37 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 |