guard-jekyll-plus 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -29,3 +29,8 @@ New config options
29
29
 
30
30
  - Removed accidental debugging output.
31
31
 
32
+ ### 1.2.2
33
+
34
+ - Copy and remove ignore changes in directories beginning with an underscore.
35
+ - Improved output for Jekyll build.
36
+
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  class JekyllPlusVersion
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
4
4
  end
5
5
  end
@@ -54,7 +54,6 @@ module Guard
54
54
  end
55
55
 
56
56
  def start
57
-
58
57
  if @options[:serve]
59
58
  start_server
60
59
  build
@@ -75,31 +74,48 @@ module Guard
75
74
  stop_server
76
75
  end
77
76
 
78
- def run_all
79
- build
80
- end
81
-
82
77
  def run_on_modifications(paths)
83
- changes(paths)
78
+ matched = jekyll_matches paths
79
+ unmatched = non_jekyll_matches paths
80
+
81
+ if matched.size > 0
82
+ build(matched, "Files changed: ", " ~ ".yellow)
83
+ elsif unmatched.size > 0
84
+ copy(unmatched)
85
+ end
84
86
  end
85
87
 
86
88
  def run_on_additions(paths)
87
- changes(paths)
89
+ matched = jekyll_matches paths
90
+ unmatched = non_jekyll_matches paths
91
+
92
+ if matched.size > 0
93
+ build(matched, "Files added: ", " + ".green)
94
+ elsif unmatched.size > 0
95
+ copy(unmatched)
96
+ end
88
97
  end
89
98
 
90
99
  def run_on_removals(paths)
91
- remove paths
100
+ matched = jekyll_matches paths
101
+ unmatched = non_jekyll_matches paths
102
+
103
+ if matched.size > 0
104
+ build(matched, "Files removed: ", " x ".red)
105
+ elsif unmatched.size > 0
106
+ remove(unmatched)
107
+ end
92
108
  end
93
109
 
94
110
 
95
111
  private
96
112
 
97
- def build(changes=nil)
113
+ def build(files = nil, message = '', mark = nil)
98
114
  begin
99
- UI.info "#{@label} " + "building...".yellow unless @config[:silent]
100
- if changes
115
+ UI.info "#{@label} #{message}" + "building...".yellow unless @config[:silent]
116
+ if files
101
117
  puts '| ' # spacing
102
- changes.each { |file| puts '|' + " ~ ".yellow + file }
118
+ files.each { |file| puts '|' + mark + file }
103
119
  puts '| ' # spacing
104
120
  end
105
121
  @site.process
@@ -170,25 +186,12 @@ module Guard
170
186
  true
171
187
  end
172
188
 
173
- def changes(paths)
174
- matches = []
175
- copy_files = []
176
-
177
- paths.each do |file|
178
- if file =~ @extensions
179
- matches.push file
180
- else
181
- copy_files.push file
182
- end
183
- end
189
+ def jekyll_matches(paths)
190
+ paths.select { |file| file =~ @extensions }
191
+ end
184
192
 
185
- # If changes match Jekyll extensions, trigger a build else, copy files manually
186
- #
187
- if matches.length > 0
188
- build(matches)
189
- else
190
- copy(copy_files)
191
- end
193
+ def non_jekyll_matches(paths)
194
+ paths.select { |file| !file.match(/^_/) and !file.match(@extensions) }
192
195
  end
193
196
 
194
197
  def jekyll_config(options)
@@ -221,6 +224,11 @@ module Guard
221
224
  end
222
225
  end
223
226
 
227
+ # Remove
228
+ def ignore_underscores(paths)
229
+ paths.select { |file| file =~ /^[^_]/ }
230
+ end
231
+
224
232
  def server(config)
225
233
  proc{ Process.fork { ::Jekyll::Commands::Serve.process(config) } }
226
234
  end
data/test/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- guard-jekyll-plus (1.2.0)
4
+ guard-jekyll-plus (1.2.2)
5
5
  guard (>= 1.1.0)
6
6
  jekyll (>= 1.0.0)
7
7
 
data/test/_config.yml CHANGED
@@ -0,0 +1,2 @@
1
+ source: ./
2
+ port: 4000
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-jekyll-plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: