rabbit 2.0.1 → 2.0.2

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 (91) hide show
  1. data/Rakefile +0 -27
  2. data/data/locale/en/LC_MESSAGES/rabbit.mo +0 -0
  3. data/data/locale/fr/LC_MESSAGES/rabbit.mo +0 -0
  4. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  5. data/doc/_config.yml +2 -2
  6. data/doc/en/index.rd +5 -5
  7. data/doc/en/news.rd +87 -0
  8. data/doc/images/screenshots/en/blue-circle.png +0 -0
  9. data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
  10. data/doc/images/screenshots/en/clear-blue.png +0 -0
  11. data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
  12. data/doc/images/screenshots/en/cozmixng.png +0 -0
  13. data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
  14. data/doc/images/screenshots/en/dark-gradation.png +0 -0
  15. data/doc/images/screenshots/en/day-white-raw.png +0 -0
  16. data/doc/images/screenshots/en/day-white.png +0 -0
  17. data/doc/images/screenshots/en/debian-raw.png +0 -0
  18. data/doc/images/screenshots/en/debian.png +0 -0
  19. data/doc/images/screenshots/en/green-circle.png +0 -0
  20. data/doc/images/screenshots/en/night-black-raw.png +0 -0
  21. data/doc/images/screenshots/en/night-black.png +0 -0
  22. data/doc/images/screenshots/en/rabbit-raw.png +0 -0
  23. data/doc/images/screenshots/en/rabbit.png +0 -0
  24. data/doc/images/screenshots/en/ranguba-raw.png +0 -0
  25. data/doc/images/screenshots/en/ranguba.png +0 -0
  26. data/doc/images/screenshots/en/red-frame-raw.png +0 -0
  27. data/doc/images/screenshots/en/red-frame.png +0 -0
  28. data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
  29. data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
  30. data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
  31. data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
  32. data/doc/images/screenshots/ja/blue-circle.png +0 -0
  33. data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
  34. data/doc/images/screenshots/ja/clear-blue.png +0 -0
  35. data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
  36. data/doc/images/screenshots/ja/cozmixng.png +0 -0
  37. data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
  38. data/doc/images/screenshots/ja/dark-gradation.png +0 -0
  39. data/doc/images/screenshots/ja/day-white-raw.png +0 -0
  40. data/doc/images/screenshots/ja/day-white.png +0 -0
  41. data/doc/images/screenshots/ja/debian-raw.png +0 -0
  42. data/doc/images/screenshots/ja/debian.png +0 -0
  43. data/doc/images/screenshots/ja/green-circle.png +0 -0
  44. data/doc/images/screenshots/ja/night-black-raw.png +0 -0
  45. data/doc/images/screenshots/ja/night-black.png +0 -0
  46. data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
  47. data/doc/images/screenshots/ja/rabbit.png +0 -0
  48. data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
  49. data/doc/images/screenshots/ja/ranguba.png +0 -0
  50. data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
  51. data/doc/images/screenshots/ja/red-frame.png +0 -0
  52. data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
  53. data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
  54. data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
  55. data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
  56. data/doc/ja/index.rd +5 -5
  57. data/doc/ja/news.rd +85 -0
  58. data/lib/rabbit/author-configuration.rb +30 -15
  59. data/lib/rabbit/command/rabbit-slide.rb +70 -184
  60. data/lib/rabbit/command/rabbit-theme.rb +46 -125
  61. data/lib/rabbit/command/rabbit.rb +2 -1
  62. data/lib/rabbit/path-manipulatable.rb +0 -3
  63. data/lib/rabbit/readme-parser.rb +49 -0
  64. data/lib/rabbit/slide-configuration.rb +127 -0
  65. data/lib/rabbit/source-generator.rb +39 -0
  66. data/lib/rabbit/source-generator/hiki.rb +63 -0
  67. data/lib/rabbit/source-generator/markdown.rb +61 -0
  68. data/lib/rabbit/source-generator/rd.rb +65 -0
  69. data/lib/rabbit/task/slide.rb +68 -31
  70. data/lib/rabbit/task/theme.rb +46 -11
  71. data/lib/rabbit/theme-configuration.rb +104 -0
  72. data/lib/rabbit/theme/default-title-text/default-title-text.rb +2 -2
  73. data/lib/rabbit/theme/entry.rb +3 -2
  74. data/lib/rabbit/theme/nari/nari.rb +2 -0
  75. data/lib/rabbit/theme/slide-number/slide-number.rb +2 -2
  76. data/lib/rabbit/version.rb +1 -1
  77. data/po/rabbit.pot +1548 -1419
  78. data/test/run-test.rb +3 -1
  79. data/test/source-generator/test-hiki.rb +68 -0
  80. data/test/source-generator/test-markdown.rb +67 -0
  81. data/test/source-generator/test-rd.rb +69 -0
  82. data/test/{test_applier.rb → test-applier.rb} +0 -0
  83. data/test/test-author-configuration.rb +36 -0
  84. data/test/{test_color.rb → test-color.rb} +0 -0
  85. data/test/{test_element.rb → test-element.rb} +0 -0
  86. data/test/test-readme-parser.rb +57 -0
  87. data/test/test-slide-configuration.rb +56 -0
  88. data/test/{test_source.rb → test-source.rb} +0 -0
  89. data/test/test-theme-configuration.rb +47 -0
  90. data/test/{test_utils.rb → test-utils.rb} +0 -0
  91. metadata +65 -12
@@ -18,7 +18,9 @@ require "yaml"
18
18
 
19
19
  require "rabbit/console"
20
20
  require "rabbit/author-configuration"
21
+ require "rabbit/slide-configuration"
21
22
  require "rabbit/path-manipulatable"
23
+ require "rabbit/source-generator"
22
24
 
23
25
  module Rabbit
24
26
  module Command
@@ -33,13 +35,9 @@ module Rabbit
33
35
  end
34
36
 
35
37
  def initialize
36
- @config_yaml_path = "config.yaml"
37
- @id = nil
38
- @base_name = nil
39
38
  @title = nil
40
- @tags = []
41
39
  @allotted_time = nil
42
- @presentation_date = nil
40
+ @slide_conf = nil
43
41
  @author_conf = nil
44
42
  @logger = nil
45
43
  end
@@ -65,6 +63,8 @@ module Rabbit
65
63
  @logger = options.default_logger
66
64
  @author_conf = AuthorConfiguration.new(@logger)
67
65
  @author_conf.load
66
+ @slide_conf = SlideConfiguration.new(@logger)
67
+ @slide_conf.author = @author_conf
68
68
 
69
69
  format = _("Usage: %s new [options]\n" \
70
70
  " e.g.: %s new \\\n" \
@@ -88,7 +88,7 @@ module Rabbit
88
88
  _("Slide ID"),
89
89
  _("(e.g.: %s)") % "--id=rubykaigi2012",
90
90
  _("(must)")) do |id|
91
- @id = id
91
+ @slide_conf.id = id
92
92
  end
93
93
 
94
94
  messages = [
@@ -98,7 +98,7 @@ module Rabbit
98
98
  ]
99
99
  parser.on("--base-name=NAME",
100
100
  *messages) do |base_name|
101
- @base_name = base_name
101
+ @slide_conf.base_name = base_name
102
102
  end
103
103
 
104
104
  available_markup_languages = [:rd, :hiki, :markdown]
@@ -129,7 +129,7 @@ module Rabbit
129
129
  _("Tags of the new slide"),
130
130
  _("(e.g.: %s)") % "--tags=rabbit,presentation,ruby",
131
131
  _("(optional)")) do |tags|
132
- @tags.concat(tags)
132
+ @slide_conf.tags.concat(tags)
133
133
  end
134
134
 
135
135
  parser.on("--allotted-time=TIME",
@@ -143,7 +143,7 @@ module Rabbit
143
143
  _("Presentation date with the new slide"),
144
144
  _("(e.g.: %s)") % "--presentation-date=2012/06/29",
145
145
  _("(optional)")) do |date|
146
- @presentation_date = date
146
+ @slide_conf.presentation_date = date
147
147
  end
148
148
 
149
149
  parser.separator(_("Your information"))
@@ -242,28 +242,39 @@ module Rabbit
242
242
  end
243
243
 
244
244
  def validate_id
245
- if @id.nil?
245
+ if @slide_conf.id.nil?
246
246
  @validation_errors << (_("%s is missing") % "--id")
247
247
  end
248
248
  end
249
249
 
250
250
  def validate_base_name
251
- if @base_name.nil?
251
+ if @slide_conf.base_name.nil?
252
252
  @validation_errors << (_("%s is missing") % "--base-name")
253
253
  end
254
254
  end
255
255
 
256
256
  def generate
257
257
  generate_directory
258
+ generate_dot_gitignore
258
259
  generate_dot_rabbit
259
- generate_config_yaml
260
+ generate_slide_configuration
260
261
  generate_readme
261
262
  generate_rakefile
262
263
  generate_slide
263
264
  end
264
265
 
265
266
  def generate_directory
266
- create_directory(@id)
267
+ create_directory(@slide_conf.id)
268
+ end
269
+
270
+ def generate_dot_gitignore
271
+ create_file(".gitignore") do |dot_gitignore|
272
+ dot_gitignore.puts(<<-EOD)
273
+ /.tmp/
274
+ /pkg/
275
+ /pdf/
276
+ EOD
277
+ end
267
278
  end
268
279
 
269
280
  def generate_dot_rabbit
@@ -277,21 +288,8 @@ module Rabbit
277
288
  end
278
289
  end
279
290
 
280
- def generate_config_yaml
281
- create_file(@config_yaml_path) do |config_yaml|
282
- config = {
283
- "id" => @id,
284
- "tags" => @tags,
285
- "base_name" => @base_name,
286
- "name" => @author_conf.name,
287
- "presentation_date" => @presentation_date,
288
- "email" => @author_conf.email,
289
- "rubygems_user" => @author_conf.rubygems_user,
290
- "slideshare_user" => @author_conf.slideshare_user,
291
- "speaker_deck_user" => @author_conf.speaker_deck_user,
292
- }
293
- config_yaml.puts(config.to_yaml)
294
- end
291
+ def generate_slide_configuration
292
+ @slide_conf.save(@slide_conf.id)
295
293
  end
296
294
 
297
295
  def generate_readme
@@ -302,107 +300,52 @@ module Rabbit
302
300
 
303
301
  def readme_content
304
302
  markup_language = @author_conf.markup_language || :rd
305
- syntax = markup_syntax(markup_language)
303
+ generator = Rabbit::SourceGenerator.find(markup_language)
306
304
 
307
305
  content = ""
308
- content << (syntax[:heading1] % {:title => _("TODO: SLIDE TITLE")})
306
+ title = @title || _("TODO: SLIDE TITLE")
307
+ content << generator.heading(1, title)
309
308
  content << "\n\n"
310
309
  content << _("TODO: SLIDE DESCRIPTION")
311
310
  content << "\n\n"
312
311
 
313
- content << (syntax[:heading2] % {:title => _("For author")})
312
+ content << generator.heading(2, _("For author"))
314
313
  content << "\n\n"
315
- content << (syntax[:heading3] % {:title => _("Show")})
314
+ content << generator.heading(3, _("Show"))
316
315
  content << "\n\n"
317
- content << (syntax[:preformatted_line] % {:content => "rake"})
316
+ content << generator.preformatted_line("rake")
318
317
  content << "\n\n"
319
- content << (syntax[:heading3] % {:title => _("Publish")})
318
+ content << generator.heading(3, _("Publish"))
320
319
  content << "\n\n"
321
- content << (syntax[:preformatted_line] % {:content => "rake publish"})
320
+ content << generator.preformatted_line("rake publish")
322
321
  content << "\n\n"
323
322
 
324
- content << (syntax[:heading2] % {:title => _("For viewers")})
323
+ content << generator.heading(2, _("For viewers"))
325
324
  content << "\n\n"
326
- content << (syntax[:heading3] % {:title => _("Install")})
325
+ content << generator.heading(3, _("Install"))
327
326
  content << "\n\n"
328
- install_command = "gem install #{gem_name}"
329
- content << (syntax[:preformatted_line] % {:content => install_command})
327
+ install_command = "gem install #{@slide_conf.gem_name}"
328
+ content << generator.preformatted_line(install_command)
330
329
  content << "\n\n"
331
- content << (syntax[:heading3] % {:title => _("Show")})
330
+ content << generator.heading(3, _("Show"))
332
331
  content << "\n\n"
333
- show_command = "rabbit #{gem_name}.gem"
334
- content << (syntax[:preformatted_line] % {:content => show_command})
332
+ show_command = "rabbit #{@slide_conf.gem_name}.gem"
333
+ content << generator.preformatted_line(show_command)
335
334
  content << "\n\n"
336
335
  end
337
336
 
338
337
  def generate_rakefile
339
338
  create_file("Rakefile") do |rakefile|
340
339
  rakefile.puts(<<-EOR)
341
- require "time"
342
- require "yaml"
343
340
  require "rabbit/task/slide"
344
341
 
345
- config = YAML.load(File.read("#{@config_yaml_path}"))
346
-
347
- slide_id = config["id"]
348
- tags = config["tags"]
349
- base_name = config["base_name"]
350
- pdf_base_path = "\#{base_name}.pdf"
351
-
352
- version = nil
353
- presentation_date = config["presentation_date"]
354
- parsed_presentation_date = nil
355
- if presentation_date
356
- begin
357
- parsed_presentation_date = Time.parse(presentation_date)
358
- rescue ArgumentError
359
- end
360
- if parsed_presentation_date
361
- version = parsed_presentation_date.strftime("%Y.%m.%d")
362
- end
363
- end
364
- version ||= "1.0.0"
365
-
366
- name = config["name"]
367
- email = config["email"]
368
- rubygems_user = config["rubygems_user"]
369
- slideshare_user = config["slideshare_user"]
370
- speaker_deck_user = config["speaker_deck_user"]
371
-
372
- readme = File.read(Dir.glob("README*")[0])
373
-
374
- readme_blocks = readme.split(/(?:\\r?\\n){2,}/)
375
- summary = (readme_blocks[0] || "TODO").gsub(/\\A(?:[=*!]+|h\\d\\.)\s*/, "")
376
- description = readme_blocks[1] || "TODO"
377
-
378
- specification = Gem::Specification.new do |spec|
379
- prefix = "#{gem_name_prefix}"
380
- spec.name = "\#{prefix}-\#{rubygems_user}-\#{slide_id}"
381
- spec.version = version
382
- spec.homepage = "http://slide.rabbit-shockers.org/\#{rubygems_user}/\#{slide_id}/"
383
- spec.authors = [name]
384
- spec.email = [email]
385
- spec.summary = summary
386
- spec.description = description
387
- spec.licenses = [] # ["CC BY-SA 3.0"]
388
-
389
- spec.files = [".rabbit", "#{@config_yaml_path}", "Rakefile"]
390
- spec.files += Dir.glob("{COPYING,GPL,README*}")
391
- spec.files += Dir.glob("rabbit/**/*.*")
392
- spec.files += Dir.glob("**/*.{svg,png,jpg,jpeg,gif,eps,pdf}")
393
- spec.files += Dir.glob("*.{rd,rab,hiki,md,pdf}")
394
- spec.files -= Dir.glob("{pkg,pdf}/**/*.*")
395
-
396
- spec.add_runtime_dependency("rabbit")
397
- end
342
+ # Edit ./config.yaml to customize meta data
398
343
 
399
- Rabbit::Task::Slide.new(specification) do |task|
400
- task.rubygems_user = rubygems_user
401
- task.slideshare_user = slideshare_user
402
- task.speaker_deck_user = speaker_deck_user
403
- task.pdf_base_path = pdf_base_path
404
- task.tags = tags
405
- task.presentation_date = parsed_presentation_date
344
+ Rabbit::Task::Slide.new do |task|
345
+ # task.spec.licenses = ["CC BY-SA 3.0"]
346
+ # task.spec.files += Dir.glob("doc/**/*.*")
347
+ # task.spec.files -= Dir.glob("private/**/*.*")
348
+ # task.spec.add_runtime_dependency("YOUR THEME")
406
349
  end
407
350
  EOR
408
351
  end
@@ -417,7 +360,7 @@ EOR
417
360
  end
418
361
 
419
362
  def slide_path
420
- "#{@base_name}.#{slide_source_extension}"
363
+ "#{@slide_conf.base_name}.#{slide_source_extension}"
421
364
  end
422
365
 
423
366
  def slide_source_extension
@@ -447,124 +390,67 @@ EOR
447
390
  end
448
391
 
449
392
  def slide_source
450
- syntax = slide_source_syntax
451
- return nil if syntax.nil?
393
+ generator = Rabbit::SourceGenerator.find(@author_conf.markup_language)
394
+ return nil if generator.nil?
452
395
 
453
396
  source = ""
454
- slide_source_title(source, syntax, _("TITLE"))
455
- slide_source_metadata(source, syntax)
456
- slide_source_title(source, syntax, _("FIRST SLIDE"))
457
- slide_source_items(source, syntax)
458
- slide_source_title(source, syntax, _("SECOND SLIDE"))
459
- slide_source_image(source, syntax)
397
+ slide_source_title(source, generator, @title || _("TITLE"))
398
+ slide_source_metadata(source, generator)
399
+ slide_source_title(source, generator, _("FIRST SLIDE"))
400
+ slide_source_items(source, generator)
401
+ slide_source_title(source, generator, _("SECOND SLIDE"))
402
+ slide_source_image(source, generator)
460
403
  end
461
404
 
462
- def slide_source_title(source, syntax, title)
463
- source << (syntax[:heading1] % {:title => _("TITLE")})
405
+ def slide_source_title(source, generator, title)
406
+ source << generator.heading(1, _("TITLE"))
464
407
  source << "\n\n"
465
408
  end
466
409
 
467
- def slide_source_metadata(source, syntax)
410
+ def slide_source_metadata(source, generator)
411
+ presentation_date = @slide_conf.presentation_date
468
412
  slide_metadata = [
469
413
  ["subtitle", nil, _("SUBTITLE")],
470
414
  ["author", @author_conf.name, _("AUTHOR")],
471
415
  ["institution", nil, _("INSTITUTION")],
472
416
  ["content-source", nil, _("EVENT NAME")],
473
- ["date", @presentation_date, Time.now.strftime("%Y/%m/%d")],
417
+ ["date", presentation_date, Time.now.strftime("%Y/%m/%d")],
474
418
  ["allotted-time", @allotted_time, "5m"],
475
419
  ["theme", nil, "default"],
476
420
  ]
477
421
  slide_metadata.each do |key, value, default_value|
478
- data = {:item => key, :description => value || default_value}
479
- item = syntax[:definition_list_item] % data
422
+ item = generator.definition_list_item(key, value || default_value)
480
423
  item << "\n"
481
424
  if value
482
425
  source << item
483
426
  else
484
427
  item.each_line do |line|
485
- source << (syntax[:comment] % {:content => line})
428
+ source << generator.comment(line)
486
429
  end
487
430
  end
488
431
  end
489
432
  source << "\n\n"
490
433
  end
491
434
 
492
- def slide_source_items(source, syntax)
435
+ def slide_source_items(source, generator)
493
436
  1.upto(3) do |i|
494
- source << syntax[:unorderd_list_item] % {:item => _("ITEM %d") % i}
437
+ source << generator.unordered_list_item(_("ITEM %d") % i)
495
438
  source << "\n"
496
439
  end
497
440
  source << "\n"
498
441
  end
499
442
 
500
- def slide_source_image(source, syntax)
443
+ def slide_source_image(source, generator)
501
444
  lavie = "https://raw.github.com/shockers/rabbit/master/sample/lavie.png"
502
- data = {
503
- :src => lavie,
445
+ options = {
504
446
  :relative_height => 100,
505
447
  }
506
- source << syntax[:image] % data
448
+ source << generator.image(lavie, options)
507
449
  source << "\n"
508
450
  end
509
451
 
510
- def slide_source_syntax
511
- markup_syntax(@author_conf.markup_language)
512
- end
513
-
514
- def markup_syntax(markup_language)
515
- case markup_language
516
- when :rd
517
- {
518
- :heading1 => "= %{title}",
519
- :heading2 => "== %{title}",
520
- :heading3 => "=== %{title}",
521
- :definition_list_item => ": %{item}\n %{description}",
522
- :unorderd_list_item => " * %{item}",
523
- :image =>
524
- " # image\n" +
525
- " # src = %{src}\n" +
526
- " # relative_height = %{relative_height}",
527
- :preformatted_line => " %{content}",
528
- :comment => "# %{content}",
529
- }
530
- when :hiki
531
- {
532
- :heading1 => "! %{title}",
533
- :heading2 => "!! %{title}",
534
- :heading3 => "!!! %{title}",
535
- :definition_list_item => ":%{item}:%{description}",
536
- :unorderd_list_item => "* %{item}",
537
- :image =>
538
- "{{image(\"%{src}\",\n" +
539
- " {\n" +
540
- " :relative_height => %{relative_height},\n" +
541
- " })}}",
542
- :preformatted_line => " %{content}",
543
- :comment => "// %{content}",
544
- }
545
- when :markdown
546
- {
547
- :heading1 => "# %{title}",
548
- :heading2 => "## %{title}",
549
- :heading3 => "### %{title}",
550
- :definition_list_item => "%{item}\n %{description}",
551
- :unorderd_list_item => "* %{item}",
552
- :image =>
553
- "![](%{src}){:relative_height='%{relative_height}'}",
554
- :preformatted_line => " %{content}",
555
- :comment => "",
556
- }
557
- else
558
- nil
559
- end
560
- end
561
-
562
- def gem_name
563
- "#{gem_name_prefix}-#{@author_conf.rubygems_user}-#{@id}"
564
- end
565
-
566
- def gem_name_prefix
567
- "rabbit-slide"
452
+ def create_file(path, &block)
453
+ super(File.join(@slide_conf.id, path), &block)
568
454
  end
569
455
  end
570
456
  end
@@ -18,7 +18,9 @@ require "yaml"
18
18
 
19
19
  require "rabbit/console"
20
20
  require "rabbit/author-configuration"
21
+ require "rabbit/theme-configuration"
21
22
  require "rabbit/path-manipulatable"
23
+ require "rabbit/source-generator"
22
24
 
23
25
  module Rabbit
24
26
  module Command
@@ -33,8 +35,7 @@ module Rabbit
33
35
  end
34
36
 
35
37
  def initialize
36
- @config_yaml_path = "config.yaml"
37
- @id = nil
38
+ @theme_conf = nil
38
39
  @author_conf = nil
39
40
  @logger = nil
40
41
  end
@@ -60,6 +61,8 @@ module Rabbit
60
61
  @logger = options.default_logger
61
62
  @author_conf = AuthorConfiguration.new(@logger)
62
63
  @author_conf.load
64
+ @theme_conf = ThemeConfiguration.new(@logger)
65
+ @theme_conf.author = @author_conf
63
66
 
64
67
  format = _("Usage: %s new [options]\n" \
65
68
  " e.g.: %s new \\\n" \
@@ -79,7 +82,7 @@ module Rabbit
79
82
  _("Theme ID"),
80
83
  _("(e.g.: %s)") % "--id=rubykaigi2012",
81
84
  _("(must)")) do |id|
82
- @id = id
85
+ @theme_conf.id = id
83
86
  end
84
87
 
85
88
  parser.separator(_("Your information"))
@@ -149,7 +152,7 @@ module Rabbit
149
152
  end
150
153
 
151
154
  def validate_id
152
- if @id.nil?
155
+ if @theme_conf.id.nil?
153
156
  @validation_errors << (_("%s is missing") % "--id")
154
157
  end
155
158
  end
@@ -157,7 +160,8 @@ module Rabbit
157
160
  def generate
158
161
  generate_directory
159
162
  generate_data_directory
160
- generate_config_yaml
163
+ generate_dot_gitignore
164
+ generate_theme_configuration
161
165
  generate_readme
162
166
  generate_rakefile
163
167
  generate_property_rb
@@ -165,25 +169,27 @@ module Rabbit
165
169
  end
166
170
 
167
171
  def generate_directory
168
- create_directory(@id)
172
+ create_directory(@theme_conf.id)
169
173
  end
170
174
 
171
175
  def generate_data_directory
172
- create_directory(File.join(@id, "data"))
176
+ create_directory(File.join(@theme_conf.id, "data"))
173
177
  end
174
178
 
175
- def generate_config_yaml
176
- create_file(@config_yaml_path) do |config_yaml|
177
- config = {
178
- "id" => @id,
179
- "name" => @author_conf.name,
180
- "email" => @author_conf.email,
181
- "rubygems_user" => @author_conf.rubygems_user,
182
- }
183
- config_yaml.puts(config.to_yaml)
179
+ def generate_dot_gitignore
180
+ create_file(".gitignore") do |dot_gitignore|
181
+ dot_gitignore.puts(<<-EOD)
182
+ /.tmp/
183
+ /pkg/
184
+ /pdf/
185
+ EOD
184
186
  end
185
187
  end
186
188
 
189
+ def generate_theme_configuration
190
+ @theme_conf.save(@theme_conf.id)
191
+ end
192
+
187
193
  def generate_readme
188
194
  create_file("README.#{readme_extension}") do |readme|
189
195
  readme.puts(readme_content)
@@ -192,85 +198,52 @@ module Rabbit
192
198
 
193
199
  def readme_content
194
200
  markup_language = @author_conf.markup_language || :rd
195
- syntax = markup_syntax(markup_language)
201
+ generator = Rabbit::SourceGenerator.find(markup_language)
196
202
 
197
203
  content = ""
198
- content << (syntax[:heading1] % {:title => _("TODO: THEME TITLE")})
204
+ content << generator.heading(1, _("TODO: THEME TITLE"))
199
205
  content << "\n\n"
200
206
  content << _("TODO: THEME DESCRIPTION")
201
207
  content << "\n\n"
202
208
 
203
- content << (syntax[:heading2] % {:title => _("For author")})
209
+ content << generator.heading(2, _("For author"))
204
210
  content << "\n\n"
205
- content << (syntax[:heading3] % {:title => _("Show")})
211
+ content << generator.heading(3, _("Show"))
206
212
  content << "\n\n"
207
- content << (syntax[:preformatted_line] % {:content => "rake"})
213
+ content << generator.preformatted_line("rake")
208
214
  content << "\n\n"
209
- content << (syntax[:heading3] % {:title => _("Publish")})
215
+ content << generator.heading(3, _("Publish"))
210
216
  content << "\n\n"
211
- content << (syntax[:preformatted_line] % {:content => "rake publish"})
217
+ content << generator.preformatted_line("rake publish")
212
218
  content << "\n\n"
213
219
 
214
- content << (syntax[:heading2] % {:title => _("For users")})
220
+ content << generator.heading(2, _("For users"))
215
221
  content << "\n\n"
216
- content << (syntax[:heading3] % {:title => _("Install")})
222
+ content << generator.heading(3, _("Install"))
217
223
  content << "\n\n"
218
- install_command = "gem install #{gem_name}"
219
- content << (syntax[:preformatted_line] % {:content => install_command})
224
+ install_command = "gem install #{@theme_conf.gem_name}"
225
+ content << generator.preformatted_line(install_command)
220
226
  content << "\n\n"
221
- content << (syntax[:heading3] % {:title => _("Show")})
227
+ content << generator.heading(3, _("Show"))
222
228
  content << "\n\n"
223
229
  theme_benchmark_gem = _("rabbit-theme-benchmark-en.gem")
224
- show_command = "rabbit -t #{gem_name} #{theme_benchmark_gem}"
225
- content << (syntax[:preformatted_line] % {:content => show_command})
230
+ show_command = "rabbit -t #{@theme_conf.gem_name} #{theme_benchmark_gem}"
231
+ content << generator.preformatted_line(show_command)
226
232
  content << "\n\n"
227
233
  end
228
234
 
229
235
  def generate_rakefile
230
236
  create_file("Rakefile") do |rakefile|
231
237
  rakefile.puts(<<-EOR)
232
- require "time"
233
- require "yaml"
234
238
  require "rabbit/task/theme"
235
239
 
236
- config = YAML.load(File.read("#{@config_yaml_path}"))
237
-
238
- theme_id = config["id"]
239
-
240
- version = "1.0.0"
241
-
242
- name = config["name"]
243
- email = config["email"]
244
- rubygems_user = config["rubygems_user"]
240
+ # Edit ./config.yaml to customize meta data
245
241
 
246
- readme = File.read(Dir.glob("README*")[0])
247
-
248
- readme_blocks = readme.split(/(?:\\r?\\n){2,}/)
249
- summary = (readme_blocks[0] || "TODO").gsub(/\\A(?:[=*!]+|h\\d\\.)\s*/, "")
250
- description = readme_blocks[1] || "TODO"
251
-
252
- specification = Gem::Specification.new do |spec|
253
- prefix = "#{gem_name_prefix}"
254
- spec.name = "\#{prefix}-\#{theme_id}"
255
- spec.version = version
256
- spec.homepage = "http://theme.rabbit-shockers.org/\#{theme_id}/"
257
- spec.authors = [name]
258
- spec.email = [email]
259
- spec.summary = summary
260
- spec.description = description
261
- spec.licenses = [] # ["CC BY-SA 3.0"]
262
-
263
- spec.files = ["#{@config_yaml_path}", "Rakefile"]
264
- spec.files += Dir.glob("{theme.rb,COPYING,GPL,README*}")
265
- spec.files += Dir.glob("data/**/*.{svg,png,jpg,jpeg,gif,eps,pdf}")
266
- spec.files += Dir.glob("locale/**/*.mo")
267
- spec.files += Dir.glob("po/*/*.po")
268
-
269
- spec.add_runtime_dependency("rabbit")
270
- end
271
-
272
- Rabbit::Task::Theme.new(specification) do |task|
273
- task.rubygems_user = rubygems_user
242
+ Rabbit::Task::Theme.new do |task|
243
+ # task.spec.licenses = ["CC BY-SA 3.0"]
244
+ # task.spec.files += Dir.glob("doc/**/*.*")
245
+ # task.spec.files -= Dir.glob("private/**/*.*")
246
+ # task.spec.add_runtime_dependency("DEPENDED THEME")
274
247
  end
275
248
  EOR
276
249
  end
@@ -280,7 +253,7 @@ EOR
280
253
  create_file("property.rb") do |property_rb|
281
254
  property_rb.puts(<<-EOP)
282
255
  @category = N_("#{category}")
283
- @title = N_("#{@id}")
256
+ @title = N_("#{@theme_conf.id}")
284
257
  # @abstract = N_("TODO")
285
258
  # @description = N_("TODO")
286
259
  EOP
@@ -297,7 +270,7 @@ EOT
297
270
  end
298
271
 
299
272
  def image_theme?
300
- @id.end_with?("-images")
273
+ @theme_conf.id.end_with?("-images")
301
274
  end
302
275
 
303
276
  def category
@@ -321,60 +294,8 @@ EOT
321
294
  end
322
295
  end
323
296
 
324
- def markup_syntax(markup_language)
325
- case markup_language
326
- when :rd
327
- {
328
- :heading1 => "= %{title}",
329
- :heading2 => "== %{title}",
330
- :heading3 => "=== %{title}",
331
- :definition_list_item => ": %{item}\n %{description}",
332
- :unorderd_list_item => " * %{item}",
333
- :image =>
334
- " # image\n" +
335
- " # src = %{src}\n" +
336
- " # relative_height = %{relative_height}",
337
- :preformatted_line => " %{content}",
338
- :comment => "# %{content}",
339
- }
340
- when :hiki
341
- {
342
- :heading1 => "! %{title}",
343
- :heading2 => "!! %{title}",
344
- :heading3 => "!!! %{title}",
345
- :definition_list_item => ":%{item}:%{description}",
346
- :unorderd_list_item => "* %{item}",
347
- :image =>
348
- "{{image(\"%{src}\",\n" +
349
- " {\n" +
350
- " :relative_height => %{relative_height},\n" +
351
- " })}}",
352
- :preformatted_line => " %{content}",
353
- :comment => "// %{content}",
354
- }
355
- when :markdown
356
- {
357
- :heading1 => "# %{title}",
358
- :heading2 => "## %{title}",
359
- :heading3 => "### %{title}",
360
- :definition_list_item => "%{item}\n %{description}",
361
- :unorderd_list_item => "* %{item}",
362
- :image =>
363
- "![](%{src}){:relative_height='%{relative_height}'}",
364
- :preformatted_line => " %{content}",
365
- :comment => "",
366
- }
367
- else
368
- nil
369
- end
370
- end
371
-
372
- def gem_name
373
- "#{gem_name_prefix}-#{@id}"
374
- end
375
-
376
- def gem_name_prefix
377
- "rabbit-theme"
297
+ def create_file(path, &block)
298
+ super(File.join(@theme_conf.id, path), &block)
378
299
  end
379
300
  end
380
301
  end