nanoc 4.0.0a1 → 4.0.0a2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +9 -4
  3. data/NEWS.md +13 -0
  4. data/lib/nanoc/base.rb +2 -0
  5. data/lib/nanoc/base/compilation/compiler.rb +0 -1
  6. data/lib/nanoc/base/compilation/compiler_dsl.rb +21 -7
  7. data/lib/nanoc/base/compilation/item_rep_proxy.rb +10 -1
  8. data/lib/nanoc/base/compilation/rule.rb +10 -12
  9. data/lib/nanoc/base/compilation/rules_collection.rb +2 -2
  10. data/lib/nanoc/base/pattern.rb +63 -0
  11. data/lib/nanoc/base/source_data/data_source.rb +33 -18
  12. data/lib/nanoc/base/source_data/identifier.rb +65 -3
  13. data/lib/nanoc/base/source_data/item.rb +1 -1
  14. data/lib/nanoc/base/source_data/item_array.rb +17 -2
  15. data/lib/nanoc/base/source_data/layout.rb +1 -1
  16. data/lib/nanoc/base/source_data/site.rb +4 -3
  17. data/lib/nanoc/base/views/config.rb +22 -0
  18. data/lib/nanoc/base/views/item.rb +76 -0
  19. data/lib/nanoc/base/views/item_collection.rb +46 -4
  20. data/lib/nanoc/base/views/item_rep.rb +23 -0
  21. data/lib/nanoc/base/views/layout.rb +4 -0
  22. data/lib/nanoc/base/views/layout_collection.rb +7 -1
  23. data/lib/nanoc/base/views/mutable_config.rb +5 -0
  24. data/lib/nanoc/base/views/mutable_item.rb +15 -0
  25. data/lib/nanoc/base/views/mutable_item_collection.rb +25 -0
  26. data/lib/nanoc/base/views/mutable_layout.rb +5 -0
  27. data/lib/nanoc/base/views/mutable_layout_collection.rb +20 -2
  28. data/lib/nanoc/cli/cleaning_stream.rb +15 -0
  29. data/lib/nanoc/cli/commands/create-site.rb +17 -35
  30. data/lib/nanoc/cli/commands/shell.rb +7 -4
  31. data/lib/nanoc/data_sources.rb +0 -1
  32. data/lib/nanoc/data_sources/filesystem.rb +75 -76
  33. data/lib/nanoc/data_sources/filesystem_unified.rb +4 -27
  34. data/lib/nanoc/data_sources/filesystem_verbose.rb +4 -21
  35. data/lib/nanoc/version.rb +1 -1
  36. data/nanoc.gemspec +1 -1
  37. data/test/base/test_compiler.rb +35 -15
  38. data/test/base/test_compiler_dsl.rb +32 -30
  39. data/test/base/test_data_source.rb +2 -2
  40. data/test/base/test_item_array.rb +10 -1
  41. data/test/base/test_rule.rb +2 -2
  42. data/test/base/test_site.rb +32 -0
  43. data/test/cli/commands/test_create_site.rb +7 -1
  44. data/test/cli/commands/test_prune.rb +2 -2
  45. data/test/data_sources/test_filesystem.rb +29 -9
  46. data/test/data_sources/test_filesystem_unified.rb +48 -68
  47. data/test/helper.rb +1 -0
  48. data/test/helpers/test_breadcrumbs.rb +4 -4
  49. data/test/test_gem.rb +0 -1
  50. metadata +4 -5
  51. data/lib/nanoc/data_sources/static.rb +0 -62
  52. data/test/data_sources/test_static.rb +0 -93
@@ -19,6 +19,7 @@ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
19
19
  require 'nanoc'
20
20
  require 'nanoc/cli'
21
21
  require 'nanoc/tasks'
22
+ Nanoc::CLI.setup
22
23
 
23
24
  # Load miscellaneous requirements
24
25
  require 'tmpdir'
@@ -4,7 +4,7 @@ class Nanoc::Helpers::BreadcrumbsTest < Nanoc::TestCase
4
4
  include Nanoc::Helpers::Breadcrumbs
5
5
 
6
6
  def test_breadcrumbs_trail_at_root
7
- @items = Nanoc::Int::ItemArray.new
7
+ @items = Nanoc::Int::ItemArray.new({})
8
8
  @items << Nanoc::Int::Item.new('root', {}, '/')
9
9
  @item = @items.last
10
10
 
@@ -12,7 +12,7 @@ class Nanoc::Helpers::BreadcrumbsTest < Nanoc::TestCase
12
12
  end
13
13
 
14
14
  def test_breadcrumbs_trail_with_1_parent
15
- @items = Nanoc::Int::ItemArray.new
15
+ @items = Nanoc::Int::ItemArray.new({})
16
16
  @items << Nanoc::Int::Item.new('parent', {}, '/')
17
17
  @items << Nanoc::Int::Item.new('child', {}, '/foo/')
18
18
  @item = @items.last
@@ -21,7 +21,7 @@ class Nanoc::Helpers::BreadcrumbsTest < Nanoc::TestCase
21
21
  end
22
22
 
23
23
  def test_breadcrumbs_trail_with_many_parents
24
- @items = Nanoc::Int::ItemArray.new
24
+ @items = Nanoc::Int::ItemArray.new({})
25
25
  @items << Nanoc::Int::Item.new('grandparent', {}, '/')
26
26
  @items << Nanoc::Int::Item.new('parent', {}, '/foo/')
27
27
  @items << Nanoc::Int::Item.new('child', {}, '/foo/bar/')
@@ -31,7 +31,7 @@ class Nanoc::Helpers::BreadcrumbsTest < Nanoc::TestCase
31
31
  end
32
32
 
33
33
  def test_breadcrumbs_trail_with_nils
34
- @items = Nanoc::Int::ItemArray.new
34
+ @items = Nanoc::Int::ItemArray.new({})
35
35
  @items << Nanoc::Int::Item.new('grandparent', {}, '/')
36
36
  @items << Nanoc::Int::Item.new('child', {}, '/foo/bar/')
37
37
  @item = @items.last
@@ -25,7 +25,6 @@ class Nanoc::GemTest < Nanoc::TestCase
25
25
 
26
26
  # Check output
27
27
  assert_match(/Successfully built RubyGem\s+Name: nanoc\s+Version: .*\s+File: nanoc-.*\.gem\s+/, stdout.string)
28
- assert_equal '', stderr.string
29
28
  ensure
30
29
  Dir['nanoc-*.gem'].each { |f| FileUtils.rm(f) }
31
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0a1
4
+ version: 4.0.0a2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-09 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -98,6 +98,7 @@ files:
98
98
  - lib/nanoc/base/errors.rb
99
99
  - lib/nanoc/base/memoization.rb
100
100
  - lib/nanoc/base/notification_center.rb
101
+ - lib/nanoc/base/pattern.rb
101
102
  - lib/nanoc/base/plugin_registry.rb
102
103
  - lib/nanoc/base/result_data/item_rep.rb
103
104
  - lib/nanoc/base/source_data/code_snippet.rb
@@ -147,7 +148,6 @@ files:
147
148
  - lib/nanoc/data_sources/filesystem.rb
148
149
  - lib/nanoc/data_sources/filesystem_unified.rb
149
150
  - lib/nanoc/data_sources/filesystem_verbose.rb
150
- - lib/nanoc/data_sources/static.rb
151
151
  - lib/nanoc/extra.rb
152
152
  - lib/nanoc/extra/checking.rb
153
153
  - lib/nanoc/extra/checking/check.rb
@@ -265,7 +265,6 @@ files:
265
265
  - test/data_sources/test_filesystem.rb
266
266
  - test/data_sources/test_filesystem_unified.rb
267
267
  - test/data_sources/test_filesystem_verbose.rb
268
- - test/data_sources/test_static.rb
269
268
  - test/extra/checking/checks/test_css.rb
270
269
  - test/extra/checking/checks/test_external_links.rb
271
270
  - test/extra/checking/checks/test_html.rb
@@ -343,7 +342,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
343
342
  requirements:
344
343
  - - ">="
345
344
  - !ruby/object:Gem::Version
346
- version: 1.9.3
345
+ version: 2.0.0
347
346
  required_rubygems_version: !ruby/object:Gem::Requirement
348
347
  requirements:
349
348
  - - ">"
@@ -1,62 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc::DataSources
4
- # The static data source provides items from a single directory. Unlike the
5
- # filesystem data sources, static provides no additional item metadata. In
6
- # addition, all items are treated as 'binary', regardless of their extension
7
- # or content. As such, it is most useful for simple assets, not for normal
8
- # content.
9
- #
10
- # The identifier for static items is the full item path. For example, if your
11
- # static data source item_root is `static`, an item named `foo.css` would have
12
- # the identifier `/static/foo.css/`. Note that, unlike the filesystem data
13
- # sources, `foo/index.html` and `foo.yaml` receive no special treatment. They
14
- # are simple static items, just like `foo.css`.
15
- #
16
- # The default data source directory is `static/`, but this can be overridden
17
- # in the data source configuration:
18
- #
19
- # data_sources:
20
- # - type: static
21
- # prefix: assets
22
- #
23
- # Unless the `hide_items` configuration attribute is false, items from static
24
- # data sources will have the :is_hidden attribute set by default, which will
25
- # exclude them from the Blogging helper's atom feed generator, among other
26
- # things.
27
- #
28
- # @api private
29
- class Static < Nanoc::DataSource
30
- identifier :static
31
-
32
- def items
33
- # Get prefix
34
- prefix = config[:prefix] || 'static'
35
-
36
- # Convert filenames to items
37
- all_files_in(prefix).map do |filename|
38
- attributes = {
39
- extension: File.extname(filename)[1..-1],
40
- filename: filename,
41
- }
42
- attributes[:is_hidden] = true unless config[:hide_items] == false
43
- identifier = filename[(prefix.length + 1)..-1] + '/'
44
- mtime = File.mtime(filename)
45
- checksum = Pathname.new(filename).__nanoc_checksum
46
-
47
- Nanoc::Int::Item.new(
48
- filename,
49
- attributes,
50
- identifier,
51
- binary: true, mtime: mtime, checksum: checksum
52
- )
53
- end
54
- end
55
-
56
- protected
57
-
58
- def all_files_in(dir_name)
59
- Nanoc::Extra::FilesystemTools.all_files_in(dir_name, config[:extra_files])
60
- end
61
- end
62
- end
@@ -1,93 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc::DataSources::StaticTest < Nanoc::TestCase
4
- def new_data_source(params = nil)
5
- # Mock site
6
- site = Nanoc::Int::Site.new({})
7
-
8
- # Create data source
9
- data_source = Nanoc::DataSources::Static.new(site, nil, nil, params)
10
-
11
- # Done
12
- data_source
13
- end
14
-
15
- def test_items_with_symlinks
16
- skip_unless_symlinks_supported
17
-
18
- # Create data source
19
- data_source = new_data_source(prefix: 'foo')
20
-
21
- # Create sample files
22
- FileUtils.mkdir_p('foo')
23
- FileUtils.mkdir_p('foo-outside-1')
24
- FileUtils.mkdir_p('foo-outside-2')
25
- File.open('foo/a.png', 'w') { |io| io.write('random binary data') }
26
- File.open('foo-outside-1/b.png', 'w') { |io| io.write('more binary data') }
27
- File.open('foo-outside-2/c.png', 'w') { |io| io.write('yet more binary data') }
28
-
29
- # Create symlinks
30
- File.symlink('../foo-outside-1', 'foo/1')
31
- File.symlink('../foo-outside-2/c.png', 'foo/c.png')
32
-
33
- # Check all files
34
- expected_filenames = ['foo/a.png', 'foo/1/b.png', 'foo/c.png'].sort
35
- actual_filenames = Nanoc::Extra::FilesystemTools.all_files_in('foo', nil).sort
36
- assert_equal expected_filenames, actual_filenames
37
-
38
- # Check items
39
- items = data_source.send(:items).sort_by(&:identifier)
40
- actual_item_identifiers = items.map(&:identifier).map(&:to_s).sort
41
- expected_item_identifiers = %w( /a.png/ /1/b.png/ /c.png/ ).sort
42
- assert_equal expected_item_identifiers, actual_item_identifiers
43
- end
44
-
45
- def test_items
46
- # Create data source
47
- data_source = new_data_source(prefix: 'foo')
48
-
49
- # Create sample files
50
- FileUtils.mkdir_p('foo')
51
- FileUtils.mkdir_p('foo/a/b')
52
- File.open('foo/bar.png', 'w') { |io| io.write('random binary data') }
53
- File.open('foo/b.c.css', 'w') { |io| io.write('more binary data') }
54
- File.open('foo/a/b/c.gif', 'w') { |io| io.write('yet more binary data') }
55
-
56
- # Get expected and actual output
57
- expected_out = [
58
- Nanoc::Int::Item.new(
59
- 'foo/bar.png',
60
- { extension: 'png', filename: 'foo/bar.png' },
61
- '/bar.png/',
62
- binary: true,
63
- mtime: File.mtime('foo/bar.png'),
64
- checksum: Pathname.new('foo/bar.png').__nanoc_checksum
65
- ),
66
- Nanoc::Int::Item.new(
67
- 'foo/b.c.css',
68
- { extension: 'css', filename: 'foo/b.c.css' },
69
- '/b.c.css/',
70
- binary: true,
71
- mtime: File.mtime('foo/b.c.css'),
72
- checksum: Pathname.new('foo/b.c.css').__nanoc_checksum
73
- ),
74
- Nanoc::Int::Item.new(
75
- 'foo/a/b/c.gif',
76
- { extension: 'gif', filename: 'foo/a/b/c.gif' },
77
- '/a/b/c.gif/',
78
- binary: true,
79
- mtime: File.mtime('foo/a/b/c.gif'),
80
- checksum: Pathname.new('foo/a/b/c.gif').__nanoc_checksum
81
- )
82
- ].sort_by(&:identifier)
83
-
84
- actual_out = data_source.send(:items).sort_by(&:identifier)
85
-
86
- (0..expected_out.size - 1).each do |i|
87
- assert_equal expected_out[i].raw_content, actual_out[i].raw_content, 'content must match'
88
- assert_equal expected_out[i].identifier, actual_out[i].identifier, 'identifier must match'
89
- assert_equal expected_out[i].attributes[:mtime], actual_out[i].attributes[:mtime], 'mtime must match'
90
- assert_equal expected_out[i].raw_filename, actual_out[i].raw_filename, 'file paths must match'
91
- end
92
- end
93
- end