bowerify 1.0.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 +7 -0
- data/README.md +35 -0
- data/bowerify.gemspec +20 -0
- data/lib/bowerify.rb +7 -0
- data/lib/bowerify/assets_processor.rb +27 -0
- data/lib/bowerify/railtie.rb +13 -0
- data/lib/bowerify/version.rb +3 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ffb2ba24914043e90291810224693c702e9751c3
|
4
|
+
data.tar.gz: c848c2261ce2d631de3eacf3c04b82e871ae908c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 52476e9da0221aa9c0c7fb8788a86f08d2be587f2a47a20f97fa31af15a54c2225a550b47a6864719cdcf321248606e57b83630250eed5316977c3f095358770
|
7
|
+
data.tar.gz: 06ca84e749dfad74a2e8d9cfc877c9368f20539c27e4b9a711b230b0e3676ee18e9f2802e389a8bb25fae0092487726304f51d7873bb50229773842db56b4d51
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Bowerify
|
2
|
+
|
3
|
+
A little gem that patches Sprockets in order for it to resolve
|
4
|
+
the [bower](http://bower.io) components relative assets paths
|
5
|
+
correclty.
|
6
|
+
|
7
|
+
Can be used with vanilla `bower` toolchain or in conjunction with
|
8
|
+
the [bower-rails](https://github.com/42dev/bower-rails) gem.
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
Add the gem to your `Gemfile`
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'bowerify'
|
16
|
+
```
|
17
|
+
|
18
|
+
Breath normally.
|
19
|
+
|
20
|
+
## Bower Components Location
|
21
|
+
|
22
|
+
This plugin assumes that you install your bower assets into the
|
23
|
+
`lib/assets/components` folder. if you need to change that, add
|
24
|
+
this to your `config/application.rb`
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
config.bower_components_path = Rails.root.join("path/to/your/components")
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
## Copyright & License
|
32
|
+
|
33
|
+
All code in this repository is released under the terms of the MIT license.
|
34
|
+
|
35
|
+
Copyrigth (C) 2014 Nikolay Nemshilov
|
data/bowerify.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'bowerify/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bowerify"
|
7
|
+
spec.version = Bowerify::VERSION
|
8
|
+
spec.authors = ["Nikolay Nemshilov"]
|
9
|
+
spec.email = ["nemshilov@gmail.com"]
|
10
|
+
spec.description = "Bower components handler for sprockets"
|
11
|
+
spec.summary = "Bower components handler for sprockets and rails"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "sprockets"
|
20
|
+
end
|
data/lib/bowerify.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Bowerify::AssetsProcessor < Sprockets::Processor
|
2
|
+
CSS_URL_RE = /(url\(('|"|))((.+?)\.(gif|png|jpg|jpeg|ttf|svg|woff|eot))(.*?\2\))/
|
3
|
+
|
4
|
+
def evaluate(context, locals={})
|
5
|
+
if context.pathname.to_s.starts_with?(bower_components_path)
|
6
|
+
fix_assets_path data, context
|
7
|
+
else
|
8
|
+
data
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def fix_assets_path(data, context)
|
13
|
+
data.gsub CSS_URL_RE do |*args|
|
14
|
+
s1, s2 = $1.dup, $6.dup
|
15
|
+
|
16
|
+
path = File.expand_path("#{context.pathname.dirname}/#{$3}")
|
17
|
+
path = path.gsub("#{bower_components_path}/", "")
|
18
|
+
path = context.asset_path(path)
|
19
|
+
|
20
|
+
"#{s1}#{path}#{s2}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def bower_components_path
|
25
|
+
Rails.application.config.bower_components_path.to_s
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Bowerify
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
railtie_name :bowerify
|
4
|
+
|
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
|
8
|
+
|
9
|
+
app.assets.register_preprocessor 'text/css', Bowerify::AssetsProcessor
|
10
|
+
app.assets.register_preprocessor 'application/javascript', Bowerify::AssetsProcessor
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bowerify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nikolay Nemshilov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sprockets
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Bower components handler for sprockets
|
28
|
+
email:
|
29
|
+
- nemshilov@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- bowerify.gemspec
|
36
|
+
- lib/bowerify.rb
|
37
|
+
- lib/bowerify/assets_processor.rb
|
38
|
+
- lib/bowerify/railtie.rb
|
39
|
+
- lib/bowerify/version.rb
|
40
|
+
homepage:
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.2.2
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Bower components handler for sprockets and rails
|
64
|
+
test_files: []
|