pannier 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b855f46010a8117eb089ac26b4cac30c4a3dd83
4
- data.tar.gz: 48e2e01afed9c21d6bed3d96ff006d600a19d4ee
3
+ metadata.gz: 3c14f6e2f30ce04e6e8b1044eb60ca68d82114c5
4
+ data.tar.gz: 112e6bc89794c96557af151afd49cd82708b94e4
5
5
  SHA512:
6
- metadata.gz: 0daa1753e2f4792161df96e1a1e61f04c07502992ddceb70e28495d492986581aaca39e6fb368e2afb80035797016e962d9e40324dcd8c518686896807cc66ac
7
- data.tar.gz: cf8cbb05ea8b5998802a3e9b60e8cc0dd9cb1a4bb907aab40ff094f6a6f7b69badfddc2e6a2b37624fc26aac82f7f8382bf1a748e6adb02d4ab41c114294ef31
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
- 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
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 a fine idea, but as soon as you need to ditch one or more of those
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`. The
43
- example below will simply take all of your stylesheets from one directory
44
- and concatenate them in another.
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 concatenated into
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, _| [foo(content), _] }
82
- modify { |content, _| [bar(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
@@ -59,8 +59,8 @@ module Pannier
59
59
 
60
60
  dsl do
61
61
 
62
- def _
63
- @locals ||= OpenStruct.new(:env => env.name)
62
+ def env
63
+ __getobj__.env
64
64
  end
65
65
 
66
66
  def input(path)
@@ -1,15 +1,9 @@
1
1
  module Pannier
2
- class Environment
2
+ class Environment < Struct.new(:name)
3
3
 
4
- attr_reader :name
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
- @name =~ expression
6
+ name =~ expression
13
7
  end
14
8
 
15
9
  end
@@ -109,8 +109,12 @@ module Pannier
109
109
 
110
110
  dsl do
111
111
 
112
- def _
113
- @locals ||= OpenStruct.new(:env => app.env.name)
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
@@ -1,3 +1,3 @@
1
1
  module Pannier
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
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.5.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-19 00:00:00.000000000 Z
11
+ date: 2014-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack