nanoc-sprockets 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3b64436c4d2e8ee089640dd6725cce5947add84b
4
+ data.tar.gz: c6b67620a1ff4e626949f573b10ba10f2096cf47
5
+ SHA512:
6
+ metadata.gz: 5db505ce5a9f404fa801dde354696d976523715b87d83ca0547a8f1032135adba52312db4efe3c7f720e8210d79921c5b2d107848c3c68c2487bdc292695718b
7
+ data.tar.gz: d84c6262f801aa52c0e9f5e436da668708db4ae45bc69e48aedd3161c8fdf5fa55ef3acc6ae5e040d04ae0743735a71b4fcb14762b06f57dddc8f46e54f16872
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Nanoc sprockets
2
+
3
+ Use [sprockets][] as a datasource for [nanoc][].
4
+
5
+ Features:
6
+
7
+ * Load your assets as nanoc's items
8
+ * Sprockets helpers *(javascript|image|stylesheet|font)_path* included
9
+ * Load and compile only the assets you want
10
+ * Configurable paths
11
+
12
+ ## Install
13
+
14
+ Add *nanoc-sprockets* to you Gemfile.
15
+
16
+ gem 'nanoc-sprockets'
17
+
18
+ ### Usage
19
+
20
+ Add a new entry in your *nanoc.yaml*.
21
+
22
+ ```yaml
23
+ data_sources:
24
+ -
25
+ type: sprockets
26
+ items_root: /assets
27
+ compile:
28
+ - application.css
29
+ - application.js
30
+ path: assets
31
+ css_compressor: scss
32
+ js_compressor: uglifier
33
+ ```
34
+
35
+ ### License
36
+
37
+ (c) 2014 Stormz
38
+
39
+ MIT
40
+
41
+ [sprockets]: https://github.com/sstephenson/sprockets
42
+ [nanoc]: http://nanoc.ws/
@@ -0,0 +1,60 @@
1
+ # encoding: utf-8
2
+
3
+ require "sprockets"
4
+ require "sprockets-helpers"
5
+
6
+ module Nanoc::DataSources
7
+ class SprocketsDataSource < Nanoc::DataSource
8
+ identifier :sprockets
9
+ LOOSE_ASSETS = lambda do |filename, path|
10
+ path =~ /assets/ && !%w(.js .css).include?(File.extname(filename))
11
+ end
12
+
13
+ def items
14
+ assets = environment.each_logical_path(*compiled_assets).to_a
15
+
16
+ assets.map do |bundle|
17
+ asset = environment.find_asset(bundle)
18
+ is_binary = !!(asset.pathname && !@site.config[:text_extensions].include?(File.extname(asset.pathname)[1..-1]))
19
+
20
+ attributes = {filename: bundle, binary: is_binary, mtime: asset.mtime}
21
+ if is_binary
22
+ Nanoc::Item.new(asset.pathname, attributes, bundle, attributes)
23
+ else
24
+ Nanoc::Item.new(asset.to_s, attributes, bundle, attributes)
25
+ end
26
+ end
27
+ end
28
+
29
+ protected
30
+ def environment
31
+ @environment ||= create_environment
32
+ end
33
+
34
+ def create_environment
35
+ env = ::Sprockets::Environment.new
36
+
37
+ env.append_path File.join(config[:path], 'javascripts')
38
+ env.append_path File.join(config[:path], 'images')
39
+ env.append_path File.join(config[:path], 'stylesheets')
40
+ config[:assets_path].each do |path|
41
+ env.append_path File.join(config[:path], path)
42
+ end
43
+ env.js_compressor = config[:js_compressor].to_sym
44
+ env.css_compressor = config[:css_compressor].to_sym
45
+
46
+ # Configure Sprockets::Helpers
47
+ Sprockets::Helpers.configure do |c|
48
+ c.environment = env
49
+ c.prefix = config[:items_root]
50
+ c.digest = production?
51
+ end
52
+ env
53
+ end
54
+
55
+ def compiled_assets
56
+ config[:compile] + [LOOSE_ASSETS]
57
+ end
58
+ end
59
+ end
60
+ include Sprockets::Helpers
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'nanoc-sprockets'
5
+ s.version = '0.0.1'
6
+ s.summary = "Use sprockets as a datasource for nanoc"
7
+ s.description = "A simple hello world gem"
8
+ s.homepage = 'https://github.com/stormz/nanoc-sprockets'
9
+ s.license = 'MIT'
10
+
11
+ s.authors = ["François de Metz"]
12
+ s.email = 'francois@2metz.fr'
13
+
14
+ s.require_paths = ["lib"]
15
+ s.files = `git ls-files`.split($\)
16
+
17
+ s.add_dependency "sprockets", ">= 2.0.0"
18
+ s.add_dependency "sprockets-helpers", ">= 1.1.0"
19
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nanoc-sprockets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - François de Metz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sprockets
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sprockets-helpers
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.0
41
+ description: A simple hello world gem
42
+ email: francois@2metz.fr
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - README.md
48
+ - lib/nanoc-sprockets.rb
49
+ - nanoc-sprockets.gemspec
50
+ homepage: https://github.com/stormz/nanoc-sprockets
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.1.5
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Use sprockets as a datasource for nanoc
74
+ test_files: []
75
+ has_rdoc: