pannier 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -13
- data/lib/pannier/app.rb +2 -2
- data/lib/pannier/environment.rb +3 -9
- data/lib/pannier/package.rb +6 -6
- data/lib/pannier/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c14f6e2f30ce04e6e8b1044eb60ca68d82114c5
|
4
|
+
data.tar.gz: 112e6bc89794c96557af151afd49cd82708b94e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c251319c0c18dfa5cc310882562361aa9127dca910cbfee5844ed828dc218d9dbb3d1c82cc5c2db0277607a3b9dbe24512d9afa0939c5a799891e650e850f71c
|
7
|
+
data.tar.gz: 6f7296726a2597f01b920e743ba4b1f017243bd21ed62762fc805d901ac9e38d9ad2691655540094980594cb258aede68de80825eb3f563433ed1e92f9451d2d
|
data/README.md
CHANGED
@@ -6,10 +6,8 @@ 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
|
-
|
10
|
-
|
11
|
-
application that handles asset processing (modification of file contents
|
12
|
-
and file names, file concatenation). No decisions about
|
9
|
+
A small configuration DSL describes asset processing: modification of file
|
10
|
+
contents and file names, file concatenation. No decisions about
|
13
11
|
uglifiers/optimisers/preprocessors have been made; that part is up to you.
|
14
12
|
|
15
13
|
The interface for plugging any asset processing library into Pannier is very
|
@@ -27,7 +25,7 @@ easy too.
|
|
27
25
|
The Rails asset pipeline essentially consists of [Sprockets][sprockets]
|
28
26
|
and a bunch of inscrutable Rails coupling. You generate a new Rails app
|
29
27
|
and everything is setup for you. We call this "convention over configuration".
|
30
|
-
It's
|
28
|
+
It's fine, but as soon as you need to ditch one or more of those
|
31
29
|
conventions you'll be frustrated.
|
32
30
|
|
33
31
|
I have found the
|
@@ -39,9 +37,11 @@ configuration.
|
|
39
37
|
|
40
38
|
## Getting started
|
41
39
|
|
42
|
-
Create a config file in the root of your project named `.assets.rb`.
|
43
|
-
|
44
|
-
|
40
|
+
Create a config file in the root of your project named `.assets.rb`.
|
41
|
+
|
42
|
+
The example below would take all of your stylesheets from one directory,
|
43
|
+
modify them and then concatenate them into a single file in another
|
44
|
+
directory.
|
45
45
|
|
46
46
|
|
47
47
|
```ruby
|
@@ -64,22 +64,28 @@ end
|
|
64
64
|
$ pannier process
|
65
65
|
```
|
66
66
|
|
67
|
-
Your stylesheets have now been quuxified and
|
68
|
-
`public/main.min.css`.
|
67
|
+
Your stylesheets from `assets/stylesheets` have now all been quuxified and
|
68
|
+
concatenated into `public/main.min.css`.
|
69
|
+
|
70
|
+
## Modifying assets
|
69
71
|
|
70
72
|
Modifiers are just Ruby *callables*; blocks, procs, lambdas, objects that
|
71
73
|
respond to `call`. They are executed in order of specification. Here's a
|
72
|
-
typical use case
|
74
|
+
typical use case: assets are run through a couple of modifiers, then
|
75
|
+
concatenated into one file, then finally that single file has a hash of
|
76
|
+
its contents appended to its name.
|
73
77
|
|
74
78
|
```ruby
|
79
|
+
require 'foo'
|
80
|
+
require 'bar'
|
75
81
|
require 'digest'
|
76
82
|
# ...
|
77
83
|
|
78
84
|
package :styles do
|
79
85
|
# ...
|
80
86
|
|
81
|
-
modify { |content,
|
82
|
-
modify { |content,
|
87
|
+
modify { |content, basename| [foo(content), basename] }
|
88
|
+
modify { |content, basename| [bar(content), basename] }
|
83
89
|
concat 'main'
|
84
90
|
modify do |content, basename|
|
85
91
|
[content, "#{basename}-#{Digest::MD5.hexdigest(content)}.min.css"]
|
@@ -95,12 +101,18 @@ Yes, please contribute! Fork this repo, then send a pull request with a
|
|
95
101
|
note that clearly explains your changes. If you're unsure or you're
|
96
102
|
asking for a big change, just open an issue and we can chat about it first.
|
97
103
|
|
104
|
+
## Credits
|
105
|
+
|
106
|
+
Built by [Joe Corcoran][joe]. Thanks to the authors of [rake-pipeline][rp],
|
107
|
+
a project which tried to address a similar problem.
|
108
|
+
|
98
109
|
## License
|
99
110
|
|
100
111
|
[MIT][license].
|
101
112
|
|
102
113
|
[sprockets]: https://github.com/sstephenson/sprockets
|
103
114
|
[pola]: http://en.wikipedia.org/wiki/Principle_of_least_astonishment
|
115
|
+
[joe]: https://corcoran.io
|
104
116
|
[rp]: https://github.com/livingsocial/rake-pipeline
|
105
117
|
[relish]: https://www.relishapp.com/joecorcoran/pannier/docs
|
106
118
|
[todo]: https://github.com/joecorcoran/pannier/wiki/Todo
|
data/lib/pannier/app.rb
CHANGED
data/lib/pannier/environment.rb
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
module Pannier
|
2
|
-
class Environment
|
2
|
+
class Environment < Struct.new(:name)
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(name)
|
7
|
-
@name = name
|
8
|
-
end
|
9
|
-
|
10
|
-
def is?(expression)
|
4
|
+
def matches?(expression)
|
11
5
|
expression = Regexp.new(expression)
|
12
|
-
|
6
|
+
name =~ expression
|
13
7
|
end
|
14
8
|
|
15
9
|
end
|
data/lib/pannier/package.rb
CHANGED
@@ -109,8 +109,12 @@ module Pannier
|
|
109
109
|
|
110
110
|
dsl do
|
111
111
|
|
112
|
-
def
|
113
|
-
|
112
|
+
def env
|
113
|
+
self.app.env
|
114
|
+
end
|
115
|
+
|
116
|
+
def env?(expression, &block)
|
117
|
+
self.instance_eval(&block) if env.matches?(expression)
|
114
118
|
end
|
115
119
|
|
116
120
|
def input(path)
|
@@ -146,10 +150,6 @@ module Pannier
|
|
146
150
|
add_concatenator(*args)
|
147
151
|
end
|
148
152
|
|
149
|
-
def env(expression, &block)
|
150
|
-
self.instance_eval(&block) if self.app.env.is?(expression)
|
151
|
-
end
|
152
|
-
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
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.6.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-05-
|
11
|
+
date: 2014-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|