From a2dfd6eddca691f33f89f6c29c84f27be42d1fcd Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 9 Aug 2014 00:13:18 -0400 Subject: [PATCH 1/4] Refactor based on jekyll-watch clean-up. https://github.com/jekyll/jekyll-watch/pull/5 --- lib/jekyll/command.rb | 25 ------------------------- lib/jekyll/commands/build.rb | 2 +- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index d11631d8..bf6d981d 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -19,31 +19,6 @@ module Jekyll super(base) end - # Paths to ignore for the watch option - # - # options - A Hash of options passed to the command - # - # Returns a list of relative paths from source that should be ignored - def ignore_paths(options) - source = options['source'] - destination = options['destination'] - config_files = Configuration[options].config_files(options) - paths = config_files + Array(destination) - ignored = [] - - source_abs = Pathname.new(source).expand_path - paths.each do |p| - path_abs = Pathname.new(p).expand_path - begin - rel_path = path_abs.relative_path_from(source_abs).to_s - ignored << Regexp.new(Regexp.escape(rel_path)) unless rel_path.start_with?('../') - rescue ArgumentError - # Could not find a relative path - end - end - ignored - end - # Run Site#process and catch errors # # site - the Jekyll::Site object diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index cbda2b65..6dc900c6 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -64,7 +64,7 @@ module Jekyll # Returns nothing. def watch(site, options) Deprecator.gracefully_require 'jekyll-watch' - Jekyll::Commands::Watch.watch(site, options) + Jekyll::Watch.watch(options) end end # end of class << self From 1261c1cd6698e35538aead69a4788f9420bb6402 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 9 Aug 2014 00:15:20 -0400 Subject: [PATCH 2/4] Bump jekyll-watch version to 1.1. --- jekyll.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 74b08846..5ad94294 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -44,7 +44,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency('jekyll-gist', '~> 1.0') s.add_runtime_dependency('jekyll-coffeescript', '~> 1.0') s.add_runtime_dependency('jekyll-sass-converter', '~> 1.0') - s.add_runtime_dependency('jekyll-watch', '~> 1.0') + s.add_runtime_dependency('jekyll-watch', '~> 1.1') s.add_development_dependency('rake', "~> 10.1") s.add_development_dependency('rdoc', "~> 3.11") From c7c1eddd4727c44130cb76e74e3f1e6905dda07c Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 10 Aug 2014 14:33:11 -0400 Subject: [PATCH 3/4] It's called Jekyll::Watcher --- lib/jekyll/commands/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index 6dc900c6..67839a17 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -64,7 +64,7 @@ module Jekyll # Returns nothing. def watch(site, options) Deprecator.gracefully_require 'jekyll-watch' - Jekyll::Watch.watch(options) + Jekyll::Watcher.watch(options) end end # end of class << self From 533ed6eb3825ea469dc0584571ef8d44b4e5f284 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 10 Aug 2014 14:46:06 -0400 Subject: [PATCH 4/4] Remove tests for the Command.ignored_paths method which now lives in jekyll-watch. --- test/test_command.rb | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/test/test_command.rb b/test/test_command.rb index 8d1a751d..10ecccc4 100644 --- a/test/test_command.rb +++ b/test/test_command.rb @@ -1,38 +1,6 @@ require 'helper' class TestCommand < Test::Unit::TestCase - context "when calling .ignore_paths" do - context "when source is absolute" do - setup { @source = source_dir } - should "return an array with regex for destination" do - absolute = source_dir('dest') - relative = Pathname.new(source_dir('dest')).relative_path_from(Pathname.new('.').expand_path).to_s - [absolute, relative].each do |dest| - config = build_configs("source" => @source, "destination" => dest) - assert Command.ignore_paths(config).include?(/dest/), "failed with destination: #{dest}" - end - end - end - context "when source is relative" do - setup { @source = Pathname.new(source_dir).relative_path_from(Pathname.new('.').expand_path).to_s } - should "return an array with regex for destination" do - absolute = source_dir('dest') - relative = Pathname.new(source_dir('dest')).relative_path_from(Pathname.new('.').expand_path).to_s - [absolute, relative].each do |dest| - config = build_configs("source" => @source, "destination" => dest) - assert Command.ignore_paths(config).include?(/dest/), "failed with destination: #{dest}" - end - end - end - context "multiple config files" do - should "return an array with regex for config files" do - config = build_configs("config"=> ["_config.yaml", "_config2.yml"]) - ignore_paths = Command.ignore_paths(config) - assert ignore_paths.include?(/_config\.yaml/), 'did not include _config.yaml' - assert ignore_paths.include?(/_config2\.yml/), 'did not include _config2.yml' - end - end - end context "when calling .add_build_options" do should "add common options" do cmd = Object.new