Class: Licensed::Source::Bower
- Inherits:
-
Object
- Object
- Licensed::Source::Bower
- Defined in:
- lib/licensed/source/bower.rb
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.
- #dependencies ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(config) ⇒ Bower
constructor
A new instance of Bower.
- #type ⇒ Object
Constructor Details
#initialize(config) ⇒ Bower
Returns a new instance of Bower.
7 8 9 |
# File 'lib/licensed/source/bower.rb', line 7 def initialize(config) @config = config end |
Instance Method Details
#bower_config ⇒ Object
Returns a parsed “.bowerrc” configuration, or an empty hash if not found
38 39 40 41 42 43 |
# File 'lib/licensed/source/bower.rb', line 38 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
47 48 49 50 |
# File 'lib/licensed/source/bower.rb', line 47 def bower_path pwd = bower_config["cwd"] ? Pathname.new(bower_config["cwd"]). : @config.pwd pwd.join bower_config["directory"] || "bower_components" end |
#dependencies ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/licensed/source/bower.rb', line 23 def dependencies @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(path, { "type" => type, "name" => package["name"], "version" => package["version"] || package["_release"], "summary" => package["description"], "homepage" => package["homepage"] }) end end |
#enabled? ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/licensed/source/bower.rb', line 15 def enabled? return false unless @config.enabled?(type) [@config.pwd.join(".bowerrc"), @config.pwd.join("bower.json")].any? do |path| File.exist?(path) end end |
#type ⇒ Object
11 12 13 |
# File 'lib/licensed/source/bower.rb', line 11 def type "bower" end |