nanoc3 3.1.7 → 3.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
 - data/LICENSE +1 -1
 - data/NEWS.md +9 -0
 - data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
 - data/lib/nanoc3/base/item.rb +1 -1
 - data/lib/nanoc3/base/item_rep.rb +1 -0
 - data/lib/nanoc3/base/layout.rb +1 -1
 - data/lib/nanoc3/cli/base.rb +4 -2
 - data/lib/nanoc3/cli/commands/view.rb +1 -0
 - data/lib/nanoc3/data_sources/filesystem.rb +25 -6
 - data/lib/nanoc3/data_sources/filesystem_unified.rb +5 -5
 - data/lib/nanoc3/extra/validators/links.rb +1 -1
 - data/lib/nanoc3/filters/rdiscount.rb +2 -1
 - data/lib/nanoc3/filters/sass.rb +20 -8
 - data/lib/nanoc3/filters/sass.rb.orig +75 -0
 - data/lib/nanoc3.rb +1 -1
 - data/nanoc3.gemspec +41 -0
 - data/tasks/clean.rake +11 -0
 - data/tasks/doc.rake +14 -0
 - data/tasks/gem.rake +13 -0
 - data/tasks/test.rake +38 -0
 - data/test/base/core_ext/array_spec.rb +23 -0
 - data/test/base/core_ext/hash_spec.rb +41 -0
 - data/test/base/core_ext/string_spec.rb +27 -0
 - data/test/base/test_code_snippet.rb +33 -0
 - data/test/base/test_compiler.rb +410 -0
 - data/test/base/test_compiler_dsl.rb +121 -0
 - data/test/base/test_context.rb +33 -0
 - data/test/base/test_data_source.rb +48 -0
 - data/test/base/test_dependency_tracker.rb +510 -0
 - data/test/base/test_directed_graph.rb +91 -0
 - data/test/base/test_filter.rb +85 -0
 - data/test/base/test_item.rb +141 -0
 - data/test/base/test_item_rep.rb +953 -0
 - data/test/base/test_layout.rb +44 -0
 - data/test/base/test_notification_center.rb +36 -0
 - data/test/base/test_plugin.rb +32 -0
 - data/test/base/test_rule.rb +21 -0
 - data/test/base/test_rule_context.rb +63 -0
 - data/test/base/test_site.rb +366 -0
 - data/test/cli/commands/test_compile.rb +12 -0
 - data/test/cli/commands/test_create_item.rb +12 -0
 - data/test/cli/commands/test_create_layout.rb +28 -0
 - data/test/cli/commands/test_create_site.rb +24 -0
 - data/test/cli/commands/test_help.rb +12 -0
 - data/test/cli/commands/test_info.rb +12 -0
 - data/test/cli/commands/test_update.rb +12 -0
 - data/test/cli/test_logger.rb +12 -0
 - data/test/data_sources/test_filesystem.rb +420 -0
 - data/test/data_sources/test_filesystem_unified.rb +538 -0
 - data/test/data_sources/test_filesystem_verbose.rb +359 -0
 - data/test/extra/core_ext/test_enumerable.rb +32 -0
 - data/test/extra/core_ext/test_time.rb +17 -0
 - data/test/extra/deployers/test_rsync.rb +234 -0
 - data/test/extra/test_auto_compiler.rb +482 -0
 - data/test/extra/test_file_proxy.rb +21 -0
 - data/test/extra/test_vcs.rb +24 -0
 - data/test/extra/validators/test_links.rb +53 -0
 - data/test/extra/validators/test_w3c.rb +49 -0
 - data/test/filters/test_bluecloth.rb +20 -0
 - data/test/filters/test_coderay.rb +46 -0
 - data/test/filters/test_colorize_syntax.rb +56 -0
 - data/test/filters/test_erb.rb +72 -0
 - data/test/filters/test_erubis.rb +72 -0
 - data/test/filters/test_haml.rb +98 -0
 - data/test/filters/test_kramdown.rb +20 -0
 - data/test/filters/test_less.rb +59 -0
 - data/test/filters/test_markaby.rb +26 -0
 - data/test/filters/test_maruku.rb +20 -0
 - data/test/filters/test_rainpress.rb +31 -0
 - data/test/filters/test_rdiscount.rb +33 -0
 - data/test/filters/test_rdoc.rb +18 -0
 - data/test/filters/test_redcloth.rb +20 -0
 - data/test/filters/test_relativize_paths.rb +231 -0
 - data/test/filters/test_rubypants.rb +20 -0
 - data/test/filters/test_sass.rb +170 -0
 - data/test/filters/test_sass.rb.orig +103 -0
 - data/test/gem_loader.rb +11 -0
 - data/test/helper.rb +99 -0
 - data/test/helpers/test_blogging.rb +808 -0
 - data/test/helpers/test_breadcrumbs.rb +83 -0
 - data/test/helpers/test_capturing.rb +42 -0
 - data/test/helpers/test_filtering.rb +108 -0
 - data/test/helpers/test_html_escape.rb +18 -0
 - data/test/helpers/test_link_to.rb +251 -0
 - data/test/helpers/test_rendering.rb +109 -0
 - data/test/helpers/test_tagging.rb +89 -0
 - data/test/helpers/test_text.rb +26 -0
 - data/test/helpers/test_xml_sitemap.rb +69 -0
 - data/test/tasks/test_clean.rb +71 -0
 - metadata +83 -8
 
| 
         @@ -0,0 +1,359 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'test/helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class Nanoc3::DataSources::FilesystemVerboseTest < MiniTest::Unit::TestCase
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              include Nanoc3::TestHelpers
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def new_data_source(params=nil)
         
     | 
| 
      
 10 
     | 
    
         
            +
                # Mock site
         
     | 
| 
      
 11 
     | 
    
         
            +
                site = Nanoc3::Site.new({})
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                # Create data source
         
     | 
| 
      
 14 
     | 
    
         
            +
                data_source = Nanoc3::DataSources::FilesystemVerbose.new(site, nil, nil, params)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                # Done
         
     | 
| 
      
 17 
     | 
    
         
            +
                data_source
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def test_items
         
     | 
| 
      
 21 
     | 
    
         
            +
                # Create data source
         
     | 
| 
      
 22 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                # Create foo item
         
     | 
| 
      
 25 
     | 
    
         
            +
                FileUtils.mkdir_p('content/foo')
         
     | 
| 
      
 26 
     | 
    
         
            +
                File.open('content/foo/foo.yaml', 'w') do |io|
         
     | 
| 
      
 27 
     | 
    
         
            +
                  io.write("---\n")
         
     | 
| 
      
 28 
     | 
    
         
            +
                  io.write("title: Foo\n")
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
                File.open('content/foo/foo.html', 'w') do |io|
         
     | 
| 
      
 31 
     | 
    
         
            +
                  io.write('Lorem ipsum dolor sit amet...')
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                # Create bar item
         
     | 
| 
      
 35 
     | 
    
         
            +
                FileUtils.mkdir_p('content/bar')
         
     | 
| 
      
 36 
     | 
    
         
            +
                File.open('content/bar/bar.yaml', 'w') do |io|
         
     | 
| 
      
 37 
     | 
    
         
            +
                  io.write("---\n")
         
     | 
| 
      
 38 
     | 
    
         
            +
                  io.write("title: Bar\n")
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
                File.open('content/bar/bar.xml', 'w') do |io|
         
     | 
| 
      
 41 
     | 
    
         
            +
                  io.write("Lorem ipsum dolor sit amet...")
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                # Load items
         
     | 
| 
      
 45 
     | 
    
         
            +
                items = data_source.items
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                # Check items
         
     | 
| 
      
 48 
     | 
    
         
            +
                assert_equal(2, items.size)
         
     | 
| 
      
 49 
     | 
    
         
            +
                assert(items.any? { |a|
         
     | 
| 
      
 50 
     | 
    
         
            +
                  a[:title]            == 'Foo' &&
         
     | 
| 
      
 51 
     | 
    
         
            +
                  a[:extension]        == 'html' &&
         
     | 
| 
      
 52 
     | 
    
         
            +
                  a[:content_filename] == 'content/foo/foo.html' &&
         
     | 
| 
      
 53 
     | 
    
         
            +
                  a[:meta_filename]    == 'content/foo/foo.yaml'
         
     | 
| 
      
 54 
     | 
    
         
            +
                })
         
     | 
| 
      
 55 
     | 
    
         
            +
                assert(items.any? { |a|
         
     | 
| 
      
 56 
     | 
    
         
            +
                  a[:title]            == 'Bar' &&
         
     | 
| 
      
 57 
     | 
    
         
            +
                  a[:extension]        == 'xml' &&
         
     | 
| 
      
 58 
     | 
    
         
            +
                  a[:content_filename] == 'content/bar/bar.xml' &&
         
     | 
| 
      
 59 
     | 
    
         
            +
                  a[:meta_filename]    == 'content/bar/bar.yaml'
         
     | 
| 
      
 60 
     | 
    
         
            +
                })
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              def test_items_with_period_in_name
         
     | 
| 
      
 64 
     | 
    
         
            +
                data_source = new_data_source(:allow_periods_in_identifiers => true)
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                # Create foo.css
         
     | 
| 
      
 67 
     | 
    
         
            +
                FileUtils.mkdir_p('content/foo')
         
     | 
| 
      
 68 
     | 
    
         
            +
                File.open('content/foo/foo.yaml', 'w') do |io|
         
     | 
| 
      
 69 
     | 
    
         
            +
                  io.write(YAML.dump({ 'title' => 'Foo' }))
         
     | 
| 
      
 70 
     | 
    
         
            +
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
                File.open('content/foo/foo.css', 'w') do |io|
         
     | 
| 
      
 72 
     | 
    
         
            +
                  io.write('body.foo {}')
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
                
         
     | 
| 
      
 75 
     | 
    
         
            +
                # Create foo.bar.css
         
     | 
| 
      
 76 
     | 
    
         
            +
                FileUtils.mkdir_p('content/foo.bar')
         
     | 
| 
      
 77 
     | 
    
         
            +
                File.open('content/foo.bar/foo.bar.yaml', 'w') do |io|
         
     | 
| 
      
 78 
     | 
    
         
            +
                  io.write(YAML.dump({ 'title' => 'Foo Bar' }))
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
                File.open('content/foo.bar/foo.bar.css', 'w') do |io|
         
     | 
| 
      
 81 
     | 
    
         
            +
                  io.write('body.foobar {}')
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
                
         
     | 
| 
      
 84 
     | 
    
         
            +
                # Load
         
     | 
| 
      
 85 
     | 
    
         
            +
                items = data_source.items
         
     | 
| 
      
 86 
     | 
    
         
            +
                
         
     | 
| 
      
 87 
     | 
    
         
            +
                # Check
         
     | 
| 
      
 88 
     | 
    
         
            +
                assert_equal 2, items.size
         
     | 
| 
      
 89 
     | 
    
         
            +
                assert_equal '/foo/',                        items[0].identifier
         
     | 
| 
      
 90 
     | 
    
         
            +
                assert_equal 'Foo',                          items[0][:title]
         
     | 
| 
      
 91 
     | 
    
         
            +
                assert_equal 'content/foo/foo.css',          items[0][:content_filename]
         
     | 
| 
      
 92 
     | 
    
         
            +
                assert_equal 'content/foo/foo.yaml',         items[0][:meta_filename]
         
     | 
| 
      
 93 
     | 
    
         
            +
                assert_equal '/foo.bar/',                    items[1].identifier
         
     | 
| 
      
 94 
     | 
    
         
            +
                assert_equal 'Foo Bar',                      items[1][:title]
         
     | 
| 
      
 95 
     | 
    
         
            +
                assert_equal 'content/foo.bar/foo.bar.css',  items[1][:content_filename]
         
     | 
| 
      
 96 
     | 
    
         
            +
                assert_equal 'content/foo.bar/foo.bar.yaml', items[1][:meta_filename]
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              def test_items_with_optional_meta_file
         
     | 
| 
      
 100 
     | 
    
         
            +
                # Create data source
         
     | 
| 
      
 101 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                # Create foo item
         
     | 
| 
      
 104 
     | 
    
         
            +
                FileUtils.mkdir_p('content/foo')
         
     | 
| 
      
 105 
     | 
    
         
            +
                File.open('content/foo/foo.html', 'w') do |io|
         
     | 
| 
      
 106 
     | 
    
         
            +
                  io.write('Lorem ipsum dolor sit amet...')
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                # Create bar item
         
     | 
| 
      
 110 
     | 
    
         
            +
                FileUtils.mkdir_p('content/bar')
         
     | 
| 
      
 111 
     | 
    
         
            +
                File.open('content/bar/bar.yaml', 'w') do |io|
         
     | 
| 
      
 112 
     | 
    
         
            +
                  io.write("---\n")
         
     | 
| 
      
 113 
     | 
    
         
            +
                  io.write("title: Bar\n")
         
     | 
| 
      
 114 
     | 
    
         
            +
                end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                # Load items
         
     | 
| 
      
 117 
     | 
    
         
            +
                items = data_source.items
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                # Check items
         
     | 
| 
      
 120 
     | 
    
         
            +
                assert_equal(2, items.size)
         
     | 
| 
      
 121 
     | 
    
         
            +
                assert(items.any? { |a|
         
     | 
| 
      
 122 
     | 
    
         
            +
                  a[:title]            == nil &&
         
     | 
| 
      
 123 
     | 
    
         
            +
                  a[:extension]        == 'html' &&
         
     | 
| 
      
 124 
     | 
    
         
            +
                  a[:content_filename] == 'content/foo/foo.html' &&
         
     | 
| 
      
 125 
     | 
    
         
            +
                  a[:meta_filename]    == nil
         
     | 
| 
      
 126 
     | 
    
         
            +
                })
         
     | 
| 
      
 127 
     | 
    
         
            +
                assert(items.any? { |a|
         
     | 
| 
      
 128 
     | 
    
         
            +
                  a[:title]            == 'Bar' &&
         
     | 
| 
      
 129 
     | 
    
         
            +
                  a[:extension]        == nil &&
         
     | 
| 
      
 130 
     | 
    
         
            +
                  a[:content_filename] == nil &&
         
     | 
| 
      
 131 
     | 
    
         
            +
                  a[:meta_filename]    == 'content/bar/bar.yaml'
         
     | 
| 
      
 132 
     | 
    
         
            +
                })
         
     | 
| 
      
 133 
     | 
    
         
            +
              end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
              def test_layouts
         
     | 
| 
      
 136 
     | 
    
         
            +
                # Create data source
         
     | 
| 
      
 137 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                # Create layout
         
     | 
| 
      
 140 
     | 
    
         
            +
                FileUtils.mkdir_p('layouts/foo')
         
     | 
| 
      
 141 
     | 
    
         
            +
                File.open('layouts/foo/foo.yaml', 'w') do |io|
         
     | 
| 
      
 142 
     | 
    
         
            +
                  io.write("---\n")
         
     | 
| 
      
 143 
     | 
    
         
            +
                  io.write("filter: erb\n")
         
     | 
| 
      
 144 
     | 
    
         
            +
                end
         
     | 
| 
      
 145 
     | 
    
         
            +
                File.open('layouts/foo/foo.rhtml', 'w') do |io|
         
     | 
| 
      
 146 
     | 
    
         
            +
                  io.write('Lorem ipsum dolor sit amet...')
         
     | 
| 
      
 147 
     | 
    
         
            +
                end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
                # Load layouts
         
     | 
| 
      
 150 
     | 
    
         
            +
                layouts = data_source.layouts
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                # Check layouts
         
     | 
| 
      
 153 
     | 
    
         
            +
                assert_equal(1,                       layouts.size)
         
     | 
| 
      
 154 
     | 
    
         
            +
                assert_equal('erb',                   layouts[0][:filter])
         
     | 
| 
      
 155 
     | 
    
         
            +
                assert_equal('rhtml',                 layouts[0][:extension])
         
     | 
| 
      
 156 
     | 
    
         
            +
                assert_equal('layouts/foo/foo.rhtml', layouts[0][:content_filename])
         
     | 
| 
      
 157 
     | 
    
         
            +
                assert_equal('layouts/foo/foo.yaml',  layouts[0][:meta_filename])
         
     | 
| 
      
 158 
     | 
    
         
            +
              end
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
              def test_layouts_with_period_in_name_disallowing_periods_in_identifiers
         
     | 
| 
      
 161 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                # Create foo.html
         
     | 
| 
      
 164 
     | 
    
         
            +
                FileUtils.mkdir_p('layouts/foo')
         
     | 
| 
      
 165 
     | 
    
         
            +
                File.open('layouts/foo/foo.yaml', 'w') do |io|
         
     | 
| 
      
 166 
     | 
    
         
            +
                  io.write(YAML.dump({ 'dog' => 'woof' }))
         
     | 
| 
      
 167 
     | 
    
         
            +
                end
         
     | 
| 
      
 168 
     | 
    
         
            +
                File.open('layouts/foo/foo.html', 'w') do |io|
         
     | 
| 
      
 169 
     | 
    
         
            +
                  io.write('body.foo {}')
         
     | 
| 
      
 170 
     | 
    
         
            +
                end
         
     | 
| 
      
 171 
     | 
    
         
            +
                
         
     | 
| 
      
 172 
     | 
    
         
            +
                # Create bar.html.erb
         
     | 
| 
      
 173 
     | 
    
         
            +
                FileUtils.mkdir_p('layouts/bar')
         
     | 
| 
      
 174 
     | 
    
         
            +
                File.open('layouts/bar/bar.yaml', 'w') do |io|
         
     | 
| 
      
 175 
     | 
    
         
            +
                  io.write(YAML.dump({ 'cat' => 'meow' }))
         
     | 
| 
      
 176 
     | 
    
         
            +
                end
         
     | 
| 
      
 177 
     | 
    
         
            +
                File.open('layouts/bar/bar.html.erb', 'w') do |io|
         
     | 
| 
      
 178 
     | 
    
         
            +
                  io.write('body.foobar {}')
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
      
 180 
     | 
    
         
            +
                
         
     | 
| 
      
 181 
     | 
    
         
            +
                # Load
         
     | 
| 
      
 182 
     | 
    
         
            +
                layouts = data_source.layouts.sort_by { |i| i.identifier }
         
     | 
| 
      
 183 
     | 
    
         
            +
                
         
     | 
| 
      
 184 
     | 
    
         
            +
                # Check
         
     | 
| 
      
 185 
     | 
    
         
            +
                assert_equal 2, layouts.size
         
     | 
| 
      
 186 
     | 
    
         
            +
                assert_equal '/bar/', layouts[0].identifier
         
     | 
| 
      
 187 
     | 
    
         
            +
                assert_equal 'meow',  layouts[0][:cat]
         
     | 
| 
      
 188 
     | 
    
         
            +
                assert_equal '/foo/', layouts[1].identifier
         
     | 
| 
      
 189 
     | 
    
         
            +
                assert_equal 'woof',  layouts[1][:dog]
         
     | 
| 
      
 190 
     | 
    
         
            +
              end
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
              def test_layouts_with_period_in_name_allowing_periods_in_identifiers
         
     | 
| 
      
 193 
     | 
    
         
            +
                data_source = new_data_source(:allow_periods_in_identifiers => true)
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                # Create foo.html
         
     | 
| 
      
 196 
     | 
    
         
            +
                FileUtils.mkdir_p('layouts/foo')
         
     | 
| 
      
 197 
     | 
    
         
            +
                File.open('layouts/foo/foo.yaml', 'w') do |io|
         
     | 
| 
      
 198 
     | 
    
         
            +
                  io.write(YAML.dump({ 'dog' => 'woof' }))
         
     | 
| 
      
 199 
     | 
    
         
            +
                end
         
     | 
| 
      
 200 
     | 
    
         
            +
                File.open('layouts/foo/foo.html', 'w') do |io|
         
     | 
| 
      
 201 
     | 
    
         
            +
                  io.write('body.foo {}')
         
     | 
| 
      
 202 
     | 
    
         
            +
                end
         
     | 
| 
      
 203 
     | 
    
         
            +
                
         
     | 
| 
      
 204 
     | 
    
         
            +
                # Create bar.html.erb
         
     | 
| 
      
 205 
     | 
    
         
            +
                FileUtils.mkdir_p('layouts/bar.xyz')
         
     | 
| 
      
 206 
     | 
    
         
            +
                File.open('layouts/bar.xyz/bar.xyz.yaml', 'w') do |io|
         
     | 
| 
      
 207 
     | 
    
         
            +
                  io.write(YAML.dump({ 'cat' => 'meow' }))
         
     | 
| 
      
 208 
     | 
    
         
            +
                end
         
     | 
| 
      
 209 
     | 
    
         
            +
                File.open('layouts/bar.xyz/bar.xyz.html', 'w') do |io|
         
     | 
| 
      
 210 
     | 
    
         
            +
                  io.write('body.foobar {}')
         
     | 
| 
      
 211 
     | 
    
         
            +
                end
         
     | 
| 
      
 212 
     | 
    
         
            +
                
         
     | 
| 
      
 213 
     | 
    
         
            +
                # Load
         
     | 
| 
      
 214 
     | 
    
         
            +
                layouts = data_source.layouts.sort_by { |i| i.identifier }
         
     | 
| 
      
 215 
     | 
    
         
            +
                
         
     | 
| 
      
 216 
     | 
    
         
            +
                # Check
         
     | 
| 
      
 217 
     | 
    
         
            +
                assert_equal 2, layouts.size
         
     | 
| 
      
 218 
     | 
    
         
            +
                assert_equal '/bar.xyz/', layouts[0].identifier
         
     | 
| 
      
 219 
     | 
    
         
            +
                assert_equal 'meow',      layouts[0][:cat]
         
     | 
| 
      
 220 
     | 
    
         
            +
                assert_equal '/foo/',     layouts[1].identifier
         
     | 
| 
      
 221 
     | 
    
         
            +
                assert_equal 'woof',      layouts[1][:dog]
         
     | 
| 
      
 222 
     | 
    
         
            +
              end
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
              def test_create_item_at_root
         
     | 
| 
      
 225 
     | 
    
         
            +
                # Create item
         
     | 
| 
      
 226 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 227 
     | 
    
         
            +
                data_source.create_item('content here', { :foo => 'bar' }, '/')
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                # Check file existance
         
     | 
| 
      
 230 
     | 
    
         
            +
                assert File.directory?('content')
         
     | 
| 
      
 231 
     | 
    
         
            +
                assert File.file?('content/content.html')
         
     | 
| 
      
 232 
     | 
    
         
            +
                assert File.file?('content/content.yaml')
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
                # Check file content
         
     | 
| 
      
 235 
     | 
    
         
            +
                assert_equal 'content here', File.read('content/content.html')
         
     | 
| 
      
 236 
     | 
    
         
            +
                assert_match 'foo: bar',     File.read('content/content.yaml')
         
     | 
| 
      
 237 
     | 
    
         
            +
              end
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
              def test_create_item_not_at_root
         
     | 
| 
      
 240 
     | 
    
         
            +
                # Create item
         
     | 
| 
      
 241 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 242 
     | 
    
         
            +
                data_source.create_item('content here', { :foo => 'bar' }, '/moo/')
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
                # Check file existance
         
     | 
| 
      
 245 
     | 
    
         
            +
                assert File.directory?('content/moo')
         
     | 
| 
      
 246 
     | 
    
         
            +
                assert File.file?('content/moo/moo.html')
         
     | 
| 
      
 247 
     | 
    
         
            +
                assert File.file?('content/moo/moo.yaml')
         
     | 
| 
      
 248 
     | 
    
         
            +
             
     | 
| 
      
 249 
     | 
    
         
            +
                # Check file content
         
     | 
| 
      
 250 
     | 
    
         
            +
                assert_equal 'content here', File.read('content/moo/moo.html')
         
     | 
| 
      
 251 
     | 
    
         
            +
                assert_match 'foo: bar',     File.read('content/moo/moo.yaml')
         
     | 
| 
      
 252 
     | 
    
         
            +
              end
         
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
      
 254 
     | 
    
         
            +
              def test_create_layout
         
     | 
| 
      
 255 
     | 
    
         
            +
                # Create layout
         
     | 
| 
      
 256 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 257 
     | 
    
         
            +
                data_source.create_layout('content here', { :foo => 'bar' }, '/moo/')
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                # Check file existance
         
     | 
| 
      
 260 
     | 
    
         
            +
                assert File.directory?('layouts/moo')
         
     | 
| 
      
 261 
     | 
    
         
            +
                assert File.file?('layouts/moo/moo.html')
         
     | 
| 
      
 262 
     | 
    
         
            +
                assert File.file?('layouts/moo/moo.yaml')
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
                # Check file content
         
     | 
| 
      
 265 
     | 
    
         
            +
                assert_equal 'content here', File.read('layouts/moo/moo.html')
         
     | 
| 
      
 266 
     | 
    
         
            +
                assert_match 'foo: bar',     File.read('layouts/moo/moo.yaml')
         
     | 
| 
      
 267 
     | 
    
         
            +
              end
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
              def test_load_binary_objects
         
     | 
| 
      
 270 
     | 
    
         
            +
                # Create data source
         
     | 
| 
      
 271 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
      
 273 
     | 
    
         
            +
                # Create sample files
         
     | 
| 
      
 274 
     | 
    
         
            +
                FileUtils.mkdir_p('foo')
         
     | 
| 
      
 275 
     | 
    
         
            +
                File.open('foo/stuff.dat', 'w') { |io| io.write("random binary data") }
         
     | 
| 
      
 276 
     | 
    
         
            +
             
     | 
| 
      
 277 
     | 
    
         
            +
                # Load
         
     | 
| 
      
 278 
     | 
    
         
            +
                items = data_source.send(:load_objects, 'foo', 'item', Nanoc3::Item)
         
     | 
| 
      
 279 
     | 
    
         
            +
             
     | 
| 
      
 280 
     | 
    
         
            +
                # Check
         
     | 
| 
      
 281 
     | 
    
         
            +
                assert_equal 1, items.size
         
     | 
| 
      
 282 
     | 
    
         
            +
                assert items[0].binary?
         
     | 
| 
      
 283 
     | 
    
         
            +
                assert_equal 'foo/stuff.dat', items[0].raw_filename
         
     | 
| 
      
 284 
     | 
    
         
            +
                assert_nil items[0].raw_content
         
     | 
| 
      
 285 
     | 
    
         
            +
              end
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
              def test_filename_for_with_single
         
     | 
| 
      
 288 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 289 
     | 
    
         
            +
             
     | 
| 
      
 290 
     | 
    
         
            +
                FileUtils.mkdir_p('foo/bar')
         
     | 
| 
      
 291 
     | 
    
         
            +
                File.open('foo/bar.ext', 'w') { |io| io.write('o hai') }
         
     | 
| 
      
 292 
     | 
    
         
            +
                assert_equal 'foo/bar.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
         
     | 
| 
      
 293 
     | 
    
         
            +
              end
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
              def test_filename_for_with_double
         
     | 
| 
      
 296 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
                FileUtils.mkdir_p('foo/bar')
         
     | 
| 
      
 299 
     | 
    
         
            +
                File.open('foo/bar/bar.ext', 'w') { |io| io.write('o hai') }
         
     | 
| 
      
 300 
     | 
    
         
            +
                assert_equal 'foo/bar/bar.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
         
     | 
| 
      
 301 
     | 
    
         
            +
              end
         
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
              def test_filename_for_with_index
         
     | 
| 
      
 304 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 305 
     | 
    
         
            +
             
     | 
| 
      
 306 
     | 
    
         
            +
                FileUtils.mkdir_p('foo/bar')
         
     | 
| 
      
 307 
     | 
    
         
            +
                File.open('foo/bar/index.ext', 'w') { |io| io.write('o hai') }
         
     | 
| 
      
 308 
     | 
    
         
            +
                assert_equal 'foo/bar/index.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
         
     | 
| 
      
 309 
     | 
    
         
            +
              end
         
     | 
| 
      
 310 
     | 
    
         
            +
             
     | 
| 
      
 311 
     | 
    
         
            +
              def test_filename_for_with_nil
         
     | 
| 
      
 312 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 313 
     | 
    
         
            +
             
     | 
| 
      
 314 
     | 
    
         
            +
                assert_equal nil, data_source.send(:filename_for, 'foo/bar', nil)
         
     | 
| 
      
 315 
     | 
    
         
            +
              end
         
     | 
| 
      
 316 
     | 
    
         
            +
             
     | 
| 
      
 317 
     | 
    
         
            +
              def test_filename_for_with_single_and_empty_ext
         
     | 
| 
      
 318 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 319 
     | 
    
         
            +
             
     | 
| 
      
 320 
     | 
    
         
            +
                FileUtils.mkdir_p('foo')
         
     | 
| 
      
 321 
     | 
    
         
            +
                File.open('foo/bar', 'w') { |io| io.write('o hai') }
         
     | 
| 
      
 322 
     | 
    
         
            +
                assert_equal 'foo/bar', data_source.send(:filename_for, 'foo/bar', '')
         
     | 
| 
      
 323 
     | 
    
         
            +
              end
         
     | 
| 
      
 324 
     | 
    
         
            +
             
     | 
| 
      
 325 
     | 
    
         
            +
              def test_filename_for_with_double_and_empty_ext
         
     | 
| 
      
 326 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
      
 328 
     | 
    
         
            +
                FileUtils.mkdir_p('foo/bar')
         
     | 
| 
      
 329 
     | 
    
         
            +
                File.open('foo/bar/bar', 'w') { |io| io.write('o hai') }
         
     | 
| 
      
 330 
     | 
    
         
            +
                assert_equal 'foo/bar/bar', data_source.send(:filename_for, 'foo/bar', '')
         
     | 
| 
      
 331 
     | 
    
         
            +
              end
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
              def test_filename_for_with_index_and_empty_ext
         
     | 
| 
      
 334 
     | 
    
         
            +
                data_source = new_data_source
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
                FileUtils.mkdir_p('foo/bar')
         
     | 
| 
      
 337 
     | 
    
         
            +
                File.open('foo/bar/index', 'w') { |io| io.write('o hai') }
         
     | 
| 
      
 338 
     | 
    
         
            +
                assert_equal 'foo/bar/index', data_source.send(:filename_for, 'foo/bar', '')
         
     | 
| 
      
 339 
     | 
    
         
            +
              end
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
              def test_compile_huge_site
         
     | 
| 
      
 342 
     | 
    
         
            +
                if_implemented do
         
     | 
| 
      
 343 
     | 
    
         
            +
                  # Create data source
         
     | 
| 
      
 344 
     | 
    
         
            +
                  data_source = new_data_source
         
     | 
| 
      
 345 
     | 
    
         
            +
             
     | 
| 
      
 346 
     | 
    
         
            +
                  # Create a lot of items
         
     | 
| 
      
 347 
     | 
    
         
            +
                  count = Process.getrlimit(Process::RLIMIT_NOFILE)[0] + 5
         
     | 
| 
      
 348 
     | 
    
         
            +
                  count.times do |i|
         
     | 
| 
      
 349 
     | 
    
         
            +
                    FileUtils.mkdir_p("content/#{i}")
         
     | 
| 
      
 350 
     | 
    
         
            +
                    File.open("content/#{i}/#{i}.html", 'w') { |io| io << "This is item #{i}." }
         
     | 
| 
      
 351 
     | 
    
         
            +
                    File.open("content/#{i}/#{i}.yaml", 'w') { |io| io << "title: Item #{i}"   }
         
     | 
| 
      
 352 
     | 
    
         
            +
                  end
         
     | 
| 
      
 353 
     | 
    
         
            +
             
     | 
| 
      
 354 
     | 
    
         
            +
                  # Read all items
         
     | 
| 
      
 355 
     | 
    
         
            +
                  data_source.items
         
     | 
| 
      
 356 
     | 
    
         
            +
                end
         
     | 
| 
      
 357 
     | 
    
         
            +
              end
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'test/helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class Nanoc3::ExtraCoreExtEnumerableTest < MiniTest::Unit::TestCase
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              include Nanoc3::TestHelpers
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              class MyCollection
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                include Enumerable
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def initialize(array)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @array = array
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def each(&block)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @array.each { |i| block.call(i) }
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def test_group_by
         
     | 
| 
      
 24 
     | 
    
         
            +
                input = MyCollection.new([ 'foo', 'bar', 'baz' ])
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                output_expected = { ?f => [ 'foo' ], ?b => [ 'bar', 'baz' ] }
         
     | 
| 
      
 27 
     | 
    
         
            +
                output_actual   = input.group_by { |i| i[0] }
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                assert_equal output_expected, output_actual
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'test/helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class Nanoc3::ExtraCoreExtTimeTest < MiniTest::Unit::TestCase
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              include Nanoc3::TestHelpers
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def test_to_iso8601_date
         
     | 
| 
      
 10 
     | 
    
         
            +
                assert_equal('2008-05-19', Time.utc(2008, 5, 19, 14, 20, 0, 0).to_iso8601_date)
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def test_to_iso8601_time
         
     | 
| 
      
 14 
     | 
    
         
            +
                assert_equal('2008-05-19T14:20:00Z', Time.utc(2008, 5, 19, 14, 20, 0, 0).to_iso8601_time)
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,234 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'test/helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class Nanoc3::Extra::Deployers::RsyncTest < MiniTest::Unit::TestCase
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              include Nanoc3::TestHelpers
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def test_new_without_site
         
     | 
| 
      
 10 
     | 
    
         
            +
                # Try creating site
         
     | 
| 
      
 11 
     | 
    
         
            +
                error = assert_raises(RuntimeError) do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                # Check error message
         
     | 
| 
      
 16 
     | 
    
         
            +
                assert_equal 'No site configuration found', error.message
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              def test_run_without_general_deploy_config
         
     | 
| 
      
 20 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 21 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 22 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 23 
     | 
    
         
            +
                  io.write "foo: bar\n"
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 27 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                # Try running
         
     | 
| 
      
 30 
     | 
    
         
            +
                error = assert_raises(RuntimeError) do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  rsync.run
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                # Check error message
         
     | 
| 
      
 35 
     | 
    
         
            +
                assert_equal 'No deploy configuration found', error.message
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              def test_run_without_special_deploy_config
         
     | 
| 
      
 39 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 40 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 41 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 42 
     | 
    
         
            +
                  io.write "deploy:\n"
         
     | 
| 
      
 43 
     | 
    
         
            +
                  io.write "  blahblah:\n"
         
     | 
| 
      
 44 
     | 
    
         
            +
                  io.write "    stuff: more stuff\n"
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 48 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                # Try running
         
     | 
| 
      
 51 
     | 
    
         
            +
                error = assert_raises(RuntimeError) do
         
     | 
| 
      
 52 
     | 
    
         
            +
                  rsync.run
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                # Check error message
         
     | 
| 
      
 56 
     | 
    
         
            +
                assert_equal 'No deploy configuration found for default', error.message
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              def test_run_without_special_deploy_config_with_custom_deploy_config
         
     | 
| 
      
 60 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 61 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 62 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 63 
     | 
    
         
            +
                  io.write "deploy:\n"
         
     | 
| 
      
 64 
     | 
    
         
            +
                  io.write "  blahblah:\n"
         
     | 
| 
      
 65 
     | 
    
         
            +
                  io.write "    stuff: more stuff\n"
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 69 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                # Try running
         
     | 
| 
      
 72 
     | 
    
         
            +
                error = assert_raises(RuntimeError) do
         
     | 
| 
      
 73 
     | 
    
         
            +
                  rsync.run(:config_name => 'potrzebie')
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                # Check error message
         
     | 
| 
      
 77 
     | 
    
         
            +
                assert_equal 'No deploy configuration found for potrzebie', error.message
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              def test_run_without_dst
         
     | 
| 
      
 81 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 82 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 83 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 84 
     | 
    
         
            +
                  io.write "deploy:\n"
         
     | 
| 
      
 85 
     | 
    
         
            +
                  io.write "  default:\n"
         
     | 
| 
      
 86 
     | 
    
         
            +
                  io.write "    foo: bar\n"
         
     | 
| 
      
 87 
     | 
    
         
            +
                end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 90 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                # Try running
         
     | 
| 
      
 93 
     | 
    
         
            +
                error = assert_raises(RuntimeError) do
         
     | 
| 
      
 94 
     | 
    
         
            +
                  rsync.run
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                # Check error message
         
     | 
| 
      
 98 
     | 
    
         
            +
                assert_equal 'No dst found in deployment configuration', error.message
         
     | 
| 
      
 99 
     | 
    
         
            +
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              def test_run_with_erroneous_dst
         
     | 
| 
      
 102 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 103 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 104 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 105 
     | 
    
         
            +
                  io.write "deploy:\n"
         
     | 
| 
      
 106 
     | 
    
         
            +
                  io.write "  default:\n"
         
     | 
| 
      
 107 
     | 
    
         
            +
                  io.write "    dst: asdf/\n"
         
     | 
| 
      
 108 
     | 
    
         
            +
                end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 111 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                # Try running
         
     | 
| 
      
 114 
     | 
    
         
            +
                error = assert_raises(RuntimeError) do
         
     | 
| 
      
 115 
     | 
    
         
            +
                  rsync.run
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                # Check error message
         
     | 
| 
      
 119 
     | 
    
         
            +
                assert_equal 'dst requires no trailing slash', error.message
         
     | 
| 
      
 120 
     | 
    
         
            +
              end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              def test_run_with_custom_deploy_config_string
         
     | 
| 
      
 123 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 124 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 125 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 126 
     | 
    
         
            +
                  io.write "deploy:\n"
         
     | 
| 
      
 127 
     | 
    
         
            +
                  io.write "  foobar:\n"
         
     | 
| 
      
 128 
     | 
    
         
            +
                  io.write "    dst: asdf\n"
         
     | 
| 
      
 129 
     | 
    
         
            +
                end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 132 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                # Mock run_shell_cmd
         
     | 
| 
      
 135 
     | 
    
         
            +
                def rsync.run_shell_cmd(args)
         
     | 
| 
      
 136 
     | 
    
         
            +
                  @shell_cms_args = args
         
     | 
| 
      
 137 
     | 
    
         
            +
                end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                # Run
         
     | 
| 
      
 140 
     | 
    
         
            +
                rsync.run(:config_name => 'foobar')
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                # Check args
         
     | 
| 
      
 143 
     | 
    
         
            +
                default_options = Nanoc3::Extra::Deployers::Rsync::DEFAULT_OPTIONS
         
     | 
| 
      
 144 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 145 
     | 
    
         
            +
                  [ 'rsync', default_options, File.expand_path('output') + '/', 'asdf' ].flatten,
         
     | 
| 
      
 146 
     | 
    
         
            +
                  rsync.instance_eval { @shell_cms_args }
         
     | 
| 
      
 147 
     | 
    
         
            +
                )
         
     | 
| 
      
 148 
     | 
    
         
            +
              end
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
              def test_run_with_custom_deploy_config_symbol
         
     | 
| 
      
 151 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 152 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 153 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 154 
     | 
    
         
            +
                  io.write "deploy:\n"
         
     | 
| 
      
 155 
     | 
    
         
            +
                  io.write "  foobar:\n"
         
     | 
| 
      
 156 
     | 
    
         
            +
                  io.write "    dst: asdf\n"
         
     | 
| 
      
 157 
     | 
    
         
            +
                end
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 160 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                # Mock run_shell_cmd
         
     | 
| 
      
 163 
     | 
    
         
            +
                def rsync.run_shell_cmd(args)
         
     | 
| 
      
 164 
     | 
    
         
            +
                  @shell_cms_args = args
         
     | 
| 
      
 165 
     | 
    
         
            +
                end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                # Run
         
     | 
| 
      
 168 
     | 
    
         
            +
                rsync.run(:config_name => :foobar)
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                # Check args
         
     | 
| 
      
 171 
     | 
    
         
            +
                default_options = Nanoc3::Extra::Deployers::Rsync::DEFAULT_OPTIONS
         
     | 
| 
      
 172 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 173 
     | 
    
         
            +
                  [ 'rsync', default_options, File.expand_path('output') + '/', 'asdf' ].flatten,
         
     | 
| 
      
 174 
     | 
    
         
            +
                  rsync.instance_eval { @shell_cms_args }
         
     | 
| 
      
 175 
     | 
    
         
            +
                )
         
     | 
| 
      
 176 
     | 
    
         
            +
              end
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
              def test_run_everything_okay
         
     | 
| 
      
 179 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 180 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 181 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 182 
     | 
    
         
            +
                  io.write "deploy:\n"
         
     | 
| 
      
 183 
     | 
    
         
            +
                  io.write "  default:\n"
         
     | 
| 
      
 184 
     | 
    
         
            +
                  io.write "    dst: asdf\n"
         
     | 
| 
      
 185 
     | 
    
         
            +
                end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 188 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                # Mock run_shell_cmd
         
     | 
| 
      
 191 
     | 
    
         
            +
                def rsync.run_shell_cmd(args)
         
     | 
| 
      
 192 
     | 
    
         
            +
                  @shell_cms_args = args
         
     | 
| 
      
 193 
     | 
    
         
            +
                end
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                # Run
         
     | 
| 
      
 196 
     | 
    
         
            +
                rsync.run
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
                # Check args
         
     | 
| 
      
 199 
     | 
    
         
            +
                default_options = Nanoc3::Extra::Deployers::Rsync::DEFAULT_OPTIONS
         
     | 
| 
      
 200 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 201 
     | 
    
         
            +
                  [ 'rsync', default_options, File.expand_path('output') + '/', 'asdf' ].flatten,
         
     | 
| 
      
 202 
     | 
    
         
            +
                  rsync.instance_eval { @shell_cms_args }
         
     | 
| 
      
 203 
     | 
    
         
            +
                )
         
     | 
| 
      
 204 
     | 
    
         
            +
              end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
              def test_run_everything_okay_dry
         
     | 
| 
      
 207 
     | 
    
         
            +
                # Create config
         
     | 
| 
      
 208 
     | 
    
         
            +
                File.open('config.yaml', 'w') do |io|
         
     | 
| 
      
 209 
     | 
    
         
            +
                  io.write "---\n"
         
     | 
| 
      
 210 
     | 
    
         
            +
                  io.write "deploy:\n"
         
     | 
| 
      
 211 
     | 
    
         
            +
                  io.write "  default:\n"
         
     | 
| 
      
 212 
     | 
    
         
            +
                  io.write "    dst: asdf\n"
         
     | 
| 
      
 213 
     | 
    
         
            +
                end
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                # Create site
         
     | 
| 
      
 216 
     | 
    
         
            +
                rsync = Nanoc3::Extra::Deployers::Rsync.new
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
                # Mock run_shell_cmd
         
     | 
| 
      
 219 
     | 
    
         
            +
                def rsync.run_shell_cmd(args)
         
     | 
| 
      
 220 
     | 
    
         
            +
                  @shell_cms_args = args
         
     | 
| 
      
 221 
     | 
    
         
            +
                end
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                # Run
         
     | 
| 
      
 224 
     | 
    
         
            +
                rsync.run(:dry_run => true)
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
                # Check args
         
     | 
| 
      
 227 
     | 
    
         
            +
                default_options = Nanoc3::Extra::Deployers::Rsync::DEFAULT_OPTIONS
         
     | 
| 
      
 228 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 229 
     | 
    
         
            +
                  [ 'echo', 'rsync', default_options, File.expand_path('output') + '/', 'asdf' ].flatten,
         
     | 
| 
      
 230 
     | 
    
         
            +
                  rsync.instance_eval { @shell_cms_args }
         
     | 
| 
      
 231 
     | 
    
         
            +
                )
         
     | 
| 
      
 232 
     | 
    
         
            +
              end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
            end
         
     |