Class: Licensed::Sources::Bower
- Defined in:
- lib/licensed/sources/bower.rb
Instance Attribute Summary
Attributes inherited from Source
Instance Method Summary collapse
-
#bower_config ⇒ Object
Returns a parsed “.bowerrc” configuration, or an empty hash if not found.
-
#bower_path ⇒ Object
Returns the expected path to bower components.
- #enabled? ⇒ Boolean
- #enumerate_dependencies ⇒ Object
Methods inherited from Source
#dependencies, full_type, #ignored?, inherited, #initialize, register_source, require_matched_dependency_version, #source_config, type, type_and_version
Constructor Details
This class inherits a constructor from Licensed::Sources::Source
Instance Method Details
#bower_config ⇒ Object
Returns a parsed “.bowerrc” configuration, or an empty hash if not found
31 32 33 34 35 36 |
# File 'lib/licensed/sources/bower.rb', line 31 def bower_config @bower_config ||= begin path = config.pwd.join(".bowerrc") path.exist? ? JSON.parse(path.read) : {} end end |
#bower_path ⇒ Object
Returns the expected path to bower components. Note this does not validate that the returned path is valid
40 41 42 43 |
# File 'lib/licensed/sources/bower.rb', line 40 def bower_path pwd = bower_config["cwd"] ? Pathname.new(bower_config["cwd"]). : config.pwd pwd.join bower_config["directory"] || "bower_components" end |
#enabled? ⇒ Boolean
7 8 9 10 11 |
# File 'lib/licensed/sources/bower.rb', line 7 def enabled? [config.pwd.join(".bowerrc"), config.pwd.join("bower.json")].any? do |path| File.exist?(path) end end |
#enumerate_dependencies ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/licensed/sources/bower.rb', line 13 def enumerate_dependencies Dir.glob(bower_path.join("*/.bower.json")).map do |file| package = JSON.parse(File.read(file)) path = bower_path.join(file).dirname.to_path Dependency.new( name: package["name"], version: package["version"] || package["_release"], path: path, metadata: { "type" => Bower.type, "summary" => package["description"], "homepage" => package["homepage"] } ) end end |