caramelize 1.2.0 → 1.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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +11 -0
  3. data/.github/workflows/main.yml +48 -0
  4. data/.rubocop.yml +3 -1
  5. data/.rubocop_todo.yml +55 -0
  6. data/Gemfile +11 -0
  7. data/Gemfile.lock +28 -22
  8. data/README.md +88 -50
  9. data/caramelize.gemspec +1 -9
  10. data/lib/caramelize/caramel.rb +10 -1
  11. data/lib/caramelize/content_transferer.rb +41 -31
  12. data/lib/caramelize/filters/add_newline_to_page_end.rb +20 -0
  13. data/lib/caramelize/filters/camel_case_to_wiki_links.rb +2 -2
  14. data/lib/caramelize/filters/mediawiki_to_markdown.rb +21 -0
  15. data/lib/caramelize/filters/swap_wiki_links.rb +2 -2
  16. data/lib/caramelize/filters/wikka_to_markdown.rb +15 -6
  17. data/lib/caramelize/health_checks/home_page_check.rb +1 -1
  18. data/lib/caramelize/input_wiki/media_wiki.rb +114 -0
  19. data/lib/caramelize/input_wiki/redmine_wiki.rb +6 -8
  20. data/lib/caramelize/input_wiki/wiki.rb +5 -5
  21. data/lib/caramelize/input_wiki/{wikkawiki.rb → wikka_wiki.rb} +6 -10
  22. data/lib/caramelize/output_wiki/gollum.rb +1 -1
  23. data/lib/caramelize/page.rb +1 -1
  24. data/lib/caramelize/version.rb +1 -1
  25. data/lib/caramelize.rb +7 -5
  26. data/samples/media_wiki.rb +14 -0
  27. data/spec/lib/caramelize/filter_processor_spec.rb +5 -3
  28. data/spec/lib/caramelize/filters/{add_newline_on_page_end_spec.rb → add_newline_to_page_end_spec.rb} +1 -1
  29. data/spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb +3 -1
  30. data/spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb +27 -0
  31. data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +5 -3
  32. data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +3 -1
  33. data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +41 -31
  34. data/spec/lib/caramelize/input_wiki/media_wiki_spec.rb +13 -0
  35. data/spec/lib/caramelize/input_wiki/wiki_spec.rb +13 -13
  36. data/spec/lib/caramelize/input_wiki/wikka_wiki_spec.rb +13 -0
  37. data/spec/lib/caramelize/output_wiki/gollum_spec.rb +9 -7
  38. metadata +17 -119
@@ -2,13 +2,15 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Caramelize::Wikka2Markdown do
5
+ # rubocop:todo RSpec/SpecFilePathFormat
6
+ describe Caramelize::WikkaToMarkdown do # rubocop:todo RSpec/FilePath, RSpec/SpecFilePathFormat
7
+ # rubocop:enable RSpec/SpecFilePathFormat
6
8
  let(:filter) { described_class.new(body) }
7
9
 
8
10
  describe '#run' do
9
11
  subject { filter.run }
10
12
 
11
- xcontext 'when keep line breaks' do
13
+ xcontext 'when keep line breaks' do # rubocop:todo RSpec/PendingWithoutReason
12
14
  let(:body) { "line1\nline2" }
13
15
 
14
16
  it { is_expected.to eq "line1 \nline2" }
@@ -69,37 +71,19 @@ describe Caramelize::Wikka2Markdown do
69
71
  end
70
72
 
71
73
  context 'when unordered list entry' do
72
- context 'with tab based' do
74
+ context 'with tabs' do
73
75
  let(:body) { "\t-unordered list entry" }
74
76
 
75
77
  it { is_expected.to eq '- unordered list entry' }
76
78
  end
77
79
 
78
- context 'with tabs' do
80
+ context 'with tilde' do
79
81
  let(:body) { '~-unordered list entry' }
80
82
 
81
83
  it { is_expected.to eq '- unordered list entry' }
82
84
  end
83
85
 
84
86
  context 'with spaces' do
85
- let(:body) { ' -unordered list entry' }
86
-
87
- it { is_expected.to eq '- unordered list entry' }
88
- end
89
-
90
- context 'with tab based with space' do
91
- let(:body) { "\t- unordered list entry" }
92
-
93
- it { is_expected.to eq '- unordered list entry' }
94
- end
95
-
96
- context 'with another tab based with space' do
97
- let(:body) { '~- unordered list entry' }
98
-
99
- it { is_expected.to eq '- unordered list entry' }
100
- end
101
-
102
- context 'with space based with space' do
103
87
  let(:body) { ' - unordered list entry' }
104
88
 
105
89
  it { is_expected.to eq '- unordered list entry' }
@@ -127,7 +111,7 @@ describe Caramelize::Wikka2Markdown do
127
111
  it { is_expected.to eq '[[LemmaLemma]]' }
128
112
  end
129
113
 
130
- context 'with only url sklfs' do
114
+ context 'with only wikilink' do
131
115
  let(:body) { "\n [[ComunitySiteIdeas]] \n" }
132
116
 
133
117
  it { is_expected.to eq "\n [[ComunitySiteIdeas]] \n" }
@@ -180,7 +164,7 @@ describe Caramelize::Wikka2Markdown do
180
164
 
181
165
  context 'when code block' do
182
166
  let(:body) do
183
- <<~EOS
167
+ <<~CPP
184
168
  Text before
185
169
 
186
170
  %%
@@ -195,10 +179,10 @@ describe Caramelize::Wikka2Markdown do
195
179
  ++stat[input];
196
180
  %%
197
181
 
198
- EOS
182
+ CPP
199
183
  end
200
184
  let(:expected_result) do
201
- <<~EOS
185
+ <<~CPP
202
186
  Text before
203
187
 
204
188
  ```
@@ -213,7 +197,7 @@ describe Caramelize::Wikka2Markdown do
213
197
  ++stat[input];
214
198
  ```
215
199
 
216
- EOS
200
+ CPP
217
201
  end
218
202
 
219
203
  it { is_expected.to eq expected_result }
@@ -221,7 +205,7 @@ describe Caramelize::Wikka2Markdown do
221
205
 
222
206
  context 'when code block with language' do
223
207
  let(:body) do
224
- <<~EOS
208
+ <<~CPP
225
209
  Text before
226
210
 
227
211
  %%(php)
@@ -236,10 +220,10 @@ describe Caramelize::Wikka2Markdown do
236
220
  ++stat[input];
237
221
  %%
238
222
 
239
- EOS
223
+ CPP
240
224
  end
241
225
  let(:expected_result) do
242
- <<~EOS
226
+ <<~CPP
243
227
  Text before
244
228
 
245
229
  ```php
@@ -254,10 +238,36 @@ describe Caramelize::Wikka2Markdown do
254
238
  ++stat[input];
255
239
  ```
256
240
 
257
- EOS
241
+ CPP
258
242
  end
259
243
 
260
244
  it { is_expected.to eq expected_result }
261
245
  end
246
+
247
+ context 'when image' do
248
+ context 'with link' do
249
+ let(:body) { '{{image class="center" alt="DVD logo" title="An image link" url="images/dvdvideo.gif" link="RecentChanges"}}' }
250
+
251
+ it { is_expected.to eq '[[<img src="images/dvdvideo.gif" alt="DVD logo">|RecentChanges]]' }
252
+ end
253
+
254
+ context 'with alt and with title' do
255
+ let(:body) { '{{image class="center" alt="DVD logo" title="An image link" url="images/dvdvideo.gif"}}' }
256
+
257
+ it { is_expected.to eq '![DVD logo](images/dvdvideo.gif)' }
258
+ end
259
+
260
+ context 'without alt and with title' do
261
+ let(:body) { '{{image class="center" title="An image link" url="images/dvdvideo.gif"}}' }
262
+
263
+ it { is_expected.to eq '![](images/dvdvideo.gif)' }
264
+ end
265
+
266
+ context 'without alt and without title' do
267
+ let(:body) { '{{image class="center" url="images/dvdvideo.gif"}}' }
268
+
269
+ it { is_expected.to eq '![](images/dvdvideo.gif)' }
270
+ end
271
+ end
262
272
  end
263
273
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Caramelize::InputWiki::MediaWiki do
6
+ subject(:wiki) { described_class.new }
7
+
8
+ describe '#filters' do
9
+ it 'has 2 filters' do
10
+ expect(wiki.filters.count).to be(2)
11
+ end
12
+ end
13
+ end
@@ -6,9 +6,9 @@ describe Caramelize::InputWiki::Wiki do
6
6
  subject(:wiki) { described_class.new }
7
7
 
8
8
  describe '#latest_revisions' do
9
- let(:page1) { double }
10
- let(:page2) { double }
11
- let(:page3) { double }
9
+ let(:page1) { double } # rubocop:todo RSpec/IndexedLet
10
+ let(:page2) { double } # rubocop:todo RSpec/IndexedLet
11
+ let(:page3) { double } # rubocop:todo RSpec/IndexedLet
12
12
 
13
13
  context 'without pages' do
14
14
  it 'return empty array' do
@@ -17,11 +17,11 @@ describe Caramelize::InputWiki::Wiki do
17
17
  end
18
18
 
19
19
  context 'with pages with revisions' do
20
- it 'returns list of latest pages' do
20
+ it 'returns list of latest pages' do # rubocop:todo RSpec/ExampleLength
21
21
  wiki.titles = %w[allosaurus brachiosaurus]
22
- allow(wiki).to receive(:revisions_by_title)
22
+ allow(wiki).to receive(:revisions_by_title) # rubocop:todo RSpec/SubjectStub
23
23
  .with('allosaurus').and_return([page1, page2])
24
- allow(wiki).to receive(:revisions_by_title)
24
+ allow(wiki).to receive(:revisions_by_title) # rubocop:todo RSpec/SubjectStub
25
25
  .with('brachiosaurus').and_return([page3])
26
26
 
27
27
  expect(wiki.latest_revisions).to eq([page2, page3])
@@ -33,7 +33,7 @@ describe Caramelize::InputWiki::Wiki do
33
33
  context 'with revisions is empty' do
34
34
  context 'with titles is empty' do
35
35
  it 'returns empty array' do
36
- allow(wiki).to receive(:titles).and_return []
36
+ allow(wiki).to receive(:titles).and_return [] # rubocop:todo RSpec/SubjectStub
37
37
  expect(wiki.revisions_by_title('title')).to eq []
38
38
  end
39
39
  end
@@ -41,15 +41,15 @@ describe Caramelize::InputWiki::Wiki do
41
41
 
42
42
  context 'with revisions are given' do
43
43
  context 'with title given' do
44
- it 'returns empty array' do
44
+ it 'returns empty array' do # rubocop:todo RSpec/ExampleLength
45
45
  pages = []
46
- home1 = double(title: 'Home', time: Time.parse('2015-01-23'))
46
+ home1 = double(title: 'Home', time: Time.parse('2015-01-23')) # rubocop:todo RSpec/VerifiedDoubles
47
47
  pages << home1
48
- pages << double(title: 'Example', time: Time.parse('2015-01-20'))
49
- pages << double(title: 'Authors', time: Time.parse('2015-01-30'))
50
- home2 = double(title: 'Home', time: Time.parse('2014-01-23'))
48
+ pages << double(title: 'Example', time: Time.parse('2015-01-20')) # rubocop:todo RSpec/VerifiedDoubles
49
+ pages << double(title: 'Authors', time: Time.parse('2015-01-30')) # rubocop:todo RSpec/VerifiedDoubles
50
+ home2 = double(title: 'Home', time: Time.parse('2014-01-23')) # rubocop:todo RSpec/VerifiedDoubles
51
51
  pages << home2
52
- allow(wiki).to receive(:revisions).and_return pages
52
+ allow(wiki).to receive(:revisions).and_return pages # rubocop:todo RSpec/SubjectStub
53
53
  expect(wiki.revisions_by_title('Home')).to eq [home2, home1]
54
54
  end
55
55
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Caramelize::InputWiki::WikkaWiki do
6
+ subject(:wiki) { described_class.new }
7
+
8
+ describe '#filters' do
9
+ it 'has 3 filters' do
10
+ expect(wiki.filters.count).to be(3)
11
+ end
12
+ end
13
+ end
@@ -10,7 +10,7 @@ describe Caramelize::OutputWiki::Gollum do
10
10
  end
11
11
 
12
12
  describe '#commit_revision' do
13
- subject(:gollum) { double(:gollum) }
13
+ subject(:gollum) { double(:gollum) } # rubocop:todo RSpec/VerifiedDoubles
14
14
 
15
15
  let(:title) { 'title' }
16
16
  let(:author) { { name: 'Steven Universe', email: 'steven@example.com' } }
@@ -22,7 +22,7 @@ describe Caramelize::OutputWiki::Gollum do
22
22
  title:,
23
23
  path: title)
24
24
  end
25
- let(:gollum_page) { double(:gollum_page, name: 'title', format: :markdown) }
25
+ let(:gollum_page) { double(:gollum_page, name: 'title', format: :markdown) } # rubocop:todo RSpec/VerifiedDoubles
26
26
 
27
27
  before do
28
28
  allow(Gollum::Wiki).to receive(:new).and_return(gollum)
@@ -30,24 +30,26 @@ describe Caramelize::OutputWiki::Gollum do
30
30
 
31
31
  context 'when page exists' do
32
32
  before do
33
- allow(gollum).to receive(:page).with(title).and_return(gollum_page)
33
+ allow(gollum).to receive(:page).with(title).and_return(gollum_page) # rubocop:todo RSpec/SubjectStub
34
34
  end
35
35
 
36
36
  it 'updates page' do
37
- expect(gollum).to receive(:update_page).once.and_return(true)
37
+ # rubocop:todo RSpec/SubjectStub
38
+ expect(gollum).to receive(:update_page).once.and_return(true) # rubocop:todo RSpec/MessageSpies, RSpec/SubjectStub
39
+ # rubocop:enable RSpec/SubjectStub
38
40
  gollum_output.commit_revision(input_page, :markdown)
39
41
  end
40
42
  end
41
43
 
42
44
  context 'when page does not exist yet' do
43
45
  before do
44
- allow(gollum).to receive(:page).with(title).and_return(nil)
46
+ allow(gollum).to receive(:page).with(title).and_return(nil) # rubocop:todo RSpec/SubjectStub
45
47
  end
46
48
 
47
49
  it 'creates page' do
48
- allow(gollum).to receive(:write_page)
50
+ allow(gollum).to receive(:write_page) # rubocop:todo RSpec/SubjectStub
49
51
  gollum_output.commit_revision(input_page, :markdown)
50
- expect(gollum).to have_received(:write_page).once
52
+ expect(gollum).to have_received(:write_page).once # rubocop:todo RSpec/SubjectStub
51
53
  end
52
54
  end
53
55
  end
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: 1.2.0
4
+ version: 1.3.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: 2024-02-03 00:00:00.000000000 Z
11
+ date: 2024-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: ruby-progressbar
56
+ name: paru
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,125 +67,13 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: bundler
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2'
83
- - !ruby/object:Gem::Dependency
84
- name: byebug
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: guard
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: guard-rspec
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rake
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: rubocop
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: rubocop-rake
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: rubocop-rspec
70
+ name: ruby-progressbar
183
71
  requirement: !ruby/object:Gem::Requirement
184
72
  requirements:
185
73
  - - ">="
186
74
  - !ruby/object:Gem::Version
187
75
  version: '0'
188
- type: :development
76
+ type: :runtime
189
77
  prerelease: false
190
78
  version_requirements: !ruby/object:Gem::Requirement
191
79
  requirements:
@@ -200,8 +88,11 @@ executables:
200
88
  extensions: []
201
89
  extra_rdoc_files: []
202
90
  files:
91
+ - ".github/dependabot.yml"
92
+ - ".github/workflows/main.yml"
203
93
  - ".gitignore"
204
94
  - ".rubocop.yml"
95
+ - ".rubocop_todo.yml"
205
96
  - CODE_OF_CONDUCT.md
206
97
  - Gemfile
207
98
  - Gemfile.lock
@@ -215,7 +106,9 @@ files:
215
106
  - lib/caramelize/content_transferer.rb
216
107
  - lib/caramelize/database_connector.rb
217
108
  - lib/caramelize/filter_processor.rb
109
+ - lib/caramelize/filters/add_newline_to_page_end.rb
218
110
  - lib/caramelize/filters/camel_case_to_wiki_links.rb
111
+ - lib/caramelize/filters/mediawiki_to_markdown.rb
219
112
  - lib/caramelize/filters/remove_table_tab_line_endings.rb
220
113
  - lib/caramelize/filters/swap_wiki_links.rb
221
114
  - lib/caramelize/filters/wikka_to_markdown.rb
@@ -223,25 +116,30 @@ files:
223
116
  - lib/caramelize/health_checks/home_page_check.rb
224
117
  - lib/caramelize/health_checks/orphaned_pages_check.rb
225
118
  - lib/caramelize/health_checks/page.rb
119
+ - lib/caramelize/input_wiki/media_wiki.rb
226
120
  - lib/caramelize/input_wiki/redmine_wiki.rb
227
121
  - lib/caramelize/input_wiki/wiki.rb
228
- - lib/caramelize/input_wiki/wikkawiki.rb
122
+ - lib/caramelize/input_wiki/wikka_wiki.rb
229
123
  - lib/caramelize/output_wiki/gollum.rb
230
124
  - lib/caramelize/page.rb
231
125
  - lib/caramelize/services/page_builder.rb
232
126
  - lib/caramelize/version.rb
127
+ - samples/media_wiki.rb
233
128
  - spec/fixtures/markup/swap-links-input.textile
234
129
  - spec/fixtures/markup/swap-links-output.textile
235
130
  - spec/fixtures/markup/table-tab-line-endings-input.textile
236
131
  - spec/fixtures/markup/table-tab-line-endings-output.textile
237
132
  - spec/lib/caramelize/content_transferer_spec.rb
238
133
  - spec/lib/caramelize/filter_processor_spec.rb
239
- - spec/lib/caramelize/filters/add_newline_on_page_end_spec.rb
134
+ - spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb
240
135
  - spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb
136
+ - spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb
241
137
  - spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb
242
138
  - spec/lib/caramelize/filters/swap_wiki_links_spec.rb
243
139
  - spec/lib/caramelize/filters/wikka_to_markdown_spec.rb
140
+ - spec/lib/caramelize/input_wiki/media_wiki_spec.rb
244
141
  - spec/lib/caramelize/input_wiki/wiki_spec.rb
142
+ - spec/lib/caramelize/input_wiki/wikka_wiki_spec.rb
245
143
  - spec/lib/caramelize/output_wiki/gollum_spec.rb
246
144
  - spec/lib/caramelize/page_spec.rb
247
145
  - spec/lib/caramelize/services/page_builder_spec.rb