Commit 2c74c57e authored by Daniel Leidert's avatar Daniel Leidert

New upstream version 2.2.1

parent 8fc38e59
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
*.bundle
*.so
*.o
*.a
mkmf.log
vendor
.sass-cache
_site
--color
--require spec_helper
inherit_gem:
jekyll: .rubocop.yml
AllCops:
TargetRubyVersion: 2.2
Include:
- lib/**/*.rb
Exclude:
- .gitignore
- .rspec
- .rubocop.yml
- .travis.yml
- History.markdown
- Gemfile.lock
- LICENSE.txt
- README.md
- script/**/*
- vendor/**/*
Lint/HandleExceptions:
Exclude:
- lib/jekyll/watcher.rb
Lint/RescueWithoutErrorClass:
Exclude:
- lib/jekyll/watcher.rb
Metrics/BlockLength:
Exclude:
- spec/**/*
Metrics/LineLength:
Exclude:
- jekyll-watch.gemspec
sudo: false
language: ruby
rvm:
- 2.2
- 2.3
- 2.4
branches:
only:
- master
install:
- travis_retry script/bootstrap
script: script/cibuild
notifications:
irc:
on_success: change
on_failure: change
channels:
- irc.freenode.org#jekyll
template:
- '%{repository}#%{build_number} %{message} %{build_url}'
email:
on_success: never
on_failure: change
# frozen_string_literal: true
source "https://rubygems.org"
gemspec
## HEAD
* Remove version lock for dependency listen (#50)
* Inherit Jekyll's rubocop config for consistency (#51)
### Development Fixes
* Update versions for Travis (#43)
* Define path with __dir__ (#48)
* Update jekyll-watch (#53)
* Drop support for old Ruby and old Jekyll (#55)
### Minor Enhancements
* Output regenerated file paths to terminal (#57)
### Major Enhancements
* Remove unnecessary method (#56)
## 1.5.0 / 2016-07-20
* reuse provided site instance if available (#40)
## 1.4.0 / 2016-04-25
* Lock Listen to less than 3.1. (#38)
## 1.3.1 / 2016-01-19
* Test against Jekyll 2 and 3. (#30)
* watcher: set `LISTEN_GEM_DEBUGGING` if `--verbose` flag set (#31)
* Apply Rubocop auditing and fix up (#32)
## 1.3.0 / 2015-09-23
* Lock to Listen 3.x (#25)
## 1.2.1 / 2015-01-24
* Show regen time & use the same `Site` object across regens (#21)
## 1.2.0 / 2014-12-05
* *Always* ignore `.jekyll-metadata`, even if it doesn't exist. (#18)
* Ignore `.jekyll-metadata` by default if it exists (#15)
## 1.1.2 / 2014-11-08
* Only ignore a file or directory if it exists (#13)
## 1.1.1 / 2014-09-05
* Exclude test files from the gem build (#9)
## 1.1.0 / 2014-08-10
### Minor Enhancements
* Refactor the whole watching thing and compartmentalize it. (#5)
* Don't listen to things in the `exclude` configuration option. (#5)
### Development Fixes
* Add github stuff and the beginnings of the test suite (#6)
* Flesh out the test suite (#7)
## 1.0.0 / 2014-06-27
* Birthday!
Copyright (c) 2014 Parker Moore
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Jekyll Watch
Rebuild your Jekyll site when a file changes with the `--watch` switch.
[![Build Status](https://travis-ci.org/jekyll/jekyll-watch.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-watch)
## Installation
**`jekyll-watch` comes pre-installed with Jekyll 2.1 or greater.**
Add this line to your application's Gemfile:
gem 'jekyll-watch'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jekyll-watch
## Usage
Pass the `--watch` flag to `jekyll build` or `jekyll serve`:
```bash
$ jekyll build --watch
$ jekyll serve --watch # this flag is the default, so no need to specify it here for the 'serve' command
```
The `--watch` flag can be used in combination with any other flags for those
two commands, except `--detach` for the `serve` command.
## Contributing
1. Fork it ( https://github.com/jekyll/jekyll-watch/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec) do |t|
t.verbose = false
end
task :default => :spec
# frozen_string_literal: true
#########################################################
# This file has been automatically generated by gem2tgz #
#########################################################
# -*- encoding: utf-8 -*-
# stub: jekyll-watch 2.2.1 ruby lib
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "jekyll-watch/version"
Gem::Specification.new do |s|
s.name = "jekyll-watch".freeze
s.version = "2.2.1"
Gem::Specification.new do |spec|
spec.name = "jekyll-watch"
spec.version = Jekyll::Watch::VERSION
spec.authors = ["Parker Moore"]
spec.email = ["parkrmoore@gmail.com"]
spec.summary = "Rebuild your Jekyll site when a file changes with the `--watch` switch."
spec.homepage = "https://github.com/jekyll/jekyll-watch"
spec.license = "MIT"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Parker Moore".freeze]
s.date = "2019-03-22"
s.email = ["parkrmoore@gmail.com".freeze]
s.files = ["lib/jekyll-watch.rb".freeze, "lib/jekyll-watch/version.rb".freeze, "lib/jekyll/commands/watch.rb".freeze, "lib/jekyll/watcher.rb".freeze]
s.homepage = "https://github.com/jekyll/jekyll-watch".freeze
s.licenses = ["MIT".freeze]
s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze)
s.rubygems_version = "2.5.2.1".freeze
s.summary = "Rebuild your Jekyll site when a file changes with the `--watch` switch.".freeze
spec.files = `git ls-files -z`.split("\x0").grep(%r!(bin|lib)/!)
spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) }
spec.require_paths = ["lib"]
if s.respond_to? :specification_version then
s.specification_version = 4
spec.required_ruby_version = ">= 2.1.0"
spec.add_runtime_dependency "listen", "~> 3.0"
require "rbconfig"
if RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!
spec.add_runtime_dependency "wdm", "~> 0.1.0"
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
s.add_development_dependency(%q<jekyll>.freeze, ["< 5.0", ">= 3.6"])
s.add_runtime_dependency(%q<listen>.freeze, ["~> 3.0"])
s.add_development_dependency(%q<rake>.freeze, [">= 0"])
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
s.add_development_dependency(%q<rubocop-jekyll>.freeze, ["~> 0.5"])
else
s.add_dependency(%q<bundler>.freeze, [">= 0"])
s.add_dependency(%q<jekyll>.freeze, ["< 5.0", ">= 3.6"])
s.add_dependency(%q<listen>.freeze, ["~> 3.0"])
s.add_dependency(%q<rake>.freeze, [">= 0"])
s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
s.add_dependency(%q<rubocop-jekyll>.freeze, ["~> 0.5"])
end
else
s.add_dependency(%q<bundler>.freeze, [">= 0"])
s.add_dependency(%q<jekyll>.freeze, ["< 5.0", ">= 3.6"])
s.add_dependency(%q<listen>.freeze, ["~> 3.0"])
s.add_dependency(%q<rake>.freeze, [">= 0"])
s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
s.add_dependency(%q<rubocop-jekyll>.freeze, ["~> 0.5"])
end
spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "jekyll", "~> 3.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop", "~> 0.51"
end
# frozen_string_literal: true
require "jekyll-watch/version"
require_relative "jekyll/watcher"
require_relative "jekyll/commands/watch"
# frozen_string_literal: true
require "jekyll-watch/version"
require_relative "jekyll/watcher"
require_relative "jekyll/commands/watch"
# frozen_string_literal: true
module Jekyll
module Watch
VERSION = "2.0.0".freeze
end
end
# frozen_string_literal: true
module Jekyll
module Watch
VERSION = "2.2.1"
end
end
# frozen_string_literal: true
module Jekyll
module Commands
module Watch
extend self
def init_with_program(prog); end
# Build your jekyll site
# Continuously watch if `watch` is set to true in the config.
def process(options)
Jekyll.logger.log_level = :error if options["quiet"]
Jekyll::Watcher.watch(options) if options["watch"]
end
end
end
end
# frozen_string_literal: true
module Jekyll
module Commands
module Watch
extend self
def init_with_program(prog); end
# Build your jekyll site
# Continuously watch if `watch` is set to true in the config.
def process(options)
Jekyll.logger.log_level = :error if options["quiet"]
Jekyll::Watcher.watch(options) if options["watch"]
end
end
end
end
# frozen_string_literal: true
require "listen"
module Jekyll
module Watcher
extend self
# Public: Continuously watch for file changes and rebuild the site
# whenever a change is detected.
#
# If the optional site argument is populated, that site instance will be
# reused and the options Hash ignored. Otherwise, a new site instance will
# be instantiated from the options Hash and used.
#
# options - A Hash containing the site configuration
# site - The current site instance (populated starting with Jekyll 3.2)
# (optional, default: nil)
#
# Returns nothing.
def watch(options, site = nil)
ENV["LISTEN_GEM_DEBUGGING"] ||= "1" if options["verbose"]
site ||= Jekyll::Site.new(options)
listener = build_listener(site, options)
listener.start
Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'"
unless options["serving"]
trap("INT") do
listener.stop
puts " Halting auto-regeneration."
exit 0
end
sleep_forever
end
rescue ThreadError
# You pressed Ctrl-C, oh my!
end
private
def build_listener(site, options)
Listen.to(
options["source"],
:ignore => listen_ignore_paths(options),
:force_polling => options["force_polling"],
&listen_handler(site)
)
end
private
def listen_handler(site)
proc do |modified, added, removed|
t = Time.now
c = modified + added + removed
n = c.length
Jekyll.logger.info "Regenerating:",
"#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
c.map { |path| path.sub("#{site.source}/", "") }.each do |file|
Jekyll.logger.info "", file
end
process(site, t)
end
end
private
def custom_excludes(options)
Array(options["exclude"]).map { |e| Jekyll.sanitized_path(options["source"], e) }
end
private
def config_files(options)
%w(yml yaml toml).map do |ext|
Jekyll.sanitized_path(options["source"], "_config.#{ext}")
end
end
private
def to_exclude(options)
[
config_files(options),
options["destination"],
custom_excludes(options),
].flatten
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
private
def listen_ignore_paths(options)
source = Pathname.new(options["source"]).expand_path
paths = to_exclude(options)
paths.map do |p|
absolute_path = Pathname.new(p).expand_path
next unless absolute_path.exist?
begin
relative_path = absolute_path.relative_path_from(source).to_s
unless relative_path.start_with?("../")
path_to_ignore = Regexp.new(Regexp.escape(relative_path))
Jekyll.logger.debug "Watcher:", "Ignoring #{path_to_ignore}"
path_to_ignore
end
rescue ArgumentError
# Could not find a relative path
end
end.compact + [%r!\.jekyll\-metadata!]
end
private
def sleep_forever
loop { sleep 1000 }
end
private
def process(site, time)
begin
site.process
Jekyll.logger.info "", "...done in #{Time.now - time} seconds."
rescue => e
Jekyll.logger.warn "Error:", e.message
Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
end
puts ""
end
end
end
# frozen_string_literal: true
require "listen"
module Jekyll
module Watcher
extend self
# Public: Continuously watch for file changes and rebuild the site
# whenever a change is detected.
#
# If the optional site argument is populated, that site instance will be
# reused and the options Hash ignored. Otherwise, a new site instance will
# be instantiated from the options Hash and used.
#
# options - A Hash containing the site configuration
# site - The current site instance (populated starting with Jekyll 3.2)
# (optional, default: nil)
#
# Returns nothing.
def watch(options, site = nil)
ENV["LISTEN_GEM_DEBUGGING"] ||= "1" if options["verbose"]
site ||= Jekyll::Site.new(options)
listener = build_listener(site, options)
listener.start
Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'"
unless options["serving"]
trap("INT") do
listener.stop
Jekyll.logger.info "", "Halting auto-regeneration."
exit 0
end
sleep_forever
end
rescue ThreadError
# You pressed Ctrl-C, oh my!
end
private
def build_listener(site, options)
Listen.to(
options["source"],
:ignore => listen_ignore_paths(options),
:force_polling => options["force_polling"],
&listen_handler(site)
)
end
def listen_handler(site)
proc do |modified, added, removed|
t = Time.now
c = modified + added + removed
n = c.length
Jekyll.logger.info "Regenerating:",
"#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
c.each { |path| Jekyll.logger.info "", path["#{site.source}/".length..-1] }
process(site, t)
end
end
def normalize_encoding(obj, desired_encoding)
case obj
when Array
obj.map { |entry| entry.encode!(desired_encoding, entry.encoding) }
when String
obj.encode!(desired_encoding, obj.encoding)
end
end
def custom_excludes(options)
Array(options["exclude"]).map { |e| Jekyll.sanitized_path(options["source"], e) }
end
def config_files(options)
%w(yml yaml toml).map do |ext|
Jekyll.sanitized_path(options["source"], "_config.#{ext}")
end
end
def to_exclude(options)
[
config_files(options),
options["destination"],
custom_excludes(options),
].flatten
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 listen_ignore_paths(options)
source = Pathname.new(options["source"]).expand_path
paths = to_exclude(options)
paths.map do |p|
absolute_path = Pathname.new(normalize_encoding(p, options["source"].encoding)).expand_path
next unless absolute_path.exist?
begin
relative_path = absolute_path.relative_path_from(source).to_s
relative_path = File.join(relative_path, "") if absolute_path.directory?
unless relative_path.start_with?("../")
path_to_ignore = %r!^#{Regexp.escape(relative_path)}!
Jekyll.logger.debug "Watcher:", "Ignoring #{path_to_ignore}"
path_to_ignore
end
rescue ArgumentError
# Could not find a relative path
end
end.compact + [%r!^\.jekyll\-metadata!]
end
def sleep_forever
loop { sleep 1000 }
end
def process(site, time)
begin
site.process
Jekyll.logger.info "", "...done in #{Time.now - time} seconds."
rescue StandardError => e
Jekyll.logger.warn "Error:", e.message
Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
end
Jekyll.logger.info ""
end
end
end
#! /bin/bash
if [[ "$TRAVIS" == "true" ]]; then
echo "We're on Travis! Installing to vendor."
time bundle install --path vendor
else
bundle install --system
fi
#!/bin/bash
time script/test
time script/fmt
#!/bin/bash
bundle exec rubocop -D -E
#! /bin/bash
rake release
#!/bin/bash
bundle exec rspec "$@"
#!/bin/bash
local-jekyll serve --watch \
--source spec/test-site \
--destination spec/test-site/_site
# frozen_string_literal: true
require "jekyll"
require File.expand_path("../lib/jekyll-watch.rb", __dir__)
TEST_DIR = __dir__
RSpec.configure do |config|
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
# get run.
config.filter_run :focus
config.run_all_when_everything_filtered = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = "doc"
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax