caramelize 0.4.0 → 1.0.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.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/README.md +3 -1
- data/Rakefile +2 -2
- data/bin/caramelize +12 -5
- data/caramelize.gemspec +2 -3
- data/lib/caramelize.rb +2 -1
- data/lib/caramelize/content_transferer.rb +31 -17
- data/lib/caramelize/filter_processor.rb +1 -2
- data/lib/caramelize/filters/remove_table_tab_line_endings.rb +6 -2
- data/lib/caramelize/filters/swap_wiki_links.rb +6 -2
- data/lib/caramelize/filters/wikka_to_markdown.rb +53 -25
- data/lib/caramelize/input_wiki/redmine_wiki.rb +55 -47
- data/lib/caramelize/input_wiki/wikkawiki.rb +15 -11
- data/lib/caramelize/output_wiki/gollum.rb +12 -7
- data/lib/caramelize/version.rb +1 -1
- data/spec/lib/caramelize/filter_processor_spec.rb +7 -5
- data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +30 -16
- data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +33 -17
- data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +152 -54
- data/spec/lib/caramelize/output_wiki/gollum_spec.rb +3 -4
- metadata +8 -24
- data/lib/caramelize/ext.rb +0 -17
- data/lib/caramelize/filters/trac_to_markdown.rb +0 -42
- data/lib/caramelize/input_wiki/trac_converter.rb +0 -82
@@ -8,9 +8,9 @@ describe Caramelize::OutputWiki::Gollum do
|
|
8
8
|
|
9
9
|
describe '#commit_revision' do
|
10
10
|
let(:title) { 'title' }
|
11
|
+
let(:author) { double(name: 'Steven Universe', email: 'steven@example.com') }
|
11
12
|
let(:input_page) do
|
12
|
-
double(
|
13
|
-
author_email: 'steven@example.com',
|
13
|
+
double(author: author,
|
14
14
|
body: 'body',
|
15
15
|
commit_message: 'done',
|
16
16
|
time: Time.now,
|
@@ -84,8 +84,7 @@ describe Caramelize::OutputWiki::Gollum do
|
|
84
84
|
let(:expected_hash) do
|
85
85
|
{
|
86
86
|
message: 'Dinosaurs really had feathers, do not forget!',
|
87
|
-
|
88
|
-
committed_date: Time.parse('2015-02-12'),
|
87
|
+
time: Time.parse('2015-02-12'),
|
89
88
|
name: 'Jeff Goldblum',
|
90
89
|
email: 'jeff.g@example.com'
|
91
90
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caramelize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Senff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: docile
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: ruby-progressbar
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +58,14 @@ dependencies:
|
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
61
|
+
version: '0'
|
76
62
|
type: :runtime
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
68
|
+
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: bundler
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,8 +164,7 @@ dependencies:
|
|
178
164
|
- - ">="
|
179
165
|
- !ruby/object:Gem::Version
|
180
166
|
version: '0'
|
181
|
-
description:
|
182
|
-
to git-based Gollum wiki repositories.
|
167
|
+
description: With Caramelize you can migrate any wiki to git-based Gollum wiki repositories.
|
183
168
|
email:
|
184
169
|
- mail@danielsenff.de
|
185
170
|
executables:
|
@@ -188,6 +173,8 @@ extensions: []
|
|
188
173
|
extra_rdoc_files: []
|
189
174
|
files:
|
190
175
|
- ".gitignore"
|
176
|
+
- ".travis.yml"
|
177
|
+
- CODE_OF_CONDUCT.md
|
191
178
|
- Gemfile
|
192
179
|
- Gemfile.lock
|
193
180
|
- LICENSE.md
|
@@ -199,14 +186,11 @@ files:
|
|
199
186
|
- lib/caramelize/caramel.rb
|
200
187
|
- lib/caramelize/content_transferer.rb
|
201
188
|
- lib/caramelize/database_connector.rb
|
202
|
-
- lib/caramelize/ext.rb
|
203
189
|
- lib/caramelize/filter_processor.rb
|
204
190
|
- lib/caramelize/filters/remove_table_tab_line_endings.rb
|
205
191
|
- lib/caramelize/filters/swap_wiki_links.rb
|
206
|
-
- lib/caramelize/filters/trac_to_markdown.rb
|
207
192
|
- lib/caramelize/filters/wikka_to_markdown.rb
|
208
193
|
- lib/caramelize/input_wiki/redmine_wiki.rb
|
209
|
-
- lib/caramelize/input_wiki/trac_converter.rb
|
210
194
|
- lib/caramelize/input_wiki/wiki.rb
|
211
195
|
- lib/caramelize/input_wiki/wikkawiki.rb
|
212
196
|
- lib/caramelize/output_wiki/gollum.rb
|
@@ -246,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
230
|
- !ruby/object:Gem::Version
|
247
231
|
version: '0'
|
248
232
|
requirements: []
|
249
|
-
rubygems_version: 3.0.
|
233
|
+
rubygems_version: 3.0.8
|
250
234
|
signing_key:
|
251
235
|
specification_version: 4
|
252
236
|
summary: Flexible and modular wiki conversion tool
|
data/lib/caramelize/ext.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'gollum-lib'
|
2
|
-
|
3
|
-
module Gollum
|
4
|
-
class Committer
|
5
|
-
def commit
|
6
|
-
@options[:parents] = parents
|
7
|
-
@options[:actor] = actor
|
8
|
-
@options[:last_tree] = nil
|
9
|
-
@options[:head] = @wiki.ref
|
10
|
-
sha1 = index.commit(@options[:message], @options)
|
11
|
-
@callbacks.each do |cb|
|
12
|
-
cb.call(self, sha1)
|
13
|
-
end
|
14
|
-
sha1
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
#Encoding: UTF-8
|
2
|
-
module Caramelize
|
3
|
-
class Trac2Markdown
|
4
|
-
|
5
|
-
def run body
|
6
|
-
body = body.dup
|
7
|
-
body.gsub!(/\r/, '')
|
8
|
-
body.gsub!(/\{\{\{([^\n]+?)\}\}\}/, '@\1@')
|
9
|
-
body.gsub!(/\{\{\{\n#!([^\n]+?)(.+?)\}\}\}/m, '<pre><code class="\1">\2</code></pre>')
|
10
|
-
body.gsub!(/\{\{\{(.+?)\}\}\}/m, '<pre>\1</pre>')
|
11
|
-
# macro
|
12
|
-
body.gsub!(/\[\[BR\]\]/, '')
|
13
|
-
body.gsub!(/\[\[PageOutline.*\]\]/, '{{toc}}')
|
14
|
-
body.gsub!(/\[\[Image\((.+?)\)\]\]/, '!\1!')
|
15
|
-
# header
|
16
|
-
body.gsub!(/=====\s(.+?)\s=====/, "== #{'\1'} ==\n\n")
|
17
|
-
body.gsub!(/====\s(.+?)\s====/, "=== #{'\1'} ===\n\n")
|
18
|
-
body.gsub!(/===\s(.+?)\s===/, "==== #{'\1'} ====\n\n")
|
19
|
-
body.gsub!(/==\s(.+?)\s==/, "===== #{'\1'} =====\n\n")
|
20
|
-
body.gsub!(/=\s(.+?)\s=[\s\n]*/, "====== #{'\1'} ======\n\n")
|
21
|
-
# table
|
22
|
-
body.gsub!(/\|\|/, "|")
|
23
|
-
# link
|
24
|
-
body.gsub!(/\[(http[^\s\[\]]+)\s([^\[\]]+)\]/, ' "\2":\1' )
|
25
|
-
body.gsub!(/\[([^\s]+)\s(.+)\]/, ' [[\1 | \2]] ')
|
26
|
-
body.gsub!(/([^"\/\!])(([A-Z][a-z0-9]+){2,})/, ' \1[[\2]] ')
|
27
|
-
body.gsub!(/\!(([A-Z][a-z0-9]+){2,})/, '\1')
|
28
|
-
# text decoration
|
29
|
-
body.gsub!(/'''(.+)'''/, '*\1*')
|
30
|
-
body.gsub!(/''(.+)''/, '_\1_')
|
31
|
-
body.gsub!(/`(.+)`/, '@\1@')
|
32
|
-
# itemize
|
33
|
-
body.gsub!(/^\s\s\s\*/, '***')
|
34
|
-
body.gsub!(/^\s\s\*/, '**')
|
35
|
-
body.gsub!(/^\s\*/, '*')
|
36
|
-
body.gsub!(/^\s\s\s\d\./, '###')
|
37
|
-
body.gsub!(/^\s\s\d\./, '##')
|
38
|
-
body.gsub!(/^\s\d\./, '#')
|
39
|
-
body
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
module Caramelize
|
2
|
-
module TracConverter
|
3
|
-
|
4
|
-
# take an input stream and convert all wikka syntax to markdown syntax
|
5
|
-
# taken from 'trac_wiki_to_textile' at
|
6
|
-
def to_textile str
|
7
|
-
body = body.dup
|
8
|
-
body.gsub!(/\r/, '')
|
9
|
-
body.gsub!(/\{\{\{([^\n]+?)\}\}\}/, '@\1@')
|
10
|
-
body.gsub!(/\{\{\{\n#!([^\n]+?)(.+?)\}\}\}/m, '<pre><code class="\1">\2</code></pre>')
|
11
|
-
body.gsub!(/\{\{\{(.+?)\}\}\}/m, '<pre>\1</pre>')
|
12
|
-
# macro
|
13
|
-
body.gsub!(/\[\[BR\]\]/, '')
|
14
|
-
body.gsub!(/\[\[PageOutline.*\]\]/, '{{toc}}')
|
15
|
-
body.gsub!(/\[\[Image\((.+?)\)\]\]/, '!\1!')
|
16
|
-
# header
|
17
|
-
body.gsub!(/=====\s(.+?)\s=====/, "h5. #{'\1'} \n\n")
|
18
|
-
body.gsub!(/====\s(.+?)\s====/, "h4. #{'\1'} \n\n")
|
19
|
-
body.gsub!(/===\s(.+?)\s===/, "h3. #{'\1'} \n\n")
|
20
|
-
body.gsub!(/==\s(.+?)\s==/, "h2. #{'\1'} \n\n")
|
21
|
-
body.gsub!(/=\s(.+?)\s=[\s\n]*/, "h1. #{'\1'} \n\n")
|
22
|
-
# table
|
23
|
-
body.gsub!(/\|\|/, "|")
|
24
|
-
# link
|
25
|
-
body.gsub!(/\[(http[^\s\[\]]+)\s([^\[\]]+)\]/, ' "\2":\1' )
|
26
|
-
body.gsub!(/\[([^\s]+)\s(.+)\]/, ' [[\1 | \2]] ')
|
27
|
-
body.gsub!(/([^"\/\!])(([A-Z][a-z0-9]+){2,})/, ' \1[[\2]] ')
|
28
|
-
body.gsub!(/\!(([A-Z][a-z0-9]+){2,})/, '\1')
|
29
|
-
# text decoration
|
30
|
-
body.gsub!(/'''(.+)'''/, '*\1*')
|
31
|
-
body.gsub!(/''(.+)''/, '_\1_')
|
32
|
-
body.gsub!(/`(.+)`/, '@\1@')
|
33
|
-
# itemize
|
34
|
-
body.gsub!(/^\s\s\s\*/, '***')
|
35
|
-
body.gsub!(/^\s\s\*/, '**')
|
36
|
-
body.gsub!(/^\s\*/, '*')
|
37
|
-
body.gsub!(/^\s\s\s\d\./, '###')
|
38
|
-
body.gsub!(/^\s\s\d\./, '##')
|
39
|
-
body.gsub!(/^\s\d\./, '#')
|
40
|
-
body
|
41
|
-
end
|
42
|
-
|
43
|
-
# TODO this is so far only copy of textile conversion
|
44
|
-
# not tested!
|
45
|
-
def to_markdown str
|
46
|
-
body = body.dup
|
47
|
-
body.gsub!(/\r/, '')
|
48
|
-
body.gsub!(/\{\{\{([^\n]+?)\}\}\}/, '@\1@')
|
49
|
-
body.gsub!(/\{\{\{\n#!([^\n]+?)(.+?)\}\}\}/m, '<pre><code class="\1">\2</code></pre>')
|
50
|
-
body.gsub!(/\{\{\{(.+?)\}\}\}/m, '<pre>\1</pre>')
|
51
|
-
# macro
|
52
|
-
body.gsub!(/\[\[BR\]\]/, '')
|
53
|
-
body.gsub!(/\[\[PageOutline.*\]\]/, '{{toc}}')
|
54
|
-
body.gsub!(/\[\[Image\((.+?)\)\]\]/, '!\1!')
|
55
|
-
# header
|
56
|
-
body.gsub!(/=====\s(.+?)\s=====/, "== #{'\1'} ==\n\n")
|
57
|
-
body.gsub!(/====\s(.+?)\s====/, "=== #{'\1'} ===\n\n")
|
58
|
-
body.gsub!(/===\s(.+?)\s===/, "==== #{'\1'} ====\n\n")
|
59
|
-
body.gsub!(/==\s(.+?)\s==/, "===== #{'\1'} =====\n\n")
|
60
|
-
body.gsub!(/=\s(.+?)\s=[\s\n]*/, "====== #{'\1'} ======\n\n")
|
61
|
-
# table
|
62
|
-
body.gsub!(/\|\|/, "|")
|
63
|
-
# link
|
64
|
-
body.gsub!(/\[(http[^\s\[\]]+)\s([^\[\]]+)\]/, ' "\2":\1' )
|
65
|
-
body.gsub!(/\[([^\s]+)\s(.+)\]/, ' [[\1 | \2]] ')
|
66
|
-
body.gsub!(/([^"\/\!])(([A-Z][a-z0-9]+){2,})/, ' \1[[\2]] ')
|
67
|
-
body.gsub!(/\!(([A-Z][a-z0-9]+){2,})/, '\1')
|
68
|
-
# text decoration
|
69
|
-
body.gsub!(/'''(.+)'''/, '*\1*')
|
70
|
-
body.gsub!(/''(.+)''/, '_\1_')
|
71
|
-
body.gsub!(/`(.+)`/, '@\1@')
|
72
|
-
# itemize
|
73
|
-
body.gsub!(/^\s\s\s\*/, '***')
|
74
|
-
body.gsub!(/^\s\s\*/, '**')
|
75
|
-
body.gsub!(/^\s\*/, '*')
|
76
|
-
body.gsub!(/^\s\s\s\d\./, '###')
|
77
|
-
body.gsub!(/^\s\s\d\./, '##')
|
78
|
-
body.gsub!(/^\s\d\./, '#')
|
79
|
-
body
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|