Class: Rails::Webpack::DependencyCollection
- Inherits:
-
Object
- Object
- Rails::Webpack::DependencyCollection
- Includes:
- Generators::Actions
- Defined in:
- lib/rails/webpack/dependency_collection.rb
Constant Summary collapse
- VALID_CATEGORY =
[:bower, :npm, :npm_develop]
Class Method Summary collapse
Instance Method Summary collapse
- #add(category, name, version_spec) ⇒ Object
-
#initialize(config) ⇒ DependencyCollection
constructor
A new instance of DependencyCollection.
- #processor ⇒ Object
- #yamlize(category) ⇒ Object
Constructor Details
#initialize(config) ⇒ DependencyCollection
Returns a new instance of DependencyCollection.
21 22 23 24 25 26 |
# File 'lib/rails/webpack/dependency_collection.rb', line 21 def initialize(config) @config, @file = config, config.source.to_s @bower_deps = normalize @config.bower.dependencies @npm_deps = normalize @config.npm.dependencies @npm_develop_deps = normalize @config.npm.develop_dependencies end |
Class Method Details
.collection_name_from(category) ⇒ Object
9 10 11 |
# File 'lib/rails/webpack/dependency_collection.rb', line 9 def collection_name_from(category) "#{category.to_s}_deps" end |
Instance Method Details
#add(category, name, version_spec) ⇒ Object
28 29 30 31 32 |
# File 'lib/rails/webpack/dependency_collection.rb', line 28 def add(category, name, version_spec) deps = get(category) deps << {'name' => name, 'version' => version_spec} deps.uniq! end |
#processor ⇒ Object
38 39 40 |
# File 'lib/rails/webpack/dependency_collection.rb', line 38 def processor Rails::Webpack::Processor.new(@file, self) end |
#yamlize(category) ⇒ Object
34 35 36 |
# File 'lib/rails/webpack/dependency_collection.rb', line 34 def yamlize(category) get(category).to_yaml.lines[1..-1].map(&:rstrip).join("\n").gsub('"', "'").gsub /^/, (' ' * 4) end |