nutils 0.6.4 → 0.7.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 +3 -0
- data/lib/nutils/base/errors.rb +16 -0
- data/lib/nutils/base.rb +5 -0
- data/lib/nutils/data_sources/filesystem_customizable.rb +1 -1
- data/lib/nutils/helpers/rules.rb +48 -0
- data/lib/nutils/helpers.rb +6 -0
- data/lib/nutils.rb +3 -1
- metadata +9 -5
data/README.md
CHANGED
@@ -13,5 +13,8 @@ A set of utilities for Nanoc3.
|
|
13
13
|
## Data Sources
|
14
14
|
* **filesystem_customizable** Allows an array for source directories and for layout directories.
|
15
15
|
|
16
|
+
## Helpers
|
17
|
+
* **load_rules** Allows to use multiple files with Nanoc rules.
|
18
|
+
|
16
19
|
## Contact
|
17
20
|
You can reach me at <arnau.siches@gmail.com>.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Nutils
|
2
|
+
module Errors
|
3
|
+
|
4
|
+
# Error that is raised when no partial rules file can be found in any
|
5
|
+
# directory provided.
|
6
|
+
class NoRulesFileFound < ::Nanoc3::Errors::NoRulesFileFound
|
7
|
+
|
8
|
+
# @param [String] filename The file name not found.
|
9
|
+
def initialize(filename)
|
10
|
+
super("No file found in any directory provided for “#{filename}”".make_compatible_with_env)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/nutils/base.rb
ADDED
@@ -8,7 +8,7 @@ module Nutils
|
|
8
8
|
# The +filesystem_customizable+ data source allows an array for source
|
9
9
|
# directories and for layout directories.
|
10
10
|
#
|
11
|
-
# @example
|
11
|
+
# @example Config.yaml excerpt
|
12
12
|
# data_sources:
|
13
13
|
# -
|
14
14
|
# type: filesystem_customizable
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Nutils
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
# @author Arnau Siches
|
5
|
+
#
|
6
|
+
# @version 0.1.0
|
7
|
+
#
|
8
|
+
# Provides some helper functions to process Rules.
|
9
|
+
module Rules
|
10
|
+
|
11
|
+
# Compiles the content as a set of Nanoc rules. Tries to use the
|
12
|
+
# +rules_dir+ attribute from the Config.yaml.
|
13
|
+
# If +rules_dir+ is not defined, it uses +"."+ as a base path.
|
14
|
+
#
|
15
|
+
# @example Config.yaml excerpt
|
16
|
+
#
|
17
|
+
# rules_dir: ['lib/rules/**', 'lib/other_rules']
|
18
|
+
#
|
19
|
+
# @example Rules excerpt
|
20
|
+
#
|
21
|
+
# # Finds any foo.rule in all directories defined in the Config.yaml
|
22
|
+
# load_rules('foo.rule')
|
23
|
+
#
|
24
|
+
# @param [String] filepath The file path to load.
|
25
|
+
#
|
26
|
+
# @return [Proc]
|
27
|
+
def load_rules(filepath)
|
28
|
+
rules_dir = @site.config[:rules_dir] || ['.']
|
29
|
+
|
30
|
+
path = rules_dir.map do |dir|
|
31
|
+
Dir[File.join(dir, filepath)].each { |filename| filename }
|
32
|
+
end.flatten
|
33
|
+
|
34
|
+
if path.length > 1
|
35
|
+
puts "\e[1mwarning\e[0m Multiple matches for #{filepath}:",
|
36
|
+
" #{path.join("\n ")}",
|
37
|
+
" \e[1mused\e[0m #{path[0]}"
|
38
|
+
elsif path.length == 0
|
39
|
+
raise Nutils::Errors::NoRulesFileFound.new(filepath)
|
40
|
+
end
|
41
|
+
|
42
|
+
instance_eval(File.read(path[0]), path[0])
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/lib/nutils.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Nutils
|
4
4
|
|
5
5
|
# The current nutils version.
|
6
|
-
VERSION = "0.
|
6
|
+
VERSION = "0.7.0"
|
7
7
|
|
8
8
|
end
|
9
9
|
|
@@ -11,5 +11,7 @@ end
|
|
11
11
|
require "nanoc3"
|
12
12
|
|
13
13
|
# Load nutils
|
14
|
+
require "nutils/base"
|
14
15
|
require "nutils/data_sources"
|
15
16
|
require "nutils/filters"
|
17
|
+
require "nutils/helpers"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 0.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Arnau Siches
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-13 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -44,6 +44,8 @@ extra_rdoc_files:
|
|
44
44
|
- README.md
|
45
45
|
- LICENSE
|
46
46
|
files:
|
47
|
+
- lib/nutils/base/errors.rb
|
48
|
+
- lib/nutils/base.rb
|
47
49
|
- lib/nutils/data_sources/filesystem_customizable.rb
|
48
50
|
- lib/nutils/data_sources.rb
|
49
51
|
- lib/nutils/filters/beautify.rb
|
@@ -53,6 +55,8 @@ files:
|
|
53
55
|
- lib/nutils/filters/svg2png.rb
|
54
56
|
- lib/nutils/filters/yuicompressor.rb
|
55
57
|
- lib/nutils/filters.rb
|
58
|
+
- lib/nutils/helpers/rules.rb
|
59
|
+
- lib/nutils/helpers.rb
|
56
60
|
- lib/nutils.rb
|
57
61
|
- README.md
|
58
62
|
- LICENSE
|