Class: BowerVendor::Utils
- Inherits:
-
Object
- Object
- BowerVendor::Utils
- Defined in:
- lib/bower-vendor/utils.rb
Instance Attribute Summary collapse
-
#bower_json ⇒ Object
Returns the value of attribute bower_json.
-
#bower_paths ⇒ Object
Returns the value of attribute bower_paths.
Instance Method Summary collapse
-
#initialize ⇒ Utils
constructor
A new instance of Utils.
- #merged_paths ⇒ Object
- #prefixed_dest(package, prefix, path) ⇒ Object
- #prefixed_source(package, path) ⇒ Object
Constructor Details
#initialize ⇒ Utils
Returns a new instance of Utils.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bower-vendor/utils.rb', line 7 def initialize bower = Bower.new @bower_json = ::JSON.load(File.read('bower.json')) begin @bower_paths = bower.list(paths: true) rescue ::ExecJS::ProgramError => e err = 'failed to retrieve installed bowser components' err << ': ' << e.to_s if e.to_s raise RuntimeError, err end end |
Instance Attribute Details
#bower_json ⇒ Object
Returns the value of attribute bower_json.
5 6 7 |
# File 'lib/bower-vendor/utils.rb', line 5 def bower_json @bower_json end |
#bower_paths ⇒ Object
Returns the value of attribute bower_paths.
5 6 7 |
# File 'lib/bower-vendor/utils.rb', line 5 def bower_paths @bower_paths end |
Instance Method Details
#merged_paths ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/bower-vendor/utils.rb', line 31 def merged_paths if bower_json.has_key? 'sources' bower_json['sources'].each do |package, paths| bower_paths[package] = paths end end bower_paths end |
#prefixed_dest(package, prefix, path) ⇒ Object
27 28 29 |
# File 'lib/bower-vendor/utils.rb', line 27 def prefixed_dest(package, prefix, path) File.join('vendor', 'assets', prefix, package, path) end |
#prefixed_source(package, path) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/bower-vendor/utils.rb', line 19 def prefixed_source(package, path) if path =~ /^#{BowerVendor::BOWER_ROOT}/ path else File.join(BowerVendor::BOWER_ROOT, package, path) end end |