nanoc 4.0.0b4 → 4.0.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +31 -32
  4. data/NEWS.md +7 -0
  5. data/README.md +1 -2
  6. data/Rakefile +2 -11
  7. data/TODO.md +0 -1
  8. data/bin/nanoc +4 -0
  9. data/lib/nanoc/base/checksummer.rb +1 -1
  10. data/lib/nanoc/base/compilation/compiler.rb +7 -13
  11. data/lib/nanoc/base/compilation/dependency_tracker.rb +1 -1
  12. data/lib/nanoc/base/compilation/rule.rb +2 -0
  13. data/lib/nanoc/base/compilation/rules_collection.rb +2 -2
  14. data/lib/nanoc/base/entities/identifier.rb +45 -15
  15. data/lib/nanoc/base/entities/pattern.rb +8 -0
  16. data/lib/nanoc/base/entities/snapshot_def.rb +16 -0
  17. data/lib/nanoc/base/entities.rb +1 -0
  18. data/lib/nanoc/base/plugin_registry.rb +1 -1
  19. data/lib/nanoc/base/{compilation → repos}/checksum_store.rb +0 -0
  20. data/lib/nanoc/base/{compilation → repos}/compiled_content_cache.rb +0 -0
  21. data/lib/nanoc/base/repos/config_loader.rb +67 -0
  22. data/lib/nanoc/base/{compilation → repos}/rule_memory_store.rb +0 -0
  23. data/lib/nanoc/base/repos/site_loader.rb +118 -0
  24. data/lib/nanoc/base/{store.rb → repos/store.rb} +0 -0
  25. data/lib/nanoc/base/repos.rb +7 -0
  26. data/lib/nanoc/base/result_data/item_rep.rb +37 -66
  27. data/lib/nanoc/base/services/executor.rb +15 -9
  28. data/lib/nanoc/base/services/item_rep_writer.rb +1 -1
  29. data/lib/nanoc/base/services/recording_executor.rb +4 -4
  30. data/lib/nanoc/base/source_data/configuration.rb +89 -3
  31. data/lib/nanoc/base/source_data/data_source.rb +2 -15
  32. data/lib/nanoc/base/source_data/site.rb +14 -378
  33. data/lib/nanoc/base/views/{config.rb → config_view.rb} +0 -0
  34. data/lib/nanoc/base/views/{identifiable_collection.rb → identifiable_collection_view.rb} +0 -0
  35. data/lib/nanoc/base/views/{item_collection.rb → item_collection_view.rb} +0 -0
  36. data/lib/nanoc/base/views/{item_rep_collection.rb → item_rep_collection_view.rb} +7 -1
  37. data/lib/nanoc/base/views/{item_rep.rb → item_rep_view.rb} +0 -0
  38. data/lib/nanoc/base/views/{item.rb → item_view.rb} +0 -0
  39. data/lib/nanoc/base/views/{layout_collection.rb → layout_collection_view.rb} +0 -0
  40. data/lib/nanoc/base/views/{layout.rb → layout_view.rb} +0 -0
  41. data/lib/nanoc/base/views/mixins/{document.rb → document_view_mixin.rb} +0 -0
  42. data/lib/nanoc/base/views/mixins/{mutable_document.rb → mutable_document_view_mixin.rb} +0 -0
  43. data/lib/nanoc/base/views/{mutable_config.rb → mutable_config_view.rb} +0 -0
  44. data/lib/nanoc/base/views/{mutable_identifiable_collection.rb → mutable_identifiable_collection_view.rb} +0 -0
  45. data/lib/nanoc/base/views/{mutable_item_collection.rb → mutable_item_collection_view.rb} +0 -0
  46. data/lib/nanoc/base/views/{mutable_item.rb → mutable_item_view.rb} +0 -0
  47. data/lib/nanoc/base/views/{mutable_layout_collection.rb → mutable_layout_collection_view.rb} +0 -0
  48. data/lib/nanoc/base/views/{mutable_layout.rb → mutable_layout_view.rb} +0 -0
  49. data/lib/nanoc/base/views/{site.rb → site_view.rb} +0 -0
  50. data/lib/nanoc/base/views.rb +17 -17
  51. data/lib/nanoc/base.rb +1 -4
  52. data/lib/nanoc/cli/ansi_string_colorizer.rb +1 -1
  53. data/lib/nanoc/cli/cleaning_stream.rb +5 -0
  54. data/lib/nanoc/cli/command_runner.rb +10 -4
  55. data/lib/nanoc/cli/commands/compile.rb +1 -1
  56. data/lib/nanoc/cli/commands/create-site.rb +12 -11
  57. data/lib/nanoc/cli/commands/prune.rb +1 -0
  58. data/lib/nanoc/cli/commands/show-plugins.rb +4 -4
  59. data/lib/nanoc/cli/commands/show-rules.rb +21 -30
  60. data/lib/nanoc/cli/commands/view.rb +1 -1
  61. data/lib/nanoc/cli/error_handler.rb +1 -1
  62. data/lib/nanoc/cli.rb +3 -3
  63. data/lib/nanoc/data_sources/filesystem.rb +4 -4
  64. data/lib/nanoc/extra/checking/runner.rb +3 -2
  65. data/lib/nanoc/extra/deployers/rsync.rb +1 -1
  66. data/lib/nanoc/extra/link_collector.rb +1 -1
  67. data/lib/nanoc/helpers/capturing.rb +1 -1
  68. data/lib/nanoc/helpers/rendering.rb +2 -2
  69. data/lib/nanoc/version.rb +1 -1
  70. data/nanoc.gemspec +3 -4
  71. data/tasks/doc.rake +1 -1
  72. data/tasks/rubocop.rake +4 -8
  73. data/tasks/test.rake +11 -27
  74. data/test/base/test_compiler.rb +21 -16
  75. data/test/base/test_compiler_dsl.rb +8 -8
  76. data/test/base/test_item.rb +1 -1
  77. data/test/base/test_item_rep.rb +16 -14
  78. data/test/base/test_memoization.rb +1 -38
  79. data/test/base/test_outdatedness_checker.rb +38 -6
  80. data/test/base/test_site.rb +19 -121
  81. data/test/cli/commands/test_compile.rb +1 -1
  82. data/test/cli/commands/test_create_site.rb +7 -8
  83. data/test/data_sources/test_filesystem.rb +7 -7
  84. data/test/data_sources/test_filesystem_unified.rb +17 -17
  85. data/test/extra/checking/checks/test_mixed_content.rb +8 -8
  86. data/test/extra/checking/checks/test_stale.rb +3 -4
  87. data/test/extra/deployers/test_fog.rb +1 -1
  88. data/test/extra/deployers/test_rsync.rb +2 -2
  89. data/test/extra/test_filesystem_tools.rb +1 -1
  90. data/test/filters/test_erb.rb +1 -1
  91. data/test/filters/test_handlebars.rb +2 -2
  92. data/test/filters/test_less.rb +2 -2
  93. data/test/filters/test_mustache.rb +2 -2
  94. data/test/filters/test_relativize_paths.rb +1 -1
  95. data/test/filters/test_sass.rb +6 -6
  96. data/test/filters/test_xsl.rb +3 -3
  97. data/test/helper.rb +10 -15
  98. data/test/helpers/test_blogging.rb +16 -16
  99. data/test/helpers/test_capturing.rb +6 -6
  100. data/test/helpers/test_link_to.rb +13 -13
  101. data/test/helpers/test_rendering.rb +33 -0
  102. data/test/helpers/test_tagging.rb +8 -8
  103. metadata +32 -30
  104. data/test/gem_loader.rb +0 -9
@@ -24,18 +24,18 @@ string_pattern_type: glob
24
24
  # A list of file extensions that nanoc will consider to be textual rather than
25
25
  # binary. If an item with an extension not in this list is found, the file
26
26
  # will be considered as binary.
27
- text_extensions: #{array_to_yaml(Nanoc::Int::Site::DEFAULT_CONFIG[:text_extensions])}
27
+ text_extensions: #{array_to_yaml(Nanoc::Int::Configuration::DEFAULT_CONFIG[:text_extensions])}
28
28
 
29
29
  # The path to the directory where all generated files will be written to. This
30
30
  # can be an absolute path starting with a slash, but it can also be path
31
31
  # relative to the site directory.
32
- output_dir: #{Nanoc::Int::Site::DEFAULT_CONFIG[:output_dir]}
32
+ output_dir: #{Nanoc::Int::Configuration::DEFAULT_CONFIG[:output_dir]}
33
33
 
34
34
  # A list of index filenames, i.e. names of files that will be served by a web
35
35
  # server when a directory is requested. Usually, index files are named
36
36
  # “index.html”, but depending on the web server, this may be something else,
37
37
  # such as “default.htm”. This list is used by nanoc to generate pretty URLs.
38
- index_filenames: #{array_to_yaml(Nanoc::Int::Site::DEFAULT_CONFIG[:index_filenames])}
38
+ index_filenames: #{array_to_yaml(Nanoc::Int::Configuration::DEFAULT_CONFIG[:index_filenames])}
39
39
 
40
40
  # Whether or not to generate a diff of the compiled content when compiling a
41
41
  # site. The diff will contain the differences between the compiled content
@@ -59,18 +59,18 @@ prune:
59
59
  data_sources:
60
60
  -
61
61
  # The type is the identifier of the data source.
62
- type: #{Nanoc::Int::Site::DEFAULT_DATA_SOURCE_CONFIG[:type]}
62
+ type: #{Nanoc::Int::Configuration::DEFAULT_DATA_SOURCE_CONFIG[:type]}
63
63
 
64
64
  # The path where items should be mounted (comparable to mount points in
65
65
  # Unix-like systems). This is “/” by default, meaning that items will have
66
66
  # “/” prefixed to their identifiers. If the items root were “/en/”
67
67
  # instead, an item at content/about.html would have an identifier of
68
68
  # “/en/about/” instead of just “/about/”.
69
- items_root: #{Nanoc::Int::Site::DEFAULT_DATA_SOURCE_CONFIG[:items_root]}
69
+ items_root: #{Nanoc::Int::Configuration::DEFAULT_DATA_SOURCE_CONFIG[:items_root]}
70
70
 
71
71
  # The path where layouts should be mounted. The layouts root behaves the
72
72
  # same as the items root, but applies to layouts rather than items.
73
- layouts_root: #{Nanoc::Int::Site::DEFAULT_DATA_SOURCE_CONFIG[:layouts_root]}
73
+ layouts_root: #{Nanoc::Int::Configuration::DEFAULT_DATA_SOURCE_CONFIG[:layouts_root]}
74
74
 
75
75
  # The encoding to use for input files. If your input files are not in
76
76
  # UTF-8 (which they should be!), change this.
@@ -266,14 +266,15 @@ EOS
266
266
  <div id="sidebar">
267
267
  <h2>Documentation</h2>
268
268
  <ul>
269
- <li><a href="http://nanoc.ws/docs/">Documentation</a></li>
270
- <li><a href="http://nanoc.ws/docs/tutorial/">Getting Started</a></li>
269
+ <li><a href="http://v4.nanoc.ws/about/">About</a></li>
270
+ <li><a href="http://v4.nanoc.ws/doc/">Documentation</a></li>
271
+ <li><a href="http://v4.nanoc.ws/doc/tutorial/">Tutorial</a></li>
271
272
  </ul>
272
273
  <h2>Community</h2>
273
274
  <ul>
274
- <li><a href="http://groups.google.com/group/nanoc/">Discussion Group</a></li>
275
- <li><a href="irc://chat.freenode.net/#nanoc">IRC Channel</a></li>
276
- <li><a href="http://github.com/nanoc/nanoc/wiki/">Wiki</a></li>
275
+ <li><a href="http://groups.google.com/group/nanoc/">Discussion group</a></li>
276
+ <li><a href="irc://chat.freenode.net/#nanoc">IRC channel</a></li>
277
+ <li><a href="http://v4.nanoc.ws/contributing/">Contributing</a></li>
277
278
  </ul>
278
279
  </div>
279
280
  </body>
@@ -16,6 +16,7 @@ module Nanoc::CLI::Commands
16
16
  class Prune < ::Nanoc::CLI::CommandRunner
17
17
  def run
18
18
  load_site
19
+ site.compiler.load
19
20
 
20
21
  if options.key?(:yes)
21
22
  Nanoc::Extra::Pruner.new(site, exclude: prune_config_exclude).run
@@ -32,7 +32,7 @@ module Nanoc::CLI::Commands
32
32
  PLUGIN_CLASS_ORDER.each do |superclass|
33
33
  plugins_with_this_superclass = {
34
34
  builtin: plugins_builtin.select { |p| p[:superclass] == superclass },
35
- custom: plugins_custom.select { |p| p[:superclass] == superclass }
35
+ custom: plugins_custom.select { |p| p[:superclass] == superclass },
36
36
  }
37
37
 
38
38
  # Print kind
@@ -58,7 +58,7 @@ module Nanoc::CLI::Commands
58
58
  puts format(
59
59
  " %-#{max_identifiers_length}s (%s)",
60
60
  plugin[:identifiers].join(', '),
61
- plugin[:class].to_s.sub(/^::/, '')
61
+ plugin[:class].to_s.sub(/^::/, ''),
62
62
  )
63
63
  end
64
64
  end
@@ -72,13 +72,13 @@ module Nanoc::CLI::Commands
72
72
  PLUGIN_CLASS_ORDER = [
73
73
  Nanoc::Filter,
74
74
  Nanoc::DataSource,
75
- Nanoc::Extra::Deployer
75
+ Nanoc::Extra::Deployer,
76
76
  ] unless defined? PLUGIN_CLASS_ORDER
77
77
 
78
78
  PLUGIN_CLASSES = {
79
79
  Nanoc::Filter => 'Filters',
80
80
  Nanoc::DataSource => 'Data Sources',
81
- Nanoc::Extra::Deployer => 'Deployers'
81
+ Nanoc::Extra::Deployer => 'Deployers',
82
82
  } unless defined? PLUGIN_CLASSES
83
83
 
84
84
  def name_for_plugin_class(klass)
@@ -10,48 +10,39 @@ module Nanoc::CLI::Commands
10
10
  def run
11
11
  require_site
12
12
 
13
- @c = Nanoc::CLI::ANSIStringColorizer
14
- @calc = site.compiler.rule_memory_calculator
13
+ @c = Nanoc::CLI::ANSIStringColorizer
14
+ @rules = site.compiler.rules_collection
15
15
 
16
- # TODO: explain /foo/
17
- # TODO: explain content/foo.html
18
- # TODO: explain output/foo/index.html
19
-
20
- site.items.each { |i| explain_item(i) }
21
- site.layouts.each { |l| explain_layout(l) }
16
+ site.items.sort_by(&:identifier).each { |e| explain_item(e) }
17
+ site.layouts.sort_by(&:identifier).each { |e| explain_layout(e) }
22
18
  end
23
19
 
24
- protected
25
-
26
20
  def explain_item(item)
27
21
  puts "#{@c.c('Item ' + item.identifier, :bold, :yellow)}:"
28
- puts " (from #{item[:filename]})" if item[:filename]
22
+
29
23
  item.reps.each do |rep|
30
- puts " Rep #{rep.name}:"
31
- if @calc[rep].empty? && rep.raw_path.nil?
32
- puts ' (nothing)'
33
- else
34
- @calc[rep].each do |mem|
35
- puts format(' %s %s',
36
- @c.c(format('%-10s', mem[0].to_s), :blue),
37
- mem[1..-1].map(&:inspect).join(', '))
38
- end
39
- if rep.raw_path
40
- puts format(' %s %s',
41
- @c.c(format('%-10s', 'write to'), :blue),
42
- rep.raw_path)
43
- end
44
- end
24
+ rule = @rules.compilation_rule_for(rep)
25
+ puts " Rep #{rep.name}: #{rule ? rule.pattern : '(none)'}"
45
26
  end
27
+
46
28
  puts
47
29
  end
48
30
 
49
31
  def explain_layout(layout)
50
32
  puts "#{@c.c('Layout ' + layout.identifier, :bold, :yellow)}:"
51
- puts " (from #{layout[:filename]})" if layout[:filename]
52
- puts format(' %s %s',
53
- @c.c(format('%-10s', 'filter'), :blue),
54
- @calc[layout].map(&:inspect).join(', '))
33
+
34
+ found = false
35
+ @rules.layout_filter_mapping.each do |pattern, _|
36
+ if pattern.match?(layout.identifier)
37
+ puts " #{pattern}"
38
+ found = true
39
+ break
40
+ end
41
+ end
42
+ unless found
43
+ puts ' (none)'
44
+ end
45
+
55
46
  puts
56
47
  end
57
48
  end
@@ -24,7 +24,7 @@ module Nanoc::CLI::Commands
24
24
  # Set options
25
25
  options_for_rack = {
26
26
  Port: (options[:port] || 3000).to_i,
27
- Host: (options[:host] || '0.0.0.0')
27
+ Host: (options[:host] || '0.0.0.0'),
28
28
  }
29
29
 
30
30
  # Get handler
@@ -207,7 +207,7 @@ module Nanoc::CLI
207
207
  'redcloth' => 'RedCloth',
208
208
  'rubypants' => 'rubypants',
209
209
  'sass' => 'sass',
210
- 'w3c_validators' => 'w3c_validators'
210
+ 'w3c_validators' => 'w3c_validators',
211
211
  }
212
212
 
213
213
  # Attempts to find a resolution for the given error, or nil if no
data/lib/nanoc/cli.rb CHANGED
@@ -116,9 +116,9 @@ module Nanoc::CLI
116
116
  #
117
117
  # @return [void]
118
118
  def self.load_custom_commands
119
- if Nanoc::Int::Site.cwd_is_nanoc_site?
120
- site = Nanoc::Int::Site.new('.')
121
- site.config[:commands_dirs].each do |path|
119
+ if Nanoc::Int::SiteLoader.cwd_is_nanoc_site?
120
+ config = Nanoc::Int::ConfigLoader.new.new_from_cwd
121
+ config[:commands_dirs].each do |path|
122
122
  load_commands_at(path)
123
123
  end
124
124
  end
@@ -54,7 +54,7 @@ module Nanoc::DataSources
54
54
  content_filename = filename_for(base_filename, content_ext)
55
55
 
56
56
  # Read content and metadata
57
- is_binary = content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1])
57
+ is_binary = content_filename && !@site_config[:text_extensions].include?(File.extname(content_filename)[1..-1])
58
58
  if is_binary && klass == Nanoc::Int::Item
59
59
  meta = (meta_filename && YAML.load_file(meta_filename)) || {}
60
60
  content_or_filename = content_filename
@@ -169,7 +169,7 @@ module Nanoc::DataSources
169
169
  # basename before concatenating it with a period and the extension).
170
170
  def filename_for(_base_filename, _ext)
171
171
  raise NotImplementedError.new(
172
- "#{self.class} does not implement #filename_for"
172
+ "#{self.class} does not implement #filename_for",
173
173
  )
174
174
  end
175
175
 
@@ -177,7 +177,7 @@ module Nanoc::DataSources
177
177
  # can be the content filename or the meta filename.
178
178
  def identifier_for_filename(_filename)
179
179
  raise NotImplementedError.new(
180
- "#{self.class} does not implement #identifier_for_filename"
180
+ "#{self.class} does not implement #identifier_for_filename",
181
181
  )
182
182
  end
183
183
 
@@ -234,7 +234,7 @@ module Nanoc::DataSources
234
234
  pieces = data.split(/^(-{5}|-{3})[ \t]*\r?\n?/, 3)
235
235
  if pieces.size < 4
236
236
  raise RuntimeError.new(
237
- "The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format."
237
+ "The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format.",
238
238
  )
239
239
  end
240
240
 
@@ -62,8 +62,6 @@ module Nanoc::Extra::Checking
62
62
  run_check_classes(check_classes_named(check_class_names))
63
63
  end
64
64
 
65
- protected
66
-
67
65
  def load_dsl_if_available
68
66
  @dsl_loaded ||= false
69
67
  unless @dsl_loaded
@@ -108,6 +106,9 @@ module Nanoc::Extra::Checking
108
106
  def run_checks(classes)
109
107
  return [] if classes.empty?
110
108
 
109
+ # TODO: remove me
110
+ @site.compiler.load
111
+
111
112
  checks = []
112
113
  issues = Set.new
113
114
  length = classes.map { |c| c.identifier.to_s.length }.max + 18
@@ -32,7 +32,7 @@ module Nanoc::Extra::Deployers
32
32
  '--compress',
33
33
  '--exclude=".hg"',
34
34
  '--exclude=".svn"',
35
- '--exclude=".git"'
35
+ '--exclude=".git"',
36
36
  ]
37
37
 
38
38
  # @see Nanoc::Extra::Deployer#run
@@ -11,7 +11,7 @@ module ::Nanoc::Extra
11
11
  'img' => :src,
12
12
  'link' => :href,
13
13
  'script' => :src,
14
- 'video' => :src
14
+ 'video' => :src,
15
15
  }
16
16
 
17
17
  def initialize(filenames, mode = nil)
@@ -113,7 +113,7 @@ module Nanoc::Helpers
113
113
  @site.unwrap.captures_store_compiled_items << item
114
114
  item.forced_outdated = true
115
115
  item.reps.each do |r|
116
- r.content_snapshots = { last: item.content }
116
+ r.snapshot_contents = { last: item.content }
117
117
  raise Nanoc::Int::Errors::UnmetDependency.new(r)
118
118
  end
119
119
  end
@@ -92,10 +92,10 @@ module Nanoc::Helpers
92
92
  item: @item,
93
93
  item_rep: @item_rep,
94
94
  items: @items,
95
- layout: Nanoc::LayoutView.new(layout), # FIXME: this does not need to be rewrapped
95
+ layout: layout,
96
96
  layouts: @layouts,
97
97
  config: @config,
98
- site: @site
98
+ site: @site,
99
99
  }.merge(other_assigns)
100
100
 
101
101
  # Get filter name
data/lib/nanoc/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Nanoc
2
2
  # The current nanoc version.
3
- VERSION = '4.0.0b4'
3
+ VERSION = '4.0.0rc1'
4
4
  end
data/nanoc.gemspec CHANGED
@@ -1,12 +1,11 @@
1
- $LOAD_PATH.unshift(File.expand_path('../lib/', __FILE__))
2
- require 'nanoc/version'
1
+ require_relative 'lib/nanoc/version'
3
2
 
4
3
  Gem::Specification.new do |s|
5
4
  s.name = 'nanoc'
6
5
  s.version = Nanoc::VERSION
7
6
  s.homepage = 'http://nanoc.ws/'
8
- s.summary = 'a web publishing system written in Ruby for building small to medium-sized websites.'
9
- 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.'
7
+ s.summary = 'A static-site generator with a focus on flexibility.'
8
+ s.description = 'nanoc is a static-site generator focused on flexibility. It transforms content from a format such as Markdown or AsciiDoc into another format, usually HTML, and lays out pages consistently to retain the site’s look and feel throughout. Static sites built with nanoc can be deployed to any web server.'
10
9
 
11
10
  s.author = 'Denis Defreyne'
12
11
  s.email = 'denis.defreyne@stoneship.org'
data/tasks/doc.rake CHANGED
@@ -11,6 +11,6 @@ YARD::Rake::YardocTask.new(:doc) do |yard|
11
11
  '--output-dir', 'doc/yardoc',
12
12
  '--template-path', 'doc/yardoc_templates',
13
13
  '--load', 'doc/yardoc_handlers/identifier.rb',
14
- '--query', '@api.text != "private"',
14
+ '--query', '@api.text != "private"'
15
15
  ]
16
16
  end
data/tasks/rubocop.rake CHANGED
@@ -1,10 +1,6 @@
1
- begin
2
- require 'rubocop/rake_task'
1
+ require 'rubocop/rake_task'
3
2
 
4
- RuboCop::RakeTask.new(:rubocop) do |task|
5
- task.options = %w( --display-cop-names --format simple )
6
- task.patterns = ['lib/**/*.rb']
7
- end
8
- rescue LoadError
9
- warn 'Could not load RuboCop. RuboCop rake tasks will be unavailable.'
3
+ RuboCop::RakeTask.new(:rubocop) do |task|
4
+ task.options = %w( --display-cop-names --format simple )
5
+ task.patterns = ['lib/**/*.rb']
10
6
  end
data/tasks/test.rake CHANGED
@@ -1,33 +1,17 @@
1
1
  require 'rspec/core/rake_task'
2
+ require 'rake/testtask'
3
+ require 'coveralls/rake/task'
2
4
 
3
- def run_tests(dir_glob)
4
- ENV['ARGS'] ||= ''
5
- ENV['QUIET'] ||= 'true'
5
+ Coveralls::RakeTask.new
6
6
 
7
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
8
-
9
- # require our test helper so we don't have to in each individual test
10
- require 'test/helper'
11
-
12
- test_files = Dir["#{dir_glob}*_spec.rb"] + Dir["#{dir_glob}test_*.rb"]
13
- test_files.each { |f| require f }
14
-
15
- res = Minitest.run(ENV['ARGS'].split)
16
- exit(res) if res != 0
17
- end
7
+ SUBDIRS = %w( * base cli data_sources extra filters helpers )
18
8
 
19
9
  namespace :test do
20
- # test:all
21
- desc 'Run all tests'
22
- task :all do
23
- run_tests 'test/**/'
24
- end
25
-
26
- # test:...
27
- %w( base cli data_sources extra filters helpers ).each do |dir|
28
- desc "Run all #{dir} tests"
29
- task dir.to_sym do |_task|
30
- run_tests "test/#{dir}/**/"
10
+ SUBDIRS.each do |dir|
11
+ Rake::TestTask.new(dir == '*' ? 'all' : dir) do |t|
12
+ t.test_files = Dir["test/#{dir}/**/*_spec.rb"] + Dir["test/#{dir}/**/test_*.rb"]
13
+ t.libs = ['./lib', '.']
14
+ t.ruby_opts = ['-r./test/helper']
31
15
  end
32
16
  end
33
17
  end
@@ -37,5 +21,5 @@ RSpec::Core::RakeTask.new(:spec) do |t|
37
21
  t.verbose = false
38
22
  end
39
23
 
40
- desc 'Alias for test:all + rubocop'
41
- task test: [:spec, :'test:all', :rubocop]
24
+ desc 'Run all tests and specs'
25
+ task test: [:spec, :'test:all', :'coveralls:push']
@@ -116,7 +116,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
116
116
  0 => 'd',
117
117
  1 => 'b', # never used! not c, because b takes priority
118
118
  2 => 'b',
119
- 3 => 'a'
119
+ 3 => 'a',
120
120
  }
121
121
 
122
122
  # Check
@@ -137,7 +137,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
137
137
  raw: 'raw.txt',
138
138
  pre: 'pre.txt',
139
139
  post: 'post.txt',
140
- last: 'last.txt'
140
+ last: 'last.txt',
141
141
  }
142
142
 
143
143
  # Create rule
@@ -190,6 +190,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
190
190
  with_site do |site|
191
191
  File.open('content/index.html', 'w') { |io| io.write('o hello') }
192
192
 
193
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
193
194
  site.compile
194
195
 
195
196
  assert Dir['output/*'].size == 1
@@ -203,6 +204,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
203
204
  File.open('content/foo.html', 'w') { |io| io.write('o hai') }
204
205
  File.open('content/bar.html', 'w') { |io| io.write('o bai') }
205
206
 
207
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
206
208
  site.compile
207
209
 
208
210
  assert Dir['output/*'].size == 2
@@ -222,6 +224,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
222
224
  io.write('manatee')
223
225
  end
224
226
 
227
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
225
228
  site.compile
226
229
 
227
230
  assert Dir['output/*'].size == 2
@@ -241,6 +244,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
241
244
  io.write('<%= @items.find { |i| i.identifier == "/foo/" }.compiled_content %>')
242
245
  end
243
246
 
247
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
244
248
  assert_raises Nanoc::Int::Errors::RecursiveCompilation do
245
249
  site.compile
246
250
  end
@@ -266,7 +270,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
266
270
  end
267
271
 
268
272
  # Create site
269
- site = Nanoc::Int::Site.new('.')
273
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
270
274
  error = assert_raises(RuntimeError) do
271
275
  site.compile
272
276
  end
@@ -279,7 +283,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
279
283
  Nanoc::CLI.run %w( create_site bar)
280
284
 
281
285
  FileUtils.cd('bar') do
282
- site = Nanoc::Int::Site.new('.')
286
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
283
287
 
284
288
  compiler = Nanoc::Int::Compiler.new(site)
285
289
  def compiler.route_reps
@@ -299,7 +303,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
299
303
  FileUtils.cd('bar') do
300
304
  Nanoc::CLI.run %w( compile )
301
305
 
302
- site = Nanoc::Int::Site.new('.')
306
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
303
307
  site.compile
304
308
 
305
309
  # At this point, even the already compiled items in the previous pass
@@ -328,7 +332,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
328
332
  end
329
333
 
330
334
  # Compile
331
- site = Nanoc::Int::Site.new('.')
335
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
332
336
  assert_raises Nanoc::Int::Errors::CannotCreateMultipleSnapshotsWithSameName do
333
337
  site.compile
334
338
  end
@@ -358,7 +362,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
358
362
  end
359
363
 
360
364
  # Compile
361
- site = Nanoc::Int::Site.new('.')
365
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
362
366
  site.compile
363
367
 
364
368
  # Check
@@ -391,7 +395,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
391
395
  end
392
396
 
393
397
  # Compile
394
- site = Nanoc::Int::Site.new('.')
398
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
395
399
  site.compile
396
400
 
397
401
  # Check
@@ -421,7 +425,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
421
425
  end
422
426
 
423
427
  # Compile
424
- site = Nanoc::Int::Site.new('.')
428
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
425
429
  site.compile
426
430
 
427
431
  # Check
@@ -454,7 +458,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
454
458
  end
455
459
 
456
460
  # Compile
457
- site = Nanoc::Int::Site.new('.')
461
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
458
462
  site.compile
459
463
 
460
464
  # Check
@@ -475,7 +479,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
475
479
  end
476
480
 
477
481
  # Compile
478
- site = Nanoc::Int::Site.new('.')
482
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
479
483
  site.compile
480
484
 
481
485
  # Check
@@ -506,7 +510,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
506
510
  end
507
511
 
508
512
  # Compile
509
- site = Nanoc::Int::Site.new('.')
513
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
510
514
  site.compile
511
515
 
512
516
  # Check
@@ -529,7 +533,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
529
533
  io.write "layout '*', :erb\n"
530
534
  end
531
535
 
532
- site = Nanoc::Int::Site.new('.')
536
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
533
537
  site.compile
534
538
 
535
539
  assert_equal Set.new(%w( content/blah.dat )), Set.new(Dir['content/*'])
@@ -545,7 +549,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
545
549
  end
546
550
 
547
551
  # Compile
548
- site = Nanoc::Int::Site.new('.')
552
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
549
553
  site.compile
550
554
 
551
555
  # Check
@@ -573,7 +577,8 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
573
577
  io.write "layout '*', :erb\n"
574
578
  end
575
579
 
576
- site = Nanoc::Int::Site.new('.')
580
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
581
+ site.compiler.load
577
582
  rep = site.items['/a/'].reps[0]
578
583
  dt = site.compiler.dependency_tracker
579
584
  dt.start
@@ -602,7 +607,7 @@ class Nanoc::Int::CompilerTest < Nanoc::TestCase
602
607
  io.write "layout '/**/*', :erb\n"
603
608
  end
604
609
 
605
- site = Nanoc::Int::Site.new('.')
610
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
606
611
  site.compile
607
612
  end
608
613
  end
@@ -41,7 +41,7 @@ class Nanoc::Int::CompilerDSLTest < Nanoc::TestCase
41
41
  File.open('more_rules.rb', 'w') { |io| io.write "preprocess { @items['/foo/'][:preprocessed] = true }" }
42
42
 
43
43
  # Create other necessary stuff
44
- site = Nanoc::Int::Site.new('.')
44
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
45
45
  site.items << item
46
46
  dsl = site.compiler.rules_collection.dsl
47
47
  io = capturing_stdio do
@@ -76,7 +76,7 @@ class Nanoc::Int::CompilerDSLTest < Nanoc::TestCase
76
76
  File.open('more_rules.rb', 'w') { |io| io.write "passthrough '/foo/'" }
77
77
 
78
78
  # Create other necessary stuff
79
- site = Nanoc::Int::Site.new('.')
79
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
80
80
  site.items << item
81
81
  dsl = site.compiler.rules_collection.dsl
82
82
 
@@ -107,7 +107,7 @@ EOS
107
107
  end
108
108
 
109
109
  # Compile
110
- site = Nanoc::Int::Site.new('.')
110
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
111
111
  site.compile
112
112
 
113
113
  # Check paths
@@ -131,7 +131,7 @@ EOS
131
131
  end
132
132
 
133
133
  # Compile
134
- site = Nanoc::Int::Site.new('.')
134
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
135
135
  site.compile
136
136
 
137
137
  # Check paths
@@ -163,7 +163,7 @@ EOS
163
163
  end
164
164
 
165
165
  # Compile
166
- site = Nanoc::Int::Site.new('.')
166
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
167
167
  site.compile
168
168
 
169
169
  # Check paths
@@ -194,7 +194,7 @@ EOS
194
194
  end
195
195
 
196
196
  # Compile
197
- site = Nanoc::Int::Site.new('.')
197
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
198
198
  site.compile
199
199
 
200
200
  # Check paths
@@ -224,7 +224,7 @@ EOS
224
224
  end
225
225
 
226
226
  # Compile
227
- site = Nanoc::Int::Site.new('.')
227
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
228
228
  site.compile
229
229
 
230
230
  # Check paths
@@ -256,7 +256,7 @@ EOS
256
256
  end
257
257
 
258
258
  # Compile
259
- site = Nanoc::Int::Site.new('.')
259
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
260
260
  site.compile
261
261
 
262
262
  # Check paths