caramelize 1.1.1 → 1.2.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +29 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +25 -13
  5. data/README.md +2 -3
  6. data/Rakefile +3 -1
  7. data/bin/caramelize +6 -5
  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 +48 -27
  42. data/.travis.yml +0 -5
  43. data/spec/lib/caramelize/services/page_builder.rb +0 -29
@@ -1,70 +1,70 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Caramelize::OutputWiki::Gollum do
4
6
  let(:gollum_output) { described_class.new('wiki.git') }
7
+
5
8
  before do
6
9
  allow(gollum_output).to receive(:initialize_repository).and_return true
7
10
  end
8
11
 
9
12
  describe '#commit_revision' do
13
+ subject(:gollum) { double(:gollum) }
14
+
10
15
  let(:title) { 'title' }
11
- let(:author) { double(name: 'Steven Universe', email: 'steven@example.com') }
16
+ let(:author) { { name: 'Steven Universe', email: 'steven@example.com' } }
12
17
  let(:input_page) do
13
- double(author: author,
14
- body: 'body',
15
- commit_message: 'done',
16
- time: Time.now,
17
- title: title,
18
- path: title)
19
- end
20
- let(:gollum_page) do
21
- double(:gollum_page,
22
- name: 'title',
23
- format: :markdown)
18
+ Caramelize::Page.new(author:,
19
+ body: 'body',
20
+ commit_message: 'done',
21
+ time: Time.now,
22
+ title:,
23
+ path: title)
24
24
  end
25
- let(:markup) { :markdown }
26
- let(:gollum) { double(:gollum) }
25
+ let(:gollum_page) { double(:gollum_page, name: 'title', format: :markdown) }
27
26
 
28
27
  before do
29
28
  allow(Gollum::Wiki).to receive(:new).and_return(gollum)
30
29
  end
31
30
 
32
- context 'page exists' do
31
+ context 'when page exists' do
33
32
  before do
34
33
  allow(gollum).to receive(:page).with(title).and_return(gollum_page)
35
34
  end
36
35
 
37
36
  it 'updates page' do
38
37
  expect(gollum).to receive(:update_page).once.and_return(true)
39
- gollum_output.commit_revision(input_page, markup)
38
+ gollum_output.commit_revision(input_page, :markdown)
40
39
  end
41
40
  end
42
41
 
43
- context 'page does not exist yet' do
42
+ context 'when page does not exist yet' do
44
43
  before do
45
44
  allow(gollum).to receive(:page).with(title).and_return(nil)
46
45
  end
47
46
 
48
47
  it 'creates page' do
49
- expect(gollum).to receive(:write_page).once
50
- gollum_output.commit_revision(input_page, markup)
48
+ allow(gollum).to receive(:write_page)
49
+ gollum_output.commit_revision(input_page, :markdown)
50
+ expect(gollum).to have_received(:write_page).once
51
51
  end
52
52
  end
53
53
  end
54
54
 
55
55
  describe '#commit_history' do
56
- pending
56
+ pending('test full history')
57
57
  end
58
58
 
59
59
  describe '#commit_namespace_overview' do
60
60
  let(:namespaces) do
61
61
  [
62
- OpenStruct.new(identifier: 'velociraptors', name: 'Velociraptor'),
63
- OpenStruct.new(identifier: 'allosaurus', name: 'Allosaurus')
62
+ { dentifier: 'velociraptors', name: 'Velociraptor' },
63
+ { identifier: 'allosaurus', name: 'Allosaurus' }
64
64
  ]
65
65
  end
66
66
 
67
- context '2 pages in namespaces' do
67
+ context 'with 2 pages in namespaces' do
68
68
  it 'commits page' do
69
69
  allow(gollum_output).to receive(:commit_revision)
70
70
  gollum_output.commit_namespace_overview(namespaces)
@@ -75,11 +75,11 @@ describe Caramelize::OutputWiki::Gollum do
75
75
 
76
76
  describe '#build_commit' do
77
77
  let(:page) do
78
- Caramelize::Page.new( title: 'Feathered Dinosaurs',
79
- message: 'Dinosaurs really had feathers, do not forget!',
80
- time: Time.parse('2015-02-12'),
81
- body: 'Dinosaurs are awesome and have feathers!',
82
- author: OpenStruct.new(name: 'Jeff Goldblum', email: 'jeff.g@example.com') )
78
+ Caramelize::Page.new(title: 'Feathered Dinosaurs',
79
+ message: 'Dinosaurs really had feathers, do not forget!',
80
+ time: Time.parse('2015-02-12'),
81
+ body: 'Dinosaurs are awesome and have feathers!',
82
+ author: { name: 'Jeff Goldblum', email: 'jeff.g@example.com' })
83
83
  end
84
84
 
85
85
  let(:expected_hash) do
@@ -95,15 +95,15 @@ describe Caramelize::OutputWiki::Gollum do
95
95
  expect(gollum_output.build_commit(page)).to eq expected_hash
96
96
  end
97
97
 
98
- context 'page has message' do
98
+ context 'when page has message' do
99
99
  it 'uses page.title' do
100
100
  expect(gollum_output.build_commit(page)[:message])
101
101
  .to eq 'Dinosaurs really had feathers, do not forget!'
102
102
  end
103
103
  end
104
104
 
105
- context 'page has no message' do
106
- it 'should create message "Edit in page Feathered Dinosaurs"' do
105
+ context 'when page has no message' do
106
+ it 'creates message "Edit in page Feathered Dinosaurs"' do
107
107
  page.message = ''
108
108
  expect(gollum_output.build_commit(page)[:message])
109
109
  .to eq 'Edit in page Feathered Dinosaurs'
@@ -1,62 +1,70 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Caramelize::Page do
4
-
5
- let(:message) { 'Dinosaurs really had feathers, do not forget!' }
6
- let(:author) { OpenStruct.new(name: 'Jeff Goldblum', email: 'jeff.g@example.com') }
7
- let(:title){ 'Feathered Dinosaurs' }
8
6
  subject(:page) do
9
- Caramelize::Page.new(title: title,
10
- message: message,
11
- time: Time.parse('2015-02-12'),
12
- body: 'Dinosaurs are awesome and have feathers!',
13
- author: author )
7
+ described_class.new(title:,
8
+ message:,
9
+ time: Time.parse('2015-02-12'),
10
+ body: 'Dinosaurs are awesome and have feathers!',
11
+ author:)
14
12
  end
15
13
 
14
+ let(:message) { 'Dinosaurs really had feathers, do not forget!' }
15
+ let(:author) { { name: 'Jeff Goldblum', email: 'jeff.g@example.com' } }
16
+ let(:title) { 'Feathered Dinosaurs' }
16
17
 
17
18
  describe '#author' do
18
- context 'no author is set' do
19
+ context 'without author' do
19
20
  let(:author) { nil }
20
21
 
21
- it 'fills with Caramelize user' do
22
- expect(page.author.name).to eql('Caramelize')
23
- expect(page.author.email).to eql('mail@example.com')
22
+ it 'fills with Caramelize user name' do
23
+ expect(page.author.fetch(:name)).to eql('Caramelize')
24
+ end
25
+
26
+ it 'fills with dummy email' do
27
+ expect(page.author.fetch(:email)).to eql('mail@example.com')
24
28
  end
25
29
  end
26
30
 
27
- context 'author is set' do
28
- it 'fills with Caramelize user' do
29
- expect(page.author.name).to eql(author.name)
30
- expect(page.author.email).to eql(author.email)
31
+ context 'with author' do
32
+ it 'fills with author name' do
33
+ expect(page.author.fetch(:name)).to eql(author[:name])
34
+ end
35
+
36
+ it 'fills with author email' do
37
+ expect(page.author.fetch(:email)).to eql(author[:email])
31
38
  end
32
39
  end
33
40
  end
34
41
 
35
42
  describe '#path' do
36
- context "title is 'Home'" do
43
+ context "when title is 'Home'" do
37
44
  let(:title) { 'Home' }
38
- it { expect(page.path).to eq 'Home'}
45
+
46
+ it { expect(page.path).to eq 'Home' }
39
47
  end
40
48
 
41
- context "title is 'Feathered Dinosaurs'" do
42
- it { expect(page.path).to eq 'Feathered Dinosaurs'}
49
+ context "when title is 'Feathered Dinosaurs'" do
50
+ it { expect(page.path).to eq 'Feathered Dinosaurs' }
43
51
  end
44
52
 
45
- context "title is 'Space/Feathered Dinosaurs'" do
53
+ context "when title is 'Space/Feathered Dinosaurs'" do
46
54
  let(:title) { 'Space/Feathered Dinosaurs' }
47
- it { expect(page.path).to eq 'Space/feathered dinosaurs'}
55
+
56
+ it { expect(page.path).to eq 'Space/feathered dinosaurs' }
48
57
  end
49
58
  end
50
59
 
51
-
52
60
  describe '#commit_message' do
53
- context 'page has message' do
61
+ context 'with page having message' do
54
62
  it 'uses page.title' do
55
63
  expect(page.commit_message).to eq 'Dinosaurs really had feathers, do not forget!'
56
64
  end
57
65
  end
58
66
 
59
- context 'page has no message' do
67
+ context 'with page having no message' do
60
68
  let(:message) { '' }
61
69
 
62
70
  it 'creates message "Edit in page Feathered Dinosaurs"' do
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Caramelize::Services::PageBuilder do
6
+ describe '.build_namespace_overview' do
7
+ subject(:page) { described_class.build_namespace_overview(namespaces) }
8
+
9
+ let(:body) do
10
+ "## Overview of namespaces\n \n* [[Velociraptor|velociraptors/wiki]] \n* [[Allosaurus|allosaurus/wiki]]"
11
+ end
12
+ let(:expected_page) do
13
+ Caramelize::Page.new(title: 'Home',
14
+ body:,
15
+ message: 'Create Namespace Overview',
16
+ latest: true)
17
+ end
18
+ let(:namespaces) do
19
+ [
20
+ { identifier: 'velociraptors', name: 'Velociraptor' },
21
+ { identifier: 'allosaurus', name: 'Allosaurus' }
22
+ ]
23
+ end
24
+
25
+ it 'returns page with expected title' do
26
+ expect(page.title).to eql(expected_page.title)
27
+ end
28
+
29
+ it 'returns page with expected page body' do
30
+ expect(page.body).to eql(expected_page.body)
31
+ end
32
+
33
+ it 'returns page with expected page latest' do
34
+ expect(page.latest).to eql(expected_page.latest)
35
+ end
36
+
37
+ it 'returns page with expected message' do
38
+ expect(page.message).to eql(expected_page.message)
39
+ end
40
+ end
41
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pry'
2
4
  require 'caramelize'
3
5
 
4
- Dir[('./spec/support/**/*.rb')].each {|f| require f}
6
+ Dir[('./spec/support/**/*.rb')].each { |f| require f }
5
7
 
6
8
  RSpec.configure do |config|
7
- #config.include TestHelpers
9
+ # config.include TestHelpers
8
10
  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.1.1
4
+ version: 1.2.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: 2023-12-08 00:00:00.000000000 Z
11
+ date: 2024-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rake
84
+ name: byebug
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rspec
98
+ name: guard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,35 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: byebug
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
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ">="
@@ -137,7 +165,7 @@ dependencies:
137
165
  - !ruby/object:Gem::Version
138
166
  version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
- name: guard
168
+ name: rubocop-rake
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
171
  - - ">="
@@ -151,7 +179,7 @@ dependencies:
151
179
  - !ruby/object:Gem::Version
152
180
  version: '0'
153
181
  - !ruby/object:Gem::Dependency
154
- name: guard-rspec
182
+ name: rubocop-rspec
155
183
  requirement: !ruby/object:Gem::Requirement
156
184
  requirements:
157
185
  - - ">="
@@ -173,7 +201,7 @@ extensions: []
173
201
  extra_rdoc_files: []
174
202
  files:
175
203
  - ".gitignore"
176
- - ".travis.yml"
204
+ - ".rubocop.yml"
177
205
  - CODE_OF_CONDUCT.md
178
206
  - Gemfile
179
207
  - Gemfile.lock
@@ -187,10 +215,14 @@ files:
187
215
  - lib/caramelize/content_transferer.rb
188
216
  - lib/caramelize/database_connector.rb
189
217
  - lib/caramelize/filter_processor.rb
218
+ - lib/caramelize/filters/camel_case_to_wiki_links.rb
190
219
  - lib/caramelize/filters/remove_table_tab_line_endings.rb
191
220
  - lib/caramelize/filters/swap_wiki_links.rb
192
221
  - lib/caramelize/filters/wikka_to_markdown.rb
193
222
  - lib/caramelize/health_check.rb
223
+ - lib/caramelize/health_checks/home_page_check.rb
224
+ - lib/caramelize/health_checks/orphaned_pages_check.rb
225
+ - lib/caramelize/health_checks/page.rb
194
226
  - lib/caramelize/input_wiki/redmine_wiki.rb
195
227
  - lib/caramelize/input_wiki/wiki.rb
196
228
  - lib/caramelize/input_wiki/wikkawiki.rb
@@ -204,18 +236,21 @@ files:
204
236
  - spec/fixtures/markup/table-tab-line-endings-output.textile
205
237
  - spec/lib/caramelize/content_transferer_spec.rb
206
238
  - spec/lib/caramelize/filter_processor_spec.rb
239
+ - spec/lib/caramelize/filters/add_newline_on_page_end_spec.rb
240
+ - spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb
207
241
  - spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb
208
242
  - spec/lib/caramelize/filters/swap_wiki_links_spec.rb
209
243
  - spec/lib/caramelize/filters/wikka_to_markdown_spec.rb
210
244
  - spec/lib/caramelize/input_wiki/wiki_spec.rb
211
245
  - spec/lib/caramelize/output_wiki/gollum_spec.rb
212
246
  - spec/lib/caramelize/page_spec.rb
213
- - spec/lib/caramelize/services/page_builder.rb
247
+ - spec/lib/caramelize/services/page_builder_spec.rb
214
248
  - spec/spec_helper.rb
215
249
  homepage: http://github.com/Dahie/caramelize
216
250
  licenses:
217
251
  - MIT
218
- metadata: {}
252
+ metadata:
253
+ rubygems_mfa_required: 'true'
219
254
  post_install_message:
220
255
  rdoc_options: []
221
256
  require_paths:
@@ -224,29 +259,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
259
  requirements:
225
260
  - - ">="
226
261
  - !ruby/object:Gem::Version
227
- version: '0'
262
+ version: '3.1'
228
263
  required_rubygems_version: !ruby/object:Gem::Requirement
229
264
  requirements:
230
265
  - - ">="
231
266
  - !ruby/object:Gem::Version
232
267
  version: '0'
233
268
  requirements: []
234
- rubygems_version: 3.4.22
269
+ rubygems_version: 3.5.5
235
270
  signing_key:
236
271
  specification_version: 4
237
272
  summary: Flexible and modular wiki conversion tool
238
- test_files:
239
- - spec/fixtures/markup/swap-links-input.textile
240
- - spec/fixtures/markup/swap-links-output.textile
241
- - spec/fixtures/markup/table-tab-line-endings-input.textile
242
- - spec/fixtures/markup/table-tab-line-endings-output.textile
243
- - spec/lib/caramelize/content_transferer_spec.rb
244
- - spec/lib/caramelize/filter_processor_spec.rb
245
- - spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb
246
- - spec/lib/caramelize/filters/swap_wiki_links_spec.rb
247
- - spec/lib/caramelize/filters/wikka_to_markdown_spec.rb
248
- - spec/lib/caramelize/input_wiki/wiki_spec.rb
249
- - spec/lib/caramelize/output_wiki/gollum_spec.rb
250
- - spec/lib/caramelize/page_spec.rb
251
- - spec/lib/caramelize/services/page_builder.rb
252
- - spec/spec_helper.rb
273
+ test_files: []
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6
4
- before_install:
5
- - gem install bundler
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Caramelize::Service::Pagebuilder do
4
- describe '.build_namespace_overview' do
5
- let(:body) do
6
- "## Overview of namespaces\n\n* [[Velociraptor|velociraptors/Wiki]] \n* [[Allosaurus|allosaurus/Wiki]] \n"
7
- end
8
- let(:expected_page) do
9
- Caramelize::Page.new(title: 'Home',
10
- body: body,
11
- message: 'Create Namespace Overview',
12
- latest: true)
13
- end
14
- let(:namespaces) do
15
- [
16
- OpenStruct.new(identifier: 'velociraptors', name: 'Velociraptor'),
17
- OpenStruct.new(identifier: 'allosaurus', name: 'Allosaurus')
18
- ]
19
- end
20
-
21
- it 'returns page with expected attributes' do
22
- page = described_class.build_namespace_overview
23
- expected(page.title).to eql(expected_page.title)
24
- expected(page.body).to eql(expected_page.body)
25
- expected(page.latest).to eql(expected_page.latest)
26
- expected(page.message).to eql(expected_page.message)
27
- end
28
- end
29
- end