Sha256: f4c35440fc67c705939bf2448e7b1dd589b163c64ee9f541c4268e02305ae350

Contents?: true

Size: 909 Bytes

Versions: 5

Compression:

Stored size: 909 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_source(package, path)
    if path =~ /^#{BowerVendor::BOWER_ROOT}/
      path
    else
      File.join(BowerVendor::BOWER_ROOT, package, path) 
    end
  end

  def prefixed_dest(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

5 entries across 5 versions & 1 rubygems

Version Path
bower-vendor-0.0.8 lib/bower-vendor/utils.rb
bower-vendor-0.0.7 lib/bower-vendor/utils.rb
bower-vendor-0.0.6 lib/bower-vendor/utils.rb
bower-vendor-0.0.5 lib/bower-vendor/utils.rb
bower-vendor-0.0.4 lib/bower-vendor/utils.rb