rabbit 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -27
- data/data/locale/en/LC_MESSAGES/rabbit.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rabbit.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
- data/doc/_config.yml +2 -2
- data/doc/en/index.rd +5 -5
- data/doc/en/news.rd +87 -0
- data/doc/images/screenshots/en/blue-circle.png +0 -0
- data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
- data/doc/images/screenshots/en/clear-blue.png +0 -0
- data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
- data/doc/images/screenshots/en/cozmixng.png +0 -0
- data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
- data/doc/images/screenshots/en/dark-gradation.png +0 -0
- data/doc/images/screenshots/en/day-white-raw.png +0 -0
- data/doc/images/screenshots/en/day-white.png +0 -0
- data/doc/images/screenshots/en/debian-raw.png +0 -0
- data/doc/images/screenshots/en/debian.png +0 -0
- data/doc/images/screenshots/en/green-circle.png +0 -0
- data/doc/images/screenshots/en/night-black-raw.png +0 -0
- data/doc/images/screenshots/en/night-black.png +0 -0
- data/doc/images/screenshots/en/rabbit-raw.png +0 -0
- data/doc/images/screenshots/en/rabbit.png +0 -0
- data/doc/images/screenshots/en/ranguba-raw.png +0 -0
- data/doc/images/screenshots/en/ranguba.png +0 -0
- data/doc/images/screenshots/en/red-frame-raw.png +0 -0
- data/doc/images/screenshots/en/red-frame.png +0 -0
- data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
- data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
- data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
- data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
- data/doc/images/screenshots/ja/blue-circle.png +0 -0
- data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
- data/doc/images/screenshots/ja/clear-blue.png +0 -0
- data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
- data/doc/images/screenshots/ja/cozmixng.png +0 -0
- data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
- data/doc/images/screenshots/ja/dark-gradation.png +0 -0
- data/doc/images/screenshots/ja/day-white-raw.png +0 -0
- data/doc/images/screenshots/ja/day-white.png +0 -0
- data/doc/images/screenshots/ja/debian-raw.png +0 -0
- data/doc/images/screenshots/ja/debian.png +0 -0
- data/doc/images/screenshots/ja/green-circle.png +0 -0
- data/doc/images/screenshots/ja/night-black-raw.png +0 -0
- data/doc/images/screenshots/ja/night-black.png +0 -0
- data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
- data/doc/images/screenshots/ja/rabbit.png +0 -0
- data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
- data/doc/images/screenshots/ja/ranguba.png +0 -0
- data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
- data/doc/images/screenshots/ja/red-frame.png +0 -0
- data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
- data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
- data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
- data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
- data/doc/ja/index.rd +5 -5
- data/doc/ja/news.rd +85 -0
- data/lib/rabbit/author-configuration.rb +30 -15
- data/lib/rabbit/command/rabbit-slide.rb +70 -184
- data/lib/rabbit/command/rabbit-theme.rb +46 -125
- data/lib/rabbit/command/rabbit.rb +2 -1
- data/lib/rabbit/path-manipulatable.rb +0 -3
- data/lib/rabbit/readme-parser.rb +49 -0
- data/lib/rabbit/slide-configuration.rb +127 -0
- data/lib/rabbit/source-generator.rb +39 -0
- data/lib/rabbit/source-generator/hiki.rb +63 -0
- data/lib/rabbit/source-generator/markdown.rb +61 -0
- data/lib/rabbit/source-generator/rd.rb +65 -0
- data/lib/rabbit/task/slide.rb +68 -31
- data/lib/rabbit/task/theme.rb +46 -11
- data/lib/rabbit/theme-configuration.rb +104 -0
- data/lib/rabbit/theme/default-title-text/default-title-text.rb +2 -2
- data/lib/rabbit/theme/entry.rb +3 -2
- data/lib/rabbit/theme/nari/nari.rb +2 -0
- data/lib/rabbit/theme/slide-number/slide-number.rb +2 -2
- data/lib/rabbit/version.rb +1 -1
- data/po/rabbit.pot +1548 -1419
- data/test/run-test.rb +3 -1
- data/test/source-generator/test-hiki.rb +68 -0
- data/test/source-generator/test-markdown.rb +67 -0
- data/test/source-generator/test-rd.rb +69 -0
- data/test/{test_applier.rb → test-applier.rb} +0 -0
- data/test/test-author-configuration.rb +36 -0
- data/test/{test_color.rb → test-color.rb} +0 -0
- data/test/{test_element.rb → test-element.rb} +0 -0
- data/test/test-readme-parser.rb +57 -0
- data/test/test-slide-configuration.rb +56 -0
- data/test/{test_source.rb → test-source.rb} +0 -0
- data/test/test-theme-configuration.rb +47 -0
- data/test/{test_utils.rb → test-utils.rb} +0 -0
- metadata +65 -12
@@ -18,6 +18,7 @@
|
|
18
18
|
require "English"
|
19
19
|
|
20
20
|
require "rabbit/gettext"
|
21
|
+
require "rabbit/slide-configuration"
|
21
22
|
|
22
23
|
module Rabbit
|
23
24
|
module Command
|
@@ -607,7 +608,7 @@ module Rabbit
|
|
607
608
|
gem_name = $PREMATCH
|
608
609
|
require "rabbit/gem-finder"
|
609
610
|
finder = GemFinder.new(@logger)
|
610
|
-
spec = finder.find(gem_name, "
|
611
|
+
spec = finder.find(gem_name, "#{SlideConfiguration::GEM_NAME_PREFIX}-")
|
611
612
|
source = spec.gem_dir if spec
|
612
613
|
end
|
613
614
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
|
17
|
+
require "rabbit/gettext"
|
18
|
+
require "rabbit/path-manipulatable"
|
19
|
+
|
20
|
+
module Rabbit
|
21
|
+
class READMEParser
|
22
|
+
include GetText
|
23
|
+
include PathManipulatable
|
24
|
+
|
25
|
+
attr_accessor :logger
|
26
|
+
attr_reader :title, :description
|
27
|
+
def initialize(logger=nil)
|
28
|
+
@logger = logger || Logger.default
|
29
|
+
@title = nil
|
30
|
+
@description = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse(path=nil)
|
34
|
+
path ||= Dir.glob("README*")[0]
|
35
|
+
raise _("No README found") if path.nil?
|
36
|
+
|
37
|
+
parse_content(File.read(path))
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def parse_content(content)
|
42
|
+
blocks = content.split(/(?:\r?\n){2,}/)
|
43
|
+
if blocks[0]
|
44
|
+
@title = blocks[0].gsub(/\A(?:[=*!]+|h\d\.)\s*/, "")
|
45
|
+
end
|
46
|
+
@description = blocks[1]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
|
17
|
+
require "time"
|
18
|
+
|
19
|
+
require "yaml"
|
20
|
+
|
21
|
+
require "rabbit/gettext"
|
22
|
+
require "rabbit/author-configuration"
|
23
|
+
require "rabbit/path-manipulatable"
|
24
|
+
|
25
|
+
module Rabbit
|
26
|
+
class SlideConfiguration
|
27
|
+
include GetText
|
28
|
+
include PathManipulatable
|
29
|
+
|
30
|
+
GEM_NAME_PREFIX = "rabbit-slide"
|
31
|
+
|
32
|
+
attr_accessor :logger
|
33
|
+
attr_accessor :id, :base_name, :tags, :presentation_date
|
34
|
+
attr_accessor :licenses
|
35
|
+
attr_writer :version
|
36
|
+
attr_accessor :author
|
37
|
+
def initialize(logger=nil)
|
38
|
+
@logger = logger || Logger.default
|
39
|
+
@id = nil
|
40
|
+
@base_name = nil
|
41
|
+
@tags = []
|
42
|
+
@presentation_date = nil
|
43
|
+
@version = nil
|
44
|
+
@licenses = []
|
45
|
+
@author = nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def load
|
49
|
+
return unless File.exist?(path)
|
50
|
+
conf = YAML.load(File.read(path))
|
51
|
+
merge!(conf)
|
52
|
+
rescue
|
53
|
+
format = _("Failed to read slide configuration: %s: %s")
|
54
|
+
@logger.error(format % [path, $!.message])
|
55
|
+
end
|
56
|
+
|
57
|
+
def save(base_dir)
|
58
|
+
config_path = File.join(base_dir, path)
|
59
|
+
create_file(config_path) do |conf_file|
|
60
|
+
conf_file.print(to_yaml)
|
61
|
+
end
|
62
|
+
rescue
|
63
|
+
format = _("Failed to write slide configuration: %s: %s")
|
64
|
+
@logger.error(format % [config_path, $!.message])
|
65
|
+
end
|
66
|
+
|
67
|
+
def merge!(conf)
|
68
|
+
@id = conf["id"]
|
69
|
+
@base_name = conf["base_name"]
|
70
|
+
@tags = conf["tags"]
|
71
|
+
@presentation_date = conf["presentation_date"]
|
72
|
+
@version = conf["version"]
|
73
|
+
@licenses = conf["licenses"]
|
74
|
+
|
75
|
+
@author = AuthorConfiguration.new(@logger)
|
76
|
+
@author.merge!(conf["author"] || {})
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_hash
|
80
|
+
config = {
|
81
|
+
"id" => @id,
|
82
|
+
"base_name" => @base_name,
|
83
|
+
"tags" => @tags,
|
84
|
+
"presentation_date" => @presentation_date,
|
85
|
+
"version" => version,
|
86
|
+
"licenses" => @licenses,
|
87
|
+
}
|
88
|
+
config["author"] = @author.to_hash if @author
|
89
|
+
config
|
90
|
+
end
|
91
|
+
|
92
|
+
def to_yaml
|
93
|
+
to_hash.to_yaml
|
94
|
+
end
|
95
|
+
|
96
|
+
def version
|
97
|
+
@version || default_version
|
98
|
+
end
|
99
|
+
|
100
|
+
def gem_name
|
101
|
+
"#{GEM_NAME_PREFIX}-#{@author.rubygems_user}-#{@id}"
|
102
|
+
end
|
103
|
+
|
104
|
+
def path
|
105
|
+
"config.yaml"
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
def parsed_presentation_date
|
110
|
+
return nil if @presentation_date.nil?
|
111
|
+
begin
|
112
|
+
Time.parse(@presentation_date)
|
113
|
+
rescue ArgumentError
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def default_version
|
119
|
+
date = parsed_presentation_date
|
120
|
+
if date
|
121
|
+
date.strftime("%Y.%m.%d")
|
122
|
+
else
|
123
|
+
"1.0.0"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
|
17
|
+
module Rabbit
|
18
|
+
module SourceGenerator
|
19
|
+
class << self
|
20
|
+
def find(markup_language)
|
21
|
+
case markup_language
|
22
|
+
when :rd
|
23
|
+
RD.new
|
24
|
+
when :hiki
|
25
|
+
Hiki.new
|
26
|
+
when :markdown
|
27
|
+
Markdown.new
|
28
|
+
else
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require "rabbit/source-generator/rd"
|
37
|
+
require "rabbit/source-generator/hiki"
|
38
|
+
require "rabbit/source-generator/markdown"
|
39
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
|
17
|
+
require "rabbit/gettext"
|
18
|
+
|
19
|
+
module Rabbit
|
20
|
+
module SourceGenerator
|
21
|
+
class Hiki
|
22
|
+
include GetText
|
23
|
+
include PathManipulatable
|
24
|
+
|
25
|
+
attr_accessor :logger
|
26
|
+
def initialize(logger=nil)
|
27
|
+
@logger = logger || Logger.default
|
28
|
+
end
|
29
|
+
|
30
|
+
def heading(level, title)
|
31
|
+
("!" * level) + " #{title}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def definition_list_item(item, description)
|
35
|
+
":#{item}:#{description}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def unordered_list_item(item)
|
39
|
+
"* #{item}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def image(source, options={})
|
43
|
+
lines = [
|
44
|
+
"{{image(#{source.dump},",
|
45
|
+
" {",
|
46
|
+
]
|
47
|
+
options.each do |key, value|
|
48
|
+
lines << " #{key.to_s.dump} => #{value.inspect},"
|
49
|
+
end
|
50
|
+
lines << " })}}"
|
51
|
+
lines.join("\n")
|
52
|
+
end
|
53
|
+
|
54
|
+
def preformatted_line(content)
|
55
|
+
" #{content}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def comment(content)
|
59
|
+
"// #{content}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
|
17
|
+
require "rabbit/gettext"
|
18
|
+
|
19
|
+
module Rabbit
|
20
|
+
module SourceGenerator
|
21
|
+
class Markdown
|
22
|
+
include GetText
|
23
|
+
include PathManipulatable
|
24
|
+
|
25
|
+
attr_accessor :logger
|
26
|
+
def initialize(logger=nil)
|
27
|
+
@logger = logger || Logger.default
|
28
|
+
end
|
29
|
+
|
30
|
+
def heading(level, title)
|
31
|
+
("#" * level) + " #{title}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def definition_list_item(item, description)
|
35
|
+
[
|
36
|
+
item,
|
37
|
+
" #{description}",
|
38
|
+
].join("\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
def unordered_list_item(item)
|
42
|
+
"* #{item}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def image(source, options={})
|
46
|
+
parameters = options.collect do |key, value|
|
47
|
+
"#{key}='#{value}'"
|
48
|
+
end
|
49
|
+
"![](#{source}){:#{parameters.join(' ')}}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def preformatted_line(content)
|
53
|
+
" #{content}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def comment(content)
|
57
|
+
""
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
|
17
|
+
require "rabbit/gettext"
|
18
|
+
|
19
|
+
module Rabbit
|
20
|
+
module SourceGenerator
|
21
|
+
class RD
|
22
|
+
include GetText
|
23
|
+
include PathManipulatable
|
24
|
+
|
25
|
+
attr_accessor :logger
|
26
|
+
def initialize(logger=nil)
|
27
|
+
@logger = logger || Logger.default
|
28
|
+
end
|
29
|
+
|
30
|
+
def heading(level, title)
|
31
|
+
("=" * level) + " #{title}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def definition_list_item(item, description)
|
35
|
+
[
|
36
|
+
": #{item}",
|
37
|
+
" #{description}",
|
38
|
+
].join("\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
def unordered_list_item(item)
|
42
|
+
" * #{item}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def image(source, options={})
|
46
|
+
lines = [
|
47
|
+
" # image",
|
48
|
+
" # src = #{source}",
|
49
|
+
]
|
50
|
+
options.each do |key, value|
|
51
|
+
lines << " # #{key} = #{value}"
|
52
|
+
end
|
53
|
+
lines.join("\n")
|
54
|
+
end
|
55
|
+
|
56
|
+
def preformatted_line(content)
|
57
|
+
" #{content}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def comment(content)
|
61
|
+
"# #{content}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/rabbit/task/slide.rb
CHANGED
@@ -19,6 +19,8 @@ require "rake"
|
|
19
19
|
require "rabbit/gettext"
|
20
20
|
require "rabbit/logger"
|
21
21
|
require "rabbit/command/rabbit"
|
22
|
+
require "rabbit/slide-configuration"
|
23
|
+
require "rabbit/readme-parser"
|
22
24
|
|
23
25
|
module Rabbit
|
24
26
|
module Task
|
@@ -26,26 +28,55 @@ module Rabbit
|
|
26
28
|
include Rake::DSL
|
27
29
|
include GetText
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
attr_accessor :tags, :presentation_date
|
32
|
-
attr_accessor :rubygems_user, :slideshare_user, :speaker_deck_user
|
33
|
-
def initialize(spec)
|
31
|
+
attr_accessor :package_dir, :pdf_dir, :required_rabbit_version
|
32
|
+
def initialize
|
34
33
|
@logger = Logger.default
|
35
|
-
@
|
34
|
+
@slide = load_slide_configuration
|
36
35
|
@package_dir = "pkg"
|
37
36
|
@pdf_dir = "pdf"
|
38
|
-
@
|
39
|
-
@tags = []
|
40
|
-
@presentation_date = nil
|
41
|
-
@rubygems_user = nil
|
42
|
-
@slideshare_user = nil
|
43
|
-
@speaker_deck_user = nil
|
37
|
+
@required_rabbit_version = ">= 2.0.2"
|
44
38
|
yield(self) if block_given?
|
45
39
|
define
|
46
40
|
end
|
47
41
|
|
42
|
+
def spec
|
43
|
+
@spec ||= create_spec
|
44
|
+
end
|
45
|
+
|
48
46
|
private
|
47
|
+
def load_slide_configuration
|
48
|
+
slide_conf = SlideConfiguration.new(@logger)
|
49
|
+
slide_conf.load
|
50
|
+
slide_conf
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_spec
|
54
|
+
readme_parser = READMEParser.new(@logger)
|
55
|
+
readme_parser.parse
|
56
|
+
|
57
|
+
Gem::Specification.new do |spec|
|
58
|
+
spec.name = @slide.gem_name
|
59
|
+
spec.version = @slide.version
|
60
|
+
spec.homepage = homepage
|
61
|
+
spec.authors = [@slide.author.name]
|
62
|
+
spec.email = [@slide.author.email]
|
63
|
+
spec.summary = readme_parser.title || "TODO"
|
64
|
+
spec.description = readme_parser.description || "TODO"
|
65
|
+
spec.licenses = @slide.licenses
|
66
|
+
|
67
|
+
slide_conf_path = @slide.path
|
68
|
+
spec.files = [".rabbit", slide_conf_path, "Rakefile"]
|
69
|
+
spec.files += Dir.glob("{COPYING,GPL,README*}")
|
70
|
+
spec.files += Dir.glob("rabbit/**/*.*")
|
71
|
+
spec.files += Dir.glob("**/*.{svg,png,jpg,jpeg,gif,eps,pdf}")
|
72
|
+
spec.files += Dir.glob("*.{rd,rab,hiki,md,pdf}")
|
73
|
+
spec.files -= Dir.glob("{pkg,pdf}/**/*.*")
|
74
|
+
spec.files += [pdf_path]
|
75
|
+
|
76
|
+
spec.add_runtime_dependency("rabbit", @required_rabbit_version)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
49
80
|
def define
|
50
81
|
task :default => :run
|
51
82
|
|
@@ -61,10 +92,10 @@ module Rabbit
|
|
61
92
|
end
|
62
93
|
|
63
94
|
desc(_("Create gem: %{gem_path}") % {:gem_path => gem_path})
|
64
|
-
task :gem => "gem:validate" do
|
95
|
+
task :gem => ["gem:validate", :pdf] do
|
65
96
|
mkdir_p(@package_dir)
|
66
|
-
Gem::Builder.new(
|
67
|
-
mv(File.basename(
|
97
|
+
Gem::Builder.new(spec).build
|
98
|
+
mv(File.basename(spec.cache_file), gem_path)
|
68
99
|
end
|
69
100
|
|
70
101
|
namespace :gem do
|
@@ -75,7 +106,7 @@ module Rabbit
|
|
75
106
|
:where => Dir.glob("README*")[0],
|
76
107
|
}
|
77
108
|
[:summary, :description].each do |item|
|
78
|
-
content =
|
109
|
+
content = spec.send(item)
|
79
110
|
if /TODO|FIXME/ =~ content
|
80
111
|
data[:item] = item
|
81
112
|
data[:content] = content
|
@@ -88,8 +119,7 @@ module Rabbit
|
|
88
119
|
end
|
89
120
|
end
|
90
121
|
|
91
|
-
pdf_path
|
92
|
-
file pdf_path => [options_file, *@spec.files] do
|
122
|
+
file pdf_path => [options_file, *(spec.files - [pdf_path])] do
|
93
123
|
mkdir_p(@pdf_dir)
|
94
124
|
rabbit("--print",
|
95
125
|
"--output-filename", pdf_path)
|
@@ -103,7 +133,7 @@ module Rabbit
|
|
103
133
|
|
104
134
|
publish_tasks = []
|
105
135
|
namespace :publish do
|
106
|
-
if @rubygems_user
|
136
|
+
if @slide.author.rubygems_user
|
107
137
|
desc(_("Publish the slide to %s" % "RubyGems.org"))
|
108
138
|
task :rubygems => :gem do
|
109
139
|
ruby("-S", "gem", "push", "--verbose", gem_path)
|
@@ -111,19 +141,20 @@ module Rabbit
|
|
111
141
|
publish_tasks << :rubygems
|
112
142
|
end
|
113
143
|
|
114
|
-
|
144
|
+
slideshare_user = @slide.author.slideshare_user
|
145
|
+
if slideshare_user
|
115
146
|
desc(_("Publish the slide to %s" % "SlideShare"))
|
116
147
|
task :slideshare => [:pdf, "gem:validate"] do
|
117
148
|
require "rabbit/slideshare"
|
118
149
|
slideshare = SlideShare.new(@logger)
|
119
|
-
slideshare.user =
|
150
|
+
slideshare.user = slideshare_user
|
120
151
|
slideshare.pdf_path = pdf_path
|
121
|
-
slideshare.title =
|
122
|
-
slideshare.description =
|
152
|
+
slideshare.title = spec.summary
|
153
|
+
slideshare.description = spec.description
|
123
154
|
slideshare.tags = @tags if @tags
|
124
155
|
id = slideshare.upload
|
125
156
|
if id
|
126
|
-
url = "http://www.slideshare.net/#{
|
157
|
+
url = "http://www.slideshare.net/#{slideshare_user}/ss-#{id}"
|
127
158
|
@logger.info(_("Uploaded successfully!"))
|
128
159
|
@logger.info(_("See %s") % url)
|
129
160
|
Gtk.show_uri(url) if Gtk.respond_to?(:show_uri)
|
@@ -132,7 +163,7 @@ module Rabbit
|
|
132
163
|
publish_tasks << :slideshare
|
133
164
|
end
|
134
165
|
|
135
|
-
if @speaker_deck_user
|
166
|
+
if @slide.author.speaker_deck_user
|
136
167
|
desc(_("Publish the slide to %s" % "Spearker Deck"))
|
137
168
|
task :speaker_deck => :pdf do
|
138
169
|
raise "Not implemented yet."
|
@@ -144,14 +175,20 @@ module Rabbit
|
|
144
175
|
end
|
145
176
|
|
146
177
|
def gem_path
|
147
|
-
File.join(@package_dir, "#{
|
178
|
+
File.join(@package_dir, "#{spec.name}-#{spec.version}.gem")
|
179
|
+
end
|
180
|
+
|
181
|
+
def pdf_path
|
182
|
+
File.join(@pdf_dir, pdf_base_path)
|
183
|
+
end
|
184
|
+
|
185
|
+
def pdf_base_path
|
186
|
+
"#{@slide.id}.pdf"
|
148
187
|
end
|
149
188
|
|
150
|
-
def
|
151
|
-
|
152
|
-
|
153
|
-
slide_id = user_name_and_slide_id.gsub(/\A#{escaped_user}-/, "")
|
154
|
-
"#{slide_id}.pdf"
|
189
|
+
def homepage
|
190
|
+
rubygems_user = @slide.author.rubygems_user
|
191
|
+
"http://slide.rabbit-shockers.org/#{rubygems_user}/\#{@slide.id}/"
|
155
192
|
end
|
156
193
|
|
157
194
|
def rabbit(*arguments)
|