nutils 1.1.0 → 1.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.
- data/README.md +0 -2
- data/lib/nutils.rb +1 -1
- data/lib/nutils/base.rb +2 -1
- data/lib/nutils/base/errors.rb +2 -1
- data/lib/nutils/data_sources.rb +1 -0
- data/lib/nutils/data_sources/filesystem_customizable.rb +1 -1
- data/lib/nutils/filters.rb +1 -2
- data/lib/nutils/filters/beautify.rb +1 -0
- data/lib/nutils/filters/crop.rb +1 -0
- data/lib/nutils/filters/svg2png.rb +1 -0
- data/lib/nutils/filters/yuicompressor.rb +5 -4
- data/lib/nutils/helpers/rules.rb +1 -0
- metadata +33 -52
- data/lib/nutils/filters/sprockets.rb +0 -62
data/README.md
CHANGED
@@ -6,10 +6,8 @@ A set of utilities for nanoc 3. Tested in Mac OS X 10.6, Ruby 1.8.7, 1.92 and na
|
|
6
6
|
|
7
7
|
* **beautify** Retabs HTML code. htmlbeautifier 0.0.6.
|
8
8
|
* **crop** Extracts the specified rectangle from the image. RMagick 2.13.1.
|
9
|
-
* **sprockets** Runs the content through [Sprockets](http://getsprockets.org). Sprockets 2.
|
10
9
|
* **svg_to_png** Converts an SVG to PNG. Batik 1.7.
|
11
10
|
* **yuicompressor** Compress the content with [YUI Compressor](http://developer.yahoo.com/yui/compressor/). yui-compressor 0.9.1.
|
12
|
-
* **sass** Importer `Nutils::SassImporters::NanocItem` which deals with `@import /nanoc/identifier/` instead of real filenames.
|
13
11
|
|
14
12
|
## Data Sources
|
15
13
|
* **filesystem_customizable** Allows an array for source directories and for layout directories.
|
data/lib/nutils.rb
CHANGED
data/lib/nutils/base.rb
CHANGED
data/lib/nutils/base/errors.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module Nutils
|
2
3
|
module Errors
|
3
4
|
|
@@ -7,7 +8,7 @@ module Nutils
|
|
7
8
|
|
8
9
|
# @param [String] filename The file name not found.
|
9
10
|
def initialize(filename)
|
10
|
-
super("No file found in any directory provided for
|
11
|
+
super("No file found in any directory provided for #{filename}".make_compatible_with_env)
|
11
12
|
end
|
12
13
|
|
13
14
|
end
|
data/lib/nutils/data_sources.rb
CHANGED
data/lib/nutils/filters.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module Nutils
|
2
3
|
module Filters
|
3
4
|
autoload 'Beautify', 'nutils/filters/beautify'
|
4
5
|
autoload 'Crop', 'nutils/filters/crop'
|
5
|
-
autoload 'SprocketWheel', 'nutils/filters/sprockets'
|
6
6
|
autoload 'SvgToPng', 'nutils/filters/svg2png'
|
7
7
|
autoload 'YuiCompressor', 'nutils/filters/yuicompressor'
|
8
8
|
|
9
9
|
::Nanoc::Filter.register '::Nutils::Filters::Beautify', :beautify
|
10
10
|
::Nanoc::Filter.register '::Nutils::Filters::Crop', :crop
|
11
|
-
::Nanoc::Filter.register '::Nutils::Filters::SprocketWheel', :sprockets
|
12
11
|
::Nanoc::Filter.register '::Nutils::Filters::SvgToPng', :svg_to_png
|
13
12
|
::Nanoc::Filter.register '::Nutils::Filters::YuiCompressor', :yuicompressor
|
14
13
|
end
|
data/lib/nutils/filters/crop.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module Nutils
|
2
3
|
module Filters
|
3
4
|
|
4
5
|
# @author Arnau Siches
|
5
6
|
#
|
6
|
-
# @version 1.2.
|
7
|
+
# @version 1.2.1
|
7
8
|
#
|
8
9
|
# @note Requires «yui-compressor»
|
9
10
|
class YuiCompressor < Nanoc::Filter
|
@@ -24,12 +25,12 @@ module Nutils
|
|
24
25
|
require "yui/compressor"
|
25
26
|
if (params[:type] == :css)
|
26
27
|
compressor = ::YUI::CssCompressor.new
|
27
|
-
|
28
|
+
else
|
29
|
+
puts "Remember to add a params[:type] to your filter declaration to ensure straight compatibility with YUICompressor" unless params.has_key?(:type)
|
30
|
+
# elsif (params[:type] == :js)
|
28
31
|
# It fallbacks to `:type => :js` because backwards compatibility w/
|
29
32
|
# prior versions of the filter.
|
30
33
|
compressor = ::YUI::JavaScriptCompressor.new
|
31
|
-
else
|
32
|
-
raise "You should define a params[:type] either :js or :css"
|
33
34
|
end
|
34
35
|
|
35
36
|
compressor.compress(content)
|
data/lib/nutils/helpers/rules.rb
CHANGED
metadata
CHANGED
@@ -1,53 +1,42 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutils
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 1.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Arnau Siches
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: nanoc
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 3
|
29
|
-
- 3
|
30
|
-
- 1
|
16
|
+
requirement: &70365351652660 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
31
21
|
version: 3.3.1
|
32
22
|
type: :runtime
|
33
|
-
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70365351652660
|
25
|
+
description: Nutils is a set of utilities like filters, data_sources and helpers for
|
26
|
+
Nanoc.
|
35
27
|
email: arnau.siches@gmail.com
|
36
28
|
executables: []
|
37
|
-
|
38
29
|
extensions: []
|
39
|
-
|
40
|
-
extra_rdoc_files:
|
30
|
+
extra_rdoc_files:
|
41
31
|
- README.md
|
42
32
|
- LICENSE
|
43
|
-
files:
|
33
|
+
files:
|
44
34
|
- lib/nutils/base/errors.rb
|
45
35
|
- lib/nutils/base.rb
|
46
36
|
- lib/nutils/data_sources/filesystem_customizable.rb
|
47
37
|
- lib/nutils/data_sources.rb
|
48
38
|
- lib/nutils/filters/beautify.rb
|
49
39
|
- lib/nutils/filters/crop.rb
|
50
|
-
- lib/nutils/filters/sprockets.rb
|
51
40
|
- lib/nutils/filters/svg2png.rb
|
52
41
|
- lib/nutils/filters/yuicompressor.rb
|
53
42
|
- lib/nutils/filters.rb
|
@@ -56,38 +45,30 @@ files:
|
|
56
45
|
- lib/nutils.rb
|
57
46
|
- README.md
|
58
47
|
- LICENSE
|
59
|
-
has_rdoc: yard
|
60
48
|
homepage: http://github.com/arnau/Nutils/
|
61
49
|
licenses: []
|
62
|
-
|
63
50
|
post_install_message:
|
64
|
-
rdoc_options:
|
51
|
+
rdoc_options:
|
65
52
|
- --main
|
66
53
|
- README.md
|
67
|
-
require_paths:
|
54
|
+
require_paths:
|
68
55
|
- lib
|
69
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
- 1
|
75
|
-
- 8
|
76
|
-
- 7
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
77
61
|
version: 1.8.7
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
version: "0"
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
85
68
|
requirements: []
|
86
|
-
|
87
69
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.
|
70
|
+
rubygems_version: 1.8.10
|
89
71
|
signing_key:
|
90
72
|
specification_version: 3
|
91
73
|
summary: A set of utilities for Nanoc3.
|
92
74
|
test_files: []
|
93
|
-
|
@@ -1,62 +0,0 @@
|
|
1
|
-
module Nutils
|
2
|
-
module Filters
|
3
|
-
# @author Arnau Siches
|
4
|
-
#
|
5
|
-
# @version 3.0.0
|
6
|
-
#
|
7
|
-
# @note Requires «sprockets»
|
8
|
-
class SprocketWheel < Nanoc::Filter
|
9
|
-
identifier :sprockets
|
10
|
-
type :text
|
11
|
-
# Concatenate the Javascript, CoffeeScript or Sass content through [Sprockets](http://getsprockets.org).
|
12
|
-
# This method takes no options.
|
13
|
-
#
|
14
|
-
# @param [String] content The content to filter.
|
15
|
-
#
|
16
|
-
# @return [String] The filtered content.
|
17
|
-
def run(content, params={})
|
18
|
-
require 'sprockets'
|
19
|
-
raise "Sprockets should be 2.0.0 or higher" if Gem.loaded_specs['sprockets'].version < Gem::Version.create('2.0')
|
20
|
-
|
21
|
-
filename = Pathname.new(@item[:content_filename])
|
22
|
-
|
23
|
-
# Create a temp file with the content received to give the desired
|
24
|
-
# content to Sprockets on the same context.
|
25
|
-
tmp_filename = filename.dirname + ('tmp_' + filename.basename.to_s)
|
26
|
-
tmp_filename.open('w') { |io| io.puts content }
|
27
|
-
|
28
|
-
load_path = params[:load_path] || []
|
29
|
-
load_path << tmp_filename.dirname.realpath
|
30
|
-
|
31
|
-
env = ::Sprockets::Environment.new(tmp_filename.dirname.realpath)
|
32
|
-
|
33
|
-
# Assign load paths to Sprockets
|
34
|
-
load_path.each do |path|
|
35
|
-
env.append_path(File.expand_path(path))
|
36
|
-
end
|
37
|
-
|
38
|
-
# Get the Sprockets BundledAsset object for the content
|
39
|
-
main_asset = env.find_asset(tmp_filename.realpath)
|
40
|
-
|
41
|
-
# Select just the possible items that can be dependencies
|
42
|
-
possible_items = @items.reject { |i| i[:content_filename].nil? }.select do |i|
|
43
|
-
load_path.find { |p| Pathname.new(p).realpath.to_s == Pathname.new(i[:content_filename]).dirname.realpath.to_s }
|
44
|
-
end
|
45
|
-
|
46
|
-
# Get Nanoc::Item equivalent for each dependence managed by Sprockets
|
47
|
-
dependencies = main_asset.dependencies.inject([]) do |dep, asset|
|
48
|
-
item = possible_items.find { |i| asset.pathname == Pathname.new(i[:content_filename]).realpath }
|
49
|
-
dep << item unless item.nil?
|
50
|
-
dep
|
51
|
-
end
|
52
|
-
# Register Nanoc dependencies
|
53
|
-
depend_on(dependencies) unless dependencies.nil?
|
54
|
-
|
55
|
-
# Output compiled asset
|
56
|
-
main_asset.to_s
|
57
|
-
ensure
|
58
|
-
tmp_filename.delete if tmp_filename.exist?
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|