assets_pipeline 0.0.1
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/.gitignore +9 -0
- data/.rspec +3 -0
- data/.travis.yml +15 -0
- data/Gemfile +16 -0
- data/README.md +31 -0
- data/Rakefile +7 -0
- data/assets_pipeline.gemspec +21 -0
- data/lib/assets_pipeline/asset_url_helper.rb +24 -0
- data/lib/assets_pipeline.rb +28 -0
- data/spec/asset_url_helper_spec.rb +52 -0
- data/spec/fixtures/manifest.json +7 -0
- data/spec/spec_helper.rb +4 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd75857595be21893c85c948b00fadcb6180fc46
|
4
|
+
data.tar.gz: cd9ce85c3b2177ec2dc6b2a4cbd628e2a6d0001d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c993b6496708dfc5aea5763ac4b5ffaa047242d412f057b12f81dfa32da74d5c3ed6537ac7591580afd4cb6640ff2396349789f45e1c2f89e3b443e7826bf3a
|
7
|
+
data.tar.gz: 7b448703db758e0c0563bcc10794eb08a8b8bef05092b58dfcdc3977215b8243f5c2acaef364220b89221ce5af07e80aaf41d2a34c1bdf346a8cd19c082feaca
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
sudo: false
|
2
|
+
|
3
|
+
language: ruby
|
4
|
+
|
5
|
+
rvm:
|
6
|
+
- 2.3.0
|
7
|
+
|
8
|
+
env:
|
9
|
+
- "RAILS_VERSION=4.0.0"
|
10
|
+
- "RAILS_VERSION='~> 4.0.0'"
|
11
|
+
- "RAILS_VERSION=4.1.0"
|
12
|
+
- "RAILS_VERSION='~> 4.1.0'"
|
13
|
+
- "RAILS_VERSION=4.2.0"
|
14
|
+
- "RAILS_VERSION='~> 4.2.0'"
|
15
|
+
- "RAILS_VERSION=master"
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
rails_version = ENV['RAILS_VERSION'] || 'default'
|
6
|
+
|
7
|
+
rails = case rails_version
|
8
|
+
when 'master'
|
9
|
+
{ github: 'rails/rails' }
|
10
|
+
when 'default'
|
11
|
+
'4.2.6'
|
12
|
+
else
|
13
|
+
rails_version
|
14
|
+
end
|
15
|
+
|
16
|
+
gem 'rails', rails
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# assets_pipeline
|
2
|
+
[](https://rubygems.org/gems/assets_pipeline)
|
3
|
+
[](https://travis-ci.org/llxff/assets_pipeline)
|
4
|
+
|
5
|
+
Asset Pipeline for Rails with your favourite js bundler.
|
6
|
+
|
7
|
+
Install
|
8
|
+
=======
|
9
|
+
|
10
|
+
```
|
11
|
+
# Create new app or remove Sprockets from existing
|
12
|
+
rails new project --skip-sprockets
|
13
|
+
|
14
|
+
# config/application.rb
|
15
|
+
config.assets_pipeline.manifest_file = 'config/manifest.json' # default: config/manifest.json
|
16
|
+
config.assets_pipeline.prefix = '/assets' # default: /assets
|
17
|
+
```
|
18
|
+
|
19
|
+
Configuration for js bundler
|
20
|
+
============================
|
21
|
+
|
22
|
+
Your js bundler should generate manifest file in JSON format:
|
23
|
+
|
24
|
+
```
|
25
|
+
# config/manifest.json
|
26
|
+
|
27
|
+
{
|
28
|
+
"application.js": "application-ea0d453146be2145f180.js",
|
29
|
+
...
|
30
|
+
}
|
31
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'assets_pipeline'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.platform = Gem::Platform::RUBY
|
5
|
+
s.authors = ['Aleksandr Fomin', 'Marat Abdullin', 'Nikolay Sverchkov']
|
6
|
+
s.email = ['ll.wg.bin@gmail.com', 'esend.work@gmail.com', 'ssnikolay@gmail.com']
|
7
|
+
s.homepage = 'https://github.com/RuntimeLLC/assets_pipeline'
|
8
|
+
s.summary = 'Asset Pipeline for Rails with your favourite js bundler'
|
9
|
+
s.description = s.summary
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
s.executables = `git ls-files -- bin/*`.split($/).map{ |f| File.basename(f) }
|
14
|
+
s.require_paths = ['lib']
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
17
|
+
s.add_dependency 'rails', '>= 4'
|
18
|
+
|
19
|
+
s.add_development_dependency 'rake'
|
20
|
+
s.add_development_dependency 'rspec', '~> 3.4'
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module AssetsPipeline
|
2
|
+
module AssetUrlHelper
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
def compute_asset_path(path, options = {})
|
7
|
+
asset_path_from_manifest(clean_path(super))
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def asset_path_from_manifest(asset_path)
|
13
|
+
config = Rails.application.config
|
14
|
+
|
15
|
+
rev_path = config.assets_pipeline.manifest[asset_path] || asset_path
|
16
|
+
[config.assets_pipeline.prefix, rev_path].join('/')
|
17
|
+
end
|
18
|
+
|
19
|
+
def clean_path(path)
|
20
|
+
path.split('/').select(&:present?).join('/')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module AssetsPipeline
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
config.assets_pipeline = ::ActiveSupport::OrderedOptions.new
|
4
|
+
|
5
|
+
config.assets_pipeline.manifest_file = 'config/manifest.json'
|
6
|
+
|
7
|
+
if config.respond_to?(:assets)
|
8
|
+
config.assets_pipeline.prefix = config.assets.prefix
|
9
|
+
else
|
10
|
+
config.assets_pipeline.prefix = '/assets'
|
11
|
+
end
|
12
|
+
|
13
|
+
config.after_initialize do
|
14
|
+
if File.exists?(config.assets_pipeline.manifest_file)
|
15
|
+
config.assets_pipeline.manifest = JSON.parse(File.read(config.assets_pipeline.manifest_file))
|
16
|
+
else
|
17
|
+
config.assets_pipeline.manifest = {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
initializer 'load assets_pipeline integration' do
|
22
|
+
ActiveSupport.on_load :action_view do
|
23
|
+
require 'assets_pipeline/asset_url_helper'
|
24
|
+
include AssetUrlHelper
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
describe ActionView::Helpers::AssetUrlHelper do
|
2
|
+
before :all do
|
3
|
+
app = Class.new(Rails::Application)
|
4
|
+
app.config.eager_load = false
|
5
|
+
app.config.assets_pipeline.manifest_file = File.join('spec', 'fixtures', 'manifest.json')
|
6
|
+
app.initialize!
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:helper) { ActionView::Base.new }
|
10
|
+
|
11
|
+
describe 'asset_path' do
|
12
|
+
context 'when chunk present' do
|
13
|
+
it 'should return javascript' do
|
14
|
+
expect(helper.asset_path(:index, type: :javascript)).to eq '/assets/index-ea0d453146be2145f180.js'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should return stylesheet' do
|
18
|
+
expect(helper.asset_path(:index, type: :stylesheet)).to eq '/assets/index-ea0d453146be2145f180.css'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should return font' do
|
22
|
+
expect(helper.asset_path('arial.eot', type: :font)).to eq '/assets/fonts/arial.ttf'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when chunk not found in webpack manifest' do
|
27
|
+
it 'should return javascript' do
|
28
|
+
expect(helper.asset_path('application.js')).to eq '/assets/application-ea0d453146be2145f180.js'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should return stylesheet' do
|
32
|
+
expect(helper.asset_path('application.css')).to eq '/assets/application-ea0d453146be2145f180.css'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return font' do
|
36
|
+
expect(helper.asset_path('fonts/arial.eot')).to eq '/assets/fonts/arial.ttf'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when asset was not found in manifest' do
|
41
|
+
it 'should return itself' do
|
42
|
+
expect(helper.asset_path('asset.js')).to eq '/assets/asset.js'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'stylesheet_link_tag' do
|
48
|
+
it 'should return link tag with valid css file' do
|
49
|
+
expect(helper.stylesheet_link_tag('index', media: 'all')).to match 'assets/index-ea0d453146be2145f180.css'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"application.js": "application-ea0d453146be2145f180.js",
|
3
|
+
"javascripts/index.js": "index-ea0d453146be2145f180.js",
|
4
|
+
"application.css": "application-ea0d453146be2145f180.css",
|
5
|
+
"stylesheets/index.css": "index-ea0d453146be2145f180.css",
|
6
|
+
"fonts/arial.eot": "fonts/arial.ttf"
|
7
|
+
}
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: assets_pipeline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aleksandr Fomin
|
8
|
+
- Marat Abdullin
|
9
|
+
- Nikolay Sverchkov
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rails
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '4'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '4'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rspec
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.4'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '3.4'
|
57
|
+
description: Asset Pipeline for Rails with your favourite js bundler
|
58
|
+
email:
|
59
|
+
- ll.wg.bin@gmail.com
|
60
|
+
- esend.work@gmail.com
|
61
|
+
- ssnikolay@gmail.com
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- ".gitignore"
|
67
|
+
- ".rspec"
|
68
|
+
- ".travis.yml"
|
69
|
+
- Gemfile
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- assets_pipeline.gemspec
|
73
|
+
- lib/assets_pipeline.rb
|
74
|
+
- lib/assets_pipeline/asset_url_helper.rb
|
75
|
+
- spec/asset_url_helper_spec.rb
|
76
|
+
- spec/fixtures/manifest.json
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
homepage: https://github.com/RuntimeLLC/assets_pipeline
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.5.1
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Asset Pipeline for Rails with your favourite js bundler
|
102
|
+
test_files:
|
103
|
+
- spec/asset_url_helper_spec.rb
|
104
|
+
- spec/fixtures/manifest.json
|
105
|
+
- spec/spec_helper.rb
|