Sha256: b6ca00515102aa775418ed531637143df5c5b4e8e60d6355c07c50490f871bce

Contents?: true

Size: 735 Bytes

Versions: 3

Compression:

Stored size: 735 Bytes

Contents

require 'ruby-bower'
require 'json'

class BowerVendor::Utils
  attr_accessor :bower_paths, :bower_json

  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

  def prefixed_path(package, prefix, path)
    File.join('vendor', 'assets', prefix, package, path)
  end

  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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bower-vendor-0.0.3 lib/bower-vendor/utils.rb
bower-vendor-0.0.2 lib/bower-vendor/utils.rb
bower-vendor-0.0.1 lib/bower-vendor/utils.rb