nanoc3 3.2.4 → 3.3.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.
- metadata +14 -313
- data/.gemtest +0 -0
- data/ChangeLog +0 -3
- data/Gemfile +0 -29
- data/LICENSE +0 -19
- data/NEWS.md +0 -449
- data/README.md +0 -108
- data/Rakefile +0 -14
- data/bin/nanoc3 +0 -12
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/nanoc3.rb +0 -28
- data/lib/nanoc3/base.rb +0 -49
- data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
- data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
- data/lib/nanoc3/base/compilation/compiler.rb +0 -455
- data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
- data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
- data/lib/nanoc3/base/compilation/filter.rb +0 -165
- data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
- data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
- data/lib/nanoc3/base/compilation/rule.rb +0 -73
- data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
- data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
- data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
- data/lib/nanoc3/base/context.rb +0 -47
- data/lib/nanoc3/base/core_ext.rb +0 -6
- data/lib/nanoc3/base/core_ext/array.rb +0 -62
- data/lib/nanoc3/base/core_ext/hash.rb +0 -63
- data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
- data/lib/nanoc3/base/core_ext/string.rb +0 -46
- data/lib/nanoc3/base/directed_graph.rb +0 -275
- data/lib/nanoc3/base/errors.rb +0 -174
- data/lib/nanoc3/base/memoization.rb +0 -67
- data/lib/nanoc3/base/notification_center.rb +0 -84
- data/lib/nanoc3/base/ordered_hash.rb +0 -200
- data/lib/nanoc3/base/plugin_registry.rb +0 -165
- data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
- data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
- data/lib/nanoc3/base/source_data/configuration.rb +0 -24
- data/lib/nanoc3/base/source_data/data_source.rb +0 -234
- data/lib/nanoc3/base/source_data/item.rb +0 -301
- data/lib/nanoc3/base/source_data/layout.rb +0 -130
- data/lib/nanoc3/base/source_data/site.rb +0 -361
- data/lib/nanoc3/base/store.rb +0 -135
- data/lib/nanoc3/cli.rb +0 -133
- data/lib/nanoc3/cli/command.rb +0 -139
- data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
- data/lib/nanoc3/cli/commands/compile.rb +0 -280
- data/lib/nanoc3/cli/commands/create_item.rb +0 -62
- data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
- data/lib/nanoc3/cli/commands/create_site.rb +0 -410
- data/lib/nanoc3/cli/commands/debug.rb +0 -119
- data/lib/nanoc3/cli/commands/info.rb +0 -98
- data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
- data/lib/nanoc3/cli/commands/update.rb +0 -72
- data/lib/nanoc3/cli/commands/view.rb +0 -84
- data/lib/nanoc3/cli/commands/watch.rb +0 -125
- data/lib/nanoc3/cli/error_handler.rb +0 -193
- data/lib/nanoc3/cli/logger.rb +0 -91
- data/lib/nanoc3/data_sources.rb +0 -29
- data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
- data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
- data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
- data/lib/nanoc3/data_sources/filesystem.rb +0 -299
- data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
- data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
- data/lib/nanoc3/extra.rb +0 -22
- data/lib/nanoc3/extra/auto_compiler.rb +0 -103
- data/lib/nanoc3/extra/chick.rb +0 -125
- data/lib/nanoc3/extra/core_ext.rb +0 -4
- data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
- data/lib/nanoc3/extra/core_ext/time.rb +0 -19
- data/lib/nanoc3/extra/deployers.rb +0 -11
- data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
- data/lib/nanoc3/extra/file_proxy.rb +0 -40
- data/lib/nanoc3/extra/validators.rb +0 -12
- data/lib/nanoc3/extra/validators/links.rb +0 -264
- data/lib/nanoc3/extra/validators/w3c.rb +0 -95
- data/lib/nanoc3/extra/vcs.rb +0 -66
- data/lib/nanoc3/extra/vcses.rb +0 -17
- data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
- data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
- data/lib/nanoc3/extra/vcses/git.rb +0 -25
- data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
- data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
- data/lib/nanoc3/filters.rb +0 -53
- data/lib/nanoc3/filters/asciidoc.rb +0 -38
- data/lib/nanoc3/filters/bluecloth.rb +0 -19
- data/lib/nanoc3/filters/coderay.rb +0 -21
- data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
- data/lib/nanoc3/filters/erb.rb +0 -35
- data/lib/nanoc3/filters/erubis.rb +0 -27
- data/lib/nanoc3/filters/haml.rb +0 -27
- data/lib/nanoc3/filters/kramdown.rb +0 -20
- data/lib/nanoc3/filters/less.rb +0 -53
- data/lib/nanoc3/filters/markaby.rb +0 -20
- data/lib/nanoc3/filters/maruku.rb +0 -20
- data/lib/nanoc3/filters/mustache.rb +0 -24
- data/lib/nanoc3/filters/rainpress.rb +0 -19
- data/lib/nanoc3/filters/rdiscount.rb +0 -22
- data/lib/nanoc3/filters/rdoc.rb +0 -33
- data/lib/nanoc3/filters/redcarpet.rb +0 -27
- data/lib/nanoc3/filters/redcloth.rb +0 -47
- data/lib/nanoc3/filters/relativize_paths.rb +0 -45
- data/lib/nanoc3/filters/rubypants.rb +0 -20
- data/lib/nanoc3/filters/sass.rb +0 -66
- data/lib/nanoc3/filters/slim.rb +0 -25
- data/lib/nanoc3/filters/typogruby.rb +0 -23
- data/lib/nanoc3/filters/uglify_js.rb +0 -42
- data/lib/nanoc3/helpers.rb +0 -16
- data/lib/nanoc3/helpers/blogging.rb +0 -319
- data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
- data/lib/nanoc3/helpers/capturing.rb +0 -138
- data/lib/nanoc3/helpers/filtering.rb +0 -50
- data/lib/nanoc3/helpers/html_escape.rb +0 -55
- data/lib/nanoc3/helpers/link_to.rb +0 -151
- data/lib/nanoc3/helpers/rendering.rb +0 -140
- data/lib/nanoc3/helpers/tagging.rb +0 -71
- data/lib/nanoc3/helpers/text.rb +0 -44
- data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
- data/lib/nanoc3/tasks.rb +0 -10
- data/lib/nanoc3/tasks/clean.rake +0 -16
- data/lib/nanoc3/tasks/clean.rb +0 -29
- data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
- data/lib/nanoc3/tasks/validate.rake +0 -92
- data/nanoc3.gemspec +0 -49
- data/tasks/doc.rake +0 -16
- data/tasks/test.rake +0 -44
- data/test/base/core_ext/array_spec.rb +0 -73
- data/test/base/core_ext/hash_spec.rb +0 -98
- data/test/base/core_ext/pathname_spec.rb +0 -27
- data/test/base/core_ext/string_spec.rb +0 -37
- data/test/base/test_checksum_store.rb +0 -35
- data/test/base/test_code_snippet.rb +0 -31
- data/test/base/test_compiler.rb +0 -316
- data/test/base/test_compiler_dsl.rb +0 -161
- data/test/base/test_context.rb +0 -31
- data/test/base/test_data_source.rb +0 -46
- data/test/base/test_dependency_tracker.rb +0 -262
- data/test/base/test_directed_graph.rb +0 -283
- data/test/base/test_filter.rb +0 -83
- data/test/base/test_item.rb +0 -179
- data/test/base/test_item_rep.rb +0 -553
- data/test/base/test_layout.rb +0 -59
- data/test/base/test_memoization.rb +0 -90
- data/test/base/test_notification_center.rb +0 -34
- data/test/base/test_outdatedness_checker.rb +0 -394
- data/test/base/test_plugin.rb +0 -30
- data/test/base/test_rule.rb +0 -19
- data/test/base/test_rule_context.rb +0 -65
- data/test/base/test_site.rb +0 -190
- data/test/cli/commands/test_compile.rb +0 -33
- data/test/cli/commands/test_create_item.rb +0 -14
- data/test/cli/commands/test_create_layout.rb +0 -28
- data/test/cli/commands/test_create_site.rb +0 -24
- data/test/cli/commands/test_help.rb +0 -12
- data/test/cli/commands/test_info.rb +0 -11
- data/test/cli/commands/test_update.rb +0 -10
- data/test/cli/test_cli.rb +0 -102
- data/test/cli/test_error_handler.rb +0 -29
- data/test/cli/test_logger.rb +0 -10
- data/test/data_sources/test_filesystem.rb +0 -433
- data/test/data_sources/test_filesystem_unified.rb +0 -536
- data/test/data_sources/test_filesystem_verbose.rb +0 -357
- data/test/extra/core_ext/test_enumerable.rb +0 -30
- data/test/extra/core_ext/test_time.rb +0 -15
- data/test/extra/deployers/test_rsync.rb +0 -232
- data/test/extra/test_auto_compiler.rb +0 -417
- data/test/extra/test_file_proxy.rb +0 -19
- data/test/extra/test_vcs.rb +0 -22
- data/test/extra/validators/test_links.rb +0 -51
- data/test/extra/validators/test_w3c.rb +0 -47
- data/test/filters/test_asciidoc.rb +0 -22
- data/test/filters/test_bluecloth.rb +0 -18
- data/test/filters/test_coderay.rb +0 -44
- data/test/filters/test_colorize_syntax.rb +0 -283
- data/test/filters/test_erb.rb +0 -99
- data/test/filters/test_erubis.rb +0 -70
- data/test/filters/test_haml.rb +0 -96
- data/test/filters/test_kramdown.rb +0 -18
- data/test/filters/test_less.rb +0 -113
- data/test/filters/test_markaby.rb +0 -24
- data/test/filters/test_maruku.rb +0 -18
- data/test/filters/test_mustache.rb +0 -25
- data/test/filters/test_rainpress.rb +0 -29
- data/test/filters/test_rdiscount.rb +0 -31
- data/test/filters/test_rdoc.rb +0 -18
- data/test/filters/test_redcarpet.rb +0 -63
- data/test/filters/test_redcloth.rb +0 -33
- data/test/filters/test_relativize_paths.rb +0 -332
- data/test/filters/test_rubypants.rb +0 -18
- data/test/filters/test_sass.rb +0 -229
- data/test/filters/test_slim.rb +0 -35
- data/test/filters/test_typogruby.rb +0 -21
- data/test/filters/test_uglify_js.rb +0 -30
- data/test/gem_loader.rb +0 -11
- data/test/helper.rb +0 -179
- data/test/helpers/test_blogging.rb +0 -754
- data/test/helpers/test_breadcrumbs.rb +0 -81
- data/test/helpers/test_capturing.rb +0 -41
- data/test/helpers/test_filtering.rb +0 -106
- data/test/helpers/test_html_escape.rb +0 -32
- data/test/helpers/test_link_to.rb +0 -249
- data/test/helpers/test_rendering.rb +0 -89
- data/test/helpers/test_tagging.rb +0 -87
- data/test/helpers/test_text.rb +0 -24
- data/test/helpers/test_xml_sitemap.rb +0 -103
- data/test/tasks/test_clean.rb +0 -67
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Nanoc3::CLI
|
|
4
|
-
|
|
5
|
-
# Catches errors and prints nice diagnostic messages, then exits.
|
|
6
|
-
#
|
|
7
|
-
# @api private
|
|
8
|
-
class ErrorHandler
|
|
9
|
-
|
|
10
|
-
# @option params [Nanoc3::CLI::Command, nil] command The command that is
|
|
11
|
-
# currently being executed, or nil if there is none
|
|
12
|
-
def initialize(params={})
|
|
13
|
-
@command = params[:command]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Enables error handling in the given block.
|
|
17
|
-
#
|
|
18
|
-
# @option params [Nanoc3::CLI::Command, nil] command The command that is
|
|
19
|
-
# currently being executed, or nil if there is none
|
|
20
|
-
#
|
|
21
|
-
# @return [void]
|
|
22
|
-
def self.handle_while(params={}, &block)
|
|
23
|
-
self.new(params).handle_while(&block)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Enables error handling in the given block. This method should not be
|
|
27
|
-
# called directly; use {Nanoc3::CLI::ErrorHandler.handle_while} instead.
|
|
28
|
-
#
|
|
29
|
-
# @return [void]
|
|
30
|
-
#
|
|
31
|
-
# @api private
|
|
32
|
-
def handle_while(&block)
|
|
33
|
-
# Set exit handler
|
|
34
|
-
[ 'INT', 'TERM' ].each do |signal|
|
|
35
|
-
Signal.trap(signal) do
|
|
36
|
-
puts
|
|
37
|
-
exit!(0)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Run
|
|
42
|
-
yield
|
|
43
|
-
rescue Interrupt => e
|
|
44
|
-
exit(1)
|
|
45
|
-
rescue StandardError, ScriptError => e
|
|
46
|
-
self.print_error(e)
|
|
47
|
-
exit(1)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Prints the given error to stderr. Includes message, possible resolution
|
|
51
|
-
# (see {#resolution_for}), compilation stack, backtrace, etc.
|
|
52
|
-
#
|
|
53
|
-
# @param [Error] error The error that should be described
|
|
54
|
-
#
|
|
55
|
-
# @return [void]
|
|
56
|
-
def self.print_error(error)
|
|
57
|
-
self.new.print_error(error)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# Prints the given error to stderr. Includes message, possible resolution
|
|
61
|
-
# (see {#resolution_for}), compilation stack, backtrace, etc.
|
|
62
|
-
#
|
|
63
|
-
# @param [Error] error The error that should be described
|
|
64
|
-
#
|
|
65
|
-
# @return [void]
|
|
66
|
-
def print_error(error)
|
|
67
|
-
# Header
|
|
68
|
-
$stderr.puts
|
|
69
|
-
$stderr.puts "Captain! We’ve been hit!"
|
|
70
|
-
|
|
71
|
-
# Exception and resolution (if any)
|
|
72
|
-
$stderr.puts
|
|
73
|
-
$stderr.puts '=== MESSAGE:'
|
|
74
|
-
$stderr.puts
|
|
75
|
-
$stderr.puts "#{error.class}: #{error.message}"
|
|
76
|
-
resolution = self.resolution_for(error)
|
|
77
|
-
$stderr.puts "#{resolution}" if resolution
|
|
78
|
-
|
|
79
|
-
# Compilation stack
|
|
80
|
-
$stderr.puts
|
|
81
|
-
$stderr.puts '=== COMPILATION STACK:'
|
|
82
|
-
$stderr.puts
|
|
83
|
-
if self.stack.empty?
|
|
84
|
-
$stderr.puts " (empty)"
|
|
85
|
-
else
|
|
86
|
-
self.stack.reverse.each do |obj|
|
|
87
|
-
if obj.is_a?(Nanoc3::ItemRep)
|
|
88
|
-
$stderr.puts " - [item] #{obj.item.identifier} (rep #{obj.name})"
|
|
89
|
-
else # layout
|
|
90
|
-
$stderr.puts " - [layout] #{obj.identifier}"
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# Backtrace
|
|
96
|
-
$stderr.puts
|
|
97
|
-
$stderr.puts '=== BACKTRACE:'
|
|
98
|
-
$stderr.puts
|
|
99
|
-
$stderr.puts error.backtrace.to_enum(:each_with_index).map { |item, index| " #{index}. #{item}" }.join("\n")
|
|
100
|
-
|
|
101
|
-
# Issue link
|
|
102
|
-
$stderr.puts
|
|
103
|
-
$stderr.puts "If you believe this is a bug in nanoc, please do report it at"
|
|
104
|
-
$stderr.puts "<https://github.com/ddfreyne/nanoc/issues/new>--thanks!"
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
protected
|
|
108
|
-
|
|
109
|
-
# @return [Boolean] true if debug output is enabled, false if not
|
|
110
|
-
#
|
|
111
|
-
# @see Nanoc3::CLI.debug?
|
|
112
|
-
def debug?
|
|
113
|
-
Nanoc3::CLI.debug?
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
# @return [Nanoc3::Site] The site that is currently being processed
|
|
117
|
-
def site
|
|
118
|
-
@command && @command.site
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# @return [Nanoc3::Compiler] The compiler for the current site
|
|
122
|
-
def compiler
|
|
123
|
-
site && site.compiler
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
# @return [Array] The current compilation stack
|
|
127
|
-
def stack
|
|
128
|
-
(compiler && compiler.stack) || []
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
# A hash that contains the name of the gem for a given required file. If a
|
|
132
|
-
# `#require` fails, the gem name is looked up in this hash.
|
|
133
|
-
GEM_NAMES = {
|
|
134
|
-
'adsf' => 'adsf',
|
|
135
|
-
'bluecloth' => 'bluecloth',
|
|
136
|
-
'builder' => 'builder',
|
|
137
|
-
'coderay' => 'coderay',
|
|
138
|
-
'cri' => 'cri',
|
|
139
|
-
'erubis' => 'erubis',
|
|
140
|
-
'escape' => 'escape',
|
|
141
|
-
'fssm' => 'fssm',
|
|
142
|
-
'haml' => 'haml',
|
|
143
|
-
'json' => 'json',
|
|
144
|
-
'kramdown' => 'kramdown',
|
|
145
|
-
'less' => 'less',
|
|
146
|
-
'markaby' => 'markaby',
|
|
147
|
-
'maruku' => 'maruku',
|
|
148
|
-
'mime/types' => 'mime-types',
|
|
149
|
-
'nokogiri' => 'nokogiri',
|
|
150
|
-
'rack' => 'rack',
|
|
151
|
-
'rack/cache' => 'rack-cache',
|
|
152
|
-
'rainpress' => 'rainpress',
|
|
153
|
-
'rdiscount' => 'rdiscount',
|
|
154
|
-
'redcarpet' => 'redcarpet',
|
|
155
|
-
'redcloth' => 'redcloth',
|
|
156
|
-
'rubypants' => 'rubypants',
|
|
157
|
-
'sass' => 'sass',
|
|
158
|
-
'systemu' => 'systemu',
|
|
159
|
-
'w3c_validators' => 'w3c_validators'
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
# Attempts to find a resolution for the given error, or nil if no
|
|
163
|
-
# resolution can be automatically obtained.
|
|
164
|
-
#
|
|
165
|
-
# @param [Error] error The error to find a resolution for
|
|
166
|
-
#
|
|
167
|
-
# @return [String] The resolution for the given error
|
|
168
|
-
def resolution_for(error)
|
|
169
|
-
case error
|
|
170
|
-
when LoadError
|
|
171
|
-
# Get gem name
|
|
172
|
-
matches = error.message.match(/(no such file to load|cannot load such file) -- ([^\s]+)/)
|
|
173
|
-
return nil if matches.nil?
|
|
174
|
-
gem_name = GEM_NAMES[matches[2]]
|
|
175
|
-
|
|
176
|
-
# Build message
|
|
177
|
-
if gem_name
|
|
178
|
-
"Try installing the '#{gem_name}' gem (`gem install #{gem_name}`) and then re-running the command."
|
|
179
|
-
end
|
|
180
|
-
when RuntimeError
|
|
181
|
-
if error.message =~ /^can't modify frozen/
|
|
182
|
-
"You attempted to modify immutable data. Some data, such as " \
|
|
183
|
-
"item/layout attributes and raw item/layout content, can not " \
|
|
184
|
-
"be modified once compilation has started. (This was " \
|
|
185
|
-
"unintentionally possible in 3.1.x and before, but has been " \
|
|
186
|
-
"disabled in 3.2.x in order to allow compiler optimisations.)"
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
end
|
data/lib/nanoc3/cli/logger.rb
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'singleton'
|
|
4
|
-
|
|
5
|
-
module Nanoc3::CLI
|
|
6
|
-
|
|
7
|
-
# Nanoc3::CLI::Logger is a singleton class responsible for generating
|
|
8
|
-
# feedback in the terminal.
|
|
9
|
-
class Logger
|
|
10
|
-
|
|
11
|
-
# Maps actions (`:create`, `:update`, `:identical` and `:skip`) onto their
|
|
12
|
-
# ANSI color codes.
|
|
13
|
-
ACTION_COLORS = {
|
|
14
|
-
:create => "\e[1m" + "\e[32m", # bold + green
|
|
15
|
-
:update => "\e[1m" + "\e[33m", # bold + yellow
|
|
16
|
-
:identical => "\e[1m", # bold
|
|
17
|
-
:skip => "\e[1m" # bold
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
include Singleton
|
|
21
|
-
|
|
22
|
-
# Returns the log level, which can be :high, :low or :off (which will log
|
|
23
|
-
# all messages, only high-priority messages, or no messages at all,
|
|
24
|
-
# respectively).
|
|
25
|
-
#
|
|
26
|
-
# @return [Symbol] The log level
|
|
27
|
-
attr_accessor :level
|
|
28
|
-
|
|
29
|
-
# @return [Boolean] True if color should be used, false otherwise
|
|
30
|
-
attr_writer :color
|
|
31
|
-
|
|
32
|
-
def initialize
|
|
33
|
-
@level = :high
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# @return [Boolean] true if colors are enabled, false otherwise
|
|
37
|
-
def color?
|
|
38
|
-
if @color.nil?
|
|
39
|
-
@color = true
|
|
40
|
-
begin
|
|
41
|
-
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /mswin|mingw/
|
|
42
|
-
rescue LoadError
|
|
43
|
-
@color = false
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
@color
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Logs a file-related action.
|
|
51
|
-
#
|
|
52
|
-
# @param [:high, :low] level The importance of this action
|
|
53
|
-
#
|
|
54
|
-
# @param [:create, :update, :identical] action The kind of file action
|
|
55
|
-
#
|
|
56
|
-
# @param [String] name The name of the file the action was performed on
|
|
57
|
-
#
|
|
58
|
-
# @return [void]
|
|
59
|
-
def file(level, action, identifier, duration=nil)
|
|
60
|
-
log(
|
|
61
|
-
level,
|
|
62
|
-
'%s%12s%s %s%s' % [
|
|
63
|
-
color? ? ACTION_COLORS[action.to_sym] : '',
|
|
64
|
-
action,
|
|
65
|
-
color? ? "\e[0m" : '',
|
|
66
|
-
duration.nil? ? '' : "[%2.2fs] " % [ duration ],
|
|
67
|
-
identifier
|
|
68
|
-
]
|
|
69
|
-
)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Logs a message.
|
|
73
|
-
#
|
|
74
|
-
# @param [:high, :low] level The importance of this message
|
|
75
|
-
#
|
|
76
|
-
# @param [String] message The message to be logged
|
|
77
|
-
#
|
|
78
|
-
# @param [#puts] io The stream to which the message should be written
|
|
79
|
-
#
|
|
80
|
-
# @return [void]
|
|
81
|
-
def log(level, message, io=$stdout)
|
|
82
|
-
# Don't log when logging is disabled
|
|
83
|
-
return if @level == :off
|
|
84
|
-
|
|
85
|
-
# Log when level permits it
|
|
86
|
-
io.puts(message) if (@level == :low or @level == level)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
end
|
data/lib/nanoc3/data_sources.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Nanoc3::DataSources
|
|
4
|
-
|
|
5
|
-
autoload 'Filesystem', 'nanoc3/data_sources/filesystem'
|
|
6
|
-
autoload 'FilesystemUnified', 'nanoc3/data_sources/filesystem_unified'
|
|
7
|
-
autoload 'FilesystemVerbose', 'nanoc3/data_sources/filesystem_verbose'
|
|
8
|
-
|
|
9
|
-
Nanoc3::DataSource.register '::Nanoc3::DataSources::FilesystemVerbose', :filesystem_verbose
|
|
10
|
-
Nanoc3::DataSource.register '::Nanoc3::DataSources::FilesystemUnified', :filesystem_unified
|
|
11
|
-
|
|
12
|
-
# Deprecated; fetch data from online data sources manually instead
|
|
13
|
-
# TODO [in nanoc 4.0] remove me
|
|
14
|
-
autoload 'Delicious', 'nanoc3/data_sources/deprecated/delicious'
|
|
15
|
-
autoload 'LastFM', 'nanoc3/data_sources/deprecated/last_fm'
|
|
16
|
-
autoload 'Twitter', 'nanoc3/data_sources/deprecated/twitter'
|
|
17
|
-
Nanoc3::DataSource.register '::Nanoc3::DataSources::Delicious', :delicious
|
|
18
|
-
Nanoc3::DataSource.register '::Nanoc3::DataSources::LastFM', :last_fm
|
|
19
|
-
Nanoc3::DataSource.register '::Nanoc3::DataSources::Twitter', :twitter
|
|
20
|
-
|
|
21
|
-
# Deprecated; use `filesystem_verbose` or `filesystem_unified` instead
|
|
22
|
-
# TODO [in nanoc 4.0] remove me
|
|
23
|
-
Nanoc3::DataSource.register '::Nanoc3::DataSources::FilesystemVerbose', :filesystem
|
|
24
|
-
Nanoc3::DataSource.register '::Nanoc3::DataSources::FilesystemUnified', :filesystem_combined
|
|
25
|
-
Nanoc3::DataSource.register '::Nanoc3::DataSources::FilesystemUnified', :filesystem_compact
|
|
26
|
-
FilesystemCombined = FilesystemUnified
|
|
27
|
-
FilesystemCompact = FilesystemUnified
|
|
28
|
-
|
|
29
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Nanoc3::DataSources
|
|
4
|
-
|
|
5
|
-
# @deprecated Fetch data from online data sources manually instead
|
|
6
|
-
class Delicious < Nanoc3::DataSource
|
|
7
|
-
|
|
8
|
-
def items
|
|
9
|
-
@items ||= begin
|
|
10
|
-
require 'json'
|
|
11
|
-
|
|
12
|
-
# Get data
|
|
13
|
-
@http_client ||= Nanoc3::Extra::CHiCk::Client.new
|
|
14
|
-
status, headers, data = *@http_client.get("http://feeds.delicious.com/v2/json/#{self.config[:username]}")
|
|
15
|
-
|
|
16
|
-
# Parse as JSON
|
|
17
|
-
raw_items = JSON.parse(data)
|
|
18
|
-
|
|
19
|
-
# Convert to items
|
|
20
|
-
raw_items.enum_with_index.map do |raw_item, i|
|
|
21
|
-
# Get data
|
|
22
|
-
content = raw_item['n']
|
|
23
|
-
attributes = {
|
|
24
|
-
:url => raw_item['u'],
|
|
25
|
-
:description => raw_item['d'],
|
|
26
|
-
:tags => raw_item['t'],
|
|
27
|
-
:date => Time.parse(raw_item['dt']),
|
|
28
|
-
:note => raw_item['n'],
|
|
29
|
-
:author => raw_item['a']
|
|
30
|
-
}
|
|
31
|
-
identifier = "/#{i}/"
|
|
32
|
-
mtime = nil
|
|
33
|
-
|
|
34
|
-
# Build item
|
|
35
|
-
Nanoc3::Item.new(content, attributes, identifier, mtime)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Nanoc3::DataSources
|
|
4
|
-
|
|
5
|
-
# @deprecated Fetch data from online data sources manually instead
|
|
6
|
-
class LastFM < Nanoc3::DataSource
|
|
7
|
-
|
|
8
|
-
def items
|
|
9
|
-
@items ||= begin
|
|
10
|
-
require 'json'
|
|
11
|
-
require 'uri'
|
|
12
|
-
|
|
13
|
-
# Check configuration
|
|
14
|
-
if self.config[:username].nil?
|
|
15
|
-
raise RuntimeError, "LastFM data source requires a username in the configuration"
|
|
16
|
-
end
|
|
17
|
-
if self.config[:api_key].nil?
|
|
18
|
-
raise RuntimeError, "LastFM data source requires an API key in the configuration"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Get data
|
|
22
|
-
@http_client ||= Nanoc3::Extra::CHiCk::Client.new
|
|
23
|
-
status, headers, data = *@http_client.get(
|
|
24
|
-
'http://ws.audioscrobbler.com/2.0/' +
|
|
25
|
-
'?method=user.getRecentTracks' +
|
|
26
|
-
'&format=json' +
|
|
27
|
-
'&user=' + URI.escape(self.config[:username]) +
|
|
28
|
-
'&api_key=' + URI.escape(self.config[:api_key])
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
# Parse as JSON
|
|
32
|
-
parsed_data = JSON.parse(data)
|
|
33
|
-
raw_items = parsed_data['recenttracks']['track']
|
|
34
|
-
|
|
35
|
-
# Convert to items
|
|
36
|
-
raw_items.enum_with_index.map do |raw_item, i|
|
|
37
|
-
# Get artist data
|
|
38
|
-
artist_status, artist_headers, artist_data = *@http_client.get(
|
|
39
|
-
'http://ws.audioscrobbler.com/2.0/' +
|
|
40
|
-
'?method=artist.getInfo' +
|
|
41
|
-
'&format=json' +
|
|
42
|
-
(
|
|
43
|
-
raw_item['artist']['mbid'].empty? ?
|
|
44
|
-
'&artist=' + URI.escape(raw_item['artist']['#text']) :
|
|
45
|
-
'&mbid=' + URI.escape(raw_item['artist']['mbid'])
|
|
46
|
-
) +
|
|
47
|
-
'&api_key=' + URI.escape(self.config[:api_key])
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
# Parse as JSON
|
|
51
|
-
parsed_artist_data = JSON.parse(artist_data)
|
|
52
|
-
raw_artist_info = parsed_artist_data['artist']
|
|
53
|
-
|
|
54
|
-
# Build data
|
|
55
|
-
content = ''
|
|
56
|
-
|
|
57
|
-
# Handle track dates
|
|
58
|
-
if raw_item['@attr'] && raw_item['@attr']['nowplaying'] == 'true'
|
|
59
|
-
track_played_at = Time.now
|
|
60
|
-
now_playing = true
|
|
61
|
-
else
|
|
62
|
-
played_at = Time.parse(raw_item['date']['#text'])
|
|
63
|
-
now_playing = false
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
attributes = {
|
|
67
|
-
:name => raw_item['name'],
|
|
68
|
-
:artist => {
|
|
69
|
-
:name => raw_artist_info['name'],
|
|
70
|
-
:url => raw_artist_info['url']
|
|
71
|
-
},
|
|
72
|
-
:url => raw_item['url'],
|
|
73
|
-
:played_at => track_played_at,
|
|
74
|
-
:now_playing => now_playing
|
|
75
|
-
}
|
|
76
|
-
identifier = "/#{i}/"
|
|
77
|
-
mtime = nil
|
|
78
|
-
|
|
79
|
-
# Build item
|
|
80
|
-
Nanoc3::Item.new(content, attributes, identifier, mtime)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Nanoc3::DataSources
|
|
4
|
-
|
|
5
|
-
# @deprecated Fetch data from online data sources manually instead
|
|
6
|
-
class Twitter < Nanoc3::DataSource
|
|
7
|
-
|
|
8
|
-
def items
|
|
9
|
-
@item ||= begin
|
|
10
|
-
require 'json'
|
|
11
|
-
|
|
12
|
-
# Get data
|
|
13
|
-
@http_client ||= Nanoc3::Extra::CHiCk::Client.new
|
|
14
|
-
status, headers, data = *@http_client.get("http://twitter.com/statuses/user_timeline/#{self.config[:username]}.json")
|
|
15
|
-
|
|
16
|
-
# Parse as JSON
|
|
17
|
-
raw_items = JSON.parse(data)
|
|
18
|
-
|
|
19
|
-
# Convert to items
|
|
20
|
-
raw_items.enum_with_index.map do |raw_item, i|
|
|
21
|
-
# Get data
|
|
22
|
-
content = raw_item['text']
|
|
23
|
-
attributes = {
|
|
24
|
-
:created_at => raw_item['created_at'],
|
|
25
|
-
:source => raw_item['source']
|
|
26
|
-
}
|
|
27
|
-
identifier = "/#{raw_item['id']}/"
|
|
28
|
-
mtime = Time.parse(raw_item['created_at'])
|
|
29
|
-
|
|
30
|
-
# Build item
|
|
31
|
-
Nanoc3::Item.new(content, attributes, identifier, mtime)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|