jekyll-watch 1.0.0 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e8b19bc631168b0a288f5ed832a574a322e6b46
4
- data.tar.gz: 33a7e14411be8f7ef8b3cfe89f3dd57677a83d44
3
+ metadata.gz: 5af48120c14729914c6d38399ba3555784b2f750
4
+ data.tar.gz: 90e8fa82eba51acc47c7407d1398fd12ff118506
5
5
  SHA512:
6
- metadata.gz: 65669640a282e62c78c50929a6b531273d530613b13cc510c3c1f39febbccc18c3b34509f704d043675ede918e67e8ee73c432bf6cb86a888edd67ef42630d74
7
- data.tar.gz: f6bd2e09034cc85e7bd69e0e744485d220c6e9c8d95b9eda38cd64b15c647d405af999bc5b2b378ab8f1f260f08067c2323593c777fa979f9104d74e6e0bca0a
6
+ metadata.gz: 4245c05ecf747b93fbc9fc86203d062f6f585a77d549807c29c2601fad7cc676a57507db5a7b90492be7ab4f88dab74d80f5b5f190cad36ec884e5f404ab25e2
7
+ data.tar.gz: 4a1196d1a352272c409fd213abec35b61391946c6085bafaffe1a1f85a9c0e38735776602e580d3694dcefa318d24d75e7c28cbe364283f3dcdeccc1e3579656
data/.gitignore CHANGED
@@ -20,3 +20,7 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ vendor
24
+
25
+ .sass-cache
26
+ _site
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0
5
+ - 2.1
6
+ install:
7
+ - travis_retry script/unbundle
8
+ - travis_retry script/bootstrap
9
+ script: script/cibuild
10
+ notifications:
11
+ irc:
12
+ on_success: change
13
+ on_failure: change
14
+ channels:
15
+ - irc.freenode.org#jekyll
16
+ template:
17
+ - '%{repository}#%{build_number} %{message} %{build_url}'
18
+ email:
19
+ on_success: never
20
+ on_failure: change
@@ -0,0 +1,15 @@
1
+ ## 1.1.0 / 2014-08-10
2
+
3
+ ### Minor Enhancements
4
+
5
+ * Refactor the whole watching thing and compartmentalize it. (#5)
6
+ * Don't listen to things in the `exclude` configuration option. (#5)
7
+
8
+ ### Development Fixes
9
+
10
+ * Add github stuff and the beginnings of the test suite (#6)
11
+ * Flesh out the test suite (#7)
12
+
13
+ ## 1.0.0 / 2014-06-27
14
+
15
+ * Birthday!
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Rebuild your Jekyll site when a file changes with the `--watch` switch.
4
4
 
5
+ [![Build Status](https://travis-ci.org/jekyll/jekyll-watch.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-watch)
6
+
5
7
  ## Installation
6
8
 
7
9
  **`jekyll-watch` comes pre-installed with Jekyll 2.1 or greater.**
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "jekyll-watch"
5
- spec.version = "1.0.0"
5
+ spec.version = "1.1.0"
6
6
  spec.authors = ["Parker Moore"]
7
7
  spec.email = ["parkrmoore@gmail.com"]
8
8
  spec.summary = %q{Rebuild your Jekyll site when a file changes with the `--watch` switch.}
@@ -24,4 +24,6 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.6"
26
26
  spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "jekyll", "~> 2.0"
27
29
  end
@@ -1 +1,2 @@
1
- require "jekyll/commands/watch"
1
+ require_relative "jekyll/watcher"
2
+ require_relative "jekyll/commands/watch"
@@ -1,61 +1,28 @@
1
1
  module Jekyll
2
2
  module Commands
3
- class Watch < Command
4
- class << self
3
+ module Watch
4
+ extend self
5
5
 
6
- def init_with_program(prog)
7
- # noop
8
- end
9
-
10
- # Build your jekyll site
11
- # Continuously watch if `watch` is set to true in the config.
12
- def process(options)
13
- Jekyll.logger.log_level = :error if options['quiet']
14
- watch(site, options) if options['watch']
15
- end
16
-
17
- # Watch for file changes and rebuild the site.
18
- #
19
- # site - A Jekyll::Site instance
20
- # options - A Hash of options passed to the command
21
- #
22
- # Returns nothing.
23
- def watch(site, options)
24
- require 'listen'
25
-
26
- listener = Listen.to(
27
- options['source'],
28
- :ignore => ignore_paths(options),
29
- :force_polling => options['force_polling']
30
- ) do |modified, added, removed|
31
- t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
32
- n = modified.length + added.length + removed.length
33
- print Jekyll.logger.formatted_topic("Regenerating:") + "#{n} files at #{t} "
34
- begin
35
- process_site(site)
36
- puts "...done."
37
- rescue => e
38
- puts "...error:"
39
- Jekyll.logger.warn "Error:", e.message
40
- Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
41
- end
42
- end
43
- listener.start
44
-
45
- Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options['source']}'"
46
-
47
- unless options['serving']
48
- trap("INT") do
49
- listener.stop
50
- puts " Halting auto-regeneration."
51
- exit 0
52
- end
6
+ def init_with_program(prog)
7
+ end
53
8
 
54
- loop { sleep 1000 }
55
- end
56
- end
9
+ # Build your jekyll site
10
+ # Continuously watch if `watch` is set to true in the config.
11
+ def process(options)
12
+ Jekyll.logger.log_level = :error if options['quiet']
13
+ watch(site, options) if options['watch']
14
+ end
57
15
 
16
+ # Watch for file changes and rebuild the site.
17
+ #
18
+ # site - A Jekyll::Site instance
19
+ # options - A Hash of options passed to the command
20
+ #
21
+ # Returns nothing.
22
+ def watch(site, options)
23
+ Jekyll::Watcher.watch(options)
58
24
  end
25
+
59
26
  end
60
27
  end
61
28
  end
@@ -0,0 +1,83 @@
1
+ module Jekyll
2
+ module Watcher
3
+ extend self
4
+
5
+ def watch(options)
6
+ listener = build_listener(options)
7
+ listener.start
8
+
9
+ Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options['source']}'"
10
+
11
+ unless options['serving']
12
+ trap("INT") do
13
+ listener.stop
14
+ puts " Halting auto-regeneration."
15
+ exit 0
16
+ end
17
+
18
+ loop { sleep 1000 }
19
+ end
20
+ rescue ThreadError => e
21
+ # You pressed Ctrl-C, oh my!
22
+ end
23
+
24
+ def build_listener(options)
25
+ require 'listen'
26
+ Listen.to(
27
+ options['source'],
28
+ :ignore => listen_ignore_paths(options),
29
+ :force_polling => options['force_polling'],
30
+ &(listen_handler(options))
31
+ )
32
+ end
33
+
34
+ def listen_handler(options)
35
+ proc { |modified, added, removed|
36
+ t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
37
+ c = modified + added + removed
38
+ n = c.length
39
+ print Jekyll.logger.message("Regenerating:", "#{n} files at #{t} ")
40
+ begin
41
+ Jekyll::Command.process_site(Jekyll::Site.new(options))
42
+ puts "...done."
43
+ rescue => e
44
+ puts "...error:"
45
+ Jekyll.logger.warn "Error:", e.message
46
+ Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
47
+ end
48
+ }
49
+ end
50
+
51
+ # Paths to ignore for the watch option
52
+ #
53
+ # options - A Hash of options passed to the command
54
+ #
55
+ # Returns a list of relative paths from source that should be ignored
56
+ def listen_ignore_paths(options)
57
+ source = options['source']
58
+ destination = options['destination']
59
+ config_files = Jekyll.sanitized_path(source, "_config.yml")
60
+ paths = (
61
+ Array(config_files) \
62
+ + Array(destination) \
63
+ + Array(options['exclude']).map { |e| Jekyll.sanitized_path(source, e) }
64
+ )
65
+ ignored = []
66
+
67
+ source_abs = Pathname.new(source).expand_path
68
+ paths.each do |p|
69
+ path_abs = Pathname.new(p).expand_path
70
+ begin
71
+ rel_path = path_abs.relative_path_from(source_abs).to_s
72
+ ignored << Regexp.new(Regexp.escape(rel_path)) unless rel_path.start_with?('../')
73
+ rescue ArgumentError
74
+ # Could not find a relative path
75
+ end
76
+ end
77
+
78
+ Jekyll.logger.debug "Watcher:", "Ignoring #{ignored.map(&:inspect).join(', ')}"
79
+ ignored
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,8 @@
1
+ #! /bin/bash
2
+
3
+ if [[ "$TRAVIS" == "true" ]]; then
4
+ echo "We're on Travis! Installing to vendor."
5
+ time bundle install --path vendor
6
+ else
7
+ bundle install --system
8
+ fi
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ time script/test
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rspec --color --require spec_helper "$@"
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ local-jekyll serve --watch \
4
+ --source spec/test-site \
5
+ --destination spec/test-site/_site
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ RELEASES_URL="https://github.com/jekyll/jekyll/releases"
4
+ JEKYLL_VERSION="2.2.0"
5
+ JEKYLL_BUNDLE="jekyll-${JEKYLL_VERSION}.tar.gz"
6
+
7
+ wget "${RELEASES_URL}/download/v${JEKYLL_VERSION}/${JEKYLL_BUNDLE}"
8
+ tar -xzvf ${JEKYLL_BUNDLE}
@@ -0,0 +1,71 @@
1
+ require 'jekyll'
2
+ require File.expand_path('../../lib/jekyll-watch.rb', __FILE__)
3
+ TEST_DIR = File.expand_path('..', __FILE__)
4
+
5
+ RSpec.configure do |config|
6
+ # These two settings work together to allow you to limit a spec run
7
+ # to individual examples or groups you care about by tagging them with
8
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
9
+ # get run.
10
+ config.filter_run :focus
11
+ config.run_all_when_everything_filtered = true
12
+
13
+ # Many RSpec users commonly either run the entire suite or an individual
14
+ # file, and it's useful to allow more verbose output when running an
15
+ # individual spec file.
16
+ if config.files_to_run.one?
17
+ # Use the documentation formatter for detailed output,
18
+ # unless a formatter has already been configured
19
+ # (e.g. via a command-line flag).
20
+ config.default_formatter = 'doc'
21
+ end
22
+
23
+ # Print the 10 slowest examples and example groups at the
24
+ # end of the spec run, to help surface which specs are running
25
+ # particularly slow.
26
+ config.profile_examples = 10
27
+
28
+ # Run specs in random order to surface order dependencies. If you find an
29
+ # order dependency and want to debug it, you can fix the order by providing
30
+ # the seed, which is printed after each run.
31
+ # --seed 1234
32
+ config.order = :random
33
+
34
+ # Seed global randomization in this process using the `--seed` CLI option.
35
+ # Setting this allows you to use `--seed` to deterministically reproduce
36
+ # test failures related to randomization by passing the same `--seed` value
37
+ # as the one that triggered the failure.
38
+ Kernel.srand config.seed
39
+
40
+ # rspec-expectations config goes here. You can use an alternate
41
+ # assertion/expectation library such as wrong or the stdlib/minitest
42
+ # assertions if you prefer.
43
+ config.expect_with :rspec do |expectations|
44
+ # Enable only the newer, non-monkey-patching expect syntax.
45
+ # For more details, see:
46
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
47
+ expectations.syntax = :expect
48
+ end
49
+
50
+ # rspec-mocks config goes here. You can use an alternate test double
51
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
52
+ config.mock_with :rspec do |mocks|
53
+ # Enable only the newer, non-monkey-patching expect syntax.
54
+ # For more details, see:
55
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
56
+ mocks.syntax = :expect
57
+
58
+ # Prevents you from mocking or stubbing a method that does not exist on
59
+ # a real object. This is generally recommended.
60
+ mocks.verify_partial_doubles = true
61
+ end
62
+
63
+
64
+ def source_dir(*files)
65
+ File.join(TEST_DIR, 'test-site', *files)
66
+ end
67
+
68
+ def dest_dir(*files)
69
+ source_dir('_site', *files)
70
+ end
71
+ end
@@ -0,0 +1 @@
1
+ _site
@@ -0,0 +1 @@
1
+ hello = "there"
@@ -0,0 +1,15 @@
1
+ # Site settings
2
+ title: jekyll-watch test site
3
+ email: your-email@domain.com
4
+ description: > # this means to ignore newlines until "baseurl:"
5
+ Write an awesome description for your new site here. You can edit this
6
+ line in _config.yml. It will appear in your document head meta (for
7
+ Google search results) and in your feed.xml site description.
8
+ baseurl: "" # the subpath of your site, e.g. /blog/
9
+ url: "http://yourdomain.com" # the base hostname & protocol for your site
10
+ twitter_username: jekyllrb
11
+ github_username: jekyll
12
+ exclude: [".gitignore"]
13
+
14
+ # Build settings
15
+ markdown: kramdown
@@ -0,0 +1,55 @@
1
+ <footer class="site-footer">
2
+
3
+ <div class="wrapper">
4
+
5
+ <h2 class="footer-heading">{{ site.title }}</h2>
6
+
7
+ <div class="footer-col-wrapper">
8
+ <div class="footer-col footer-col-1">
9
+ <ul class="contact-list">
10
+ <li>{{ site.title }}</li>
11
+ <li><a href="mailto:{{ site.email }}">{{ site.email }}</a></li>
12
+ </ul>
13
+ </div>
14
+
15
+ <div class="footer-col footer-col-2">
16
+ <ul class="social-media-list">
17
+ {% if site.github_username %}
18
+ <li>
19
+ <a href="https://github.com/{{ site.github_username }}">
20
+ <span class="icon icon--github">
21
+ <svg viewBox="0 0 16 16">
22
+ <path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/>
23
+ </svg>
24
+ </span>
25
+
26
+ <span class="username">{{ site.github_username }}</span>
27
+ </a>
28
+ </li>
29
+ {% endif %}
30
+
31
+ {% if site.twitter_username %}
32
+ <li>
33
+ <a href="https://twitter.com/{{ site.twitter_username }}">
34
+ <span class="icon icon--twitter">
35
+ <svg viewBox="0 0 16 16">
36
+ <path fill="#828282" d="M15.969,3.058c-0.586,0.26-1.217,0.436-1.878,0.515c0.675-0.405,1.194-1.045,1.438-1.809
37
+ c-0.632,0.375-1.332,0.647-2.076,0.793c-0.596-0.636-1.446-1.033-2.387-1.033c-1.806,0-3.27,1.464-3.27,3.27 c0,0.256,0.029,0.506,0.085,0.745C5.163,5.404,2.753,4.102,1.14,2.124C0.859,2.607,0.698,3.168,0.698,3.767 c0,1.134,0.577,2.135,1.455,2.722C1.616,6.472,1.112,6.325,0.671,6.08c0,0.014,0,0.027,0,0.041c0,1.584,1.127,2.906,2.623,3.206 C3.02,9.402,2.731,9.442,2.433,9.442c-0.211,0-0.416-0.021-0.615-0.059c0.416,1.299,1.624,2.245,3.055,2.271 c-1.119,0.877-2.529,1.4-4.061,1.4c-0.264,0-0.524-0.015-0.78-0.046c1.447,0.928,3.166,1.469,5.013,1.469 c6.015,0,9.304-4.983,9.304-9.304c0-0.142-0.003-0.283-0.009-0.423C14.976,4.29,15.531,3.714,15.969,3.058z"/>
38
+ </svg>
39
+ </span>
40
+
41
+ <span class="username">{{ site.twitter_username }}</span>
42
+ </a>
43
+ </li>
44
+ {% endif %}
45
+ </ul>
46
+ </div>
47
+
48
+ <div class="footer-col footer-col-3">
49
+ <p class="text">{{ site.description }}</p>
50
+ </div>
51
+ </div>
52
+
53
+ </div>
54
+
55
+ </footer>
@@ -0,0 +1,11 @@
1
+ <head>
2
+ <meta charset="utf-8">
3
+ <meta name="viewport" content="width=device-width">
4
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
+
6
+ <title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
7
+ <meta name="description" content="{{ site.description }}">
8
+
9
+ <link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
10
+ <link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
11
+ </head>