guard-jekyll-plus 2.0.0 → 2.0.1
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 +4 -4
- data/.rspec +2 -0
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +32 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +6 -2
- data/Gemfile +12 -2
- data/Guardfile +30 -0
- data/README.md +5 -5
- data/Rakefile +9 -1
- data/guard-jekyll-plus.gemspec +20 -15
- data/lib/guard/jekyll_plus.rb +54 -0
- data/lib/guard/jekyll_plus/builder.rb +46 -0
- data/lib/guard/jekyll_plus/builder/action.rb +126 -0
- data/lib/guard/jekyll_plus/builder/adder.rb +23 -0
- data/lib/guard/jekyll_plus/builder/modifier.rb +23 -0
- data/lib/guard/jekyll_plus/builder/rebuilder.rb +37 -0
- data/lib/guard/jekyll_plus/builder/remover.rb +24 -0
- data/lib/guard/jekyll_plus/config.rb +131 -0
- data/lib/guard/jekyll_plus/server.rb +111 -0
- data/lib/guard/jekyll_plus/templates/Guardfile +4 -0
- data/lib/guard/{jekyll-plus → jekyll_plus}/version.rb +1 -1
- data/spec/lib/guard/jekyll-plus/builder/adder_spec.rb +94 -0
- data/spec/lib/guard/jekyll-plus/builder/modifier_spec.rb +113 -0
- data/spec/lib/guard/jekyll-plus/builder/rebuilder_spec.rb +76 -0
- data/spec/lib/guard/jekyll-plus/builder/remover_spec.rb +97 -0
- data/spec/lib/guard/jekyll-plus/builder_spec.rb +57 -0
- data/spec/lib/guard/jekyll-plus/config_spec.rb +138 -0
- data/spec/lib/guard/jekyll-plus/server_spec.rb +79 -0
- data/spec/lib/guard/jekyll-plus_spec.rb +114 -0
- data/spec/spec_helper.rb +44 -0
- data/test/Guardfile +3 -4
- metadata +70 -14
- data/lib/guard/jekyll-plus.rb +0 -300
- data/lib/guard/jekyll-plus/templates/Guardfile +0 -5
- data/test/Gemfile +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076743d79bba521d0febc7610d79d83fff4e3e06
|
4
|
+
data.tar.gz: 32a121773ebec897e7799df0de0db78aca64710e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df7d740d999f05818c70cb31b089538f96cdec8544706905be63582917aea9964e36c49ce707a7f62eb82d5a4ad5ff9a4c65a74c168d798bd8ef26833a1be6e0
|
7
|
+
data.tar.gz: 54a1aca7708d5aeb3a0cb64c83afebd742569b688d373a5c9846d19d4e488c7e6a06353902d2b18686234e37e854d3207201c9ddce87eafd443bb659dc12cab3
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-12-15 14:17:36 +0100 using RuboCop version 0.28.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 4
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Max: 34
|
11
|
+
|
12
|
+
# Offense count: 1
|
13
|
+
# Configuration parameters: CountComments.
|
14
|
+
Metrics/ClassLength:
|
15
|
+
Max: 250
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
Metrics/CyclomaticComplexity:
|
19
|
+
Max: 8
|
20
|
+
|
21
|
+
# Offense count: 5
|
22
|
+
# Configuration parameters: CountComments.
|
23
|
+
Metrics/MethodLength:
|
24
|
+
Max: 25
|
25
|
+
|
26
|
+
# Offense count: 1
|
27
|
+
Metrics/PerceivedComplexity:
|
28
|
+
Max: 8
|
29
|
+
|
30
|
+
# Offense count: 2
|
31
|
+
Style/Documentation:
|
32
|
+
Enabled: false
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
guard-jekyll-plus
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
### 2.0.
|
3
|
+
### 2.0.1 - 12-15-2014
|
4
|
+
|
5
|
+
- Changed guard template name for better compatibility with Guard's naming scheme.
|
6
|
+
|
7
|
+
### 2.0.0 - 12-15-2014
|
4
8
|
|
5
9
|
- Updated to work with Guard 2.x
|
6
10
|
|
@@ -51,7 +55,7 @@
|
|
51
55
|
|
52
56
|
### 1.3.0
|
53
57
|
|
54
|
-
- Changed guard name to
|
58
|
+
- Changed guard name to jekyll_plus to help Guard properly init the Guardfile.
|
55
59
|
|
56
60
|
### 1.2.3
|
57
61
|
|
data/Gemfile
CHANGED
@@ -1,4 +1,14 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in guard-
|
4
|
-
|
3
|
+
# Specify your gem's dependencies in guard-jekyll_plus.gemspec
|
4
|
+
#
|
5
|
+
# NOTE: it's more convenient to use gemspec for bare-minimum test deps
|
6
|
+
# and the Gemfile for any extra dev gems
|
7
|
+
gemspec development_group: :test
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem 'guard-rspec', require: false
|
11
|
+
gem 'guard-rubocop', require: false
|
12
|
+
gem 'pry'
|
13
|
+
gem 'pry-byebug'
|
14
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %(app lib config test spec feature)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
group :bdd, halt_on_fail: true do
|
11
|
+
guard :rspec, cmd: "bundle exec rspec", all_on_start: false do
|
12
|
+
require "guard/rspec/dsl"
|
13
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
14
|
+
|
15
|
+
# RSpec files
|
16
|
+
rspec = dsl.rspec
|
17
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
18
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
19
|
+
watch(rspec.spec_files)
|
20
|
+
|
21
|
+
# Ruby files
|
22
|
+
ruby = dsl.ruby
|
23
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
24
|
+
end
|
25
|
+
|
26
|
+
guard :rubocop, all_on_start: false do
|
27
|
+
watch(%r{.+\.rb$})
|
28
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
29
|
+
end
|
30
|
+
end
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ Navigate to your Jekyll project directory and create a Guardfile using:
|
|
42
42
|
Or if you already have a Guardfile, add a Jekyll guard.
|
43
43
|
|
44
44
|
```ruby
|
45
|
-
guard "
|
45
|
+
guard "jekyll_plus" do
|
46
46
|
watch /.*/
|
47
47
|
ignore /^_site/
|
48
48
|
end
|
@@ -66,7 +66,7 @@ If your Jekyll project has a non-standard directory stucture like this:
|
|
66
66
|
You would do this instead:
|
67
67
|
|
68
68
|
```ruby
|
69
|
-
guard "
|
69
|
+
guard "jekyll_plus" do
|
70
70
|
watch /^source/
|
71
71
|
watch /_config.yml/
|
72
72
|
end
|
@@ -97,7 +97,7 @@ This guard has these configurations.
|
|
97
97
|
To use Jekyll's built-in server, simply set `:serve => true` in your rack options
|
98
98
|
|
99
99
|
```ruby
|
100
|
-
guard "
|
100
|
+
guard "jekyll_plus", :serve => true do
|
101
101
|
watch /.*/
|
102
102
|
ignore /^_site/
|
103
103
|
end
|
@@ -115,7 +115,7 @@ If you wish to use your own rack server configuration, simply drop a `config.ru`
|
|
115
115
|
Here's how you would add `txt` to the list of file extensions which triggers a Jekyll build.
|
116
116
|
|
117
117
|
```ruby
|
118
|
-
guard "
|
118
|
+
guard "jekyll_plus", :extensions => ['txt'] do
|
119
119
|
watch /.*/
|
120
120
|
ignore /^_site/
|
121
121
|
end
|
@@ -129,7 +129,7 @@ which don't match these extensions will be simply copied over to the destination
|
|
129
129
|
Here's how you might tell Jekyll to read from multiple configuration files.
|
130
130
|
|
131
131
|
```ruby
|
132
|
-
guard "
|
132
|
+
guard "jekyll_plus", :config => ['settings.yml', 'override.yml'] do
|
133
133
|
watch /.*/
|
134
134
|
ignore /^_site/
|
135
135
|
end
|
data/Rakefile
CHANGED
data/guard-jekyll-plus.gemspec
CHANGED
@@ -1,28 +1,33 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'guard/
|
4
|
+
require 'guard/jekyll_plus/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'guard-jekyll-plus'
|
8
8
|
gem.version = Guard::JekyllPlusVersion::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
11
|
-
gem.description =
|
12
|
-
gem.summary =
|
13
|
-
|
9
|
+
gem.authors = ['Brandon Mathis']
|
10
|
+
gem.email = ['brandon@imathis.com']
|
11
|
+
gem.description = 'A Guard plugin for smarter Jekyll watching'
|
12
|
+
gem.summary = 'A Guard plugin for Jekyll which intelligently handles'\
|
13
|
+
' changes to static and template files, only running a'\
|
14
|
+
' Jekyll build when necessary. '
|
15
|
+
|
16
|
+
gem.homepage = 'http://github.com/imathis/guard-jekyll-plus'
|
14
17
|
gem.license = 'MIT'
|
15
18
|
|
16
|
-
gem.files = `git ls-files`.split(
|
17
|
-
gem.require_paths = [
|
19
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
20
|
+
gem.require_paths = ['lib']
|
18
21
|
|
19
|
-
gem.add_dependency 'guard', '~> 2.
|
22
|
+
gem.add_dependency 'guard', '~> 2.10', '>= 2.10.3'
|
23
|
+
gem.add_dependency 'guard-compat', '~> 1.1'
|
20
24
|
gem.add_dependency 'jekyll', '>= 1.0.0'
|
21
25
|
|
22
|
-
|
23
|
-
|
26
|
+
# Note: we use these for test depedencies, because it's more convenient
|
27
|
+
# to use Gemfile for development deps
|
28
|
+
gem.add_development_dependency 'rake'
|
29
|
+
gem.add_development_dependency 'rspec', '~> 3.1'
|
30
|
+
gem.add_development_dependency 'nenv', '~> 0.1'
|
24
31
|
|
25
|
-
if RUBY_VERSION >=
|
26
|
-
gem.add_development_dependency "bundler"
|
27
|
-
end
|
32
|
+
gem.add_development_dependency 'bundler' if RUBY_VERSION >= '2'
|
28
33
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
require 'jekyll'
|
6
|
+
|
7
|
+
require 'guard/compat/plugin'
|
8
|
+
|
9
|
+
require 'guard/jekyll_plus/server'
|
10
|
+
require 'guard/jekyll_plus/config'
|
11
|
+
require 'guard/jekyll_plus/builder'
|
12
|
+
|
13
|
+
module Guard
|
14
|
+
class JekyllPlus < Plugin
|
15
|
+
def initialize(options = {})
|
16
|
+
super
|
17
|
+
|
18
|
+
@config = Config.new(options)
|
19
|
+
@server = Server.new(@config)
|
20
|
+
@builder = Builder.new(@config)
|
21
|
+
end
|
22
|
+
|
23
|
+
def start
|
24
|
+
@builder.build
|
25
|
+
@server.start if @config.serve?
|
26
|
+
@config.info 'watching'
|
27
|
+
end
|
28
|
+
|
29
|
+
def reload
|
30
|
+
stop
|
31
|
+
@config.info 'Reloading Jekyll configuration!'
|
32
|
+
@config.reload
|
33
|
+
@builder.reload
|
34
|
+
start
|
35
|
+
end
|
36
|
+
|
37
|
+
def stop
|
38
|
+
@server.stop
|
39
|
+
end
|
40
|
+
|
41
|
+
def run_on_modifications(paths)
|
42
|
+
reload if paths.any? { |f| @config.config_file?(f) }
|
43
|
+
@builder.modified(paths)
|
44
|
+
end
|
45
|
+
|
46
|
+
def run_on_additions(paths)
|
47
|
+
@builder.added(paths)
|
48
|
+
end
|
49
|
+
|
50
|
+
def run_on_removals(paths)
|
51
|
+
@builder.removed(paths)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
|
3
|
+
require 'guard/jekyll_plus/config'
|
4
|
+
|
5
|
+
require 'guard/jekyll_plus/builder/modifier'
|
6
|
+
require 'guard/jekyll_plus/builder/adder'
|
7
|
+
require 'guard/jekyll_plus/builder/remover'
|
8
|
+
require 'guard/jekyll_plus/builder/rebuilder'
|
9
|
+
|
10
|
+
module Guard
|
11
|
+
class JekyllPlus < Plugin
|
12
|
+
class Builder
|
13
|
+
def initialize(config)
|
14
|
+
@config = config
|
15
|
+
reload
|
16
|
+
end
|
17
|
+
|
18
|
+
def reload
|
19
|
+
Jekyll.logger.log_level = :error
|
20
|
+
@site = ::Jekyll::Site.new(@config.jekyll_config)
|
21
|
+
Jekyll.logger.log_level = :info
|
22
|
+
|
23
|
+
@adder = Adder.new(@config, @site)
|
24
|
+
@modifier = Modifier.new(@config, @site)
|
25
|
+
@remover = Remover.new(@config, @site)
|
26
|
+
@rebuilder = Rebuilder.new(@config, @site)
|
27
|
+
end
|
28
|
+
|
29
|
+
def build
|
30
|
+
@rebuilder.update
|
31
|
+
end
|
32
|
+
|
33
|
+
def added(paths)
|
34
|
+
@adder.update(paths)
|
35
|
+
end
|
36
|
+
|
37
|
+
def modified(paths)
|
38
|
+
@modifier.update(paths)
|
39
|
+
end
|
40
|
+
|
41
|
+
def removed(paths)
|
42
|
+
@remover.update(paths)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'benchmark'
|
4
|
+
require 'jekyll'
|
5
|
+
require 'guard/compat/plugin'
|
6
|
+
|
7
|
+
require 'guard/jekyll_plus/config'
|
8
|
+
|
9
|
+
module Guard
|
10
|
+
class JekyllPlus < Plugin
|
11
|
+
class Builder
|
12
|
+
class Action
|
13
|
+
def initialize(config, site)
|
14
|
+
@config, @site = config, site
|
15
|
+
end
|
16
|
+
|
17
|
+
def jekyll_matches(paths)
|
18
|
+
paths.select { |file| file =~ @config.extensions }
|
19
|
+
end
|
20
|
+
|
21
|
+
def non_jekyll_matches(paths)
|
22
|
+
paths.select do |file|
|
23
|
+
!file.match(/^_/) && !file.match(@config.extensions)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def build(files, message, mark)
|
28
|
+
@config.info [message, 'building...'.yellow].join(' ')
|
29
|
+
|
30
|
+
if files
|
31
|
+
puts '| ' # spacing
|
32
|
+
files.each { |file| puts '|' + mark + file }
|
33
|
+
puts '| ' # spacing
|
34
|
+
end
|
35
|
+
|
36
|
+
elapsed = Benchmark.realtime { @site.process }.round(2)
|
37
|
+
|
38
|
+
change = format('%s → %s', @config.source, @config.destination)
|
39
|
+
@config.info format('build completed in %ss '.green + change, elapsed)
|
40
|
+
|
41
|
+
# rescue almost everything because Jekyll::Convertible forwards
|
42
|
+
# every plugin-specific exception it encounters
|
43
|
+
rescue StandardError => e
|
44
|
+
@config.error 'build has failed'
|
45
|
+
@config.error e.to_s
|
46
|
+
throw :task_has_failed
|
47
|
+
end
|
48
|
+
|
49
|
+
def ignore_stitch_sources(files)
|
50
|
+
return files unless (ignore = ENV['GUARD_STITCH_PLUS_FILES'])
|
51
|
+
|
52
|
+
ignore = ignore.split(',')
|
53
|
+
files.reject { |f| ignore.include? f }
|
54
|
+
end
|
55
|
+
|
56
|
+
def pluralize(word, array)
|
57
|
+
"#{word}#{array.size > 1 ? 's' : ''}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def destination_path(file)
|
61
|
+
if @config.source =~ /^\./
|
62
|
+
File.join @config.destination, file
|
63
|
+
else
|
64
|
+
file.sub(/^#{@config.source}/, "#{@config.destination}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_was_needed(paths)
|
69
|
+
matched = jekyll_matches(paths)
|
70
|
+
return false if matched.empty?
|
71
|
+
build(matched, @msg, @mark)
|
72
|
+
end
|
73
|
+
|
74
|
+
def update(paths)
|
75
|
+
return if build_was_needed(paths)
|
76
|
+
|
77
|
+
unmatched = non_jekyll_matches(paths)
|
78
|
+
return if unmatched.empty?
|
79
|
+
files = ignore_stitch_sources(unmatched)
|
80
|
+
return if files.empty?
|
81
|
+
|
82
|
+
do_update(files)
|
83
|
+
footer
|
84
|
+
rescue RuntimeError, SystemCallError => e
|
85
|
+
@config.error "#{@name} has failed"
|
86
|
+
@config.error e.to_s
|
87
|
+
throw :task_has_failed
|
88
|
+
end
|
89
|
+
|
90
|
+
def copy(src, dst)
|
91
|
+
if @config.excluded?(src)
|
92
|
+
puts '|' + (' ~ ' + "Ignoring excluded file: #{src}").yellow
|
93
|
+
return
|
94
|
+
end
|
95
|
+
|
96
|
+
FileUtils.mkdir_p File.dirname(dst)
|
97
|
+
FileUtils.cp src, dst
|
98
|
+
puts '|' + ' → '.green + dst
|
99
|
+
end
|
100
|
+
|
101
|
+
def remove(path)
|
102
|
+
if File.exist? path
|
103
|
+
FileUtils.rm path
|
104
|
+
puts '|' + ' → '.red + path
|
105
|
+
end
|
106
|
+
|
107
|
+
dir = File.dirname path
|
108
|
+
return if Dir[dir + '/*'].any?
|
109
|
+
|
110
|
+
FileUtils.rm_rk(dir)
|
111
|
+
puts '|' + ' x '.red + dir
|
112
|
+
end
|
113
|
+
|
114
|
+
def header(files)
|
115
|
+
plural = files.nil? ? '' : pluralize('file', files.size)
|
116
|
+
@config.info [@activity, plural].join(' ').send(@color)
|
117
|
+
puts '| ' unless files.nil? # spacing
|
118
|
+
end
|
119
|
+
|
120
|
+
def footer
|
121
|
+
puts '| ' # spacing
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|