pannier 0.1.0 → 0.2.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 +4 -4
- data/README.md +44 -18
- data/lib/pannier.rb +0 -28
- data/lib/pannier/app.rb +1 -9
- data/lib/pannier/mounted.rb +30 -0
- data/lib/pannier/mounted/app.rb +14 -0
- data/lib/pannier/mounted/asset.rb +4 -3
- data/lib/pannier/package.rb +0 -1
- data/lib/pannier/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8446bb452a6e9dac934bda3bea546d78a4522be0
|
4
|
+
data.tar.gz: 33ffee121ef5394d3f21b5b83cda927ff71f9b56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07a9fbfb6d7146d26ac14993f78813f978e768af192e0fd73b5fc938459407c4296803aa837af7b301cd817a3e43abd80bc38b86e49976bd5a53104b5f8cdd0c
|
7
|
+
data.tar.gz: a3213222ce4ca0dfedf894e7b96e158355187a32d1cb1893d432a57665aade8b4988d7556a344ddea6c20aa1759d8e32532733ced8eb603618ec3139811c4aa8
|
data/README.md
CHANGED
@@ -6,12 +6,28 @@ Pannier is a general-purpose Ruby asset processing tool. Its goal is to
|
|
6
6
|
work the same way in any Rack environment. No Rails glue, no mandatory
|
7
7
|
JavaScript or CSS libraries, preprocessors or gems.
|
8
8
|
|
9
|
+
The configuration DSL was inspired by — but is ultimately quite
|
10
|
+
different from — [rake-pipeline][rp]. The config describes a Rack
|
11
|
+
application that handles asset processing (modification of file contents
|
12
|
+
and file names, file concatenation). No decisions about
|
13
|
+
uglifiers/optimisers/preprocessors have been made; that part is up to you.
|
14
|
+
|
15
|
+
The interface for plugging any asset processing library into Pannier is very
|
16
|
+
basic and inspired by Rack. The lack of a plugin ecosystem that binds you to any
|
17
|
+
particular preprocessor is considered a feature.
|
18
|
+
|
19
|
+
Pannier can also act as a Rack application that
|
20
|
+
can be mounted (mapped to a path) within another Rack application, so
|
21
|
+
it can serve your assets too. In that case, there are helper methods for
|
22
|
+
including your assets in the view layer. Adding your own view helpers is
|
23
|
+
easy too.
|
24
|
+
|
9
25
|
## Why?
|
10
26
|
|
11
27
|
The Rails asset pipeline essentially consists of [Sprockets][sprockets]
|
12
28
|
and a bunch of inscrutable Rails coupling. You generate a new Rails app
|
13
29
|
and everything is setup for you. We call this "convention over configuration".
|
14
|
-
It's a fine idea, but as soon as you need to ditch one
|
30
|
+
It's a fine idea, but as soon as you need to ditch one or more of those
|
15
31
|
conventions you'll be frustrated.
|
16
32
|
|
17
33
|
I have found the
|
@@ -21,23 +37,6 @@ true where asset processing in Rails is concerned. I want explicit control
|
|
21
37
|
over my assets and I don't mind spending a small amount of time on
|
22
38
|
configuration.
|
23
39
|
|
24
|
-
## What does it do?
|
25
|
-
|
26
|
-
The configuration DSL was inspired by — but is ultimately quite
|
27
|
-
different from — [rake-pipeline][rp]. The config describes a Rack
|
28
|
-
application that handles asset processing (modification of file contents
|
29
|
-
and file names, file concatenation). No decisions about
|
30
|
-
uglifiers/optimisers/preprocessors have been made; that part is up to you.
|
31
|
-
The interface to plug any of these libraries into Pannier is very simple
|
32
|
-
and inspired by Rack. The lack of a plugin ecosystem that binds you to any
|
33
|
-
particular preprocessor is considered a feature.
|
34
|
-
|
35
|
-
In some cases the above is all you'll need, but the application
|
36
|
-
can also be mounted (mapped to a path) within another Rack application, so
|
37
|
-
it can serve your assets too. In that case, there are helper methods for
|
38
|
-
including your assets in the view layer. Adding your own view helpers is
|
39
|
-
easy too.
|
40
|
-
|
41
40
|
## Getting started
|
42
41
|
|
43
42
|
Create a config file in the root of your project named `.assets.rb`. The
|
@@ -61,6 +60,33 @@ package :styles do
|
|
61
60
|
end
|
62
61
|
```
|
63
62
|
|
63
|
+
```bash
|
64
|
+
$ pannier process
|
65
|
+
```
|
66
|
+
|
67
|
+
Your stylesheets have now been quuxified and concatenated into
|
68
|
+
`public/main.min.css`.
|
69
|
+
|
70
|
+
Modifiers are just Ruby *callables*; blocks, procs, lambdas, objects that
|
71
|
+
respond to `call`. They are executed in order of specification. Here's a
|
72
|
+
typical use case.
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
require 'digest'
|
76
|
+
# ...
|
77
|
+
|
78
|
+
package :styles do
|
79
|
+
# ...
|
80
|
+
|
81
|
+
modify { |content, _| [foo(content), _] }
|
82
|
+
modify { |content, _| [bar(content), _] }
|
83
|
+
concat 'main'
|
84
|
+
modify do |content, basename|
|
85
|
+
[content, "#{basename}-#{Digest::MD5.hexdigest(content)}.min.css"]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
64
90
|
To understand further, you can [browse the current features on relish][relish].
|
65
91
|
|
66
92
|
## Contributing
|
data/lib/pannier.rb
CHANGED
@@ -13,32 +13,4 @@ module Pannier
|
|
13
13
|
block = eval("proc { #{config} }", TOPLEVEL_BINDING, path, 0)
|
14
14
|
App.build(env_name, &block)
|
15
15
|
end
|
16
|
-
|
17
|
-
def self.prime(path, env_name = 'development')
|
18
|
-
app = load(path, env_name)
|
19
|
-
if manifest_exists?(app, env_name)
|
20
|
-
manifest = load_manifest(app, env_name)
|
21
|
-
app.prime!(manifest)
|
22
|
-
end
|
23
|
-
app
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.rackup!(ru, path = './.assets.rb')
|
27
|
-
app = prime(path, ENV['RACK_ENV'])
|
28
|
-
ru.map(app.root) { run(app) }
|
29
|
-
app
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def self.load_manifest(app, env_name)
|
35
|
-
path = File.join(app.input_path, ".assets.#{env_name}.json")
|
36
|
-
json = File.read(path)
|
37
|
-
MultiJson.load(json, :symbolize_keys => true)
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.manifest_exists?(app, env_name)
|
41
|
-
path = File.join(app.input_path, ".assets.#{env_name}.json")
|
42
|
-
File.exists?(path)
|
43
|
-
end
|
44
16
|
end
|
data/lib/pannier/app.rb
CHANGED
@@ -9,7 +9,7 @@ module Pannier
|
|
9
9
|
class App
|
10
10
|
extend DSL
|
11
11
|
|
12
|
-
attr_reader :env, :
|
12
|
+
attr_reader :env, :input_path, :output_path,
|
13
13
|
:behaviors, :packages
|
14
14
|
|
15
15
|
def initialize(env_name = 'development')
|
@@ -17,10 +17,6 @@ module Pannier
|
|
17
17
|
@behaviors, @packages, @root = {}, [], '/'
|
18
18
|
end
|
19
19
|
|
20
|
-
def set_root(path)
|
21
|
-
@root = path
|
22
|
-
end
|
23
|
-
|
24
20
|
def set_input(path)
|
25
21
|
@input_path = File.expand_path(path)
|
26
22
|
end
|
@@ -57,10 +53,6 @@ module Pannier
|
|
57
53
|
@locals ||= OpenStruct.new(:env => env.name)
|
58
54
|
end
|
59
55
|
|
60
|
-
def root(path)
|
61
|
-
set_root(path)
|
62
|
-
end
|
63
|
-
|
64
56
|
def input(path)
|
65
57
|
set_input(path)
|
66
58
|
end
|
data/lib/pannier/mounted.rb
CHANGED
@@ -5,3 +5,33 @@ require 'pannier/mounted/app'
|
|
5
5
|
require 'pannier/mounted/asset'
|
6
6
|
require 'pannier/mounted/package'
|
7
7
|
require 'pannier/mounted/tags'
|
8
|
+
|
9
|
+
module Pannier
|
10
|
+
def self.prime(path, env_name = 'development')
|
11
|
+
app = load(path, env_name)
|
12
|
+
if manifest_exists?(app, env_name)
|
13
|
+
manifest = load_manifest(app, env_name)
|
14
|
+
app.prime!(manifest)
|
15
|
+
end
|
16
|
+
app
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.rackup(ru, path = './.assets.rb')
|
20
|
+
app = prime(path, ENV['RACK_ENV'])
|
21
|
+
ru.map(app.mount_path) { run(app) }
|
22
|
+
app
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.load_manifest(app, env_name)
|
28
|
+
path = File.join(app.input_path, ".assets.#{env_name}.json")
|
29
|
+
json = File.read(path)
|
30
|
+
MultiJson.load(json, :symbolize_keys => true)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.manifest_exists?(app, env_name)
|
34
|
+
path = File.join(app.input_path, ".assets.#{env_name}.json")
|
35
|
+
File.exists?(path)
|
36
|
+
end
|
37
|
+
end
|
data/lib/pannier/mounted/app.rb
CHANGED
@@ -3,6 +3,12 @@ require 'pannier/app'
|
|
3
3
|
module Pannier
|
4
4
|
class App
|
5
5
|
|
6
|
+
attr_reader :mount_path
|
7
|
+
|
8
|
+
def set_mount_path(path)
|
9
|
+
@mount_path = path
|
10
|
+
end
|
11
|
+
|
6
12
|
def prime!(manifest)
|
7
13
|
manifest.each do |name, paths|
|
8
14
|
if (pkg = self[name])
|
@@ -28,5 +34,13 @@ module Pannier
|
|
28
34
|
handler.call(env)
|
29
35
|
end
|
30
36
|
|
37
|
+
dsl do
|
38
|
+
|
39
|
+
def mount(path)
|
40
|
+
set_mount_path(path)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
31
45
|
end
|
32
46
|
end
|
@@ -4,9 +4,10 @@ module Pannier
|
|
4
4
|
class Asset
|
5
5
|
|
6
6
|
def serve_from(app)
|
7
|
-
asset_path
|
8
|
-
|
9
|
-
|
7
|
+
asset_path = Pathname.new(path)
|
8
|
+
app_output_path = Pathname.new(app.output_path)
|
9
|
+
relative_path = asset_path.relative_path_from(app_output_path)
|
10
|
+
File.join(*['/', app.mount_path, relative_path.to_s].compact)
|
10
11
|
end
|
11
12
|
|
12
13
|
end
|
data/lib/pannier/package.rb
CHANGED
data/lib/pannier/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pannier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Corcoran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -192,9 +192,8 @@ dependencies:
|
|
192
192
|
version: 0.6.2
|
193
193
|
description: |
|
194
194
|
Pannier is a Ruby tool for the processing of web assets like CSS
|
195
|
-
and JavaScript files
|
196
|
-
|
197
|
-
application.
|
195
|
+
and JavaScript files. It can be used as a standalone asset organizer or mounted
|
196
|
+
within any Rack-compatible application.
|
198
197
|
email:
|
199
198
|
- joecorcoran@gmail.com
|
200
199
|
executables:
|
@@ -243,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
242
|
version: '0'
|
244
243
|
requirements: []
|
245
244
|
rubyforge_project:
|
246
|
-
rubygems_version: 2.2.
|
245
|
+
rubygems_version: 2.2.0
|
247
246
|
signing_key:
|
248
247
|
specification_version: 4
|
249
248
|
summary: A simple, portable asset processing tool for Ruby web apps
|