jekyll-assets 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 0.5.2 (2013-05-25)
2
+
3
+ * Use Sprocket assets cache for compilation speed improvement. See #32.
4
+ (Thanks @beanieboi).
5
+ * Minor fix in gemspec.
6
+
7
+
1
8
  ### 0.5.1 (2013-05-13)
2
9
 
3
10
  * Re-use underlying asset file to avoid "recompilation" of fresh assets.
data/README.md CHANGED
@@ -170,11 +170,6 @@ body
170
170
  background-color: <%= (12 == Date.today.month) ? "red" : "white" %>
171
171
  ```
172
172
 
173
- *Note* that all assets are pre-processed with Liquid. So if you just need to
174
- output asset URL within your javascript/coffeescript or pure css, you don't
175
- need to use ERB, just use `asset_path` Liquid tag same as you do it in your
176
- layouts/pages. See "Liquid Assets Pre-processing" for more details.
177
-
178
173
  Want more? Sure, here you are. You can use JavaScript templating with EJS or ECO
179
174
  for example. Create a file `_assets/javascripts/hello.jst.ejs` with following
180
175
  contents:
@@ -215,16 +210,17 @@ assets:
215
210
  [amazon-s3]: http://aws.amazon.com/s3
216
211
 
217
212
 
218
- ## Liquid Assets Pre-processing
213
+ ### Compilation Cache
219
214
 
220
- All javascript and stylesheet assets are preprocessed with Liquid automagically.
221
- That means that you can use all liquid tags available to you in Jekyll, but most
222
- like;y you would want it for `asset_path` tag only:
215
+ To improve build time, we have Sprockets caching enabled. You might want to
216
+ clean this cache time after time with `assets:cleanup` jekyll command:
223
217
 
224
- ``` coffeescript
225
- # file: _assets/javascripts/app.js.coffee
226
- yepnope.load "{% asset_path app.css %}"
227
- ```
218
+ $ jekyll assets:cleanup
219
+
220
+ You can turn caching off with `cache_assests` configuration option.
221
+
222
+ At the moment we use *FileStore* cache which keeps compiled data on file system.
223
+ If you need MemCache or Redis based store, please raise a ticket.
228
224
 
229
225
 
230
226
  ## Custom Vendors
@@ -454,6 +450,12 @@ assets:
454
450
  #
455
451
  cachebust: hard
456
452
  #
453
+ # Whenever or not cache compiled assets (enabled by default).
454
+ # Caching significantly improves compilation performance, but you might need
455
+ # clean it up time after time with `jekyll assets:cleanup` command.
456
+ #
457
+ cache_assets: true
458
+ #
457
459
  # Specifies list of MIME types that needs to have gzipped versions.
458
460
  # You can set it to `false` to disable gzipping. Only javascripts and
459
461
  # stylesheets are gzipped by default.
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.name = "jekyll-assets"
7
7
  gem.version = Jekyll::AssetsPlugin::VERSION
8
8
  gem.homepage = "http://ixti.github.com/jekyll-assets"
9
- gem.authors = "Aleksey V Zapparov"
9
+ gem.authors = ["Aleksey V Zapparov"]
10
10
  gem.email = %w{ixti@member.fsf.org}
11
11
  gem.license = "MIT"
12
12
  gem.summary = "jekyll-assets-#{Jekyll::AssetsPlugin::VERSION}"
@@ -2,3 +2,4 @@ require "jekyll/assets_plugin/patches"
2
2
  require "jekyll/assets_plugin/filters"
3
3
  require "jekyll/assets_plugin/tag"
4
4
  require "jekyll/assets_plugin/version"
5
+ require "jekyll/assets_plugin/commands"
@@ -0,0 +1,16 @@
1
+ # 3rd-party
2
+ require "commander"
3
+
4
+
5
+ ::Commander::Runner.instance.command "assets:cleanup" do |c|
6
+ c.syntax = "jekyll assets:cleanup"
7
+ c.description = "Clenup jekyll-assets cache"
8
+
9
+ c.option "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
10
+ "Custom Jekyll configuration file"
11
+
12
+ c.action do |_, options|
13
+ assets = Jekyll::Site.new(Jekyll.configuration(options)).assets
14
+ assets.cache_path.rmtree if assets.cache_path.exist?
15
+ end
16
+ end
@@ -6,11 +6,12 @@ module Jekyll
6
6
  module AssetsPlugin
7
7
  class Configuration
8
8
  DEFAULTS = {
9
- :dirname => "assets",
10
- :sources => %w{_assets/javascripts _assets/stylesheets _assets/images},
11
- :compress => { :css => nil, :js => nil },
12
- :cachebust => :hard,
13
- :gzip => %w{ text/css application/javascript }
9
+ :dirname => "assets",
10
+ :sources => %w{_assets/javascripts _assets/stylesheets _assets/images},
11
+ :compress => { :css => nil, :js => nil },
12
+ :cachebust => :hard,
13
+ :cache_assets => true,
14
+ :gzip => %w{ text/css application/javascript }
14
15
  }.freeze
15
16
 
16
17
 
@@ -45,6 +46,12 @@ module Jekyll
45
46
  none?(@data.cachebust) ? :none : @data.cachebust.to_sym
46
47
  end
47
48
 
49
+
50
+ def cache_assets?
51
+ !!@data.cache_assets
52
+ end
53
+
54
+
48
55
  def gzip
49
56
  return @data.gzip if @data.gzip.is_a? Array
50
57
  @data.gzip ? DEFAULTS[:gzip] : []
@@ -1,3 +1,7 @@
1
+ # stdlib
2
+ require "pathname"
3
+
4
+
1
5
  # 3rd-party
2
6
  require "sprockets"
3
7
 
@@ -27,6 +31,10 @@ module Jekyll
27
31
  self.js_compressor = @site.assets_config.js_compressor
28
32
  self.css_compressor = @site.assets_config.css_compressor
29
33
 
34
+ if @site.assets_config.cache_assets?
35
+ self.cache = Sprockets::Cache::FileStore.new cache_path
36
+ end
37
+
30
38
  # bind jekyll and Sprockets context together
31
39
  context_class.instance_variable_set :@site, @site
32
40
 
@@ -34,6 +42,11 @@ module Jekyll
34
42
  end
35
43
 
36
44
 
45
+ def cache_path
46
+ Pathname.new(@site.source).join ".jekyll-assets-cache"
47
+ end
48
+
49
+
37
50
  def find_asset path, *args
38
51
  super or raise AssetNotFound, path
39
52
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module AssetsPlugin
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
@@ -1 +1,2 @@
1
1
  _site/
2
+ .jekyll-assets-cache
@@ -41,6 +41,11 @@ module Jekyll::AssetsPlugin
41
41
  it { should =~ %w{ text/css application/javascript } }
42
42
  end
43
43
 
44
+ context "cache_assets?" do
45
+ subject { config.cache_assets? }
46
+ it { should be_true }
47
+ end
48
+
44
49
  end
45
50
 
46
51
  it "should override specified options and leave defaults for missing" do
@@ -18,6 +18,13 @@ module Jekyll::AssetsPlugin
18
18
  subject { site.assets }
19
19
  it { should be_a_kind_of Sprockets::Environment }
20
20
 
21
+ context "#cache_path" do
22
+ let(:source_path) { Pathname.new site.source }
23
+ subject { site.assets.cache_path }
24
+
25
+ it { should == source_path.join(".jekyll-assets-cache") }
26
+ end
27
+
21
28
  context "calling #asset_path within assets" do
22
29
  context "when requested file not found" do
23
30
  it "should raise a NotFound error" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-13 00:00:00.000000000 Z
12
+ date: 2013-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll
@@ -181,6 +181,7 @@ files:
181
181
  - lib/jekyll-assets/neat.rb
182
182
  - lib/jekyll/assets_plugin.rb
183
183
  - lib/jekyll/assets_plugin/asset_file.rb
184
+ - lib/jekyll/assets_plugin/commands.rb
184
185
  - lib/jekyll/assets_plugin/configuration.rb
185
186
  - lib/jekyll/assets_plugin/environment.rb
186
187
  - lib/jekyll/assets_plugin/filters.rb
@@ -242,7 +243,7 @@ rubyforge_project:
242
243
  rubygems_version: 1.8.23
243
244
  signing_key:
244
245
  specification_version: 3
245
- summary: jekyll-assets-0.5.1
246
+ summary: jekyll-assets-0.5.2
246
247
  test_files:
247
248
  - spec/fixtures/.gitignore
248
249
  - spec/fixtures/_assets/app.css.erb