caramelize 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +29 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +83 -71
  5. data/README.md +2 -3
  6. data/Rakefile +3 -1
  7. data/bin/caramelize +8 -7
  8. data/caramelize.gemspec +23 -19
  9. data/lib/caramelize/caramel.rb +26 -30
  10. data/lib/caramelize/content_transferer.rb +48 -29
  11. data/lib/caramelize/database_connector.rb +8 -8
  12. data/lib/caramelize/filter_processor.rb +2 -0
  13. data/lib/caramelize/filters/camel_case_to_wiki_links.rb +26 -0
  14. data/lib/caramelize/filters/remove_table_tab_line_endings.rb +3 -2
  15. data/lib/caramelize/filters/swap_wiki_links.rb +5 -3
  16. data/lib/caramelize/filters/wikka_to_markdown.rb +26 -20
  17. data/lib/caramelize/health_check.rb +6 -68
  18. data/lib/caramelize/health_checks/home_page_check.rb +23 -0
  19. data/lib/caramelize/health_checks/orphaned_pages_check.rb +56 -0
  20. data/lib/caramelize/health_checks/page.rb +28 -0
  21. data/lib/caramelize/input_wiki/redmine_wiki.rb +14 -13
  22. data/lib/caramelize/input_wiki/wiki.rb +8 -2
  23. data/lib/caramelize/input_wiki/wikkawiki.rb +22 -13
  24. data/lib/caramelize/output_wiki/gollum.rb +10 -10
  25. data/lib/caramelize/page.rb +13 -9
  26. data/lib/caramelize/services/page_builder.rb +11 -8
  27. data/lib/caramelize/version.rb +3 -1
  28. data/lib/caramelize.rb +5 -0
  29. data/spec/lib/caramelize/content_transferer_spec.rb +3 -1
  30. data/spec/lib/caramelize/filter_processor_spec.rb +5 -2
  31. data/spec/lib/caramelize/filters/add_newline_on_page_end_spec.rb +27 -0
  32. data/spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb +44 -0
  33. data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +14 -9
  34. data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +16 -13
  35. data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +123 -58
  36. data/spec/lib/caramelize/input_wiki/wiki_spec.rb +15 -14
  37. data/spec/lib/caramelize/output_wiki/gollum_spec.rb +31 -31
  38. data/spec/lib/caramelize/page_spec.rb +34 -26
  39. data/spec/lib/caramelize/services/page_builder_spec.rb +41 -0
  40. data/spec/spec_helper.rb +4 -2
  41. metadata +50 -29
  42. data/.travis.yml +0 -5
  43. data/spec/lib/caramelize/services/page_builder.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 033fa149f2fd6a1823143125c966ea4ce7ea45b4106dec98762f4764db0b3c09
4
- data.tar.gz: 80c47ef70453d79d01979f9fada6987d4f91cc4101aae488d4b5cba21841016e
3
+ metadata.gz: cb93f32560a4999584cc9e883655f867ed7f02bdffc4ef9a7088a5c44e68b29b
4
+ data.tar.gz: a3ae3187dc3a45c831daa833e991692f7c7108c8967da53efcafb2a4330dbadc
5
5
  SHA512:
6
- metadata.gz: aed7b973e815bc6680210aef38f3519e6d46d45c10efd095126cce67edcd6d64cbd46bfd31b03cc68abf0f60bd8be57bf948d687f874a78fc8e37cb9a4a812a1
7
- data.tar.gz: f9e3d0d1c1ba24c73d7f13699f71fb9d1abfb0022c9b42a5ed94a241bd88a09aab93f43bb69ba622f8e03a0ba1d85b92b97c7be1a7545a50886ce06536891203
6
+ metadata.gz: 0da855d0680a06673e8ad2b98734ee8fe4d04063ebd40e5b5a3b37cd1f7446fd4ea10502e349dfc1e27787b8f395b976f870595e7622e1524a2504f9676000a4
7
+ data.tar.gz: 886e63abc962ee8e830d12efc632bd832000ca70951081e9cfb185fabba1f40711db6574ef2df40b2c8c946f5ae61ef06f51877a66288eef9f9ef431c4237937
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ NewCops: enable
7
+ Exclude:
8
+ - 'vendor/**/*'
9
+ - 'spec/fixtures/**/*'
10
+ - 'tmp/**/*'
11
+ - '.git/**/*'
12
+ - 'bin/*'
13
+ - '*.cmlz'
14
+ TargetRubyVersion: 3.1
15
+ SuggestExtensions: false
16
+
17
+
18
+ Style/Documentation:
19
+ Enabled: false
20
+ StyleGuide: http://relaxed.ruby.style/#styledocumentation
21
+
22
+ Metrics/BlockLength:
23
+ Enabled: false
24
+
25
+ Layout/LineLength:
26
+ Enabled: false
27
+
28
+ RSpec/NestedGroups:
29
+ Enabled: false
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in testgem.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- caramelize (1.1.0)
4
+ caramelize (1.2.0)
5
5
  commander
6
6
  gollum-lib
7
7
  mysql2
@@ -10,37 +10,36 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- ast (2.4.0)
13
+ ast (2.4.2)
14
14
  byebug (11.1.3)
15
- coderay (1.1.2)
16
- commander (4.5.2)
17
- highline (~> 2.0.0)
15
+ coderay (1.1.3)
16
+ commander (5.0.0)
17
+ highline (~> 3.0.0)
18
18
  crass (1.0.6)
19
- diff-lcs (1.3)
20
- ffi (1.12.2)
21
- formatador (0.2.5)
19
+ diff-lcs (1.5.1)
20
+ ffi (1.16.3)
21
+ formatador (1.1.0)
22
22
  gemojione (4.3.3)
23
23
  json
24
- github-markup (3.0.5)
25
- gollum-lib (5.0.6)
24
+ github-markup (4.0.2)
25
+ gollum-lib (6.0)
26
26
  gemojione (~> 4.1)
27
- github-markup (~> 3.0)
28
- gollum-rugged_adapter (~> 1.0)
27
+ github-markup (~> 4.0)
28
+ gollum-rugged_adapter (~> 3.0)
29
29
  loofah (~> 2.3)
30
30
  nokogiri (~> 1.8)
31
- octicons (~> 8.5)
32
31
  rouge (~> 3.1)
33
32
  twitter-text (= 1.14.7)
34
- gollum-rugged_adapter (1.0)
35
- mime-types (>= 1.15)
36
- rugged (~> 0.99)
37
- guard (2.16.2)
33
+ gollum-rugged_adapter (3.0)
34
+ mime-types (~> 3.4)
35
+ rugged (~> 1.5)
36
+ guard (2.18.1)
38
37
  formatador (>= 0.2.4)
39
38
  listen (>= 2.7, < 4.0)
40
39
  lumberjack (>= 1.0.12, < 2.0)
41
40
  nenv (~> 0.1)
42
41
  notiffany (~> 0.0)
43
- pry (>= 0.9.12)
42
+ pry (>= 0.13.0)
44
43
  shellany (~> 0.0)
45
44
  thor (>= 0.18.1)
46
45
  guard-compat (1.2.1)
@@ -48,93 +47,106 @@ GEM
48
47
  guard (~> 2.1)
49
48
  guard-compat (~> 1.1)
50
49
  rspec (>= 2.99.0, < 4.0)
51
- highline (2.0.3)
52
- io-console (0.5.6)
53
- irb (1.2.7)
54
- reline (>= 0.1.5)
55
- jaro_winkler (1.5.4)
56
- json (2.3.1)
57
- listen (3.2.1)
50
+ highline (3.0.1)
51
+ json (2.7.1)
52
+ language_server-protocol (3.17.0.3)
53
+ listen (3.8.0)
58
54
  rb-fsevent (~> 0.10, >= 0.10.3)
59
55
  rb-inotify (~> 0.9, >= 0.9.10)
60
- loofah (2.8.0)
56
+ loofah (2.22.0)
61
57
  crass (~> 1.0.2)
62
- nokogiri (>= 1.5.9)
63
- lumberjack (1.2.4)
58
+ nokogiri (>= 1.12.0)
59
+ lumberjack (1.2.10)
64
60
  method_source (1.0.0)
65
- mime-types (3.3.1)
61
+ mime-types (3.5.2)
66
62
  mime-types-data (~> 3.2015)
67
- mime-types-data (3.2020.1104)
68
- mini_portile2 (2.4.0)
69
- mysql2 (0.5.3)
63
+ mime-types-data (3.2023.1205)
64
+ mini_portile2 (2.8.5)
65
+ mysql2 (0.5.5)
70
66
  nenv (0.3.0)
71
- nokogiri (1.10.10)
72
- mini_portile2 (~> 2.4.0)
67
+ nokogiri (1.16.0)
68
+ mini_portile2 (~> 2.8.2)
69
+ racc (~> 1.4)
73
70
  notiffany (0.1.3)
74
71
  nenv (~> 0.1)
75
72
  shellany (~> 0.0)
76
- octicons (8.5.0)
77
- nokogiri (>= 1.6.3.1)
78
- parallel (1.19.1)
79
- parser (2.7.1.2)
80
- ast (~> 2.4.0)
81
- pry (0.13.1)
73
+ parallel (1.24.0)
74
+ parser (3.3.0.5)
75
+ ast (~> 2.4.1)
76
+ racc
77
+ pry (0.14.2)
82
78
  coderay (~> 1.1)
83
79
  method_source (~> 1.0)
84
- rainbow (3.0.0)
85
- rake (13.0.1)
86
- rb-fsevent (0.10.3)
80
+ racc (1.7.3)
81
+ rainbow (3.1.1)
82
+ rake (13.1.0)
83
+ rb-fsevent (0.11.2)
87
84
  rb-inotify (0.10.1)
88
85
  ffi (~> 1.0)
89
- reline (0.1.9)
90
- io-console (~> 0.5)
91
- rexml (3.2.4)
92
- rouge (3.26.0)
93
- rspec (3.9.0)
94
- rspec-core (~> 3.9.0)
95
- rspec-expectations (~> 3.9.0)
96
- rspec-mocks (~> 3.9.0)
97
- rspec-core (3.9.1)
98
- rspec-support (~> 3.9.1)
99
- rspec-expectations (3.9.1)
86
+ regexp_parser (2.9.0)
87
+ rexml (3.2.6)
88
+ rouge (3.30.0)
89
+ rspec (3.12.0)
90
+ rspec-core (~> 3.12.0)
91
+ rspec-expectations (~> 3.12.0)
92
+ rspec-mocks (~> 3.12.0)
93
+ rspec-core (3.12.2)
94
+ rspec-support (~> 3.12.0)
95
+ rspec-expectations (3.12.3)
100
96
  diff-lcs (>= 1.2.0, < 2.0)
101
- rspec-support (~> 3.9.0)
102
- rspec-mocks (3.9.1)
97
+ rspec-support (~> 3.12.0)
98
+ rspec-mocks (3.12.6)
103
99
  diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.9.0)
105
- rspec-support (3.9.2)
106
- rubocop (0.82.0)
107
- jaro_winkler (~> 1.5.1)
100
+ rspec-support (~> 3.12.0)
101
+ rspec-support (3.12.1)
102
+ rubocop (1.60.2)
103
+ json (~> 2.3)
104
+ language_server-protocol (>= 3.17.0)
108
105
  parallel (~> 1.10)
109
- parser (>= 2.7.0.1)
106
+ parser (>= 3.3.0.2)
110
107
  rainbow (>= 2.2.2, < 4.0)
111
- rexml
108
+ regexp_parser (>= 1.8, < 3.0)
109
+ rexml (>= 3.2.5, < 4.0)
110
+ rubocop-ast (>= 1.30.0, < 2.0)
112
111
  ruby-progressbar (~> 1.7)
113
- unicode-display_width (>= 1.4.0, < 2.0)
114
- ruby-progressbar (1.10.1)
115
- rugged (0.99.0)
112
+ unicode-display_width (>= 2.4.0, < 3.0)
113
+ rubocop-ast (1.30.0)
114
+ parser (>= 3.2.1.0)
115
+ rubocop-capybara (2.20.0)
116
+ rubocop (~> 1.41)
117
+ rubocop-factory_bot (2.25.1)
118
+ rubocop (~> 1.41)
119
+ rubocop-rake (0.6.0)
120
+ rubocop (~> 1.0)
121
+ rubocop-rspec (2.26.1)
122
+ rubocop (~> 1.40)
123
+ rubocop-capybara (~> 2.17)
124
+ rubocop-factory_bot (~> 2.22)
125
+ ruby-progressbar (1.13.0)
126
+ rugged (1.7.1)
116
127
  shellany (0.0.1)
117
- thor (1.0.1)
128
+ thor (1.3.0)
118
129
  twitter-text (1.14.7)
119
130
  unf (~> 0.1.0)
120
131
  unf (0.1.4)
121
132
  unf_ext
122
- unf_ext (0.0.7.7)
123
- unicode-display_width (1.7.0)
133
+ unf_ext (0.0.9.1)
134
+ unicode-display_width (2.5.0)
124
135
 
125
136
  PLATFORMS
126
137
  ruby
127
138
 
128
139
  DEPENDENCIES
129
- bundler (~> 1.6)
140
+ bundler (~> 2)
130
141
  byebug
131
142
  caramelize!
132
143
  guard
133
144
  guard-rspec
134
- irb
135
145
  rake
136
146
  rspec
137
147
  rubocop
148
+ rubocop-rake
149
+ rubocop-rspec
138
150
 
139
151
  BUNDLED WITH
140
- 1.17.3
152
+ 2.5.5
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Caramelize
2
2
 
3
- [![Build Status](https://travis-ci.org/dahie/caramelize.svg?branch=master)](https://travis-ci.org/dahie/caramelize) [![Maintainability](https://api.codeclimate.com/v1/badges/7fe3ef34e09ba8133424/maintainability)](https://codeclimate.com/github/Dahie/caramelize/maintainability)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/7fe3ef34e09ba8133424/maintainability)](https://codeclimate.com/github/Dahie/caramelize/maintainability)
4
4
 
5
5
  Caramelize is a compact and flexible wiki content migration tool. It is intended for easily transfering content from otherwise rare supported legacy wikis. With caramelize you can create your own export configurations and migrate your data into a git-based [gollum](https://github.com/github/gollum)-wiki retaining all your history and gaining the most flexible access to your wiki content.
6
6
 
@@ -107,8 +107,7 @@ Once the object is established we need to hook in a method that defines how revi
107
107
  latest: row["latest"] == "Y",
108
108
  time: row["time"],
109
109
  message: row["note"],
110
- author: author,
111
- author_name: row["user"]})
110
+ author: author})
112
111
  revisions << page
113
112
  end
114
113
  # titles is the list of all unique page titles contained in the wiki
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec/core/rake_task'
2
4
  require 'bundler/gem_tasks'
3
5
 
@@ -7,4 +9,4 @@ RSpec::Core::RakeTask.new(:spec) do |task|
7
9
  task.rspec_opts = ['--color', '--format', 'documentation']
8
10
  end
9
11
 
10
- task :default => :spec
12
+ task default: :spec
data/bin/caramelize CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'caramelize'
4
5
  require 'commander/import'
@@ -20,10 +21,10 @@ command :new do |c|
20
21
  c.option '--config STRING', String, 'The config file (default: caramel.rb)'
21
22
  c.example 'Create a fresh config file as "caramel.rb"', 'caramelize create'
22
23
  c.example 'Create a fresh config file as "config.rb"', 'caramelize create --config config.rb'
23
- c.action do |args, options|
24
- target_file ||= (options.config || 'caramel.rb')
24
+ c.action do |_args, options|
25
+ target_file || options.config || 'caramel.rb'
25
26
  options.default({ config: 'caramel.rb' })
26
- FileUtils.cp(File.dirname(__FILE__) + '/../lib/caramelize/caramel.rb',
27
+ FileUtils.cp("#{File.dirname(__FILE__)}/../lib/caramelize/#{target_file}",
27
28
  options.config)
28
29
  say "Created new configuration file: #{options.config}"
29
30
  end
@@ -37,7 +38,7 @@ command :run do |c|
37
38
  c.option '--config STRING', String, 'The config file (default: caramel.rb)'
38
39
  c.example 'Run transfer for "caramel.rb"', 'caramelize run'
39
40
  c.example 'Run transfer for "config.rb"', 'caramelize run --config config.rb'
40
- c.action do |args, options|
41
+ c.action do |_args, options|
41
42
  time_start = Time.now
42
43
  options.default({ config: 'caramel.rb', target: 'wiki-export' })
43
44
 
@@ -45,7 +46,7 @@ command :run do |c|
45
46
 
46
47
  target = options.target
47
48
 
48
- if File.exists?(target)
49
+ if File.exist?(target)
49
50
  answer = agree("#{target} already exists. Overwrite with fresh repository?")
50
51
  FileUtils.rm_rf(target) if answer
51
52
  end
@@ -63,10 +64,10 @@ command :doctor do |c|
63
64
  c.description = 'Run health-check'
64
65
  c.option '--target STRING', String, 'The target path to Gollum git repository (default: wiki-export)'
65
66
  c.example 'Run transfer for "caramel.rb"', 'caramelize doctor'
66
- c.action do |args, options|
67
+ c.action do |_args, options|
67
68
  options.default(target: 'wiki-export')
68
69
 
69
- if File.exists?(options.target)
70
+ if File.exist?(options.target)
70
71
  Caramelize::HealthCheck.new(options.target).execute
71
72
  else
72
73
  say("No wiki repositry found in directory #{options.target}")
data/caramelize.gemspec CHANGED
@@ -1,33 +1,37 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "caramelize/version"
5
+ require 'caramelize/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "caramelize"
8
+ spec.name = 'caramelize'
8
9
  spec.version = Caramelize::VERSION
9
- spec.license = "MIT"
10
- spec.authors = ["Daniel Senff"]
11
- spec.email = ["mail@danielsenff.de"]
12
- spec.homepage = "http://github.com/Dahie/caramelize"
13
- spec.summary = %q{Flexible and modular wiki conversion tool}
14
- spec.description = %q{With Caramelize you can migrate any wiki to git-based Gollum wiki repositories.}
10
+ spec.license = 'MIT'
11
+ spec.authors = ['Daniel Senff']
12
+ spec.email = ['mail@danielsenff.de']
13
+ spec.homepage = 'http://github.com/Dahie/caramelize'
14
+ spec.summary = 'Flexible and modular wiki conversion tool'
15
+ spec.description = 'With Caramelize you can migrate any wiki to git-based Gollum wiki repositories.'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0")
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
+ spec.required_ruby_version = '>= 3.1'
20
21
 
21
22
  spec.add_dependency('commander')
22
23
  spec.add_dependency('gollum-lib')
23
24
  spec.add_dependency('mysql2')
24
25
  spec.add_dependency('ruby-progressbar')
25
26
 
26
- spec.add_development_dependency "bundler", "~> 1.6"
27
- spec.add_development_dependency "rake"
28
- spec.add_development_dependency "rspec"
29
- spec.add_development_dependency "byebug"
30
- spec.add_development_dependency "rubocop"
31
- spec.add_development_dependency "guard"
32
- spec.add_development_dependency "guard-rspec"
27
+ spec.add_development_dependency 'bundler', '~> 2'
28
+ spec.add_development_dependency 'byebug'
29
+ spec.add_development_dependency 'guard'
30
+ spec.add_development_dependency 'guard-rspec'
31
+ spec.add_development_dependency 'rake'
32
+ spec.add_development_dependency 'rspec'
33
+ spec.add_development_dependency 'rubocop'
34
+ spec.add_development_dependency 'rubocop-rake'
35
+ spec.add_development_dependency 'rubocop-rspec'
36
+ spec.metadata['rubygems_mfa_required'] = 'true'
33
37
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'caramelize/input_wiki/wikkawiki'
2
4
  require 'caramelize/input_wiki/redmine_wiki'
3
5
 
@@ -8,31 +10,29 @@ require 'caramelize/input_wiki/redmine_wiki'
8
10
 
9
11
  # Note, if you want to activate this, you need to uncomment the line below.
10
12
  def customized_wiki
11
-
12
13
  # This example is a reimplementation of the WikkaWiki-Connector.
13
14
  # To connect to WikkaWiki, I suggest to use the predefined Connector below.
14
- options = { host: "localhost",
15
- username: "user",
16
- database: "database_name",
15
+ options = { host: 'localhost',
16
+ username: 'user',
17
+ database: 'database_name',
17
18
  password: 'Picard-Delta-5',
18
- markup: :wikka}
19
+ markup: :wikka }
19
20
  wiki = Caramelize::InputWiki::Wiki.new(options)
20
21
  wiki.instance_eval do
21
22
  def read_pages
22
- sql = "SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;"
23
+ sql = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'
23
24
  results = database.query(sql)
24
25
  results.each do |row|
25
- titles << row["tag"]
26
- author = @authors[row["user"]]
27
- properties = { id: row["id"],
28
- title: row["tag"],
29
- body: row["body"],
30
- markup: 'wikka',
31
- latest: row["latest"] == "Y",
32
- time: row["time"],
33
- message: row["note"],
34
- author: author,
35
- author_name: row["user"]}
26
+ titles << row['tag']
27
+ author = @authors[row['user']]
28
+ properties = { id: row['id'],
29
+ title: row['tag'],
30
+ body: row['body'],
31
+ markup: 'wikka',
32
+ latest: row['latest'] == 'Y',
33
+ time: row['time'],
34
+ message: row['note'],
35
+ author: }
36
36
  page = Page.new(properties)
37
37
  revisions << page
38
38
  end
@@ -44,35 +44,31 @@ def customized_wiki
44
44
  wiki
45
45
  end
46
46
 
47
-
48
47
  # if you want to use one of the preset Wiki-Connectors uncomment the connector
49
48
  # and edit the database logins accordingly.
50
49
  def predefined_wiki
51
-
52
50
  # For connection to a WikkaWiki-Database use this Connector
53
- #options = { host: "localhost",
51
+ # options = { host: "localhost",
54
52
  # username: "root",
55
53
  # password: "root",
56
54
  # database: "wikka" }
57
- #return Caramelize::InputWiki::WikkaWiki.new(options)
58
-
55
+ # return Caramelize::InputWiki::WikkaWiki.new(options)
59
56
 
60
57
  # For connection to a Redmine-Database use this Connector
61
58
  # Additional options:
62
59
  # :create_namespace_overview => true/false (Default: true) - Creates a new wikipage at /home as root page for Gollum wiki
63
- options = { host: "localhost",
64
- username: "root",
65
- password: "root",
66
- database: "redmine_development" }
67
- return Caramelize::InputWiki::RedmineWiki.new(options)
60
+ options = { host: 'localhost',
61
+ username: 'root',
62
+ password: 'root',
63
+ database: 'redmine_development' }
64
+ Caramelize::InputWiki::RedmineWiki.new(options)
68
65
  end
69
66
 
70
-
71
67
  def input_wiki
72
68
  # comment and uncomment to easily switch between predefined and
73
69
  # costumized Wiki-connectors.
74
70
 
75
- #return customized_wiki
71
+ # return customized_wiki
76
72
 
77
- return predefined_wiki
73
+ predefined_wiki
78
74
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ruby-progressbar'
2
4
 
3
5
  module Caramelize
4
-
5
6
  require 'caramelize/page'
6
7
  require 'caramelize/content_transferer'
7
8
  require 'caramelize/database_connector'
@@ -12,37 +13,37 @@ module Caramelize
12
13
  class ContentTransferer
13
14
  attr_reader :input_wiki, :options
14
15
 
15
- DEFAULT_GOLLUM_HOME_TITLE = 'Home'.freeze
16
+ DEFAULT_GOLLUM_HOME_TITLE = 'Home'
17
+ DEFAULT_AUTHOR_NAME = 'Caramelize'
18
+ DEFAULT_AUTHOR_EMAIL = 'caramelize@example.com'
16
19
 
17
20
  def initialize(input_wiki, options)
18
21
  @input_wiki = input_wiki
19
22
  @options = options
20
23
 
21
- options[:default_author] = options.fetch(:default_author, "Caramelize")
24
+ options[:default_author] = options.fetch(:default_author, 'Caramelize')
22
25
  options[:markup] = target_markup
23
26
  end
24
27
 
25
28
  def execute
26
29
  input_wiki.read_authors
27
-
28
30
  commit_history
29
-
30
- if verbose?
31
- puts "From markup: #{input_wiki.markup.to_s}"
32
- puts "To markup: #{target_markup.to_s}"
33
- puts "Convert latest revisions:"
34
- end
31
+ print_meta_data if verbose?
35
32
 
36
33
  migrate_markup_of_latest_revisions
37
34
 
38
- puts 'Create Namespace Overview' if verbose?
39
35
  create_overview_page_of_namespaces if options[:create_namespace_overview]
40
36
 
41
- rename_home_page
37
+ rename_home_page if options[:home_page_title]
42
38
  end
43
39
 
44
40
  private
45
41
 
42
+ def print_meta_data
43
+ puts "From markup: #{input_wiki.markup}"
44
+ puts "To markup: #{target_markup}"
45
+ end
46
+
46
47
  def target_markup
47
48
  @target_markup ||=
48
49
  needs_conversion_to_target_markup? ? input_wiki.markup : :markdown
@@ -77,29 +78,47 @@ module Caramelize
77
78
  end
78
79
 
79
80
  def create_overview_page_of_namespaces
81
+ puts 'Create Namespace Overview' if verbose?
80
82
  output_wiki.commit_namespace_overview(input_wiki.namespaces)
81
83
  end
82
84
 
83
85
  def migrate_markup_progress_bar
84
86
  @migrate_markup_progress_bar ||=
85
- ProgressBar.create(title: "Markup filters",
87
+ ProgressBar.create(title: 'Markup filters',
86
88
  total: latest_revisions_count)
87
89
  end
88
90
 
89
91
  def commit_history_progress_bar
90
92
  @commit_history_progress_bar ||=
91
- ProgressBar.create(title: "Revisions",
93
+ ProgressBar.create(title: 'Revisions',
92
94
  total: revisions_count)
93
95
  end
94
96
 
95
97
  def migrate_markup_of_latest_revisions
98
+ puts 'Convert latest revisions:' if verbose?
96
99
  input_wiki.latest_revisions.each do |revision|
100
+ if input_wiki.excluded_pages.include?(revision.title)
101
+ puts "Exclude Page: #{revision.title}" if verbose?
102
+ next
103
+ end
104
+
105
+ if verbose?
106
+ puts "Filter source: #{revision.title} #{revision.time}"
107
+ else
108
+ migrate_markup_progress_bar.increment
109
+ end
110
+
97
111
  migrate_markup_of_revision(revision)
98
112
  end
99
113
  end
100
114
 
101
115
  def commit_history
102
116
  output_wiki.commit_history(revisions, options) do |page, index|
117
+ if input_wiki.excluded_pages.include?(page.title)
118
+ puts "Exclude Page: #{page.title}" if verbose?
119
+ next
120
+ end
121
+
103
122
  if verbose?
104
123
  puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
105
124
  else
@@ -109,27 +128,27 @@ module Caramelize
109
128
  end
110
129
 
111
130
  def migrate_markup_of_revision(revision)
112
- if verbose?
113
- puts "Filter source: #{revision.title} #{revision.time}"
114
- else
115
- migrate_markup_progress_bar.increment
116
- end
117
-
118
131
  body_new = filter_processor.run(revision.body)
119
132
 
120
- unless body_new == revision.body
121
- revision.body = body_new
122
- revision.author_name = 'Caramelize'
123
- revision.time = Time.now
124
- revision.author = nil
125
- revision.message = "Markup of '#{revision.title}' converted to #{target_markup}"
133
+ return if body_new == revision.body
126
134
 
127
- # commit as latest page revision
128
- output_wiki.commit_revision(revision, options[:markup])
129
- end
135
+ message = "Markup of '#{revision.title}' converted to #{target_markup}"
136
+
137
+ # commit as latest page revision
138
+ output_wiki.commit_revision(build_revision_metadata(revision, body_new, message), options[:markup])
139
+ end
140
+
141
+ def build_revision_metadata(revision, body_new, message)
142
+ revision.body = body_new
143
+ revision.author = { name: DEFAULT_AUTHOR_NAME, email: DEFAULT_AUTHOR_EMAIL }
144
+ revision.time = Time.now
145
+ revision.message = message
146
+
147
+ revision
130
148
  end
131
149
 
132
150
  def rename_home_page
151
+ puts "Rename page #{options[:home_page_title]} to #{DEFAULT_GOLLUM_HOME_TITLE}" if verbose?
133
152
  output_wiki.rename_page(options[:home_page_title], DEFAULT_GOLLUM_HOME_TITLE)
134
153
  end
135
154
  end