padrino-pipeline 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/Gemfile +0 -1
- data/README.md +101 -13
- data/lib/padrino-pipeline.rb +8 -4
- data/lib/padrino-pipeline/compilers/asset_pack.rb +9 -0
- data/lib/padrino-pipeline/compilers/sprockets.rb +61 -0
- data/lib/padrino-pipeline/configuration.rb +27 -1
- data/lib/padrino-pipeline/ext/padrino-helpers/asset_tag_helper.rb +73 -4
- data/lib/padrino-pipeline/pipelines/asset_pack.rb +11 -10
- data/lib/padrino-pipeline/pipelines/sprockets.rb +5 -3
- data/lib/padrino-pipeline/tasks.rb +9 -0
- data/lib/padrino-pipeline/tasks/pipeline_tasks.rb +37 -0
- data/lib/padrino-pipeline/version.rb +1 -1
- data/padrino-pipeline.gemspec +3 -3
- data/test/fixtures/asset_pack_app/asset_pack_app.rb +11 -0
- data/test/fixtures/sprockets_app/assets/javascripts/application.js +2 -0
- data/test/fixtures/sprockets_app/assets/javascripts/coffee.js.coffee +2 -0
- data/test/fixtures/sprockets_app/assets/javascripts/second_js_file.js +1 -0
- data/test/fixtures/sprockets_app/assets/stylesheets/application.css +1 -0
- data/test/{extra → helpers}/helper.rb +9 -18
- data/test/{extra → helpers}/mini_shoulda.rb +0 -0
- data/test/pipelines/asset_pack/test_packages.rb +31 -0
- data/test/pipelines/sprockets/test_compiler.rb +131 -0
- data/test/{sprockets → pipelines/sprockets}/test_js.rb +4 -4
- data/test/test_asset_tag.rb +52 -0
- data/test/test_compiler.rb +18 -0
- data/test/{api/test_compression.rb → test_compression.rb} +5 -5
- data/test/{api/test_css.rb → test_css.rb} +4 -4
- data/test/{api/test_images.rb → test_images.rb} +4 -4
- data/test/{api/test_js.rb → test_js.rb} +4 -4
- data/test/{api/test_other.rb → test_other.rb} +4 -4
- metadata +35 -40
- data/test/asset_pack/test_packages.rb +0 -61
- data/test/sprockets/test_asset_tag.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c780188a8a746db35ba46d78a7c8c940861c0fc3
|
4
|
+
data.tar.gz: 0a625506df07794e7f75b81ba6f63ab5cb98ceb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af6ff7d0500ed852640d8a5c7572776a2c21b5557181f304872bc0b83667a0ec02ebc7fe5b10bbc5812be59364567429a67f4a5bf55d08d761b94da7fdf6c73e
|
7
|
+
data.tar.gz: 4d1076133feb2a8a3727196eaf146d570cbbf2030ff48aba906cae12d9c9f07014c8f0340abbdd408cce2f336832047ea8258c998207edfda75ab9abf14ea755
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@ a unified way to use several different asset management systems.
|
|
8
8
|
|
9
9
|
|
10
10
|
##Supported Pipelines
|
11
|
-
- [
|
11
|
+
- [sprockets](https://github.com/sstephenson/sprockets)
|
12
12
|
- [sinatra-assetpack](https://github.com/rstacruz/sinatra-assetpack)
|
13
13
|
|
14
14
|
##Simple Usage
|
@@ -62,25 +62,113 @@ module Example
|
|
62
62
|
end
|
63
63
|
```
|
64
64
|
|
65
|
-
The following options can be set
|
66
65
|
|
67
|
-
|
68
|
-
|
66
|
+
## Pipeline
|
67
|
+
```ruby
|
68
|
+
module Example
|
69
|
+
class App < Padrino::Application
|
70
|
+
register Padrino::Pipeline
|
71
|
+
configure_assets do |config|
|
72
|
+
config.pipeline = Padrino::Pipeline::AssetPack
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
`config.pipeline = Padrino::Pipeline::AssetPack`
|
79
|
+
`config.pipeline = Padrino::Pipeline::Sprockets`
|
69
80
|
|
70
|
-
|
71
|
-
- #css_prefix
|
72
|
-
- #js_prefix
|
81
|
+
## Assets URI(mounting location) String
|
73
82
|
|
74
|
-
###
|
75
|
-
|
76
|
-
|
83
|
+
###css_prefix
|
84
|
+
```ruby
|
85
|
+
module Example
|
86
|
+
class App < Padrino::Application
|
87
|
+
register Padrino::Pipeline
|
88
|
+
configure_assets do |config|
|
89
|
+
config.pipeline = Padrino::Pipeline::Sprockets
|
90
|
+
config.css_prefix = '/my_custom_location'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
```
|
95
|
+
`/my_custom_location` will be the location css assets are served
|
96
|
+
e.g. `/my_custom_location/application.css`
|
77
97
|
|
78
|
-
###
|
79
|
-
|
98
|
+
###js_prefix
|
99
|
+
```ruby
|
100
|
+
module Example
|
101
|
+
class App < Padrino::Application
|
102
|
+
register Padrino::Pipeline
|
103
|
+
configure_assets do |config|
|
104
|
+
config.pipeline = Padrino::Pipeline::Sprockets
|
105
|
+
config.js_prefix = '/js'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
```
|
110
|
+
`/js` will be the location css assets are served
|
111
|
+
e.g. `/js/application.js`
|
80
112
|
|
81
|
-
|
113
|
+
## Asset location(path to files) String/Array
|
114
|
+
###css_assets
|
115
|
+
```ruby
|
116
|
+
module Example
|
117
|
+
class App < Padrino::Application
|
118
|
+
register Padrino::Pipeline
|
119
|
+
configure_assets do |config|
|
120
|
+
config.pipeline = Padrino::Pipeline::Sprockets
|
121
|
+
config.css_assets = '/path/to/stylesheets'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
```
|
126
|
+
`/path/to/stylesheets` will be served at the css_prefix(default: /assets/stylesheets)
|
127
|
+
|
128
|
+
###js_assets
|
129
|
+
```ruby
|
130
|
+
module Example
|
131
|
+
class App < Padrino::Application
|
132
|
+
register Padrino::Pipeline
|
133
|
+
configure_assets do |config|
|
134
|
+
config.pipeline = Padrino::Pipeline::Sprockets
|
135
|
+
config.js_assets = '/path/to/javascripts'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
```
|
140
|
+
`/path/to/javascripts` will be served at the js_prefix(default: /assets/javascripts)
|
141
|
+
|
142
|
+
## Prefix prepend this prefix before all assets
|
143
|
+
###prefix
|
144
|
+
```ruby
|
145
|
+
module Example
|
146
|
+
class App < Padrino::Application
|
147
|
+
register Padrino::Pipeline
|
148
|
+
configure_assets do |config|
|
149
|
+
config.pipeline = Padrino::Pipeline::Sprockets
|
150
|
+
config.prefix = '/public'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
```
|
155
|
+
prefixes `/public` to all asset URLs. Above example will serve assets from:
|
156
|
+
- `/public/assets/stylesheets/application.css`
|
157
|
+
# => `http://localhost:3000/public/assets/stylesheets/application.css`
|
158
|
+
- `/public/assets/javascripts/application.js`
|
159
|
+
# => `http://localhost:3000/public/assets/javascripts/application.js`
|
160
|
+
|
161
|
+
## Default option values
|
162
|
+
TODO
|
163
|
+
|
164
|
+
## compile asset rake tasks
|
82
165
|
TODO
|
83
166
|
|
167
|
+
## Sprocket compiled assets
|
168
|
+
`javascript_include_tag` & `stylesheet_link_tag` have been patched to include the hex digest of compiled assets.
|
169
|
+
if the assets do not exist a fresh copy will be served via the normal asset URL.
|
170
|
+
e.g. `application-12abc456xyz.js` vs `application.js`
|
171
|
+
|
84
172
|
## Asset pack packages
|
85
173
|
```ruby
|
86
174
|
module Example
|
data/lib/padrino-pipeline.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'padrino-pipeline/pipelines/sprockets'
|
2
2
|
require 'padrino-pipeline/pipelines/asset_pack'
|
3
|
+
require 'padrino-pipeline/compilers/sprockets'
|
4
|
+
require 'padrino-pipeline/compilers/asset_pack'
|
5
|
+
|
3
6
|
require 'padrino-pipeline/ext/padrino-helpers/asset_tag_helper'
|
4
7
|
require 'padrino-pipeline/configuration'
|
5
8
|
|
@@ -7,11 +10,12 @@ module Padrino
|
|
7
10
|
##
|
8
11
|
# Add public api docs here
|
9
12
|
module Pipeline
|
10
|
-
|
13
|
+
|
11
14
|
def configure_assets(&block)
|
12
|
-
|
13
|
-
yield
|
14
|
-
|
15
|
+
config = Padrino::Pipeline::Configuration.new(self)
|
16
|
+
yield config if block_given?
|
17
|
+
config.pipeline = config.pipeline.new(self, config)
|
18
|
+
set :pipeline, config
|
15
19
|
end
|
16
20
|
|
17
21
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Padrino
|
2
|
+
module Pipeline
|
3
|
+
module Compiler
|
4
|
+
class Sprockets
|
5
|
+
def initialize(config)
|
6
|
+
@config = config
|
7
|
+
end
|
8
|
+
|
9
|
+
def compile(type)
|
10
|
+
create_directory(@config.compiled_output)
|
11
|
+
create_directory("#{@config.compiled_output}/#{@config.js_compiled_output}")
|
12
|
+
create_directory("#{@config.compiled_output}/#{@config.css_compiled_output}")
|
13
|
+
return unless @config.app
|
14
|
+
case type
|
15
|
+
when :js then compile_js
|
16
|
+
when :css then compile_css
|
17
|
+
else
|
18
|
+
throw RuntimeError, "Can not compile #{type} asset"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def js_output_path(file_name = '')
|
23
|
+
output_path(@config.js_compiled_output).join(file_name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def css_output_path(file_name = '')
|
27
|
+
output_path(@config.css_compiled_output).join(file_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def assets
|
32
|
+
@config.app.assets
|
33
|
+
end
|
34
|
+
|
35
|
+
def output_path(directory_name)
|
36
|
+
output_path = Pathname.new(@config.compiled_output).join(directory_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def compile_css
|
40
|
+
compile_assets(:css, ['css', 'css.gz'])
|
41
|
+
end
|
42
|
+
|
43
|
+
def compile_js
|
44
|
+
compile_assets(:js, ['js', 'js.gz'])
|
45
|
+
end
|
46
|
+
|
47
|
+
def compile_assets(type, extensions = [])
|
48
|
+
asset = assets[@config.send("#{type.to_s}_compiled_asset")]
|
49
|
+
extensions.each do |ext|
|
50
|
+
output_path = self.send("#{type.to_s}_output_path", "application-#{asset.digest}.#{ext}")
|
51
|
+
asset.write_to output_path
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_directory(path)
|
56
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -5,7 +5,9 @@ module Padrino
|
|
5
5
|
attr_accessor :pipeline, :packages, :prefix
|
6
6
|
attr_accessor :css_prefix, :js_prefix, :image_prefix
|
7
7
|
attr_accessor :css_assets, :js_assets, :image_assets
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :js_compiled_output, :css_compiled_output, :compiled_output
|
9
|
+
attr_accessor :js_compiled_asset, :css_compiled_asset
|
10
|
+
attr_accessor :enable_compression, :app
|
9
11
|
|
10
12
|
def initialize(app)
|
11
13
|
@app = app
|
@@ -17,6 +19,17 @@ module Padrino
|
|
17
19
|
@image_assets = "#{app_root}/assets/images"
|
18
20
|
@js_assets = "#{app_root}/assets/javascripts"
|
19
21
|
@css_assets = "#{app_root}/assets/stylesheets"
|
22
|
+
|
23
|
+
@compiled_output = "#{app_root}/public"
|
24
|
+
@js_compiled_output = "javascripts"
|
25
|
+
@css_compiled_output = "stylesheets"
|
26
|
+
|
27
|
+
@js_compiled_asset = 'application.js'
|
28
|
+
@css_compiled_asset = 'application.css'
|
29
|
+
end
|
30
|
+
|
31
|
+
def compile(*args)
|
32
|
+
asset_compiler.compile(*args)
|
20
33
|
end
|
21
34
|
|
22
35
|
def app_root
|
@@ -38,7 +51,20 @@ module Padrino
|
|
38
51
|
def serve_compressed?
|
39
52
|
enable_compression || PADRINO_ENV == "production"
|
40
53
|
end
|
54
|
+
|
55
|
+
def asset_compiler
|
56
|
+
@asset_compiler ||= match_compiler.new(self)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def pipeline_class
|
61
|
+
@pipeline.class.name
|
62
|
+
end
|
41
63
|
|
64
|
+
def match_compiler
|
65
|
+
pipeline_type = pipeline_class.split('::').last
|
66
|
+
"Padrino::Pipeline::Compiler::#{pipeline_type}".constantize
|
67
|
+
end
|
42
68
|
end
|
43
69
|
end
|
44
70
|
end
|
@@ -1,11 +1,80 @@
|
|
1
|
+
require 'padrino-helpers'
|
2
|
+
|
1
3
|
module Padrino
|
2
4
|
module Helpers
|
3
5
|
module AssetTagHelpers
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def pipeline_asset_folder_name(kind)
|
8
|
+
pipeline = settings.pipeline
|
9
|
+
case kind
|
10
|
+
when :css then pipeline.css_prefix
|
11
|
+
when :js then pipeline.js_prefix
|
12
|
+
when :images then pipeline.image_prefix
|
13
|
+
else kind.to_s
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_method :original_asset_folder_name, :asset_folder_name
|
18
|
+
alias_method :asset_folder_name, :pipeline_asset_folder_name
|
19
|
+
|
20
|
+
alias_method :original_javascript_include_tag, :javascript_include_tag
|
21
|
+
def javascript_include_tag(*sources)
|
22
|
+
options = sources.extract_options!.symbolize_keys
|
23
|
+
options.reverse_merge!(:type => 'text/javascript')
|
24
|
+
sources.flatten.map { |source|
|
25
|
+
content_tag(:script, nil, options.reverse_merge(:src => resolve_js_path(source)))
|
26
|
+
}.join("\n").html_safe
|
27
|
+
end
|
28
|
+
|
29
|
+
alias_method :original_stylesheet_link_tag, :stylesheet_link_tag
|
30
|
+
def stylesheet_link_tag(*sources)
|
31
|
+
options = sources.extract_options!.symbolize_keys
|
32
|
+
options.reverse_merge!(:media => 'screen', :rel => 'stylesheet', :type => 'text/css')
|
33
|
+
sources.flatten.map { |source|
|
34
|
+
tag(:link, options.reverse_merge(:href => asset_path(:css, resolve_css_path(source))))
|
35
|
+
}.join("\n").html_safe
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def resolve_css_path(source)
|
40
|
+
resolve_path(:css, source)
|
41
|
+
end
|
42
|
+
|
43
|
+
def resolve_js_path(source)
|
44
|
+
resolve_path(:js, source)
|
45
|
+
end
|
46
|
+
|
47
|
+
def resolve_path(type, source)
|
48
|
+
digested_source = digested_source(source)
|
49
|
+
digested_source_path = digested_source_path(type, digested_source)
|
50
|
+
File.exists?(digested_source_path) ? asset_path(type, digested_source) : asset_path(type, source)
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Get the full path of the digested_source
|
55
|
+
def digested_source_path(type, digested_source)
|
56
|
+
#hackzor
|
57
|
+
settings.pipeline.asset_compiler.send("#{type.to_s}_output_path", digested_source)
|
58
|
+
rescue
|
59
|
+
''
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Add the hex digest to the source path
|
64
|
+
def digested_source(source)
|
65
|
+
digest = asset_digest(source)
|
66
|
+
parts = source.split('.')
|
67
|
+
(parts[0...parts.count-1]).join('.') << "-#{digest}.#{parts.last}"
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# Get the hex digest for a particular asset
|
72
|
+
def asset_digest(source)
|
73
|
+
return '' unless defined? settings
|
74
|
+
return '' unless settings.respond_to?(:assets)
|
75
|
+
return '' unless settings.assets.respond_to?(:[])
|
76
|
+
settings.assets[source] && settings.assets[source].digest
|
77
|
+
end
|
9
78
|
|
10
79
|
end #AssetTagHelpers
|
11
80
|
end #Helpers
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require 'sinatra/assetpack' unless defined? Sinatra::AssetPack
|
2
|
-
|
3
1
|
module Padrino
|
4
2
|
module Pipeline
|
5
3
|
class AssetPack
|
6
4
|
|
7
5
|
def initialize(app, config)
|
6
|
+
require_libraries
|
8
7
|
@app = app
|
9
8
|
@config = config
|
10
9
|
setup_enviroment
|
@@ -16,6 +15,10 @@ module Padrino
|
|
16
15
|
end
|
17
16
|
|
18
17
|
private
|
18
|
+
def require_libraries
|
19
|
+
require 'sinatra/assetpack'
|
20
|
+
end
|
21
|
+
|
19
22
|
def setup_enviroment
|
20
23
|
@app.set :serve_assets, true
|
21
24
|
@app.register Sinatra::AssetPack
|
@@ -29,20 +32,18 @@ module Padrino
|
|
29
32
|
|
30
33
|
@app.assets {
|
31
34
|
def mount_asset(prefix, assets)
|
32
|
-
|
33
|
-
|
34
|
-
else
|
35
|
-
serve prefix, :from => assets
|
35
|
+
[*assets].flatten.each do |asset|
|
36
|
+
serve(prefix, :from => asset) if File.exists? asset
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
mount_asset
|
40
|
-
mount_asset
|
41
|
-
mount_asset
|
40
|
+
mount_asset(js_prefix, js_assets)
|
41
|
+
mount_asset(css_prefix, css_assets)
|
42
|
+
mount_asset(image_prefix, image_assets)
|
42
43
|
|
43
44
|
packages.each { |package| send(package.shift, *package) }
|
44
45
|
if compression_enabled
|
45
|
-
js_compression :
|
46
|
+
js_compression :jsmin
|
46
47
|
css_compression :sass
|
47
48
|
end
|
48
49
|
}
|
@@ -1,11 +1,9 @@
|
|
1
|
-
require 'sprockets'
|
2
|
-
require 'uglifier'
|
3
|
-
|
4
1
|
module Padrino
|
5
2
|
module Pipeline
|
6
3
|
class Sprockets
|
7
4
|
|
8
5
|
def initialize(app, config)
|
6
|
+
require_libraries
|
9
7
|
@app = app
|
10
8
|
@config = config
|
11
9
|
setup_enviroment
|
@@ -13,6 +11,10 @@ module Padrino
|
|
13
11
|
end
|
14
12
|
|
15
13
|
private
|
14
|
+
def require_libraries
|
15
|
+
%w[sprockets uglifier].each { |package| require package }
|
16
|
+
end
|
17
|
+
|
16
18
|
def paths
|
17
19
|
js_assets = @config.js_assets.kind_of?(Array) ? @config.js_assets : [@config.js_assets]
|
18
20
|
css_assets = @config.css_assets.kind_of?(Array) ? @config.css_assets : [@config.css_assets]
|
@@ -0,0 +1,37 @@
|
|
1
|
+
namespace :pipeline do
|
2
|
+
def load_apps
|
3
|
+
require File.expand_path('config/boot.rb', Rake.application.original_dir)
|
4
|
+
end
|
5
|
+
|
6
|
+
def send_to_pipeline(method, *args)
|
7
|
+
Padrino.mounted_apps.each do |mounted_app|
|
8
|
+
app = mounted_app.app_obj
|
9
|
+
app.pipeline.send(method, *args) if app.pipeline?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Compile javascript assets"
|
14
|
+
task :compile_js do
|
15
|
+
load_apps
|
16
|
+
send_to_pipeline(:compile, :js)
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Compile CSS assets"
|
20
|
+
task :compile_css do
|
21
|
+
load_apps
|
22
|
+
send_to_pipeline(:compile, :css)
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Clean javascipt assets"
|
26
|
+
task :clean_js do
|
27
|
+
load_apps
|
28
|
+
send_to_pipeline(:clean, :js)
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Clean CSS assets"
|
32
|
+
task :clean_css do
|
33
|
+
load_apps
|
34
|
+
send_to_pipeline(:clean, :css)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/padrino-pipeline.gemspec
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
4
|
require File.expand_path("../lib/padrino-pipeline/version.rb", __FILE__)
|
5
|
+
require File.expand_path("../lib/padrino-pipeline/tasks.rb", __FILE__)
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "padrino-pipeline"
|
@@ -16,7 +17,7 @@ Gem::Specification.new do |s|
|
|
16
17
|
s.date = Time.now.strftime("%Y-%m-%d")
|
17
18
|
|
18
19
|
s.extra_rdoc_files = Dir["*.rdoc"]
|
19
|
-
s.files = `git ls-files`.split("\n")
|
20
|
+
s.files = `git ls-files`.split("\n") | Dir.glob("{lib}/**/*")
|
20
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
22
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
23
|
s.require_paths = ["lib"]
|
@@ -29,6 +30,5 @@ Gem::Specification.new do |s|
|
|
29
30
|
s.add_dependency("sprockets", "~> 2.10.0")
|
30
31
|
s.add_dependency("uglifier", "~> 2.1.0")
|
31
32
|
|
32
|
-
s.add_dependency("sinatra-assetpack", "~> 0.
|
33
|
-
s.add_dependency("padrino-core", "~> 0.11.0")
|
33
|
+
s.add_dependency("sinatra-assetpack", "~> 0.3.0")
|
34
34
|
end
|
@@ -29,4 +29,15 @@ class AssetsAppAssetPackCustom < BaseApp
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
class CustomPackagesAppDev < BaseApp
|
33
|
+
configure_assets do |config|
|
34
|
+
config.pipeline = Padrino::Pipeline::AssetPack
|
35
|
+
|
36
|
+
config.packages << [:js, :application, '/assets/javascripts/application.js', ['/assets/javascripts/*']]
|
37
|
+
config.packages << [:css, :application, '/assets/stylesheets/application.css', ['/assets/stylesheets/*']]
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
32
43
|
Padrino.load!
|
@@ -1,17 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
2
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..','lib'))
|
4
3
|
require 'rack/test'
|
5
|
-
require 'webrat'
|
6
4
|
require 'padrino-helpers'
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/mini_shoulda')
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/sprockets_app/sprockets_app')
|
7
7
|
|
8
8
|
class MiniTest::Spec
|
9
9
|
include Rack::Test::Methods
|
10
|
-
|
11
|
-
include Webrat::Matchers
|
12
|
-
|
13
|
-
Webrat.configure { |config| config.mode = :rack }
|
14
|
-
|
10
|
+
|
15
11
|
def mock_app(base=Padrino::Application, &block)
|
16
12
|
@app = Sinatra.new(base, &block)
|
17
13
|
@app.set :logging, false
|
@@ -48,13 +44,8 @@ end
|
|
48
44
|
|
49
45
|
Object.class_eval { include(MiniTest::Spec::SharedExamples) }
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
@logger = nil
|
56
|
-
end
|
57
|
-
end
|
47
|
+
# Asserts that a file matches the pattern
|
48
|
+
def assert_match_in_file(pattern, file)
|
49
|
+
assert File.exist?(file), "File '#{file}' does not exist!"
|
50
|
+
assert_match pattern, File.read(file)
|
58
51
|
end
|
59
|
-
|
60
|
-
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../fixtures/asset_pack_app/asset_pack_app')
|
3
|
+
|
4
|
+
describe :asset_pack_packages do
|
5
|
+
context :custom_package do
|
6
|
+
let(:app) { CustomPackagesAppDev }
|
7
|
+
|
8
|
+
it 'can serve a js asset pack' do
|
9
|
+
get '/assets/javascripts/app.js'
|
10
|
+
assert_equal 200, last_response.status
|
11
|
+
assert_match 'mainApp', last_response.body
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'can serve a css asset pack' do
|
15
|
+
get '/assets/stylesheets/app.css'
|
16
|
+
assert_equal 200, last_response.status
|
17
|
+
assert_match 'body', last_response.body
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'can get application.js' do
|
21
|
+
get '/assets/javascripts/application.js'
|
22
|
+
assert_equal 200, last_response.status
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can get application.css' do
|
26
|
+
get '/assets/stylesheets/application.css'
|
27
|
+
assert_equal 200, last_response.status
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/helper')
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe Padrino::Pipeline::Compiler::Sprockets do
|
5
|
+
before do
|
6
|
+
@asset_path = "#{fixture_path('sprockets_app')}/assets"
|
7
|
+
@public_path = "#{fixture_path('sprockets_app')}/public"
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
FileUtils.rm_rf @public_path
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'creates a directory to put compiled assets' do
|
15
|
+
config = OpenStruct.new(compiled_output: @public_path)
|
16
|
+
compiler = Padrino::Pipeline::Compiler::Sprockets.new(config)
|
17
|
+
|
18
|
+
compiler.compile(:js)
|
19
|
+
assert_equal true, File.exists?(@public_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'raises exception on incorrect compile type' do
|
23
|
+
skip
|
24
|
+
config = OpenStruct.new( compiled_output: @public_path)
|
25
|
+
compiler = Padrino::Pipeline::Compiler::Sprockets.new(config)
|
26
|
+
|
27
|
+
assert_throws(RuntimeError) { compiler.compile(:somehting) }
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'creates the correct directory for javascripts' do
|
31
|
+
config_hash = { compiled_output: @public_path, js_compiled_output: 'javascripts' }
|
32
|
+
config = OpenStruct.new(config_hash)
|
33
|
+
compiler = Padrino::Pipeline::Compiler::Sprockets.new(config).compile(:js)
|
34
|
+
assert_equal true, File.exists?("#{@public_path}/javascripts")
|
35
|
+
|
36
|
+
config_hash = { compiled_output: @public_path, js_compiled_output: 'javascripts-compiled' }
|
37
|
+
config = OpenStruct.new(config_hash)
|
38
|
+
compiler = Padrino::Pipeline::Compiler::Sprockets.new(config).compile(:js)
|
39
|
+
assert_equal true, File.exists?("#{@public_path}/javascripts-compiled")
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'creates the correct directory for stylesheets' do
|
43
|
+
config_hash = { compiled_output: @public_path, css_compiled_output: 'stylesheets' }
|
44
|
+
config = OpenStruct.new(config_hash)
|
45
|
+
compiler = Padrino::Pipeline::Compiler::Sprockets.new(config).compile(:css)
|
46
|
+
assert_equal true, File.exists?("#{@public_path}/stylesheets")
|
47
|
+
|
48
|
+
config_hash = { compiled_output: @public_path, css_compiled_output: 'stylesheets-compiled' }
|
49
|
+
config = OpenStruct.new(config_hash)
|
50
|
+
compiler = Padrino::Pipeline::Compiler::Sprockets.new(config).compile(:js)
|
51
|
+
assert_equal true, File.exists?("#{@public_path}/stylesheets-compiled")
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'cleans '
|
55
|
+
|
56
|
+
describe 'Custom compiler settings' do
|
57
|
+
let(:app) { rack_app }
|
58
|
+
before do
|
59
|
+
asset_path, public_path = @asset_path, @public_path
|
60
|
+
mock_app do
|
61
|
+
register Padrino::Pipeline
|
62
|
+
register Padrino::Helpers
|
63
|
+
|
64
|
+
configure_assets do |assets|
|
65
|
+
assets.pipeline = Padrino::Pipeline::Sprockets
|
66
|
+
assets.js_assets = "#{asset_path}/javascripts"
|
67
|
+
assets.css_assets = "#{asset_path}/stylesheets"
|
68
|
+
assets.compiled_output = "#{public_path}"
|
69
|
+
end
|
70
|
+
|
71
|
+
get('/js') { render :erb, "<%= javascript_include_tag 'application.js' %>" }
|
72
|
+
get('/css') { render :erb, "<%= stylesheet_link_tag 'application.css' %>" }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
after { FileUtils.rm_rf "#{@public_path}/javascripts" }
|
77
|
+
|
78
|
+
context 'asset_tags' do
|
79
|
+
it 'should return javascript with the correct digest' do
|
80
|
+
@app.pipeline.compile :js
|
81
|
+
|
82
|
+
digest = @app.assets['application.js'].digest
|
83
|
+
get '/js'
|
84
|
+
assert_match "/assets/javascripts/application-#{digest}.js", last_response.body
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should return stylesheet with the correct digest' do
|
88
|
+
@app.pipeline.compile :css
|
89
|
+
digest = @app.assets['application.css'].digest
|
90
|
+
get '/css'
|
91
|
+
assert_match "/assets/stylesheets/application-#{digest}.css", last_response.body
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'javascripts' do
|
96
|
+
it 'should compile application.js and application.js.gz' do
|
97
|
+
@app.pipeline.compile :js
|
98
|
+
|
99
|
+
digest = @app.assets['application.js'].digest
|
100
|
+
assert_equal true, File.exists?("#{@public_path}/javascripts/application-#{digest}.js")
|
101
|
+
assert_equal true, File.exists?("#{@public_path}/javascripts/application-#{digest}.js.gz")
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should compile files included in the manifest' do
|
105
|
+
@app.pipeline.compile :js
|
106
|
+
|
107
|
+
digest = @app.assets['application.js'].digest
|
108
|
+
assert_match_in_file 'function in_second_file()', "#{@public_path}/javascripts/application-#{digest}.js"
|
109
|
+
assert_match_in_file 'coffee_method', "#{@public_path}/javascripts/application-#{digest}.js"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'stylesheets' do
|
114
|
+
it 'should compile application.css and application.css.gz' do
|
115
|
+
@app.pipeline.compile :css
|
116
|
+
|
117
|
+
digest = @app.assets['application.css'].digest
|
118
|
+
assert_equal true, File.exists?("#{@public_path}/stylesheets/application-#{digest}.css")
|
119
|
+
assert_equal true, File.exists?("#{@public_path}/stylesheets/application-#{digest}.css.gz")
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should compile files included in the manifest' do
|
123
|
+
@app.pipeline.compile :css
|
124
|
+
|
125
|
+
digest = @app.assets['application.css'].digest
|
126
|
+
assert_match_in_file '.home', "#{@public_path}/stylesheets/application-#{digest}.css"
|
127
|
+
assert_match_in_file '.div', "#{@public_path}/stylesheets/application-#{digest}.css"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../helpers/helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../fixtures/sprockets_app/sprockets_app')
|
3
3
|
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe :sprockets_javascript do
|
6
6
|
let(:app) { AssetsAppSprockets }
|
7
7
|
context 'for //= require' do
|
8
8
|
it 'picks up require statements' do
|
@@ -11,4 +11,4 @@ describe 'Javascripts' do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
end
|
14
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helpers/helper')
|
2
|
+
|
3
|
+
shared_examples_for :pipeline do
|
4
|
+
describe :asset_tags do
|
5
|
+
|
6
|
+
context 'asset tags for #js #css #image' do
|
7
|
+
let(:app) { rack_app }
|
8
|
+
before :each do
|
9
|
+
assets_location = "#{fixture_path('sprockets_app')}/assets/javascripts"
|
10
|
+
public_path = "#{fixture_path('sprockets_app')}/public"
|
11
|
+
pipeline = @pipeline
|
12
|
+
mock_app do
|
13
|
+
register Padrino::Pipeline
|
14
|
+
register Padrino::Helpers
|
15
|
+
configure_assets do |assets|
|
16
|
+
assets.pipeline = pipeline
|
17
|
+
assets.js_assets = [assets_location]
|
18
|
+
end
|
19
|
+
get('/js') { render :erb, "<%= javascript_include_tag 'app.js' %>" }
|
20
|
+
get('/css') { render :erb, "<%= stylesheet_link_tag 'app.css' %>" }
|
21
|
+
get('/image') { render :erb, "<%= image_tag 'image.png' %>" }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can use the default javascript_include_tag to resolve JS asset' do
|
26
|
+
get '/js'
|
27
|
+
assert_match '/assets/javascripts/app.js', last_response.body
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'can use the default stylesheet_link_tag to resolve css asset' do
|
31
|
+
get '/css'
|
32
|
+
assert_match '/assets/stylesheets/app.css', last_response.body
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can use the default image_tag to resolve img asset' do
|
36
|
+
get '/image'
|
37
|
+
assert_match '/assets/images/image.png', last_response.body
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe Padrino::Pipeline::Sprockets do
|
45
|
+
before { @pipeline = Padrino::Pipeline::Sprockets }
|
46
|
+
it_behaves_like :pipeline
|
47
|
+
end
|
48
|
+
|
49
|
+
describe Padrino::Pipeline::AssetPack do
|
50
|
+
before { @pipeline = Padrino::Pipeline::AssetPack}
|
51
|
+
it_behaves_like :pipeline
|
52
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helpers/helper')
|
2
|
+
|
3
|
+
describe :configuration do
|
4
|
+
it 'can find the correct compiler' do
|
5
|
+
class SomeApp < Padrino::Application; end
|
6
|
+
config = Padrino::Pipeline::Configuration.new(SomeApp)
|
7
|
+
|
8
|
+
config.pipeline = Padrino::Pipeline::Sprockets.new(SomeApp, config)
|
9
|
+
assert_equal Padrino::Pipeline::Compiler::Sprockets, config.send(:match_compiler)
|
10
|
+
|
11
|
+
config.pipeline = Padrino::Pipeline::AssetPack.new(SomeApp, config)
|
12
|
+
assert_equal Padrino::Pipeline::Compiler::AssetPack, config.send(:match_compiler)
|
13
|
+
|
14
|
+
# config.pipeline = nil
|
15
|
+
# assert_equal nil, config.send(:match_compiler)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helpers/helper')
|
2
2
|
|
3
|
-
shared_examples_for
|
4
|
-
describe
|
3
|
+
shared_examples_for :pipeline do
|
4
|
+
describe :asset_compression do
|
5
5
|
let(:app) { rack_app }
|
6
6
|
before do
|
7
7
|
assets_location = "#{fixture_path('asset_pack_app')}/assets/"
|
@@ -31,10 +31,10 @@ end
|
|
31
31
|
|
32
32
|
describe Padrino::Pipeline::Sprockets do
|
33
33
|
before { @pipeline = Padrino::Pipeline::Sprockets }
|
34
|
-
it_behaves_like
|
34
|
+
it_behaves_like :pipeline
|
35
35
|
end
|
36
36
|
|
37
37
|
describe Padrino::Pipeline::AssetPack do
|
38
38
|
before { @pipeline = Padrino::Pipeline::AssetPack}
|
39
|
-
it_behaves_like
|
39
|
+
it_behaves_like :pipeline
|
40
40
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helpers/helper')
|
2
2
|
|
3
|
-
shared_examples_for
|
3
|
+
shared_examples_for :pipeline do
|
4
4
|
describe 'default options' do
|
5
5
|
let(:app) { rack_app }
|
6
6
|
before do
|
@@ -93,12 +93,12 @@ end
|
|
93
93
|
|
94
94
|
describe Padrino::Pipeline::Sprockets do
|
95
95
|
before { @pipeline = Padrino::Pipeline::Sprockets }
|
96
|
-
it_behaves_like
|
96
|
+
it_behaves_like :pipeline
|
97
97
|
end
|
98
98
|
|
99
99
|
describe Padrino::Pipeline::AssetPack do
|
100
100
|
before { @pipeline = Padrino::Pipeline::AssetPack}
|
101
|
-
it_behaves_like
|
101
|
+
it_behaves_like :pipeline
|
102
102
|
end
|
103
103
|
|
104
104
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helpers/helper')
|
2
2
|
|
3
|
-
shared_examples_for
|
3
|
+
shared_examples_for :pipeline do
|
4
4
|
describe 'default options' do
|
5
5
|
let(:app) { rack_app }
|
6
6
|
before do
|
@@ -102,12 +102,12 @@ end
|
|
102
102
|
|
103
103
|
describe Padrino::Pipeline::Sprockets do
|
104
104
|
before { @pipeline = Padrino::Pipeline::Sprockets }
|
105
|
-
it_behaves_like
|
105
|
+
it_behaves_like :pipeline
|
106
106
|
end
|
107
107
|
|
108
108
|
describe Padrino::Pipeline::AssetPack do
|
109
109
|
before { @pipeline = Padrino::Pipeline::AssetPack}
|
110
|
-
it_behaves_like
|
110
|
+
it_behaves_like :pipeline
|
111
111
|
end
|
112
112
|
|
113
113
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helpers/helper')
|
2
2
|
|
3
|
-
shared_examples_for
|
3
|
+
shared_examples_for :pipeline do
|
4
4
|
describe 'default options' do
|
5
5
|
let(:app) { rack_app }
|
6
6
|
before do
|
@@ -100,12 +100,12 @@ end
|
|
100
100
|
|
101
101
|
describe Padrino::Pipeline::Sprockets do
|
102
102
|
before { @pipeline = Padrino::Pipeline::Sprockets }
|
103
|
-
it_behaves_like
|
103
|
+
it_behaves_like :pipeline
|
104
104
|
end
|
105
105
|
|
106
106
|
describe Padrino::Pipeline::AssetPack do
|
107
107
|
before { @pipeline = Padrino::Pipeline::AssetPack}
|
108
|
-
it_behaves_like
|
108
|
+
it_behaves_like :pipeline
|
109
109
|
end
|
110
110
|
|
111
111
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helpers/helper')
|
2
2
|
|
3
|
-
shared_examples_for
|
3
|
+
shared_examples_for :pipeline do
|
4
4
|
describe 'non-default options' do
|
5
5
|
let(:app) { rack_app }
|
6
6
|
before do
|
@@ -38,10 +38,10 @@ end
|
|
38
38
|
|
39
39
|
describe Padrino::Pipeline::Sprockets do
|
40
40
|
before { @pipeline = Padrino::Pipeline::Sprockets }
|
41
|
-
it_behaves_like
|
41
|
+
it_behaves_like :pipeline
|
42
42
|
end
|
43
43
|
|
44
44
|
describe Padrino::Pipeline::AssetPack do
|
45
45
|
before { @pipeline = Padrino::Pipeline::AssetPack}
|
46
|
-
it_behaves_like
|
46
|
+
it_behaves_like :pipeline
|
47
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sumeet Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: padrino-core
|
@@ -100,28 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.3.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: padrino-core
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.11.0
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ~>
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.11.0
|
110
|
+
version: 0.3.0
|
125
111
|
description: The Padrino asset management system allowing frictionless serving of
|
126
112
|
assets
|
127
113
|
email: ortuna@gmail.com
|
@@ -136,20 +122,16 @@ files:
|
|
136
122
|
- README.md
|
137
123
|
- Rakefile
|
138
124
|
- lib/padrino-pipeline.rb
|
125
|
+
- lib/padrino-pipeline/compilers/asset_pack.rb
|
126
|
+
- lib/padrino-pipeline/compilers/sprockets.rb
|
139
127
|
- lib/padrino-pipeline/configuration.rb
|
140
128
|
- lib/padrino-pipeline/ext/padrino-helpers/asset_tag_helper.rb
|
141
129
|
- lib/padrino-pipeline/pipelines/asset_pack.rb
|
142
130
|
- lib/padrino-pipeline/pipelines/sprockets.rb
|
131
|
+
- lib/padrino-pipeline/tasks.rb
|
132
|
+
- lib/padrino-pipeline/tasks/pipeline_tasks.rb
|
143
133
|
- lib/padrino-pipeline/version.rb
|
144
134
|
- padrino-pipeline.gemspec
|
145
|
-
- test/api/test_compression.rb
|
146
|
-
- test/api/test_css.rb
|
147
|
-
- test/api/test_images.rb
|
148
|
-
- test/api/test_js.rb
|
149
|
-
- test/api/test_other.rb
|
150
|
-
- test/asset_pack/test_packages.rb
|
151
|
-
- test/extra/helper.rb
|
152
|
-
- test/extra/mini_shoulda.rb
|
153
135
|
- test/fixtures/asset_pack_app/asset_pack_app.rb
|
154
136
|
- test/fixtures/asset_pack_app/assets/css/meow.css
|
155
137
|
- test/fixtures/asset_pack_app/assets/javascripts/app.js
|
@@ -160,6 +142,7 @@ files:
|
|
160
142
|
- test/fixtures/asset_pack_app/assets/stylesheets/default.scss
|
161
143
|
- test/fixtures/sprockets_app/assets/images/glass.png
|
162
144
|
- test/fixtures/sprockets_app/assets/javascripts/app.js
|
145
|
+
- test/fixtures/sprockets_app/assets/javascripts/application.js
|
163
146
|
- test/fixtures/sprockets_app/assets/javascripts/coffee.js.coffee
|
164
147
|
- test/fixtures/sprockets_app/assets/javascripts/second_js_file.js
|
165
148
|
- test/fixtures/sprockets_app/assets/javascripts/unrequired.js
|
@@ -168,8 +151,18 @@ files:
|
|
168
151
|
- test/fixtures/sprockets_app/assets/stylesheets/sass.scss
|
169
152
|
- test/fixtures/sprockets_app/assets/stylesheets/second_file.css
|
170
153
|
- test/fixtures/sprockets_app/sprockets_app.rb
|
171
|
-
- test/
|
172
|
-
- test/
|
154
|
+
- test/helpers/helper.rb
|
155
|
+
- test/helpers/mini_shoulda.rb
|
156
|
+
- test/pipelines/asset_pack/test_packages.rb
|
157
|
+
- test/pipelines/sprockets/test_compiler.rb
|
158
|
+
- test/pipelines/sprockets/test_js.rb
|
159
|
+
- test/test_asset_tag.rb
|
160
|
+
- test/test_compiler.rb
|
161
|
+
- test/test_compression.rb
|
162
|
+
- test/test_css.rb
|
163
|
+
- test/test_images.rb
|
164
|
+
- test/test_js.rb
|
165
|
+
- test/test_other.rb
|
173
166
|
homepage: http://www.padrinorb.com
|
174
167
|
licenses: []
|
175
168
|
metadata: {}
|
@@ -190,19 +183,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
183
|
version: 1.3.6
|
191
184
|
requirements: []
|
192
185
|
rubyforge_project: padrino-pipeline
|
193
|
-
rubygems_version: 2.0.
|
186
|
+
rubygems_version: 2.0.3
|
194
187
|
signing_key:
|
195
188
|
specification_version: 4
|
196
189
|
summary: The Padrino asset management system
|
197
190
|
test_files:
|
198
|
-
- test/api/test_compression.rb
|
199
|
-
- test/api/test_css.rb
|
200
|
-
- test/api/test_images.rb
|
201
|
-
- test/api/test_js.rb
|
202
|
-
- test/api/test_other.rb
|
203
|
-
- test/asset_pack/test_packages.rb
|
204
|
-
- test/extra/helper.rb
|
205
|
-
- test/extra/mini_shoulda.rb
|
206
191
|
- test/fixtures/asset_pack_app/asset_pack_app.rb
|
207
192
|
- test/fixtures/asset_pack_app/assets/css/meow.css
|
208
193
|
- test/fixtures/asset_pack_app/assets/javascripts/app.js
|
@@ -213,6 +198,7 @@ test_files:
|
|
213
198
|
- test/fixtures/asset_pack_app/assets/stylesheets/default.scss
|
214
199
|
- test/fixtures/sprockets_app/assets/images/glass.png
|
215
200
|
- test/fixtures/sprockets_app/assets/javascripts/app.js
|
201
|
+
- test/fixtures/sprockets_app/assets/javascripts/application.js
|
216
202
|
- test/fixtures/sprockets_app/assets/javascripts/coffee.js.coffee
|
217
203
|
- test/fixtures/sprockets_app/assets/javascripts/second_js_file.js
|
218
204
|
- test/fixtures/sprockets_app/assets/javascripts/unrequired.js
|
@@ -221,6 +207,15 @@ test_files:
|
|
221
207
|
- test/fixtures/sprockets_app/assets/stylesheets/sass.scss
|
222
208
|
- test/fixtures/sprockets_app/assets/stylesheets/second_file.css
|
223
209
|
- test/fixtures/sprockets_app/sprockets_app.rb
|
224
|
-
- test/
|
225
|
-
- test/
|
226
|
-
|
210
|
+
- test/helpers/helper.rb
|
211
|
+
- test/helpers/mini_shoulda.rb
|
212
|
+
- test/pipelines/asset_pack/test_packages.rb
|
213
|
+
- test/pipelines/sprockets/test_compiler.rb
|
214
|
+
- test/pipelines/sprockets/test_js.rb
|
215
|
+
- test/test_asset_tag.rb
|
216
|
+
- test/test_compiler.rb
|
217
|
+
- test/test_compression.rb
|
218
|
+
- test/test_css.rb
|
219
|
+
- test/test_images.rb
|
220
|
+
- test/test_js.rb
|
221
|
+
- test/test_other.rb
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/asset_pack_app/asset_pack_app')
|
3
|
-
|
4
|
-
describe 'AssetPack Packages' do
|
5
|
-
let(:app) { rack_app }
|
6
|
-
|
7
|
-
context 'for javascripts' do
|
8
|
-
it 'can serve an asset pack' do
|
9
|
-
mock_app do
|
10
|
-
register Padrino::Pipeline
|
11
|
-
configure_assets do |config|
|
12
|
-
config.pipeline = Padrino::Pipeline::AssetPack
|
13
|
-
config.packages << [:js, :application, '/assets/javascripts/application.js', ['/assets/javascripts/*.js']]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
get '/assets/javascripts/application.js'
|
17
|
-
assert_equal 200, last_response.status
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'can serve an asset pack from a non-standard location' do
|
21
|
-
mock_app do
|
22
|
-
register Padrino::Pipeline
|
23
|
-
configure_assets do |config|
|
24
|
-
config.pipeline = Padrino::Pipeline::AssetPack
|
25
|
-
config.js_prefix = '/meow/javascripts'
|
26
|
-
config.packages << [:js, :application, '/meow/javascripts/application.js', ['/assets/javascripts/*.js']]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
get '/meow/javascripts/application.js'
|
30
|
-
assert_equal 200, last_response.status
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'for stylesheets' do
|
35
|
-
it 'can serve an asset pack' do
|
36
|
-
mock_app do
|
37
|
-
register Padrino::Pipeline
|
38
|
-
configure_assets do |config|
|
39
|
-
config.pipeline = Padrino::Pipeline::AssetPack
|
40
|
-
config.packages << [:css, :application, '/assets/stylesheets/application.css', ['/assets/stylesheets/*.css']]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
get '/assets/stylesheets/application.css'
|
44
|
-
assert_equal 200, last_response.status
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'can serve an asset pack from a non-standard location' do
|
48
|
-
mock_app do
|
49
|
-
register Padrino::Pipeline
|
50
|
-
configure_assets do |config|
|
51
|
-
config.pipeline = Padrino::Pipeline::AssetPack
|
52
|
-
config.js_prefix = '/meow/stylesheets'
|
53
|
-
config.packages << [:css, :application, '/meow/stylesheets/application.css', ['/assets/stylesheets/*.css']]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
get '/meow/stylesheets/application.css'
|
57
|
-
assert_equal 200, last_response.status
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
|
2
|
-
|
3
|
-
describe 'Asset tags' do
|
4
|
-
|
5
|
-
context 'javascript_include_tag' do
|
6
|
-
let(:app) { rack_app }
|
7
|
-
|
8
|
-
it 'can use the default javascript_include_tag to resolve JS asset' do
|
9
|
-
skip
|
10
|
-
assets_location = "#{fixture_path('sprockets_app')}/assets/javascripts"
|
11
|
-
mock_app do
|
12
|
-
register Padrino::Pipeline
|
13
|
-
register Padrino::Helpers
|
14
|
-
configure_assets do |assets|
|
15
|
-
assets.pipeline = Padrino::Pipeline::Sprockets
|
16
|
-
assets.js_assets = [assets_location]
|
17
|
-
end
|
18
|
-
get('/') { render :erb, "<%= javascript_include_tag 'app.js' %>" }
|
19
|
-
end
|
20
|
-
|
21
|
-
get '/'
|
22
|
-
assert_equal '/assets/javascripts/app.js', last_response.body
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|