deplot 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. data/bin/deplot +44 -11
  2. data/deplot.gemspec +2 -2
  3. metadata +5 -5
data/bin/deplot CHANGED
@@ -22,6 +22,17 @@ $current_source = ""
22
22
  $layout = ""
23
23
  $options = {}
24
24
 
25
+ $errors_occured = 0
26
+
27
+ # helper methods
28
+ def puts_alert text
29
+ puts "#{Thor::Shell::Color::RED}#{text}#{Thor::Shell::Color::CLEAR}"
30
+ $errors_occured += 1
31
+ end
32
+ def puts_success text
33
+ puts "#{Thor::Shell::Color::GREEN}#{text}#{Thor::Shell::Color::CLEAR}"
34
+ end
35
+
25
36
  # dsl methods for page specification
26
37
  def assets_dir dir
27
38
  $assets_dir = $root_dir + "/" + dir.gsub(/^\//, "").gsub(/\/$/, "")
@@ -124,6 +135,9 @@ def publish
124
135
  puts "Publishing site..."
125
136
  $tasks.each do |task|
126
137
  action, path, source, $layout, options, variables = task
138
+ unless path == "/"
139
+ path = "/" + path.gsub(/^\//, "")
140
+ end
127
141
  variables.merge! $global_variables
128
142
  content = ""
129
143
  $template_arguments = {:path => "", :source => "", :file_name => "", :depth => 0}
@@ -143,13 +157,13 @@ def publish
143
157
  if /\/$/ =~ path
144
158
  destination_dir = path.gsub /\/$/, ""
145
159
  destination_base = "index.#{options[:extension]}"
146
- end
160
+ end
147
161
  $template_arguments.merge! :path => "#{destination_dir}/#{destination_base}"
148
162
  $template_arguments.merge! :file_name => destination_base
149
163
  $template_arguments.merge! :source => source
150
164
  $template_arguments.merge! :depth => (destination_dir.count "/")
151
165
 
152
- puts "Rendering path '#{destination_dir}/#{destination_base}'"
166
+ puts "Rendering path '"+destination_dir.gsub(/\/$/, "")+"/#{destination_base}'"
153
167
  # make path
154
168
  FileUtils.mkdir_p "."+destination_dir
155
169
  unless File.directory? "."+destination_dir
@@ -173,7 +187,7 @@ def publish
173
187
  begin
174
188
  layout_tilt = Tilt.new($layout)
175
189
  rescue Exception => e
176
- puts "- ERROR creating tilt instance (possibly missing layout file)."
190
+ puts_alert "- ERROR creating tilt instance (possibly missing layout file)."
177
191
  layout_tilt = nil
178
192
  end
179
193
  end
@@ -186,7 +200,7 @@ def publish
186
200
  begin
187
201
  source_tilt = Tilt.new(source)
188
202
  rescue Exception => e
189
- puts "- ERROR creating tilt instance (possibly missing source file)."
203
+ puts_alert "- ERROR creating tilt instance (possibly missing source file)."
190
204
  source_tilt = nil
191
205
  end
192
206
  end
@@ -214,7 +228,7 @@ def publish
214
228
  if /\/$/ =~ path
215
229
  destination_dir = path.gsub /\/$/, ""
216
230
  destination_base = "index.#{options[:extension]}"
217
- end
231
+ end
218
232
 
219
233
  puts "Rendering path/s '"+destination_dir+"/...'"
220
234
  # make path
@@ -237,7 +251,7 @@ def publish
237
251
  begin
238
252
  layout_tilt = Tilt.new($layout)
239
253
  rescue Exception => e
240
- puts "- ERROR creating tilt instance (possibly missing layout file)."
254
+ puts_alert "- ERROR creating tilt instance (possibly missing layout file)."
241
255
  layout_tilt = nil
242
256
  end
243
257
  end
@@ -254,7 +268,7 @@ def publish
254
268
  begin
255
269
  source_tilt = Tilt.new(content_file)
256
270
  rescue Exception => e
257
- puts "- ERROR creating tilt instance (possibly missing source file)."
271
+ puts_alert "- ERROR creating tilt instance (possibly missing source file)."
258
272
  source_tilt = nil
259
273
  end
260
274
  if source_tilt.nil?
@@ -287,7 +301,7 @@ def publish
287
301
  if /\/$/ =~ path
288
302
  destination_dir = path.gsub /\/$/, ""
289
303
  destination_base = "index.#{options[:extension]}"
290
- end
304
+ end
291
305
 
292
306
  $template_arguments.merge! :path => "#{destination_dir}/#{destination_base}"
293
307
  $template_arguments.merge! :file_name => destination_base
@@ -315,7 +329,7 @@ def publish
315
329
  end
316
330
  paths.each do |content_file|
317
331
  #content = File.read content_file
318
- puts " Read source file #{source}/#{content_file}"
332
+ puts " Read source file #{source}#{content_file}"
319
333
  $template_arguments.merge! :source => "#{source}#{content_file}"
320
334
 
321
335
  # Create tilt instance
@@ -323,7 +337,7 @@ def publish
323
337
  begin
324
338
  source_tilt = Tilt.new(content_file)
325
339
  rescue Exception => e
326
- puts "- ERROR creating tilt instance (possibly missing source file)."
340
+ puts_alert "- ERROR creating tilt instance (possibly missing source file)."
327
341
  source_tilt = nil
328
342
  end
329
343
  if source_tilt.nil?
@@ -341,7 +355,7 @@ def publish
341
355
  begin
342
356
  layout_tilt = Tilt.new($layout)
343
357
  rescue Exception => e
344
- puts "- ERROR creating tilt instance (possibly missing layout file)."
358
+ puts_alert "- ERROR creating tilt instance (possibly missing layout file)."
345
359
  layout_tilt = nil
346
360
  end
347
361
  end
@@ -358,6 +372,13 @@ def publish
358
372
  puts " Wrote to file."
359
373
  end # End of action switching
360
374
  end
375
+ if $errors_occured == 0
376
+ puts_success "Successfully created all pages."
377
+ elsif $errors_occured == 1
378
+ puts_alert "#{$errors_occured} error occurred!"
379
+ else
380
+ puts_alert "#{$errors_occured} errors occurred!"
381
+ end
361
382
  end
362
383
 
363
384
  # Thor: Deplot CLI
@@ -443,6 +464,18 @@ watch(/(assets|content)\\/(.*)/) do |m|
443
464
  `echo ""; echo "File '\#{m[2]}' changed."; deplot make`
444
465
  end
445
466
  end
467
+ EOF
468
+ end
469
+ # .git-ftp-ignore
470
+ puts " Creating .git-ftp-ignore..."
471
+ File.open ".git-ftp-ignore", "w" do |file|
472
+ file.write <<-EOF
473
+ .gitignore
474
+ .git-ftp-ignore
475
+ Deplotfile
476
+ Guardfile
477
+ assets/.*
478
+ content/.*
446
479
  EOF
447
480
  end
448
481
  # Example content
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'deplot'
3
- s.version = '0.0.3'
4
- s.date = '2012-04-10'
3
+ s.version = '0.0.4'
4
+ s.date = '2012-04-29'
5
5
  s.description = "A ruby static web site generator"
6
6
  s.summary = s.description
7
7
  s.authors = ["Cyril Nusko"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deplot
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Cyril Nusko
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-10 00:00:00 Z
18
+ date: 2012-04-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: thor
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements: []
93
93
 
94
94
  rubyforge_project:
95
- rubygems_version: 1.8.21
95
+ rubygems_version: 1.8.4
96
96
  signing_key:
97
97
  specification_version: 3
98
98
  summary: A ruby static web site generator