caramelize 0.2.0 → 0.3.0

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 (36) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -53
  3. data/Gemfile +3 -3
  4. data/LICENSE.md +1 -1
  5. data/README.md +25 -25
  6. data/Rakefile +10 -1
  7. data/bin/caramelize +2 -9
  8. data/caramelize.gemspec +27 -23
  9. data/lib/caramelize/caramel.rb +22 -24
  10. data/lib/caramelize/cli.rb +33 -26
  11. data/lib/caramelize/cli/create_command.rb +4 -20
  12. data/lib/caramelize/content_transferer.rb +126 -68
  13. data/lib/caramelize/database_connector.rb +3 -6
  14. data/lib/caramelize/filters/remove_table_tab_line_endings.rb +11 -0
  15. data/lib/caramelize/filters/swap_wiki_links.rb +11 -9
  16. data/lib/caramelize/filters/wikka_to_markdown.rb +8 -8
  17. data/lib/caramelize/gollum_output.rb +50 -37
  18. data/lib/caramelize/page.rb +23 -10
  19. data/lib/caramelize/version.rb +1 -1
  20. data/lib/caramelize/wiki/redmine_wiki.rb +25 -32
  21. data/lib/caramelize/wiki/wiki.rb +28 -15
  22. data/lib/caramelize/wiki/wikkawiki.rb +16 -24
  23. data/spec/fixtures/markup/swap-links-input.textile +57 -0
  24. data/spec/fixtures/markup/swap-links-output.textile +57 -0
  25. data/spec/fixtures/markup/table-tab-line-endings-input.textile +145 -0
  26. data/spec/fixtures/markup/table-tab-line-endings-output.textile +145 -0
  27. data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +35 -0
  28. data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +33 -0
  29. data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +88 -0
  30. data/spec/lib/caramelize/gollum_output_spec.rb +64 -0
  31. data/spec/lib/caramelize/wiki/wiki_spec.rb +31 -0
  32. data/spec/spec_helper.rb +8 -0
  33. metadata +136 -33
  34. data/lib/caramelize/author.rb +0 -8
  35. data/test/helper.rb +0 -18
  36. data/test/test_caramelize.rb +0 -7
@@ -1,28 +1,41 @@
1
1
  module Caramelize
2
2
  class Page
3
-
3
+
4
4
  attr_accessor :title, :body, :id, :markup, :latest, :time, :message, :author, :author_name
5
-
5
+
6
6
  def initialize page={}
7
7
  @id = page[:id]
8
- @title = page[:title] ? page[:title] : ""
9
- @body = page[:body] ? page[:body] : ""
8
+ @title = page[:title] || ""
9
+ @body = page[:body] || ""
10
10
  @syntax = page[:markup]
11
- @latest = page[:latest] ? page[:latest] : false
12
- @time = page[:time] ? page[:time] : Time.now
13
- @message = page[:message] ? page[:message] : ""
11
+ @latest = page[:latest] || false
12
+ @time = page[:time] || Time.now
13
+ @message = page[:message] || ""
14
14
  @author = page[:author]
15
15
  @author_name = page[:author_name]
16
16
  end
17
-
17
+
18
+ def author_email
19
+ author.email
20
+ end
21
+
22
+ def author_name
23
+ author.name
24
+ end
25
+
26
+ def author
27
+ @author ||= OpenStruct.new(name: @author_name || "Caramelize",
28
+ email: "mail@example.com")
29
+ end
30
+
18
31
  def latest?
19
32
  @latest
20
33
  end
21
-
34
+
22
35
  def set_latest
23
36
  @latest = true
24
37
  end
25
-
38
+
26
39
  def to_s
27
40
  @title
28
41
  end
@@ -1,3 +1,3 @@
1
1
  module Caramelize
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,30 +1,26 @@
1
- #Encoding: UTF-8
1
+ require 'caramelize/wiki/wiki'
2
+ require 'caramelize/filters/swap_wiki_links'
3
+ require 'caramelize/filters/remove_table_tab_line_endings'
2
4
  module Caramelize
3
- autoload :DatabaseConnector, 'caramelize/database_connector'
4
- autoload :SwapWikiLinks, 'caramelize/filters/swap_wiki_links'
5
-
5
+
6
6
  class RedmineWiki < Wiki
7
7
  include DatabaseConnector
8
-
8
+
9
9
  def initialize options={}
10
10
  super(options)
11
11
  @options[:markup] = :textile
12
- @options[:create_namespace_home] = true unless @options[:create_namespace_home]
13
- @options[:swap_interwiki_links] = true
14
12
  @options[:filters] << Caramelize::SwapWikiLinks.new
13
+ @options[:filters] << Caramelize::RemoveTableTabLineEndings.new
14
+ @options[:create_namespace_overview] = true
15
15
  end
16
-
17
- # after calling this action, I expect the @titles and @revisions to be filled
18
- def read_pages
19
- @revisions = []
20
- @titles = []
21
- @latest_revisions = {}
22
16
 
17
+ # after calling this action, I expect the titles and revisions to be filled
18
+ def read_pages
23
19
  # get all projects
24
20
  results_projects = database.query("SELECT id, identifier, name FROM projects;")
25
21
  results_projects.each do |row_project|
26
22
  #collect all namespaces
27
- @namespaces << {:identifier => row_project["identifier"], :name => row_project["name"]}
23
+ namespaces << OpenStruct.new(identifier: row_project["identifier"], name: row_project["name"])
28
24
  end
29
25
 
30
26
  # get all wikis
@@ -52,10 +48,11 @@ module Caramelize
52
48
  project_identifier = project_row ? project_row["identifier"] + '/' : ""
53
49
 
54
50
  title = project_identifier + row_page["title"]
55
- @titles << title
56
-
51
+ titles << title
52
+
53
+ @latest_revisions = {}
57
54
  results_contents.each do |row_content|
58
- author = @authors[row_content["author_id"]] ? @authors[row_content["author_id"]] : nil
55
+ author = authors[row_content["author_id"]] ? @authors[row_content["author_id"]] : nil
59
56
  page = Page.new({:id => row_content["id"],
60
57
  :title => title,
61
58
  :body => row_content["data"],
@@ -65,31 +62,27 @@ module Caramelize
65
62
  :message => row_content["comments"],
66
63
  :author => author,
67
64
  :author_name => author.name})
68
- @revisions << page
65
+ revisions << page
69
66
  @latest_revisions[title] = page
70
67
  end
71
68
  end
72
- @titles.uniq!
69
+ titles.uniq!
73
70
  @latest_revisions.each { |rev| rev[1].set_latest }
74
- @revisions.sort! { |a,b| a.time <=> b.time }
71
+ revisions.sort! { |a,b| a.time <=> b.time }
75
72
 
76
73
  # TODO find latest revision for each limit
77
-
78
- @revisions
74
+
75
+ revisions
79
76
  end
80
-
77
+
81
78
  def read_authors
82
- sql = "SELECT id, login, mail FROM users;"
83
- @authors = {}
84
- results = database.query(sql)
79
+ results = database.query("SELECT id, login, mail FROM users;")
85
80
  results.each do |row|
86
- author = Author.new
87
- author.id = row["id"]
88
- author.name = row["login"]
89
- author.email = row["mail"]
90
- @authors[author.id] = author
81
+ authors[row["id"]] = OpenStruct.new(id: row["id"],
82
+ name: row["login"],
83
+ email: row["mail"])
91
84
  end
92
- @authors
85
+ authors
93
86
  end
94
87
  end
95
88
  end
@@ -1,41 +1,54 @@
1
- #Encoding: UTF-8
2
1
  module Caramelize
3
- autoload :DatabaseConnector, 'caramelize/database_connector'
4
2
  class Wiki
5
3
  include DatabaseConnector
4
+
6
5
  attr_accessor :revisions, :wiki_title, :titles, :description, :namespaces, :options
7
-
6
+
8
7
  def initialize options={}
9
8
  @options = options
10
9
  @options[:filters] = []
11
10
  @namespaces = []
12
11
  end
13
-
14
- def revisions_by_title title
15
- if @titles.index title
16
- # new array only containing pages by this name sorted by time
17
- # TODO this is probably bad for renamed pages if supported
18
- return @revisions.reject { |revision| revision.title != title }.sort { |x,y| x.time <=> y.time }
19
- end
12
+
13
+ def revisions_by_title(title)
14
+ # new array only containing pages by this name sorted by time asc
15
+ # TODO this is probably bad for renamed pages if supported
16
+ return revisions.select { |revision| revision.title == title }.sort { |x,y| x.time <=> y.time }
17
+ []
20
18
  end
21
-
19
+
22
20
  # return an empty array in case this action was not overridden
23
21
  def read_authors
24
22
  return []
25
23
  end
26
24
 
27
-
28
- def convert_markup? to_markup
25
+ def namespaces
26
+ @namespaces ||= {}
27
+ end
28
+
29
+ def authors
30
+ @authors ||= {}
31
+ end
32
+
33
+ def revisions
34
+ @revisions ||= []
35
+ end
36
+
37
+ def titles
38
+ @titles ||= []
39
+ end
40
+
41
+ def convert_markup?(to_markup)
29
42
  markup != to_markup
30
43
  end
31
44
 
32
45
  def filters
33
46
  @options[:filters]
34
47
  end
35
-
48
+
36
49
  def latest_revisions
37
50
  @latest_revisions = []
38
- for title in @titles
51
+ titles.each do |title|
39
52
  # pick first revision by descending date
40
53
  @latest_revisions << revisions_by_title(title).last
41
54
  end
@@ -1,27 +1,24 @@
1
- #Encoding: UTF-8
2
1
  module Caramelize
3
- autoload :DatabaseConnector, 'caramelize/database_connector'
4
- autoload :Wikka2Markdown, 'caramelize/filters/wikka_to_markdown'
5
-
2
+ require 'caramelize/wiki/wiki'
3
+ require 'caramelize/database_connector'
4
+ require 'caramelize/filters/wikka_to_markdown'
5
+
6
6
  class WikkaWiki < Wiki
7
7
  include DatabaseConnector
8
-
8
+
9
9
  def initialize options={}
10
10
  super(options)
11
11
  @options[:markup] = :wikka
12
- @options[:swap_interwiki_links] = false
13
12
  @options[:filters] << Caramelize::Wikka2Markdown.new
14
13
  end
15
14
 
16
- # after calling this action, I expect the @titles and @revisions to be filled
15
+ # after calling this action, I expect the titles and @revisions to be filled
17
16
  def read_pages
18
17
  sql = "SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;"
19
- @revisions = []
20
- @titles = []
21
18
  results = database.query(sql)
22
19
  results.each do |row|
23
- @titles << row["tag"]
24
- author = @authors[row["user"]]
20
+ titles << row["tag"]
21
+ author = authors[row["user"]]
25
22
  page = Page.new({:id => row["id"],
26
23
  :title => row["tag"],
27
24
  :body => row["body"],
@@ -31,26 +28,21 @@ module Caramelize
31
28
  :message => row["note"],
32
29
  :author => author,
33
30
  :author_name => row["user"]})
34
- @revisions << page
31
+ revisions << page
35
32
  end
36
- @titles.uniq!
37
- #@revisions.sort! { |a,b| a.time <=> b.time }
38
-
39
- @revisions
33
+ titles.uniq!
34
+ #revisions.sort! { |a,b| a.time <=> b.time }
35
+
36
+ revisions
40
37
  end
41
-
38
+
42
39
  def read_authors
43
40
  sql = "SELECT name, email FROM wikka_users;"
44
- @authors = {}
45
41
  results = database.query(sql)
46
42
  results.each do |row|
47
- author = Author.new
48
- #author.id = row["id"]
49
- author.name = row["name"]
50
- author.email = row["email"]
51
- @authors[author.name] = author
43
+ authors[row["name"]] = OpenStruct.new(name: row["name"],
44
+ email: row["email"] )
52
45
  end
53
- @authors
54
46
  end
55
47
  end
56
48
  end
@@ -0,0 +1,57 @@
1
+ h1. Wiki
2
+
3
+ h2. The 1994 Formula One Season
4
+
5
+ *[[statistics|Driver & Team Statistics]]*
6
+ *[[race-by-race|Race by Race]]*
7
+ *[[technical-regulations|Technical Regulations]]*
8
+ *[[technical-rules|Technical Rule Changes]]*
9
+ *[[HD-rear-wings|HD Rear Wing Configurations]]*
10
+ *[[helmets|Helmet variants]]*
11
+
12
+ h2. Development
13
+
14
+ *[[Review Process F1 1994]]*
15
+ *[[Credits]]*
16
+
17
+ h2. Season data
18
+
19
+ h3. Drivers
20
+
21
+ Early season package
22
+ Driver list from Brazil: "Discussion here":http://forum.ctdp.net/viewtopic.php?f=214&t=62989
23
+
24
+ |_.Nr|_.Driver |_.Team|
25
+ |0|Damon Hill |/2.[[Williams|Williams-Renault]]|
26
+ |2|Ayrton Senna |
27
+ |3|Ukyo Katayama |/2.[[Tyrrell|Tyrrell-Yamaha]]|
28
+ |4|Mark Blundell |
29
+ |5|Michael Schumacher|/2.[[Benetton|Benetton-Ford]]|
30
+ |6|Jos Verstappen |
31
+ |7|Mika Häkkinen |/2.[[McLaren|McLaren-Peugeot]]|
32
+ |8|Martin Brundle |
33
+ |9|Christian Fittipaldi|/2.[[Footwork|Footwork-Ford]]|
34
+ |10|Gianni Morbidelli|
35
+ |11|Pedro Lamy |/2.[[Lotus|Lotus-Mugen-Honda]]|
36
+ |12|Johnny Herbert |
37
+ |14|Rubens Barrichello|/2.[[Jordan|Jordan-Hart]]|
38
+ |15|Eddie Irvine |
39
+ |19|Olivier Beretta |/2.[[Larrousse|Larrousse-Ford]]|
40
+ |20|Érik Comas |
41
+ |23|Pierluigi Martini|/2.[[Minardi|Minardi-Ford]]|
42
+ |24|Michele Alboreto |
43
+ |25|Éric Bernard |/2.[[Ligier|Ligier-Renault]]|
44
+ |26|Olivier Panis |
45
+ |27|Jean Alesi |/2.[[Ferrari|Ferrari]]|
46
+ |28|Gerhard Berger |
47
+ |29|Karl Wendlinger |/2.[[Sauber|Sauber-Mercedes]]|
48
+ |30|Heinz-Harald Frentzen|
49
+ |31|David Brabham |/2.[[Simtek|Simtek-Ford]]|
50
+ |32|Roland Ratzenberger|
51
+ |33|Paul Belmondo |/2.[[Pacific|Pacific-Ilmor]]|
52
+ |34|Bertrand Gachot |
53
+
54
+
55
+ [[Getting new people]]
56
+
57
+ [[Contact form]]
@@ -0,0 +1,57 @@
1
+ h1. Wiki
2
+
3
+ h2. The 1994 Formula One Season
4
+
5
+ *[[Driver & Team Statistics|statistics]]*
6
+ *[[Race by Race|race-by-race]]*
7
+ *[[Technical Regulations|technical-regulations]]*
8
+ *[[Technical Rule Changes|technical-rules]]*
9
+ *[[HD Rear Wing Configurations|HD-rear-wings]]*
10
+ *[[Helmet variants|helmets]]*
11
+
12
+ h2. Development
13
+
14
+ *[[Review Process F1 1994|Review_Process_F1_1994]]*
15
+ *[[Credits|Credits]]*
16
+
17
+ h2. Season data
18
+
19
+ h3. Drivers
20
+
21
+ Early season package
22
+ Driver list from Brazil: "Discussion here":http://forum.ctdp.net/viewtopic.php?f=214&t=62989
23
+
24
+ |_.Nr|_.Driver |_.Team|
25
+ |0|Damon Hill |/2.[[Williams-Renault|Williams]]|
26
+ |2|Ayrton Senna |
27
+ |3|Ukyo Katayama |/2.[[Tyrrell-Yamaha|Tyrrell]]|
28
+ |4|Mark Blundell |
29
+ |5|Michael Schumacher|/2.[[Benetton-Ford|Benetton]]|
30
+ |6|Jos Verstappen |
31
+ |7|Mika Häkkinen |/2.[[McLaren-Peugeot|McLaren]]|
32
+ |8|Martin Brundle |
33
+ |9|Christian Fittipaldi|/2.[[Footwork-Ford|Footwork]]|
34
+ |10|Gianni Morbidelli|
35
+ |11|Pedro Lamy |/2.[[Lotus-Mugen-Honda|Lotus]]|
36
+ |12|Johnny Herbert |
37
+ |14|Rubens Barrichello|/2.[[Jordan-Hart|Jordan]]|
38
+ |15|Eddie Irvine |
39
+ |19|Olivier Beretta |/2.[[Larrousse-Ford|Larrousse]]|
40
+ |20|Érik Comas |
41
+ |23|Pierluigi Martini|/2.[[Minardi-Ford|Minardi]]|
42
+ |24|Michele Alboreto |
43
+ |25|Éric Bernard |/2.[[Ligier-Renault|Ligier]]|
44
+ |26|Olivier Panis |
45
+ |27|Jean Alesi |/2.[[Ferrari|Ferrari]]|
46
+ |28|Gerhard Berger |
47
+ |29|Karl Wendlinger |/2.[[Sauber-Mercedes|Sauber]]|
48
+ |30|Heinz-Harald Frentzen|
49
+ |31|David Brabham |/2.[[Simtek-Ford|Simtek]]|
50
+ |32|Roland Ratzenberger|
51
+ |33|Paul Belmondo |/2.[[Pacific-Ilmor|Pacific]]|
52
+ |34|Bertrand Gachot |
53
+
54
+
55
+ [[Getting new people|Getting_new_people]]
56
+
57
+ [[Contact form|Contact_form]]
@@ -0,0 +1,145 @@
1
+ h1. Williams-Renault 1994
2
+
3
+ "Williams FW16 Launch Press Conference on YouTube":http://www.youtube.com/watch?v=qJF5TYS9uX0
4
+ "Williams FW16 Testing (Senna, Estoril) on YouTube":http://www.youtube.com/watch?v=smRQ2YnAfv0
5
+
6
+ h2. Livery Changes
7
+
8
+ | |_.Mainsponsor |_.Mirrors|
9
+ |*Brazil* |/5.Rothmans|/2.white/elf|
10
+ |Pacific|
11
+ |San Marino |/14.blue/elf|
12
+ |Monaco |
13
+ |Spain |
14
+ |*Canada* |Rothmans Ltd|
15
+ |*France* |Barcode|
16
+ |*Great Britain*|/2.Racing|
17
+ |Germany |
18
+ |Hungary |/7.Rothmans|
19
+ |Belgium |
20
+ |Italy |
21
+ |Portugal |
22
+ |Europe |
23
+ |Japan |
24
+ |Australia |
25
+
26
+ h2. Selected Technical Upgrades
27
+
28
+ The upgrades we are going to do on the mod:
29
+ * **A-Spec**
30
+ ** Frontwing
31
+ *** High V1
32
+ ** Rearwing
33
+ *** High V1
34
+ *** Regular V1
35
+ * **B-Spec**
36
+ ** Frontwing
37
+ *** High V3
38
+ *** High V2
39
+ ** Rearwing
40
+ *** High V3
41
+ *** Regular V3
42
+ *** Low V3
43
+
44
+ h2. Technical Upgrades
45
+
46
+ _This is for keeping track of all upgrades. We will not implement everything in the actual mod!_
47
+
48
+ | |_.Front wing |_.Rear wing|_.Nose |_.Barge boards|_.Airbox|
49
+ |*Brazil* |/2.High V1 |Regular V1|/2.with flipups |/4.none|/5. |
50
+ |Pacific | High V1|
51
+ |San Marino |Low V1|Regular V1|/14. without flipups|
52
+ |Monaco |/2.High V2 |High V1|
53
+ |Spain |??|/12.bargeboard|
54
+ |Canada |/3.High V3|/2.High V1|/11.Airbox cutout|
55
+ |France |
56
+ |Great Britain |Regular V1|
57
+ |Germany |Low V2 |Low|
58
+ |Hungary |High V3|High V3|
59
+ |Belgium |/2.Low V2|Regular V2|
60
+ |Italy |Low |
61
+ |Portugal |/4.High V3|??|
62
+ |Europe |/3.Regular V3|
63
+ |Japan |
64
+ |Australia |
65
+
66
+ h3. Front wing
67
+
68
+ All frontwings from Spain onwards have new triangular endplates.
69
+
70
+ *Low V2*: flat angle and large gurney flaps
71
+ *High V2*: added large gurney flaps
72
+ *High V3*: like v2, but with triangular sideplates
73
+
74
+ h3. Front wing
75
+
76
+ *High V3*: adds one additional plane on the top and the wing additions inside the tires
77
+ *Regular V2*: has different striped-down endplates
78
+ *Regular V3*: has different endplates featuring the wing additions from the high-downforce variant
79
+
80
+
81
+
82
+ h2. Technical Data (Autocourse 1994/95)
83
+
84
+ !F1-1994_01_Williams.jpg!
85
+ For comparison (from Histomobile):
86
+ "FW16":http://www.histomobile.com/dvd_histomobile/usa/286/1994-Williams-FW16-.asp 515 kg, 2990 mm (wheelbase), 1669 mm (track front), 1598 mm (track rear)
87
+ "FW16B":http://www.histomobile.com/dvd_histomobile/usa/286/1994-Williams-FW16B-.asp 595 kg, 2890 mm (wheelbase), 1669 mm (track front), 1598 mm (track rear)
88
+
89
+ According to Autocourse 94/95, the FW16 started the season with the 67° V10 engine RS6 and got the RS6B for the Hockenheim GP as well as the RS6C for Monza. Both upgrades featured higher revs and improved top-end power. The RS6 delivered about 790 bhp / 589 KW @ 14300 rpm according to *"ultimatecarpage.com":http://www.ultimatecarpage.com/car/1054/Williams-FW16-Renault.html*.
90
+
91
+ h2. Technical Data (Grand Prix 1994)
92
+
93
+ !F1-1994_01_Williams_GP94.jpg!
94
+
95
+ h2. Technical Upgrades
96
+
97
+ The Ferrari car upgrades are listed below as reported in Autosport Magazine.
98
+
99
+ h2. Pre-Season (Autosport 134(4), January 27)
100
+
101
+ * Passive front suspension
102
+ * New and simplified cockpit
103
+
104
+ !Williams_000_AS-134_4_-1994-January-27.jpg!
105
+
106
+ !Williams_010_AS-134_4_-1994-January-27.jpg!
107
+
108
+ h3. Photos of the new cockpit and display (late season!)
109
+
110
+ !Williams_010_cockpit1.jpg!
111
+ !Williams_010_cockpit2.jpg!
112
+ !Williams_010_cockpit3.jpg!
113
+
114
+ h2. Pre-Season (Autosport 134(9), March 3)
115
+
116
+ * General car design
117
+ * Suspension
118
+ * Rear wing
119
+
120
+ !Williams_015_AS-134_9_-1994-March-3.jpg!
121
+ !Williams_016_AS-134_9_-1994-March-3.jpg!
122
+ !Williams_018_AS-134_9_-1994-March-3.jpg!
123
+
124
+ h2. Brazilian GP, Interlagos (Autosport 134(11), March 17)
125
+
126
+ * Re-designed ear end
127
+ * Chassis (cockpit, fuel tank, ...)
128
+
129
+ !Williams_020_AS-134_11_-1994-March-17.jpg!
130
+
131
+ h2. Testing between Brazilian and Pacific GP (Autosport 134(14), April 7)
132
+
133
+ !Williams_030_AS-134_14_-1994-April-7.jpg!
134
+
135
+ h2. German GP, Hockenheim (Autosport 136(5), August 4)
136
+
137
+ * Shortened sidepods
138
+ * Revised (elongated) bargeboards
139
+ * Revised cockpit edge (now rounded at the front)
140
+ * New airbox vent in agreement with the new regulations
141
+ * Rear suspension
142
+ * Diffuser
143
+
144
+ !Williams_040_AS-136_5_-1994-August-4.jpg!
145
+