nanoc 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. data/.gemtest +0 -0
  2. data/ChangeLog +3 -0
  3. data/Gemfile +32 -0
  4. data/LICENSE +19 -0
  5. data/NEWS.md +470 -0
  6. data/README.md +114 -0
  7. data/Rakefile +14 -0
  8. data/bin/nanoc +7 -27
  9. data/bin/nanoc3 +3 -0
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
  11. data/lib/nanoc.rb +41 -0
  12. data/lib/nanoc/base.rb +49 -0
  13. data/lib/nanoc/base/compilation/checksum_store.rb +57 -0
  14. data/lib/nanoc/base/compilation/compiled_content_cache.rb +62 -0
  15. data/lib/nanoc/base/compilation/compiler.rb +458 -0
  16. data/lib/nanoc/base/compilation/compiler_dsl.rb +214 -0
  17. data/lib/nanoc/base/compilation/dependency_tracker.rb +200 -0
  18. data/lib/nanoc/base/compilation/filter.rb +165 -0
  19. data/lib/nanoc/base/compilation/item_rep_proxy.rb +103 -0
  20. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +102 -0
  21. data/lib/nanoc/base/compilation/outdatedness_checker.rb +223 -0
  22. data/lib/nanoc/base/compilation/outdatedness_reasons.rb +46 -0
  23. data/lib/nanoc/base/compilation/rule.rb +73 -0
  24. data/lib/nanoc/base/compilation/rule_context.rb +84 -0
  25. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +40 -0
  26. data/lib/nanoc/base/compilation/rule_memory_store.rb +53 -0
  27. data/lib/nanoc/base/compilation/rules_collection.rb +243 -0
  28. data/lib/nanoc/base/context.rb +47 -0
  29. data/lib/nanoc/base/core_ext.rb +6 -0
  30. data/lib/nanoc/base/core_ext/array.rb +62 -0
  31. data/lib/nanoc/base/core_ext/hash.rb +63 -0
  32. data/lib/nanoc/base/core_ext/pathname.rb +26 -0
  33. data/lib/nanoc/base/core_ext/string.rb +46 -0
  34. data/lib/nanoc/base/directed_graph.rb +275 -0
  35. data/lib/nanoc/base/errors.rb +211 -0
  36. data/lib/nanoc/base/memoization.rb +67 -0
  37. data/lib/nanoc/base/notification_center.rb +84 -0
  38. data/lib/nanoc/base/ordered_hash.rb +200 -0
  39. data/lib/nanoc/base/plugin_registry.rb +181 -0
  40. data/lib/nanoc/base/result_data/item_rep.rb +492 -0
  41. data/lib/nanoc/base/source_data/code_snippet.rb +58 -0
  42. data/lib/nanoc/base/source_data/configuration.rb +24 -0
  43. data/lib/nanoc/base/source_data/data_source.rb +234 -0
  44. data/lib/nanoc/base/source_data/item.rb +301 -0
  45. data/lib/nanoc/base/source_data/layout.rb +130 -0
  46. data/lib/nanoc/base/source_data/site.rb +361 -0
  47. data/lib/nanoc/base/store.rb +135 -0
  48. data/lib/nanoc/cli.rb +137 -0
  49. data/lib/nanoc/cli/command_runner.rb +104 -0
  50. data/lib/nanoc/cli/commands/autocompile.rb +58 -0
  51. data/lib/nanoc/cli/commands/compile.rb +297 -0
  52. data/lib/nanoc/cli/commands/create_item.rb +60 -0
  53. data/lib/nanoc/cli/commands/create_layout.rb +73 -0
  54. data/lib/nanoc/cli/commands/create_site.rb +411 -0
  55. data/lib/nanoc/cli/commands/debug.rb +117 -0
  56. data/lib/nanoc/cli/commands/deploy.rb +79 -0
  57. data/lib/nanoc/cli/commands/info.rb +98 -0
  58. data/lib/nanoc/cli/commands/nanoc.rb +38 -0
  59. data/lib/nanoc/cli/commands/prune.rb +50 -0
  60. data/lib/nanoc/cli/commands/update.rb +70 -0
  61. data/lib/nanoc/cli/commands/view.rb +82 -0
  62. data/lib/nanoc/cli/commands/watch.rb +124 -0
  63. data/lib/nanoc/cli/error_handler.rb +199 -0
  64. data/lib/nanoc/cli/logger.rb +92 -0
  65. data/lib/nanoc/data_sources.rb +29 -0
  66. data/lib/nanoc/data_sources/deprecated/delicious.rb +42 -0
  67. data/lib/nanoc/data_sources/deprecated/last_fm.rb +87 -0
  68. data/lib/nanoc/data_sources/deprecated/twitter.rb +38 -0
  69. data/lib/nanoc/data_sources/filesystem.rb +299 -0
  70. data/lib/nanoc/data_sources/filesystem_unified.rb +121 -0
  71. data/lib/nanoc/data_sources/filesystem_verbose.rb +91 -0
  72. data/lib/nanoc/extra.rb +24 -0
  73. data/lib/nanoc/extra/auto_compiler.rb +103 -0
  74. data/lib/nanoc/extra/chick.rb +125 -0
  75. data/lib/nanoc/extra/core_ext.rb +6 -0
  76. data/lib/nanoc/extra/core_ext/enumerable.rb +33 -0
  77. data/lib/nanoc/extra/core_ext/pathname.rb +30 -0
  78. data/lib/nanoc/extra/core_ext/time.rb +19 -0
  79. data/lib/nanoc/extra/deployer.rb +47 -0
  80. data/lib/nanoc/extra/deployers.rb +15 -0
  81. data/lib/nanoc/extra/deployers/fog.rb +98 -0
  82. data/lib/nanoc/extra/deployers/rsync.rb +70 -0
  83. data/lib/nanoc/extra/file_proxy.rb +40 -0
  84. data/lib/nanoc/extra/pruner.rb +86 -0
  85. data/lib/nanoc/extra/validators.rb +12 -0
  86. data/lib/nanoc/extra/validators/links.rb +268 -0
  87. data/lib/nanoc/extra/validators/w3c.rb +95 -0
  88. data/lib/nanoc/extra/vcs.rb +66 -0
  89. data/lib/nanoc/extra/vcses.rb +17 -0
  90. data/lib/nanoc/extra/vcses/bazaar.rb +25 -0
  91. data/lib/nanoc/extra/vcses/dummy.rb +24 -0
  92. data/lib/nanoc/extra/vcses/git.rb +25 -0
  93. data/lib/nanoc/extra/vcses/mercurial.rb +25 -0
  94. data/lib/nanoc/extra/vcses/subversion.rb +25 -0
  95. data/lib/nanoc/filters.rb +59 -0
  96. data/lib/nanoc/filters/asciidoc.rb +38 -0
  97. data/lib/nanoc/filters/bluecloth.rb +19 -0
  98. data/lib/nanoc/filters/coderay.rb +21 -0
  99. data/lib/nanoc/filters/coffeescript.rb +20 -0
  100. data/lib/nanoc/filters/colorize_syntax.rb +298 -0
  101. data/lib/nanoc/filters/erb.rb +38 -0
  102. data/lib/nanoc/filters/erubis.rb +34 -0
  103. data/lib/nanoc/filters/haml.rb +27 -0
  104. data/lib/nanoc/filters/kramdown.rb +20 -0
  105. data/lib/nanoc/filters/less.rb +53 -0
  106. data/lib/nanoc/filters/markaby.rb +20 -0
  107. data/lib/nanoc/filters/maruku.rb +20 -0
  108. data/lib/nanoc/filters/mustache.rb +24 -0
  109. data/lib/nanoc/filters/rainpress.rb +19 -0
  110. data/lib/nanoc/filters/rdiscount.rb +22 -0
  111. data/lib/nanoc/filters/rdoc.rb +33 -0
  112. data/lib/nanoc/filters/redcarpet.rb +62 -0
  113. data/lib/nanoc/filters/redcloth.rb +47 -0
  114. data/lib/nanoc/filters/relativize_paths.rb +94 -0
  115. data/lib/nanoc/filters/rubypants.rb +20 -0
  116. data/lib/nanoc/filters/sass.rb +74 -0
  117. data/lib/nanoc/filters/slim.rb +25 -0
  118. data/lib/nanoc/filters/typogruby.rb +23 -0
  119. data/lib/nanoc/filters/uglify_js.rb +42 -0
  120. data/lib/nanoc/filters/xsl.rb +46 -0
  121. data/lib/nanoc/filters/yui_compressor.rb +23 -0
  122. data/lib/nanoc/helpers.rb +16 -0
  123. data/lib/nanoc/helpers/blogging.rb +319 -0
  124. data/lib/nanoc/helpers/breadcrumbs.rb +40 -0
  125. data/lib/nanoc/helpers/capturing.rb +138 -0
  126. data/lib/nanoc/helpers/filtering.rb +50 -0
  127. data/lib/nanoc/helpers/html_escape.rb +55 -0
  128. data/lib/nanoc/helpers/link_to.rb +151 -0
  129. data/lib/nanoc/helpers/rendering.rb +140 -0
  130. data/lib/nanoc/helpers/tagging.rb +71 -0
  131. data/lib/nanoc/helpers/text.rb +44 -0
  132. data/lib/nanoc/helpers/xml_sitemap.rb +76 -0
  133. data/lib/nanoc/tasks.rb +10 -0
  134. data/lib/nanoc/tasks/clean.rake +16 -0
  135. data/lib/nanoc/tasks/clean.rb +29 -0
  136. data/lib/nanoc/tasks/deploy/rsync.rake +16 -0
  137. data/lib/nanoc/tasks/validate.rake +92 -0
  138. data/nanoc.gemspec +49 -0
  139. data/tasks/doc.rake +16 -0
  140. data/tasks/test.rake +46 -0
  141. data/test/base/core_ext/array_spec.rb +73 -0
  142. data/test/base/core_ext/hash_spec.rb +98 -0
  143. data/test/base/core_ext/pathname_spec.rb +27 -0
  144. data/test/base/core_ext/string_spec.rb +37 -0
  145. data/test/base/test_checksum_store.rb +35 -0
  146. data/test/base/test_code_snippet.rb +31 -0
  147. data/test/base/test_compiler.rb +403 -0
  148. data/test/base/test_compiler_dsl.rb +161 -0
  149. data/test/base/test_context.rb +31 -0
  150. data/test/base/test_data_source.rb +46 -0
  151. data/test/base/test_dependency_tracker.rb +262 -0
  152. data/test/base/test_directed_graph.rb +288 -0
  153. data/test/base/test_filter.rb +83 -0
  154. data/test/base/test_item.rb +179 -0
  155. data/test/base/test_item_rep.rb +579 -0
  156. data/test/base/test_layout.rb +59 -0
  157. data/test/base/test_memoization.rb +90 -0
  158. data/test/base/test_notification_center.rb +34 -0
  159. data/test/base/test_outdatedness_checker.rb +394 -0
  160. data/test/base/test_plugin.rb +30 -0
  161. data/test/base/test_rule.rb +19 -0
  162. data/test/base/test_rule_context.rb +65 -0
  163. data/test/base/test_site.rb +190 -0
  164. data/test/cli/commands/test_compile.rb +33 -0
  165. data/test/cli/commands/test_create_item.rb +14 -0
  166. data/test/cli/commands/test_create_layout.rb +28 -0
  167. data/test/cli/commands/test_create_site.rb +24 -0
  168. data/test/cli/commands/test_deploy.rb +74 -0
  169. data/test/cli/commands/test_help.rb +12 -0
  170. data/test/cli/commands/test_info.rb +11 -0
  171. data/test/cli/commands/test_prune.rb +98 -0
  172. data/test/cli/commands/test_update.rb +10 -0
  173. data/test/cli/test_cli.rb +102 -0
  174. data/test/cli/test_error_handler.rb +29 -0
  175. data/test/cli/test_logger.rb +10 -0
  176. data/test/data_sources/test_filesystem.rb +433 -0
  177. data/test/data_sources/test_filesystem_unified.rb +536 -0
  178. data/test/data_sources/test_filesystem_verbose.rb +357 -0
  179. data/test/extra/core_ext/test_enumerable.rb +30 -0
  180. data/test/extra/core_ext/test_pathname.rb +17 -0
  181. data/test/extra/core_ext/test_time.rb +15 -0
  182. data/test/extra/deployers/test_fog.rb +67 -0
  183. data/test/extra/deployers/test_rsync.rb +100 -0
  184. data/test/extra/test_auto_compiler.rb +417 -0
  185. data/test/extra/test_file_proxy.rb +19 -0
  186. data/test/extra/test_vcs.rb +22 -0
  187. data/test/extra/validators/test_links.rb +62 -0
  188. data/test/extra/validators/test_w3c.rb +47 -0
  189. data/test/filters/test_asciidoc.rb +22 -0
  190. data/test/filters/test_bluecloth.rb +18 -0
  191. data/test/filters/test_coderay.rb +44 -0
  192. data/test/filters/test_coffeescript.rb +18 -0
  193. data/test/filters/test_colorize_syntax.rb +379 -0
  194. data/test/filters/test_erb.rb +105 -0
  195. data/test/filters/test_erubis.rb +78 -0
  196. data/test/filters/test_haml.rb +96 -0
  197. data/test/filters/test_kramdown.rb +18 -0
  198. data/test/filters/test_less.rb +113 -0
  199. data/test/filters/test_markaby.rb +24 -0
  200. data/test/filters/test_maruku.rb +18 -0
  201. data/test/filters/test_mustache.rb +25 -0
  202. data/test/filters/test_rainpress.rb +29 -0
  203. data/test/filters/test_rdiscount.rb +31 -0
  204. data/test/filters/test_rdoc.rb +18 -0
  205. data/test/filters/test_redcarpet.rb +73 -0
  206. data/test/filters/test_redcloth.rb +33 -0
  207. data/test/filters/test_relativize_paths.rb +533 -0
  208. data/test/filters/test_rubypants.rb +18 -0
  209. data/test/filters/test_sass.rb +229 -0
  210. data/test/filters/test_slim.rb +35 -0
  211. data/test/filters/test_typogruby.rb +21 -0
  212. data/test/filters/test_uglify_js.rb +30 -0
  213. data/test/filters/test_xsl.rb +105 -0
  214. data/test/filters/test_yui_compressor.rb +44 -0
  215. data/test/gem_loader.rb +11 -0
  216. data/test/helper.rb +207 -0
  217. data/test/helpers/test_blogging.rb +754 -0
  218. data/test/helpers/test_breadcrumbs.rb +81 -0
  219. data/test/helpers/test_capturing.rb +41 -0
  220. data/test/helpers/test_filtering.rb +106 -0
  221. data/test/helpers/test_html_escape.rb +32 -0
  222. data/test/helpers/test_link_to.rb +249 -0
  223. data/test/helpers/test_rendering.rb +89 -0
  224. data/test/helpers/test_tagging.rb +87 -0
  225. data/test/helpers/test_text.rb +24 -0
  226. data/test/helpers/test_xml_sitemap.rb +103 -0
  227. data/test/tasks/test_clean.rb +67 -0
  228. metadata +327 -15
  229. data/bin/nanoc-select +0 -86
  230. data/lib/nanoc-select.rb +0 -11
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc::Helpers
4
+
5
+ # Provides support for managing tags added to items.
6
+ #
7
+ # To add tags to items, set the `tags` attribute to an array of tags that
8
+ # should be applied to the item.
9
+ #
10
+ # @example Adding tags to an item
11
+ #
12
+ # tags: [ 'foo', 'bar', 'baz' ]
13
+ module Tagging
14
+
15
+ require 'nanoc/helpers/html_escape'
16
+ include Nanoc::Helpers::HTMLEscape
17
+
18
+ # Returns a formatted list of tags for the given item as a string. The
19
+ # tags will be linked using the {#link_for_tag} function; the
20
+ # HTML-escaping rules for {#link_for_tag} apply here as well.
21
+ #
22
+ # @option params [String] base_url ("http://technorati.com/tag/") The URL
23
+ # to which the tag will be appended to construct the link URL. This URL
24
+ # must have a trailing slash.
25
+ #
26
+ # @option params [String] none_text ("(none)") The text to display when
27
+ # the item has no tags
28
+ #
29
+ # @option params [String] separator (", ") The separator to put between
30
+ # tags
31
+ #
32
+ # @return [String] A hyperlinked list of tags for the given item
33
+ def tags_for(item, params={})
34
+ base_url = params[:base_url] || 'http://technorati.com/tag/'
35
+ none_text = params[:none_text] || '(none)'
36
+ separator = params[:separator] || ', '
37
+
38
+ if item[:tags].nil? or item[:tags].empty?
39
+ none_text
40
+ else
41
+ item[:tags].map { |tag| link_for_tag(tag, base_url) }.join(separator)
42
+ end
43
+ end
44
+
45
+ # Find all items with the given tag.
46
+ #
47
+ # @param [String] tag The tag for which to find all items
48
+ #
49
+ # @return [Array] All items with the given tag
50
+ def items_with_tag(tag)
51
+ @items.select { |i| (i[:tags] || []).include?(tag) }
52
+ end
53
+
54
+ # Returns a link to to the specified tag. The link is marked up using the
55
+ # rel-tag microformat. The `href` attribute of the link will be HTML-
56
+ # escaped, as will the content of the `a` element.
57
+ #
58
+ # @param [String] tag The name of the tag, which should consist of letters
59
+ # and numbers (no spaces, slashes, or other special characters).
60
+ #
61
+ # @param [String] base_url The URL to which the tag will be appended to
62
+ # construct the link URL. This URL must have a trailing slash.
63
+ #
64
+ # @return [String] A link for the given tag and the given base URL
65
+ def link_for_tag(tag, base_url)
66
+ %[<a href="#{h base_url}#{h tag}" rel="tag">#{h tag}</a>]
67
+ end
68
+
69
+ end
70
+
71
+ end
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc::Helpers
4
+
5
+ # Contains several useful text-related helper functions.
6
+ module Text
7
+
8
+ # Returns an excerpt for the given string. HTML tags are ignored, so if
9
+ # you don't want them to turn up, they should be stripped from the string
10
+ # before passing it to the excerpt function.
11
+ #
12
+ # @param [String] string The string for which to build an excerpt
13
+ #
14
+ # @option params [Number] length (25) The maximum number of characters
15
+ # this excerpt can contain, including the omission.
16
+ #
17
+ # @option params [String] omission ("...") The string to append to the
18
+ # excerpt when the excerpt is shorter than the original string
19
+ #
20
+ # @return [String] The excerpt of the given string
21
+ def excerptize(string, params={})
22
+ # Initialize params
23
+ params[:length] ||= 25
24
+ params[:omission] ||= '...'
25
+
26
+ # Get excerpt
27
+ length = params[:length] - params[:omission].length
28
+ length = 0 if length < 0
29
+ (string.length > params[:length] ? string[0...length] + params[:omission] : string)
30
+ end
31
+
32
+ # Strips all HTML tags out of the given string.
33
+ #
34
+ # @param [String] string The string from which to strip all HTML
35
+ #
36
+ # @return [String] The given string with all HTML stripped
37
+ def strip_html(string)
38
+ # FIXME will need something more sophisticated than this, because it sucks
39
+ string.gsub(/<[^>]*(>+|\s*\z)/m, '').strip
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc::Helpers
4
+
5
+ # Contains functionality for building XML sitemaps that will be crawled by
6
+ # search engines. See the [Sitemaps protocol site](http://www.sitemaps.org)
7
+ # for details.
8
+ module XMLSitemap
9
+
10
+ # Builds an XML sitemap and returns it.
11
+ #
12
+ # The following attributes can optionally be set on items to change the
13
+ # behaviour of the sitemap:
14
+ #
15
+ # * `changefreq` — The estimated change frequency as defined by the
16
+ # Sitemaps protocol
17
+ #
18
+ # * `priority` — The item's priority, ranging from 0.0 to 1.0, as defined
19
+ # by the Sitemaps protocol
20
+ #
21
+ # The sitemap will also include dates on which the items were updated.
22
+ # These are generated automatically; the way this happens depends on the
23
+ # used data source (the filesystem data source checks the file mtimes, for
24
+ # instance).
25
+ #
26
+ # The site configuration will need to have the following attributes:
27
+ #
28
+ # * `base_url` — The URL to the site, without trailing slash. For example,
29
+ # if the site is at "http://example.com/", the `base_url` would be
30
+ # "http://example.com".
31
+ #
32
+ # @example Excluding binary items from the sitemap
33
+ #
34
+ # <%= xml_sitemap :items => @items.reject{ |i| i[:is_hidden] || i[:binary] } %>
35
+ #
36
+ # @option params [Array] :items A list of items to include in the sitemap
37
+ #
38
+ # @return [String] The XML sitemap
39
+ def xml_sitemap(params={})
40
+ require 'builder'
41
+
42
+ # Extract parameters
43
+ items = params[:items] || @items.reject { |i| i[:is_hidden] }
44
+
45
+ # Create builder
46
+ buffer = ''
47
+ xml = Builder::XmlMarkup.new(:target => buffer, :indent => 2)
48
+
49
+ # Check for required attributes
50
+ if @site.config[:base_url].nil?
51
+ raise RuntimeError.new("The Nanoc::Helpers::XMLSitemap helper requires the site configuration to specify the base URL for the site.")
52
+ end
53
+
54
+ # Build sitemap
55
+ xml.instruct!
56
+ xml.urlset(:xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9') do
57
+ # Add item
58
+ items.each do |item|
59
+ item.reps.reject { |r| r.raw_path.nil? }.each do |rep|
60
+ xml.url do
61
+ xml.loc @site.config[:base_url] + rep.path
62
+ xml.lastmod item.mtime.to_iso8601_date unless item.mtime.nil?
63
+ xml.changefreq item[:changefreq] unless item[:changefreq].nil?
64
+ xml.priority item[:priority] unless item[:priority].nil?
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ # Return sitemap
71
+ buffer
72
+ end
73
+
74
+ end
75
+
76
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require 'nanoc'
4
+ require 'rake'
5
+
6
+ module Nanoc::Tasks
7
+ end
8
+
9
+ Dir[File.dirname(__FILE__) + '/tasks/**/*.rb'].each { |f| load f }
10
+ Dir[File.dirname(__FILE__) + '/tasks/**/*.rake'].each { |f| Rake.application.add_import(f) }
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ desc 'Remove output files generated by nanoc'
4
+ task :clean do
5
+ # Load site
6
+ site = Nanoc::Site.new('.')
7
+ if site.nil?
8
+ $stderr.puts 'The current working directory does not seem to be a ' +
9
+ 'valid/complete nanoc site directory; aborting.'
10
+ exit 1
11
+ end
12
+
13
+ # Clean
14
+ clean = ::Nanoc::Tasks::Clean.new(site)
15
+ clean.run
16
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc::Tasks
4
+
5
+ class Clean
6
+
7
+ def initialize(site)
8
+ @site = site
9
+ end
10
+
11
+ def run
12
+ filenames.each do |filename|
13
+ FileUtils.rm_f filename unless filename.nil?
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def filenames
20
+ @site.items.map do |item|
21
+ item.reps.map do |rep|
22
+ rep.raw_path
23
+ end
24
+ end.flatten
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ namespace :deploy do
4
+
5
+ desc 'Upload the compiled site using rsync'
6
+ task :rsync do
7
+ dry_run = !!ENV['dry_run']
8
+ config_name = ENV['config'] || :default
9
+
10
+ cmd = [ 'deploy', '-t', config_name ]
11
+ cmd << '-n' if dry_run
12
+
13
+ Nanoc::CLI.run cmd
14
+ end
15
+
16
+ end
@@ -0,0 +1,92 @@
1
+ # encoding: utf-8
2
+
3
+ namespace :validate do
4
+
5
+ desc 'Validate the site’s HTML files'.make_compatible_with_env
6
+ task :html do
7
+ # Get output directory
8
+ site = Nanoc::Site.new('.')
9
+ if site.nil?
10
+ $stderr.puts 'The current working directory does not seem to be a ' +
11
+ 'valid/complete nanoc site directory; aborting.'
12
+ exit 1
13
+ end
14
+ dir = site.config[:output_dir]
15
+
16
+ # Validate
17
+ validator = ::Nanoc::Extra::Validators::W3C.new(dir, [ :html ])
18
+ validator.run
19
+ end
20
+
21
+ desc 'Validate the site’s CSS files'.make_compatible_with_env
22
+ task :css do
23
+ # Get output directory
24
+ site = Nanoc::Site.new('.')
25
+ if site.nil?
26
+ $stderr.puts 'The current working directory does not seem to be a ' +
27
+ 'valid/complete nanoc site directory; aborting.'
28
+ exit 1
29
+ end
30
+ dir = site.config[:output_dir]
31
+
32
+ # Validate
33
+ validator = ::Nanoc::Extra::Validators::W3C.new(dir, [ :css ])
34
+ validator.run
35
+ end
36
+
37
+ namespace :links do
38
+
39
+ desc 'Validate the site’s internal links'.make_compatible_with_env
40
+ task :internal do
41
+ # Get output directory
42
+ site = Nanoc::Site.new('.')
43
+ if site.nil?
44
+ $stderr.puts 'The current working directory does not seem to be a ' +
45
+ 'valid/complete nanoc site directory; aborting.'
46
+ exit 1
47
+ end
48
+ dir = site.config[:output_dir]
49
+ index_filenames = site.config[:index_filenames]
50
+
51
+ # Validate
52
+ validator = ::Nanoc::Extra::Validators::Links.new(dir, index_filenames, :internal => true)
53
+ validator.run
54
+ end
55
+
56
+ desc 'Validate the site’s internal links'.make_compatible_with_env
57
+ task :external do
58
+ # Get output directory
59
+ site = Nanoc::Site.new('.')
60
+ if site.nil?
61
+ $stderr.puts 'The current working directory does not seem to be a ' +
62
+ 'valid/complete nanoc site directory; aborting.'
63
+ exit 1
64
+ end
65
+ dir = site.config[:output_dir]
66
+ index_filenames = site.config[:index_filenames]
67
+
68
+ # Validate
69
+ validator = ::Nanoc::Extra::Validators::Links.new(dir, index_filenames, :external => true)
70
+ validator.run
71
+ end
72
+
73
+ end
74
+
75
+ desc 'Validate the site’s internal and external links'.make_compatible_with_env
76
+ task :links do
77
+ # Get output directory
78
+ site = Nanoc::Site.new('.')
79
+ if site.nil?
80
+ $stderr.puts 'The current working directory does not seem to be a ' +
81
+ 'valid/complete nanoc site directory; aborting.'
82
+ exit 1
83
+ end
84
+ dir = site.config[:output_dir]
85
+ index_filenames = site.config[:index_filenames]
86
+
87
+ # Validate
88
+ validator = ::Nanoc::Extra::Validators::Links.new(dir, index_filenames, :internal => true, :external => true)
89
+ validator.run
90
+ end
91
+
92
+ end
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ $LOAD_PATH.unshift(File.expand_path('../lib/', __FILE__))
4
+ require 'nanoc'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'nanoc'
8
+ s.version = Nanoc::VERSION
9
+ s.homepage = 'http://nanoc.stoneship.org/'
10
+ s.summary = 'a web publishing system written in Ruby for building small to medium-sized websites.'
11
+ s.description = 'nanoc is a simple but very flexible static site generator written in Ruby. It operates on local files, and therefore does not run on the server. nanoc “compiles” the local source files into HTML (usually), by evaluating eRuby, Markdown, etc.'
12
+
13
+ s.author = 'Denis Defreyne'
14
+ s.email = 'denis.defreyne@stoneship.org'
15
+
16
+ s.files = Dir['[A-Z]*'] +
17
+ Dir['doc/yardoc_templates/**/*'] +
18
+ Dir['{bin,lib,tasks,test}/**/*'] +
19
+ [ 'nanoc.gemspec', '.gemtest' ]
20
+ s.executables = [ 'nanoc', 'nanoc3' ]
21
+ s.require_paths = [ 'lib' ]
22
+
23
+ s.rdoc_options = [ '--main', 'README.md' ]
24
+ s.extra_rdoc_files = [ 'ChangeLog', 'LICENSE', 'README.md', 'NEWS.md' ]
25
+
26
+ s.add_runtime_dependency('cri', '~> 2.1')
27
+
28
+ s.add_development_dependency('minitest')
29
+ s.add_development_dependency('mocha')
30
+ s.add_development_dependency('rake')
31
+ s.add_development_dependency('rdiscount')
32
+ s.add_development_dependency('yard')
33
+
34
+ s.post_install_message = %q{------------------------------------------------------------------------------
35
+ Thanks for installing nanoc 3.3! Here are some resources to help you get
36
+ started:
37
+
38
+ * The web site at <http://nanoc.stoneship.org/>
39
+ * The tutorial at <http://nanoc.stoneship.org/docs/3-getting-started/>
40
+ * The manual at <http://nanoc.stoneship.org/docs/4-basic-concepts/>
41
+
42
+ If you have questions, issues or simply want to share ideas, join the
43
+ discussion at <http://groups.google.com/group/nanoc> or stop by in the IRC
44
+ channel on irc.freenode.net, channel #nanoc. See you there!
45
+
46
+ Enjoy!
47
+ ------------------------------------------------------------------------------
48
+ }
49
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yard'
4
+
5
+ YARD::Rake::YardocTask.new(:doc) do |yard|
6
+ yard.files = Dir['lib/**/*.rb']
7
+ yard.options = [
8
+ '--markup', 'markdown',
9
+ '--markup-provider', 'kramdown',
10
+ '--charset', 'utf-8',
11
+ '--readme', 'README.md',
12
+ '--files', 'NEWS.md,LICENSE',
13
+ '--output-dir', 'doc/yardoc',
14
+ '--template-path', 'doc/yardoc_templates'
15
+ ]
16
+ end
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ require 'minitest/unit'
4
+
5
+ test = namespace :test do
6
+
7
+ # test:all
8
+ desc 'Run all tests'
9
+ task :all do
10
+ ENV['QUIET'] ||= 'true'
11
+ $VERBOSE = (ENV['VERBOSE'] == 'true')
12
+
13
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
14
+
15
+ # require our test helper so we don't have to in each individual test
16
+ require 'test/helper'
17
+
18
+ test_files = Dir['test/**/*_spec.rb'] + Dir['test/**/test_*.rb']
19
+ test_files.each { |f| require f }
20
+
21
+ MiniTest::Unit.new.run($VERBOSE ? %w( --verbose ) : %w())
22
+ end
23
+
24
+ # test:...
25
+ %w( base cli data_sources extra filters helpers tasks ).each do |dir|
26
+ desc "Run all #{dir} tests"
27
+ task dir.to_sym do |task|
28
+ ENV['QUIET'] ||= 'true'
29
+ $VERBOSE = (ENV['VERBOSE'] == 'true')
30
+
31
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
32
+
33
+ # require our test helper so we don't have to in each individual test
34
+ require 'test/helper'
35
+
36
+ test_files = Dir["test/#{dir}/**/*_spec.rb"] + Dir["test/#{dir}/**/test_*.rb"]
37
+ test_files.each { |f| require f }
38
+
39
+ MiniTest::Unit.new.run($VERBOSE ? %w( --verbose ) : %w())
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ desc 'Alias for test:all'
46
+ task :test => [ :'test:all' ]