guard-jekyll-plus 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ### 1.0.0
4
+ - Initial release. A nice guard watcher for Jekyll projects.
5
+
6
+ ### 1.1.0
7
+ - Added support for Jekyll serve.
8
+
9
+ ### 1.1.1
10
+ - Improved colorized output.
11
+ - Rescued errors kill the Jekyll WEBrick server.
data/README.md CHANGED
@@ -8,6 +8,11 @@ Features:
8
8
  - Batched processing! (Adding a directory of `n` files triggers a single build)
9
9
  - Reads options from your YAML config file(s)
10
10
  - Supports multiple config files (Jekyll 1.0)
11
+ - Clear and colorized output
12
+
13
+ Here's a look
14
+
15
+ ![Colorized output](http://cl.ly/QAK9/content.png)
11
16
 
12
17
  ## Installation
13
18
 
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  class JekyllVersion
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
data/lib/guard/jekyll.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require 'guard'
2
4
  require 'guard/guard'
3
5
 
@@ -34,10 +36,10 @@ module Guard
34
36
  if @options[:serve]
35
37
  start_server
36
38
 
37
- UI.info "Guard::Jekyll is watching files and serving at #{@config['host']}:#{@config['port']}#{@config['baseurl']}".bold
39
+ UI.info "Guard::Jekyll " + "watching and serving at #{@config['host']}:#{@config['port']}#{@config['baseurl']}"
38
40
  else
39
41
  build
40
- UI.info "Guard::Jekyll is watching".bold
42
+ UI.info "Guard::Jekyll " + "watching"
41
43
  end
42
44
  end
43
45
 
@@ -64,61 +66,84 @@ module Guard
64
66
  end
65
67
 
66
68
  def run_on_removals(paths)
67
- paths.each { |file| remove file }
69
+ remove paths
68
70
  end
69
71
 
70
72
 
71
73
  private
72
74
 
73
- def build
75
+ def build(changes=nil)
74
76
  begin
75
- UI.info "Guard::Jekyll "+" building".yellow + " source: #{@source}, destination: #{@destination}"
77
+ UI.info "Guard::Jekyll " + "building...".yellow
78
+ if changes
79
+ puts '| ' # spacing
80
+ changes.each { |file| puts '|' + " ~ ".yellow + file }
81
+ puts '| ' # spacing
82
+ end
76
83
  @site.process
77
- UI.info "Guard::Jekyll "+" complete".green + " #{@source} built to #{@destination}"
84
+ UI.info "Guard::Jekyll " + "build complete ".green + "#{@source} #{@destination}"
78
85
 
79
86
  rescue Exception => e
80
87
  UI.error "Guard::Jekyll build has failed"
88
+ stop_server
81
89
  throw :task_has_failed
82
90
  end
83
91
  end
84
92
 
85
93
  # Copy static files to destination directory
86
94
  #
87
- def copy(file)
95
+ def copy(files=[])
88
96
  begin
89
- path = destination_path file
90
- FileUtils.mkdir_p File.dirname(path)
91
- FileUtils.cp file, path
92
- UI.info "Guard::Jekyll" + " copied ".green + "#{file} -> #{path}"
97
+ message = 'copied file'
98
+ message += 's' if files.size > 1
99
+ UI.info "Guard::Jekyll #{message.green}"
100
+ puts '| ' #spacing
101
+ files.each do |file|
102
+ path = destination_path file
103
+ FileUtils.mkdir_p File.dirname(path)
104
+ FileUtils.cp file, path
105
+ puts '|' + " → ".green + path
106
+ end
107
+ puts '| ' #spacing
108
+
93
109
  rescue Exception => e
94
110
  UI.error "Guard::Jekyll copy has failed"
95
111
  UI.error e
112
+ stop_server
96
113
  throw :task_has_failed
97
114
  end
115
+ true
98
116
  end
99
117
 
100
118
  # Remove deleted source file/directories from destination
101
119
  #
102
- def remove(file)
103
- path = destination_path file
104
- if File.exist? path
105
- begin
106
-
107
- FileUtils.rm path
108
- UI.info "Guard::Jekyll" + " removed ".red + path
120
+ def remove(files=[])
121
+ begin
122
+ message = 'removed file'
123
+ message += 's' if files.size > 1
124
+ UI.info "Guard::Jekyll #{message.red}"
125
+ puts '| ' #spacing
126
+
127
+ files.each do |file|
128
+ path = destination_path file
129
+ if File.exist? path
130
+ FileUtils.rm path
131
+ puts '|' + " x ".red + path
132
+ end
109
133
 
110
134
  dir = File.dirname path
111
135
  if Dir[dir+'/*'].empty?
112
136
  FileUtils.rm_r(dir)
113
- UI.info "Guard::Jekyll" + " removed ".red + dir
137
+ puts '|' + " x ".red + dir
114
138
  end
115
-
116
- rescue Exception => e
117
- UI.error "Guard::Jekyll remove has failed"
118
- UI.error e
119
- throw :task_has_failed
120
139
  end
140
+ puts '| ' #spacing
121
141
 
142
+ rescue Exception => e
143
+ UI.error "Guard::Jekyll remove has failed"
144
+ UI.error e
145
+ stop_server
146
+ throw :task_has_failed
122
147
  end
123
148
  true
124
149
  end
@@ -138,9 +163,9 @@ module Guard
138
163
  # If changes match Jekyll extensions, trigger a build else, copy files manually
139
164
  #
140
165
  if matches.length > 0
141
- build
166
+ build(matches)
142
167
  else
143
- copy_files.each { |f| copy f }
168
+ copy(copy_files)
144
169
  end
145
170
  end
146
171
 
data/test/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- guard-jekyll-plus (1.0.0)
4
+ guard-jekyll-plus (1.1.0)
5
5
  guard (>= 1.1.0)
6
6
  jekyll (>= 1.0.0)
7
7
 
data/test/_override.yml CHANGED
@@ -1,2 +1 @@
1
1
  port: 3500
2
- baseurl: dang
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.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-09 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -51,6 +51,7 @@ extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
53
  - .gitignore
54
+ - CHANGELOG.md
54
55
  - Gemfile
55
56
  - Gemfile.lock
56
57
  - LICENSE.txt