caramelize 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1f1a5ad803a7cb1d2b0492ef8608748f1d929dc87964ca5d57b41ca97e02866
4
- data.tar.gz: ab3996a5e628285a09651362295f4939855f22a8a1c3fbfc08e7f234a95bfd22
3
+ metadata.gz: 949bb3270455131310d65fd3e8e7f7dae80c9012aa4497efb479c8d77a0f8be8
4
+ data.tar.gz: 3ba47fd373b387b1935e9c56315784f89d00f71a35e34a33816578098e1219eb
5
5
  SHA512:
6
- metadata.gz: 2b6c3ddbf3c8283671a1f63e7bd235b8da9ceb39604ec738700d311526f89e174fab2bd6256e740ddebacf0fe20363a7a81963b8b642bd9c1a77dbf2ba11cbdd
7
- data.tar.gz: '09de5bfa96bfa3156cbb1e047e9d9678997def63108afc467b5b80aace63ba0a736cca803061f2b2d3ad96b8bbd1a515871c2f5a5c481380850e7a6fb83d2295'
6
+ metadata.gz: 36b60fb485ca76922faa32e6c91c8e69f3e639cbcd009abd47eb555bf9f9e3d4a02cfff0f6fd29452321c65231a87e0169b5cea853543489654b44cf8399c888
7
+ data.tar.gz: f6bf9599cdff4c248e2393e63e476ce9adbb2a7de9ec9fd07bc180a19e8d4bd64265649c6ada7721902bbd5906c24d4628f8e766efa4006bfa9f5fc8931636ab
@@ -6,11 +6,11 @@ jobs:
6
6
  test:
7
7
  runs-on: ubuntu-latest
8
8
 
9
-
10
9
  steps:
11
10
  - uses: actions/checkout@v3
12
- # - name: Set up Redis
13
- # uses: zhulik/redis-action@1.1.0
11
+ - uses: r-lib/actions/setup-pandoc@v2
12
+ with:
13
+ pandoc-version: '3.1.11'
14
14
  - name: Install Ruby and gems
15
15
  uses: ruby/setup-ruby@v1
16
16
  with:
data/.rubocop.yml CHANGED
@@ -1,6 +1,9 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  require:
2
4
  - rubocop-rake
3
5
  - rubocop-rspec
6
+ - rubocop-performance
4
7
 
5
8
  AllCops:
6
9
  NewCops: enable
@@ -14,7 +17,6 @@ AllCops:
14
17
  TargetRubyVersion: 3.1
15
18
  SuggestExtensions: false
16
19
 
17
-
18
20
  Style/Documentation:
19
21
  Enabled: false
20
22
  StyleGuide: http://relaxed.ruby.style/#styledocumentation
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,55 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2024-03-04 19:34:06 UTC using RuboCop version 1.61.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
11
+ Lint/NestedMethodDefinition:
12
+ Exclude:
13
+ - 'lib/caramelize/filters/textile_to_markdown.rb'
14
+
15
+ # Offense count: 5
16
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
17
+ Metrics/AbcSize:
18
+ Max: 79
19
+
20
+ # Offense count: 2
21
+ # Configuration parameters: CountComments, CountAsOne.
22
+ Metrics/ClassLength:
23
+ Max: 118
24
+
25
+ # Offense count: 1
26
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
27
+ Metrics/CyclomaticComplexity:
28
+ Max: 9
29
+
30
+ # Offense count: 10
31
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
32
+ Metrics/MethodLength:
33
+ Max: 102
34
+
35
+ # Offense count: 1
36
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
37
+ Metrics/PerceivedComplexity:
38
+ Max: 9
39
+
40
+ # Offense count: 2
41
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
42
+ # Include: **/*_spec*rb*, **/spec/**/*
43
+ RSpec/FilePath:
44
+ Exclude:
45
+ - 'spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb'
46
+ - 'spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb'
47
+
48
+ # Offense count: 2
49
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
50
+ # Include: **/*_spec.rb
51
+ RSpec/SpecFilePathFormat:
52
+ Exclude:
53
+ - '**/spec/routing/**/*'
54
+ - 'spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb'
55
+ - 'spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb'
data/Gemfile CHANGED
@@ -12,5 +12,6 @@ gem 'guard-rspec'
12
12
  gem 'rake'
13
13
  gem 'rspec'
14
14
  gem 'rubocop'
15
+ gem 'rubocop-performance'
15
16
  gem 'rubocop-rake'
16
17
  gem 'rubocop-rspec'
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- caramelize (1.2.1)
4
+ caramelize (1.3.0)
5
5
  commander
6
6
  gollum-lib
7
7
  mysql2
8
+ paru
8
9
  ruby-progressbar
9
10
 
10
11
  GEM
@@ -50,7 +51,7 @@ GEM
50
51
  highline (3.0.1)
51
52
  json (2.7.1)
52
53
  language_server-protocol (3.17.0.3)
53
- listen (3.8.0)
54
+ listen (3.9.0)
54
55
  rb-fsevent (~> 0.10, >= 0.10.3)
55
56
  rb-inotify (~> 0.9, >= 0.9.10)
56
57
  loofah (2.22.0)
@@ -60,7 +61,7 @@ GEM
60
61
  method_source (1.0.0)
61
62
  mime-types (3.5.2)
62
63
  mime-types-data (~> 3.2015)
63
- mime-types-data (3.2023.1205)
64
+ mime-types-data (3.2024.0206)
64
65
  mini_portile2 (2.8.5)
65
66
  mysql2 (0.5.6)
66
67
  nenv (0.3.0)
@@ -74,6 +75,7 @@ GEM
74
75
  parser (3.3.0.5)
75
76
  ast (~> 2.4.1)
76
77
  racc
78
+ paru (1.2.0)
77
79
  pry (0.14.2)
78
80
  coderay (~> 1.1)
79
81
  method_source (~> 1.0)
@@ -98,8 +100,8 @@ GEM
98
100
  rspec-mocks (3.13.0)
99
101
  diff-lcs (>= 1.2.0, < 2.0)
100
102
  rspec-support (~> 3.13.0)
101
- rspec-support (3.13.0)
102
- rubocop (1.60.2)
103
+ rspec-support (3.13.1)
104
+ rubocop (1.61.0)
103
105
  json (~> 2.3)
104
106
  language_server-protocol (>= 3.17.0)
105
107
  parallel (~> 1.10)
@@ -110,22 +112,25 @@ GEM
110
112
  rubocop-ast (>= 1.30.0, < 2.0)
111
113
  ruby-progressbar (~> 1.7)
112
114
  unicode-display_width (>= 2.4.0, < 3.0)
113
- rubocop-ast (1.30.0)
114
- parser (>= 3.2.1.0)
115
+ rubocop-ast (1.31.1)
116
+ parser (>= 3.3.0.4)
115
117
  rubocop-capybara (2.20.0)
116
118
  rubocop (~> 1.41)
117
119
  rubocop-factory_bot (2.25.1)
118
120
  rubocop (~> 1.41)
121
+ rubocop-performance (1.18.0)
122
+ rubocop (>= 1.7.0, < 2.0)
123
+ rubocop-ast (>= 0.4.0)
119
124
  rubocop-rake (0.6.0)
120
125
  rubocop (~> 1.0)
121
- rubocop-rspec (2.26.1)
126
+ rubocop-rspec (2.27.1)
122
127
  rubocop (~> 1.40)
123
128
  rubocop-capybara (~> 2.17)
124
129
  rubocop-factory_bot (~> 2.22)
125
130
  ruby-progressbar (1.13.0)
126
- rugged (1.7.1)
131
+ rugged (1.7.2)
127
132
  shellany (0.0.1)
128
- thor (1.3.0)
133
+ thor (1.3.1)
129
134
  twitter-text (1.14.7)
130
135
  unf (~> 0.1.0)
131
136
  unf (0.1.4)
@@ -145,6 +150,7 @@ DEPENDENCIES
145
150
  rake
146
151
  rspec
147
152
  rubocop
153
+ rubocop-performance
148
154
  rubocop-rake
149
155
  rubocop-rspec
150
156
 
data/README.md CHANGED
@@ -2,52 +2,72 @@
2
2
 
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/7fe3ef34e09ba8133424/maintainability)](https://codeclimate.com/github/Dahie/caramelize/maintainability)
4
4
 
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.
5
+ Caramelize is a compact and flexible wiki migration tool. It is intended for easy transfer of content from legacy wikis. With caramelize you can create your own export configurations and migrate your page revisions into a git repository of markdown files. This retains all your history and you gain the most flexible access to your wiki content available for use with git-based wikis like [gollum](https://github.com/github/gollum), [Otter Wiki](https://github.com/redimp/otterwiki), [Wiki.js](https://js.wiki/) or [Obsidian](https://obsidian.md/).
6
+
7
+ By default, it ships with configurations for [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/).
6
8
 
7
- In the future more target wikis may be added. For the moment migration is supported for [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/)-Wiki.
8
9
 
9
10
  ## Usage
10
11
 
11
12
  ### Installation
12
13
 
13
- $ gem install caramelize
14
+ ```sh
15
+ $ gem install caramelize
16
+ ```
14
17
 
15
18
  Install the latest release of caramelize using RubyGems.
19
+ Requires pandoc to be installed.
16
20
 
17
21
  ### Use
18
22
 
19
- $ caramelize create
23
+ ```sh
24
+ $ caramelize create
25
+ ```
20
26
 
21
27
  Creates a template configuration file "caramel.rb". This includes documentation on how to use the preset Wiki-connectors and how to write addition customized connectors. More about this below.
22
28
 
23
- $ caramelize run
29
+ ```sh
30
+ $ caramelize run
31
+ ```
24
32
 
25
33
  Will start the wiki migration based on the configuration file. These are either found in predefined paths (./caramel.rb, ./config.rb, …), or passed as argument, as below.
26
34
 
27
- $ caramelize doctor
35
+ ```sh
36
+ $ caramelize doctor
37
+ ```
28
38
 
29
39
  Can be used to assess the quality of your wiki conversion. It'll help you see
30
40
  how many wiki links may be broken and how many pages were orphaned.
31
41
 
32
- $ caramelize help
42
+ ```sh
43
+ $ caramelize help
44
+ ```
33
45
 
34
46
  Returns help information.
35
47
 
36
- $ caramelize version
48
+ ```sh
49
+ $ caramelize version
50
+ ```
37
51
 
38
52
  Returns version and release information.
39
53
 
40
54
  ### Options
41
55
 
42
- $ caramelize create --config my_caramel_configuration.rb
56
+ ```sh
57
+ $ caramelize create --config my_caramel_configuration.rb
58
+ ```
43
59
 
44
60
  Creates an example configuration by the given name.
45
61
 
46
- $ caramelize run --config my_caramel_configuration.rb
62
+ ```sh
63
+ $ caramelize run --config my_caramel_configuration.rb
64
+ ```
47
65
 
48
66
  Executes the given configuration.
49
67
 
50
- $ caramelize --verbose [command]
68
+ ```sh
69
+ $ caramelize --verbose [command]
70
+ ```
51
71
 
52
72
  Displays more verbose output to the command line.
53
73
 
@@ -55,10 +75,11 @@ Displays more verbose output to the command line.
55
75
 
56
76
  ### Wiki support
57
77
 
58
- Caramelize comes with direct support for [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/)-Wiki.
78
+ Caramelize comes with direct support for [MediaWiki](https://www.mediawiki.org), [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/)-Wiki.
59
79
  More custom wikis can be supported by creating a suitable configuration file.
60
80
 
61
- Any imported wiki exports into a [gollum](https://github.com/github/gollum) git-repository. This is a wiki based around a git-repository. This gives you the flexibility of having all wiki pages exported as physical files, while keeping the history and having an easy and wide-supported way of access by using the wiki server gollum features.
81
+ The wiki is exported to markdown files in a git-repository. This can be directly used as source for [gollum](https://github.com/github/gollum) wiki, [Otter Wiki](https://github.com/redimp/otterwiki), or if you don't care about the history even [Obsidian](https://obsidian.md/).
82
+ This gives you the flexibility of having all wiki pages exported as physical files, while keeping the history and having an easy and wide-supported way of access.
62
83
 
63
84
  Since wiki software may have special features, that are not common among other wikis, content migration may always have a loss of style or information. Caramelize tries to support the most common features.
64
85
 
@@ -75,50 +96,54 @@ Since wiki software may have special features, that are not common among other w
75
96
 
76
97
  ### Configuration recipes
77
98
 
78
- The `caramel.rb` configuration contains the settings on how to import the data of the existing wiki and how to convert it into the format required by caramelize to export to gollum.
99
+ The `lib/caramelize/caramel.rb` configuration contains the settings on how to import the data of the existing wiki and how to convert it into the format required by caramelize to export to gollum.
79
100
  You also find the predefined definitions for importing from WikkaWiki and Redmine and and example for a custom import.
80
101
 
81
102
  Custom import allows you to import data from wikis that are not natively supported by caramelize. Defining your own wiki import requires a bit of knowledge on Ruby and MySQL as you setup the access to your wiki database and need to define how the data is to be transformed. Depending on the database model of the wiki this can be one simple call for all revisions in the database, or it can get more complicated with multiple mysql-calls as the database becomes more complex.
82
103
 
83
104
  For a custom wiki you need to create a `wiki` instance object, that receives the necessary database creditials.
84
105
 
85
- wiki = Caramelize::InputWiki::Wiki.new(host: "localhost",
86
- username: "user",
87
- database: "database_name",
88
- password: 'monkey',
89
- markup: :wikka})
106
+ ```ruby
107
+ wiki = Caramelize::InputWiki::Wiki.new(host: "localhost",
108
+ username: "user",
109
+ database: "database_name",
110
+ password: 'monkey',
111
+ markup: :wikka})
112
+ ```
90
113
 
91
114
  This example ignores custom markup conversion and assumes WikkaWiki-markup.
92
115
 
93
116
  Once the object is established we need to hook in a method that defines how revisions are read from the database and how they are processed.
94
117
 
95
- wiki.instance_eval do
96
- def read_pages
97
- sql = "SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;"
98
- revisions, titles = [], []
99
- results = database.query(sql)
100
- results.each do |row|
101
- titles << row["tag"]
102
- author = authors[row["user"]]
103
- page = Page.new({id: row["id"],
104
- title: row["tag"],
105
- body: row["body"],
106
- markup: 'wikka',
107
- latest: row["latest"] == "Y",
108
- time: row["time"],
109
- message: row["note"],
110
- author: author})
111
- revisions << page
112
- end
113
- # titles is the list of all unique page titles contained in the wiki
114
- titles.uniq!
115
- # revisions is the list of all revisions ordered by date
116
- revisions
118
+ ```ruby
119
+ wiki.instance_eval do
120
+ def read_pages
121
+ sql = "SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;"
122
+ revisions, titles = [], []
123
+ results = database.query(sql)
124
+ results.each do |row|
125
+ titles << row["tag"]
126
+ author = authors[row["user"]]
127
+ page = Page.new({id: row["id"],
128
+ title: row["tag"],
129
+ body: row["body"],
130
+ markup: 'wikka',
131
+ latest: row["latest"] == "Y",
132
+ time: row["time"],
133
+ message: row["note"],
134
+ author: author})
135
+ revisions << page
117
136
  end
137
+ # titles is the list of all unique page titles contained in the wiki
138
+ titles.uniq!
139
+ # revisions is the list of all revisions ordered by date
140
+ revisions
141
+ end
142
+ ```
118
143
 
119
144
  In the end the `wiki` instance needs the `titles` and `revisions` filled.
120
145
 
121
- Some wikis don't have all necessary metadata saved in the revision. In this case additional database queries are necessary. **The configuration recipe is pure ruby code, that is included on execution. This gives you alot of freedom in writing your configuration, but also a lot of power to break things for yourself. Be advised.**
146
+ Some wikis don't have all necessary metadata saved in the revision. In this case additional database queries are necessary. **The configuration recipe is pure ruby code, that is included on execution. This gives you a lot of freedom in writing your configuration, but also a lot of power to break things. Be advised.**
122
147
 
123
148
  I'm happy to give support on your recipes and I'd also like to extend caramelize with more wiki modules, if you send in your configurations (minus database credentials of course).
124
149
 
@@ -126,33 +151,46 @@ I'm happy to give support on your recipes and I'd also like to extend caramelize
126
151
 
127
152
  This is how you can build caramelize, in case you'd like to develop it further. To get startered you'll need Bundler.
128
153
 
129
- $ gem install bundler
154
+ ```sh
155
+ $ gem install bundler
156
+ ```
130
157
 
131
158
  Clone or fork this repository and start building.
132
159
 
133
- $ git clone git@github.com:Dahie/caramelize.git
134
- $ gem build caramelize.gemspec
160
+ ```sh
161
+ $ git clone git@github.com:Dahie/caramelize.git
162
+ $ gem build caramelize.gemspec
163
+ ```
135
164
 
136
165
  Now to build and package the gem do
137
166
 
138
- $ rake build
167
+ ```sh
168
+ $ rake build
169
+ ```
139
170
 
140
171
  or
141
172
 
142
- $ rake install
173
+ ```sh
174
+ $ rake install
175
+ ```
143
176
 
144
177
  to install the new gem right to your system.
145
178
 
179
+ Tests run with
180
+
181
+ ```sh
182
+ $ rspec
183
+ ```
184
+
146
185
  ## Contributing to caramelize
147
186
 
148
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
187
+ * Check out the latest main to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
149
188
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
150
189
  * Fork the project
151
190
  * Start a feature/bugfix branch
152
191
  * Commit and push until you are happy with your contribution
153
192
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
154
193
 
155
-
156
194
  ## Copyright
157
195
 
158
- Copyright (c) 2011-2015 Daniel Senff. See LICENSE.md for further details.
196
+ Copyright (c) 2011-2024 Daniel Senff. See LICENSE.md for further details.
data/caramelize.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency('commander')
23
23
  spec.add_dependency('gollum-lib')
24
24
  spec.add_dependency('mysql2')
25
+ spec.add_dependency('paru')
25
26
  spec.add_dependency('ruby-progressbar')
26
27
 
27
28
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caramelize/input_wiki/wikkawiki'
3
+ require 'caramelize/input_wiki/media_wiki'
4
4
  require 'caramelize/input_wiki/redmine_wiki'
5
+ require 'caramelize/input_wiki/wikka_wiki'
5
6
 
6
7
  ## Example caramelize configuration file
7
8
 
@@ -9,8 +10,7 @@ require 'caramelize/input_wiki/redmine_wiki'
9
10
  # not supported by default in this software
10
11
 
11
12
  # Note, if you want to activate this, you need to uncomment the line below.
12
- # rubocop:todo Metrics/MethodLength
13
- def customized_wiki # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
13
+ def customized_wiki
14
14
  # This example is a reimplementation of the WikkaWiki-Connector.
15
15
  # To connect to WikkaWiki, I suggest to use the predefined Connector below.
16
16
  options = { host: 'localhost',
@@ -20,8 +20,7 @@ def customized_wiki # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
20
20
  markup: :wikka }
21
21
  wiki = Caramelize::InputWiki::Wiki.new(options)
22
22
  wiki.instance_eval do
23
- # rubocop:todo Metrics/MethodLength
24
- def read_pages # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
23
+ def read_pages
25
24
  sql = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'
26
25
  results = database.query(sql)
27
26
  results.each do |row|
@@ -41,12 +40,10 @@ def customized_wiki # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
41
40
  titles.uniq!
42
41
  revisions
43
42
  end
44
- # rubocop:enable Metrics/MethodLength
45
43
  end
46
44
 
47
45
  wiki
48
46
  end
49
- # rubocop:enable Metrics/MethodLength
50
47
 
51
48
  # if you want to use one of the preset Wiki-Connectors uncomment the connector
52
49
  # and edit the database logins accordingly.
@@ -57,6 +54,14 @@ def predefined_wiki
57
54
  # password: "root",
58
55
  # database: "wikka" }
59
56
  # return Caramelize::InputWiki::WikkaWiki.new(options)
57
+ #
58
+ # For connection to a MediaWiki-Database use this Connector
59
+ # By default it converts to markdown
60
+ # options = { host: "localhost",
61
+ # username: "root",
62
+ # password: "root",
63
+ # database: "my_wiki" }
64
+ # return Caramelize::InputWiki::MediaWiki.new(options)
60
65
 
61
66
  # For connection to a Redmine-Database use this Connector
62
67
  # Additional options:
@@ -5,12 +5,12 @@ require 'ruby-progressbar'
5
5
  module Caramelize
6
6
  require 'caramelize/page'
7
7
  require 'caramelize/content_transferer'
8
- require 'caramelize/database_connector'
9
8
  require 'caramelize/output_wiki/gollum'
9
+ require 'caramelize/input_wiki/media_wiki'
10
10
  require 'caramelize/input_wiki/redmine_wiki'
11
- require 'caramelize/input_wiki/wikkawiki'
11
+ require 'caramelize/input_wiki/wikka_wiki'
12
12
 
13
- class ContentTransferer # rubocop:todo Metrics/ClassLength
13
+ class ContentTransferer
14
14
  attr_reader :input_wiki, :options
15
15
 
16
16
  DEFAULT_GOLLUM_HOME_TITLE = 'Home'
@@ -94,59 +94,65 @@ module Caramelize
94
94
  total: revisions_count)
95
95
  end
96
96
 
97
- # rubocop:todo Metrics/MethodLength
98
- def migrate_markup_of_latest_revisions # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
97
+ def migrate_markup_of_latest_revisions
99
98
  puts 'Convert latest revisions:' if verbose?
100
99
  input_wiki.latest_revisions.each do |revision|
101
- if input_wiki.excluded_pages.include?(revision.title)
102
- puts "Exclude Page: #{revision.title}" if verbose?
103
- next
104
- end
105
-
106
- if verbose?
107
- puts "Filter source: #{revision.title} #{revision.time}"
108
- else
109
- migrate_markup_progress_bar.increment
110
- end
111
-
112
- migrate_markup_of_revision(revision)
100
+ convert_markup_of_revision(revision)
113
101
  end
114
102
  end
115
- # rubocop:enable Metrics/MethodLength
116
103
 
117
- # rubocop:todo Metrics/MethodLength
118
- def commit_history # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
104
+ def commit_history
119
105
  output_wiki.commit_history(revisions, options) do |page, index|
120
- if input_wiki.excluded_pages.include?(page.title)
121
- puts "Exclude Page: #{page.title}" if verbose?
122
- next
123
- end
124
-
125
- if verbose?
126
- puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
127
- else
128
- commit_history_progress_bar.increment
129
- end
106
+ commit_page(page, index)
130
107
  end
131
108
  end
132
- # rubocop:enable Metrics/MethodLength
133
109
 
134
- def migrate_markup_of_revision(revision)
110
+ def commit_page(page, index)
111
+ if input_wiki.excluded_pages.include?(page.title)
112
+ puts "Exclude Page: #{page.title}" if verbose?
113
+ return
114
+ end
115
+
116
+ if verbose?
117
+ puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
118
+ else
119
+ commit_history_progress_bar.increment
120
+ end
121
+ end
122
+
123
+ def run_filter_processor_on_revision(revision)
135
124
  body_new = filter_processor.run(revision.body)
136
125
 
137
126
  return if body_new == revision.body
138
127
 
139
- message = "Markup of '#{revision.title}' converted to #{target_markup}"
128
+ revision.message = "Markup of '#{revision.title}' converted to #{target_markup}"
129
+
130
+ commit_as_latest_page(revision)
131
+ end
132
+
133
+ def convert_markup_of_revision(revision)
134
+ if input_wiki.excluded_pages.include?(revision.title)
135
+ puts "Exclude Page: #{revision.title}" if verbose?
136
+ return
137
+ end
138
+
139
+ if verbose?
140
+ puts "Filter source: #{revision.title} #{revision.time}"
141
+ else
142
+ migrate_markup_progress_bar.increment
143
+ end
144
+
145
+ run_filter_processor_on_revision(revision)
146
+ end
140
147
 
141
- # commit as latest page revision
142
- output_wiki.commit_revision(build_revision_metadata(revision, body_new, message), options[:markup])
148
+ def commit_as_latest_page(revision)
149
+ output_wiki.commit_revision(build_revision_metadata(revision, body_new), options[:markup])
143
150
  end
144
151
 
145
- def build_revision_metadata(revision, body_new, message)
152
+ def build_revision_metadata(revision, body_new)
146
153
  revision.body = body_new
147
154
  revision.author = { name: DEFAULT_AUTHOR_NAME, email: DEFAULT_AUTHOR_EMAIL }
148
- revision.time = Time.now
149
- revision.message = message
155
+ revision.time = Time.zone.now
150
156
 
151
157
  revision
152
158
  end
@@ -1,22 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Caramelize
4
- module Filter
5
- class AddNewlineToPageEnd
6
- def initialize(body)
7
- @body = body
8
- end
4
+ class AddNewlineToPageEnd
5
+ def initialize(body)
6
+ @body = body
7
+ end
9
8
 
10
- # take an input stream and convert all wikka syntax to markdown syntax
11
- def run
12
- return @body if @body[@body.length - 1] == "\n"
9
+ # take an input stream and convert all wikka syntax to markdown syntax
10
+ def run
11
+ return @body if @body[@body.length - 1] == "\n"
13
12
 
14
- migrated_body = @body.dup
13
+ migrated_body = @body.dup
15
14
 
16
- migrated_body << "\n"
15
+ migrated_body << "\n"
17
16
 
18
- migrated_body
19
- end
17
+ migrated_body
20
18
  end
21
19
  end
22
20
  end
@@ -18,8 +18,8 @@ module Caramelize
18
18
  private
19
19
 
20
20
  def format_link(link)
21
- link.gsub!(' ', '_')
22
- link.gsub!('.', '')
21
+ link.tr!(' ', '_')
22
+ link.delete!('.')
23
23
  "[[#{link}]]"
24
24
  end
25
25
  end