bowerify 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffb2ba24914043e90291810224693c702e9751c3
4
- data.tar.gz: c848c2261ce2d631de3eacf3c04b82e871ae908c
3
+ metadata.gz: ddb2bff8a18c29320ed3358725922f7c8067b157
4
+ data.tar.gz: c0a9b09296af0a8e93548025fa8f4cc730e11c9b
5
5
  SHA512:
6
- metadata.gz: 52476e9da0221aa9c0c7fb8788a86f08d2be587f2a47a20f97fa31af15a54c2225a550b47a6864719cdcf321248606e57b83630250eed5316977c3f095358770
7
- data.tar.gz: 06ca84e749dfad74a2e8d9cfc877c9368f20539c27e4b9a711b230b0e3676ee18e9f2802e389a8bb25fae0092487726304f51d7873bb50229773842db56b4d51
6
+ metadata.gz: a437cac64117b488cf80a083b5596425e66d585181306f19a9e4d10c4c366a07e05f72ec8195ea123b7667e38fe09f9c0785f7cb2a6e0253266fd00dcccb2d27
7
+ data.tar.gz: a6725a52d7f0c6f483397dca2552742b0608b944830fc38625ab2a628face6c81a600bc9eb15ecadd21f524940762b4532f3f8f66161634cc9b0adfb436b72e7
@@ -2,7 +2,7 @@ class Bowerify::AssetsProcessor < Sprockets::Processor
2
2
  CSS_URL_RE = /(url\(('|"|))((.+?)\.(gif|png|jpg|jpeg|ttf|svg|woff|eot))(.*?\2\))/
3
3
 
4
4
  def evaluate(context, locals={})
5
- if context.pathname.to_s.starts_with?(bower_components_path)
5
+ if bower_component?(context.pathname)
6
6
  fix_assets_path data, context
7
7
  else
8
8
  data
@@ -14,14 +14,26 @@ class Bowerify::AssetsProcessor < Sprockets::Processor
14
14
  s1, s2 = $1.dup, $6.dup
15
15
 
16
16
  path = File.expand_path("#{context.pathname.dirname}/#{$3}")
17
- path = path.gsub("#{bower_components_path}/", "")
17
+ bower_components_paths.each do |bower_path|
18
+ path = path.gsub("#{bower_path}/", "")
19
+ end
18
20
  path = context.asset_path(path)
19
21
 
20
22
  "#{s1}#{path}#{s2}"
21
23
  end
22
24
  end
23
25
 
24
- def bower_components_path
25
- Rails.application.config.bower_components_path.to_s
26
+ def bower_component?(path)
27
+ bower_components_paths.each do |bower_path|
28
+ if path.to_s.starts_with?(bower_path)
29
+ return true
30
+ end
31
+ end
32
+
33
+ false
34
+ end
35
+
36
+ def bower_components_paths
37
+ Array(Rails.application.config.bower_components_path).map(&:to_s)
26
38
  end
27
39
  end
@@ -3,11 +3,23 @@ module Bowerify
3
3
  railtie_name :bowerify
4
4
 
5
5
  config.before_initialize do |app|
6
- app.config.bower_components_path = Rails.root.join('lib', 'assets', 'components')
7
- app.config.assets.paths << app.config.bower_components_path
6
+ app.config.bower_components_path = [
7
+ Rails.root.join('lib', 'assets', 'components'),
8
+ Rails.root.join('vendor', 'assets', 'components')
9
+ ]
8
10
 
9
11
  app.assets.register_preprocessor 'text/css', Bowerify::AssetsProcessor
10
12
  app.assets.register_preprocessor 'application/javascript', Bowerify::AssetsProcessor
11
13
  end
14
+
15
+ config.after_initialize do |app|
16
+ app.config.assets.paths += Array(app.config.bower_components_path)
17
+
18
+ %w[png gif jpg jpeg ttf svg eot woff].each do |ext|
19
+ Array(app.config.bower_components_path).each do |bower_path|
20
+ config.assets.precompile += Dir.glob("#{bower_path}/**/*.#{ext}")
21
+ end
22
+ end
23
+ end
12
24
  end
13
25
  end
@@ -1,3 +1,3 @@
1
1
  module Bowerify
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bowerify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikolay Nemshilov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-10 00:00:00.000000000 Z
11
+ date: 2014-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets