caramelize 1.3.0 → 1.3.2

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +30 -0
  3. data/.github/dependabot.yml +1 -1
  4. data/.github/workflows/main.yml +4 -4
  5. data/.ruby-version +1 -0
  6. data/Gemfile +6 -11
  7. data/Gemfile.lock +85 -90
  8. data/LICENSE.md +1 -1
  9. data/Rakefile +3 -3
  10. data/bin/caramelize +2 -3
  11. data/caramelize.gemspec +24 -20
  12. data/lib/caramelize/caramel.rb +23 -23
  13. data/lib/caramelize/content_transferer.rb +18 -18
  14. data/lib/caramelize/database_connector.rb +6 -6
  15. data/lib/caramelize/filters/camel_case_to_wiki_links.rb +2 -2
  16. data/lib/caramelize/filters/mediawiki_to_markdown.rb +4 -4
  17. data/lib/caramelize/filters/swap_wiki_links.rb +2 -2
  18. data/lib/caramelize/filters/wikka_to_markdown.rb +2 -2
  19. data/lib/caramelize/health_check.rb +1 -1
  20. data/lib/caramelize/health_checks/home_page_check.rb +2 -2
  21. data/lib/caramelize/health_checks/orphaned_pages_check.rb +1 -1
  22. data/lib/caramelize/health_checks/page.rb +2 -2
  23. data/lib/caramelize/input_wiki/media_wiki.rb +17 -17
  24. data/lib/caramelize/input_wiki/redmine_wiki.rb +23 -23
  25. data/lib/caramelize/input_wiki/wiki.rb +1 -1
  26. data/lib/caramelize/input_wiki/wikka_wiki.rb +15 -15
  27. data/lib/caramelize/output_wiki/gollum.rb +3 -3
  28. data/lib/caramelize/page.rb +11 -11
  29. data/lib/caramelize/services/page_builder.rb +4 -4
  30. data/lib/caramelize/version.rb +1 -1
  31. data/lib/caramelize.rb +16 -16
  32. data/samples/media_wiki.rb +4 -4
  33. data/spec/lib/caramelize/content_transferer_spec.rb +4 -4
  34. data/spec/lib/caramelize/filter_processor_spec.rb +7 -7
  35. data/spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb +7 -7
  36. data/spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb +17 -19
  37. data/spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb +4 -4
  38. data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +15 -17
  39. data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +23 -25
  40. data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +82 -84
  41. data/spec/lib/caramelize/input_wiki/media_wiki_spec.rb +3 -3
  42. data/spec/lib/caramelize/input_wiki/wiki_spec.rb +21 -21
  43. data/spec/lib/caramelize/input_wiki/wikka_wiki_spec.rb +3 -3
  44. data/spec/lib/caramelize/output_wiki/gollum_spec.rb +39 -39
  45. data/spec/lib/caramelize/page_spec.rb +30 -30
  46. data/spec/lib/caramelize/services/page_builder_spec.rb +12 -12
  47. data/spec/spec_helper.rb +2 -3
  48. metadata +62 -9
  49. data/.rubocop.yml +0 -31
  50. data/.rubocop_todo.yml +0 -55
@@ -34,7 +34,7 @@ module Caramelize
34
34
  target_body.gsub!(/(\*\*)(.*?)(\*\*)/) { |_s| "**#{::Regexp.last_match(2)}**" } # bold
35
35
  target_body.gsub!(%r{(//)(.*?)(//)}, '*\2*') # italic
36
36
  target_body.gsub!(/(__)(.*?)(__)/) { |_s| "<u>#{::Regexp.last_match(2)}</u>" } # underline
37
- target_body.gsub!(/(---)/, ' ') # forced linebreak
37
+ target_body.gsub!(/(---)/, " ") # forced linebreak
38
38
  end
39
39
 
40
40
  def replace_lists
@@ -51,7 +51,7 @@ module Caramelize
51
51
 
52
52
  def replace_links
53
53
  target_body.gsub!(/\[{2}((\w+):\S[^| ]*)[| ](.*)\]{2}/,
54
- '[\3](\1)')
54
+ '[\3](\1)')
55
55
  target_body.gsub!(/\[{2}((\w+):.*)\]{2}/, '<\1>')
56
56
  end
57
57
 
@@ -17,7 +17,7 @@ module Caramelize
17
17
  private
18
18
 
19
19
  def gollum
20
- @gollum ||= ::Gollum::Wiki.new(wiki_path, { ref: 'main' })
20
+ @gollum ||= ::Gollum::Wiki.new(wiki_path, {ref: "main"})
21
21
  end
22
22
  end
23
23
  end
@@ -10,13 +10,13 @@ module Caramelize
10
10
  end
11
11
 
12
12
  def check
13
- puts 'Home.md missing' unless has_home_page?
13
+ puts "Home.md missing" unless has_home_page?
14
14
  end
15
15
 
16
16
  private
17
17
 
18
18
  def has_home_page? # rubocop:todo Naming/PredicateName
19
- gollum.file('Home')
19
+ gollum.file("Home")
20
20
  end
21
21
  end
22
22
  end
@@ -33,7 +33,7 @@ module Caramelize
33
33
  end
34
34
 
35
35
  def page_paths
36
- pages.map(&:path).map { |path| path.split('.').first }
36
+ pages.map(&:path).map { |path| path.split(".").first }
37
37
  end
38
38
 
39
39
  def check_pages
@@ -12,12 +12,12 @@ module Caramelize
12
12
  def intra_wiki_links
13
13
  gollum_page.text_data.scan(/\[\[(.+\|)?(\S+)\]\]/).map do |match|
14
14
  link = match[1]
15
- filename == path ? link : [filename, link].join('/')
15
+ (filename == path) ? link : [filename, link].join("/")
16
16
  end.uniq
17
17
  end
18
18
 
19
19
  def filename
20
- path.split('/').first
20
+ path.split("/").first
21
21
  end
22
22
 
23
23
  def path
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caramelize/filters/add_newline_to_page_end'
4
- require 'caramelize/filters/mediawiki_to_markdown'
3
+ require "caramelize/filters/add_newline_to_page_end"
4
+ require "caramelize/filters/mediawiki_to_markdown"
5
5
 
6
6
  module Caramelize
7
7
  module InputWiki
@@ -20,7 +20,7 @@ module Caramelize
20
20
  JOIN text as t ON cn.content_address = CONCAT('tt:', t.old_id)
21
21
  ORDER BY r.rev_timestamp ASC;
22
22
  }
23
- SQL_AUTHORS = 'SELECT user_id, user_name, user_real_name, user_email FROM user;'
23
+ SQL_AUTHORS = "SELECT user_id, user_name, user_real_name, user_email FROM user;"
24
24
  NAMESPACE_MAPPING = {
25
25
  0 => :NS_MAIN,
26
26
  1 => :NS_TALK,
@@ -41,7 +41,7 @@ module Caramelize
41
41
  }.freeze
42
42
 
43
43
  def initialize(options = {})
44
- super(options)
44
+ super
45
45
  @options[:markup] = :media_wiki
46
46
  @options[:filters] << Caramelize::AddNewlineToPageEnd
47
47
  @options[:filters] << ::Caramelize::MediawikiToMarkdown
@@ -50,7 +50,7 @@ module Caramelize
50
50
  # after calling this action, titles and @revisions are expected to be filled
51
51
  def read_pages
52
52
  pages.each do |row|
53
- titles << row['page_title']
53
+ titles << row["page_title"]
54
54
  revisions << Page.new(build_properties(row))
55
55
  end
56
56
  titles.uniq!
@@ -59,9 +59,9 @@ module Caramelize
59
59
 
60
60
  def read_authors
61
61
  database.query(authors_query).each do |row|
62
- name = row['user_real_name'].empty? ? row['user_name'] : 'Anonymous'
63
- email = row['user_email'].empty? ? nil : row['user_email']
64
- authors[row['user_id']] = { name:, email: }
62
+ name = row["user_real_name"].empty? ? row["user_name"] : "Anonymous"
63
+ email = row["user_email"].empty? ? nil : row["user_email"]
64
+ authors[row["user_id"]] = {name:, email:}
65
65
  end
66
66
 
67
67
  authors
@@ -86,24 +86,24 @@ module Caramelize
86
86
  end
87
87
 
88
88
  def build_properties(row)
89
- author = authors[row['actor_user']] || { name: 'Anonymous', email: 'anonymous@example.com' }
89
+ author = authors[row["actor_user"]] || {name: "Anonymous", email: "anonymous@example.com"}
90
90
  {
91
- id: row['rev_id'],
91
+ id: row["rev_id"],
92
92
  title: title_by_namespace(row),
93
- body: row['old_text'],
93
+ body: row["old_text"],
94
94
  markup: :media_wiki,
95
- latest: row['page_latest'] == row['rev_id'],
96
- time: Time.strptime(row['rev_timestamp'], '%Y%m%d%H%M%S'),
97
- message: row['comment_text'],
95
+ latest: row["page_latest"] == row["rev_id"],
96
+ time: Time.strptime(row["rev_timestamp"], "%Y%m%d%H%M%S"),
97
+ message: row["comment_text"],
98
98
  author:
99
99
  }
100
100
  end
101
101
 
102
102
  def title_by_namespace(row)
103
- return row['page_title'] if namespace_matches?(row['page_namespace'], :NS_MAIN)
104
- return "#{row['page_title']}_Discussion" if namespace_matches?(row['page_namespace'], :NS_TALK)
103
+ return row["page_title"] if namespace_matches?(row["page_namespace"], :NS_MAIN)
104
+ return "#{row["page_title"]}_Discussion" if namespace_matches?(row["page_namespace"], :NS_TALK)
105
105
 
106
- row['page_title']
106
+ row["page_title"]
107
107
  end
108
108
 
109
109
  def namespace_matches?(namespace_id, expected_namespace)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caramelize/filters/swap_wiki_links'
4
- require 'caramelize/filters/remove_table_tab_line_endings'
3
+ require "caramelize/filters/swap_wiki_links"
4
+ require "caramelize/filters/remove_table_tab_line_endings"
5
5
 
6
6
  module Caramelize
7
7
  module InputWiki
@@ -9,7 +9,7 @@ module Caramelize
9
9
  include DatabaseConnector
10
10
 
11
11
  def initialize(options = {})
12
- super(options)
12
+ super
13
13
  @options[:markup] = :textile
14
14
  @options[:filters] << ::Caramelize::SwapWikiLinks
15
15
  @options[:filters] << ::Caramelize::RemoveTableTabLineEndings
@@ -31,9 +31,9 @@ module Caramelize
31
31
 
32
32
  def read_authors
33
33
  database.query(authors_query).each do |row|
34
- authors[row['id']] = { id: row['id'],
35
- name: row['login'],
36
- email: row['mail'] }
34
+ authors[row["id"]] = {id: row["id"],
35
+ name: row["login"],
36
+ email: row["mail"]}
37
37
  end
38
38
  authors
39
39
  end
@@ -41,18 +41,18 @@ module Caramelize
41
41
  private
42
42
 
43
43
  def build_page(row_page)
44
- results_contents = database.query(single_page_query(row_page['id']))
44
+ results_contents = database.query(single_page_query(row_page["id"]))
45
45
 
46
- wiki = wikis.find { |row| row['id'] == row_page['wiki_id'] }
46
+ wiki = wikis.find { |row| row["id"] == row_page["wiki_id"] }
47
47
 
48
- project_identifier = ''
48
+ project_identifier = ""
49
49
 
50
50
  if wiki
51
- project = projects.find { |row| row['id'] == wiki['project_id'] }
52
- project_identifier = "#{project['identifier']}/"
51
+ project = projects.find { |row| row["id"] == wiki["project_id"] }
52
+ project_identifier = "#{project["identifier"]}/"
53
53
  end
54
54
 
55
- title = project_identifier + row_page['title']
55
+ title = project_identifier + row_page["title"]
56
56
  titles << title
57
57
 
58
58
  results_contents.each do |row_content|
@@ -63,14 +63,14 @@ module Caramelize
63
63
 
64
64
  def add_projects_as_namespaces
65
65
  projects.each do |row_project|
66
- namespace = { identifier: row_project['identifier'],
67
- name: row_project['name'] }
66
+ namespace = {identifier: row_project["identifier"],
67
+ name: row_project["name"]}
68
68
  namespaces << namespace
69
69
  end
70
70
  end
71
71
 
72
72
  def authors_query
73
- 'SELECT id, login, mail FROM users;'
73
+ "SELECT id, login, mail FROM users;"
74
74
  end
75
75
 
76
76
  def single_page_query(page_id)
@@ -78,15 +78,15 @@ module Caramelize
78
78
  end
79
79
 
80
80
  def projects_query
81
- 'SELECT id, identifier, name FROM projects;'
81
+ "SELECT id, identifier, name FROM projects;"
82
82
  end
83
83
 
84
84
  def pages_query
85
- 'SELECT id, title, wiki_id FROM wiki_pages;'
85
+ "SELECT id, title, wiki_id FROM wiki_pages;"
86
86
  end
87
87
 
88
88
  def wikis_query
89
- 'SELECT id, project_id FROM wikis;'
89
+ "SELECT id, project_id FROM wikis;"
90
90
  end
91
91
 
92
92
  def pages
@@ -102,15 +102,15 @@ module Caramelize
102
102
  end
103
103
 
104
104
  def build_properties(title, row_content)
105
- author = authors.fetch(row_content['author_id'], nil)
105
+ author = authors.fetch(row_content["author_id"], nil)
106
106
  {
107
- id: row_content['id'],
107
+ id: row_content["id"],
108
108
  title:,
109
- body: row_content['data'],
109
+ body: row_content["data"],
110
110
  markup: :textile,
111
111
  latest: false,
112
- time: row_content['updated_on'],
113
- message: row_content['comments'],
112
+ time: row_content["updated_on"],
113
+ message: row_content["comments"],
114
114
  author:
115
115
  }
116
116
  end
@@ -17,7 +17,7 @@ module Caramelize
17
17
  # new array only containing pages by this name sorted by time asc
18
18
  # this does not support renamed pages
19
19
  revisions.select { |revision| revision.title == title }
20
- .sort_by(&:time)
20
+ .sort_by(&:time)
21
21
  end
22
22
 
23
23
  # return an empty array in case this action was not overridden
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caramelize/filters/add_newline_to_page_end'
4
- require 'caramelize/filters/camel_case_to_wiki_links'
5
- require 'caramelize/filters/wikka_to_markdown'
3
+ require "caramelize/filters/add_newline_to_page_end"
4
+ require "caramelize/filters/camel_case_to_wiki_links"
5
+ require "caramelize/filters/wikka_to_markdown"
6
6
 
7
7
  module Caramelize
8
8
  module InputWiki
9
9
  class WikkaWiki < Wiki
10
10
  include DatabaseConnector
11
11
 
12
- SQL_PAGES = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'
13
- SQL_AUTHORS = 'SELECT name, email FROM wikka_users;'
12
+ SQL_PAGES = "SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;"
13
+ SQL_AUTHORS = "SELECT name, email FROM wikka_users;"
14
14
  FUNCTION_PAGES = %w[AdminBadWords AdminPages AdminUsers AdminSpamLog CategoryAdmin CategoryCategory CategoryWiki DatabaseInfo FormattingRules HighScores InterWiki MyChanges MyPages OrphanedPages OwnedPages PageIndex PasswordForgotten RecentChanges RecentlyCommented Sandbox SysInfo TableMarkup TableMarkupReference TextSearch TextSearchExpanded UserSettings WantedPages WikiCategory WikkaInstaller WikkaConfig WikkaDocumentation WikkaMenulets WikkaReleaseNotes].freeze
15
15
 
16
16
  def initialize(options = {})
17
- super(options)
17
+ super
18
18
  @options[:markup] = :wikka
19
19
  @options[:filters] << ::Caramelize::AddNewlineToPageEnd
20
20
  @options[:filters] << ::Caramelize::WikkaToMarkdown
@@ -24,7 +24,7 @@ module Caramelize
24
24
  # after calling this action, titles and @revisions are expected to be filled
25
25
  def read_pages
26
26
  pages.each do |row|
27
- titles << row['tag']
27
+ titles << row["tag"]
28
28
  revisions << Page.new(build_properties(row))
29
29
  end
30
30
  titles.uniq!
@@ -34,7 +34,7 @@ module Caramelize
34
34
  def read_authors
35
35
  results = database.query(authors_query)
36
36
  results.each do |row|
37
- authors[row['name']] = { name: row['name'], email: row['email'] }
37
+ authors[row["name"]] = {name: row["name"], email: row["email"]}
38
38
  end
39
39
  end
40
40
 
@@ -57,15 +57,15 @@ module Caramelize
57
57
  end
58
58
 
59
59
  def build_properties(row)
60
- author = authors[row['user']]
60
+ author = authors[row["user"]]
61
61
  {
62
- id: row['id'],
63
- title: row['tag'],
64
- body: row['body'],
62
+ id: row["id"],
63
+ title: row["tag"],
64
+ body: row["body"],
65
65
  markup: :wikka,
66
- latest: row['latest'] == 'Y',
67
- time: row['time'],
68
- message: row['note'],
66
+ latest: row["latest"] == "Y",
67
+ time: row["time"],
68
+ message: row["note"],
69
69
  author:
70
70
  }
71
71
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gollum-lib'
3
+ require "gollum-lib"
4
4
 
5
5
  module Caramelize
6
6
  module OutputWiki
@@ -31,7 +31,7 @@ module Caramelize
31
31
 
32
32
  def rename_page(page_title, new_title)
33
33
  gollum_page = gollum.page(page_title)
34
- gollum.rename_page(gollum_page, new_title, { message: 'Rename home page' })
34
+ gollum.rename_page(gollum_page, new_title, {message: "Rename home page"})
35
35
  end
36
36
 
37
37
  # Commit all revisions of the given history into this gollum-wiki-repository.
@@ -67,7 +67,7 @@ module Caramelize
67
67
  end
68
68
 
69
69
  def gollum
70
- @gollum ||= ::Gollum::Wiki.new(wiki_path, { repo_is_bare: true, ref: 'main' })
70
+ @gollum ||= ::Gollum::Wiki.new(wiki_path, {repo_is_bare: true, ref: "main"})
71
71
  end
72
72
 
73
73
  def initialize_repository
@@ -5,14 +5,14 @@ module Caramelize
5
5
  attr_accessor :title, :body, :id, :markup, :latest, :time, :message, :author
6
6
 
7
7
  def initialize(page = {})
8
- @id = page[:id]
9
- @title = page.fetch(:title, '')
10
- @body = page.fetch(:body, '')
11
- @syntax = page[:markup]
12
- @latest = page[:latest] || false
13
- @time = page.fetch(:time, Time.now)
14
- @message = page.fetch(:message, '')
15
- @author = page[:author]
8
+ @id = page[:id]
9
+ @title = page.fetch(:title, "")
10
+ @body = page.fetch(:body, "")
11
+ @syntax = page[:markup]
12
+ @latest = page[:latest] || false
13
+ @time = page.fetch(:time, Time.now)
14
+ @message = page.fetch(:message, "")
15
+ @author = page[:author]
16
16
  end
17
17
 
18
18
  def author_email
@@ -24,7 +24,7 @@ module Caramelize
24
24
  end
25
25
 
26
26
  def author # rubocop:todo Lint/DuplicateMethods
27
- @author ||= { name: 'Caramelize', email: 'mail@example.com' }
27
+ @author ||= {name: "Caramelize", email: "mail@example.com"}
28
28
  end
29
29
 
30
30
  def latest?
@@ -32,13 +32,13 @@ module Caramelize
32
32
  end
33
33
 
34
34
  def path
35
- return @title unless @title.index('/')
35
+ return @title unless @title.index("/")
36
36
 
37
37
  "#{title_pieces.first}/#{title_pieces.last.downcase}"
38
38
  end
39
39
 
40
40
  def title_pieces
41
- @title.split('/')
41
+ @title.split("/")
42
42
  end
43
43
 
44
44
  def set_latest
@@ -13,10 +13,10 @@ module Caramelize
13
13
  "* [[#{namespace[:name]}|#{namespace[:identifier]}/wiki]]"
14
14
  end.prepend(HEADLINE).join(" \n")
15
15
 
16
- Page.new(title: 'Home',
17
- body:,
18
- message: 'Create Namespace Overview',
19
- latest: true)
16
+ Page.new(title: "Home",
17
+ body:,
18
+ message: "Create Namespace Overview",
19
+ latest: true)
20
20
  end
21
21
  end
22
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Caramelize
4
- VERSION = '1.3.0'
4
+ VERSION = "1.3.2"
5
5
  end
data/lib/caramelize.rb CHANGED
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'caramelize/version'
4
- require 'caramelize/page'
5
- require 'caramelize/database_connector'
6
- require 'caramelize/filters/add_newline_to_page_end'
7
- require 'caramelize/filter_processor'
8
- require 'caramelize/input_wiki/wiki'
9
- require 'caramelize/input_wiki/media_wiki'
10
- require 'caramelize/input_wiki/redmine_wiki'
11
- require 'caramelize/input_wiki/wikka_wiki'
12
- require 'caramelize/content_transferer'
13
- require 'caramelize/health_check'
14
- require 'caramelize/health_checks/home_page_check'
15
- require 'caramelize/health_checks/orphaned_pages_check'
16
- require 'caramelize/health_checks/page'
17
- require 'caramelize/output_wiki/gollum'
18
- require 'caramelize/services/page_builder'
3
+ require "caramelize/version"
4
+ require "caramelize/page"
5
+ require "caramelize/database_connector"
6
+ require "caramelize/filters/add_newline_to_page_end"
7
+ require "caramelize/filter_processor"
8
+ require "caramelize/input_wiki/wiki"
9
+ require "caramelize/input_wiki/media_wiki"
10
+ require "caramelize/input_wiki/redmine_wiki"
11
+ require "caramelize/input_wiki/wikka_wiki"
12
+ require "caramelize/content_transferer"
13
+ require "caramelize/health_check"
14
+ require "caramelize/health_checks/home_page_check"
15
+ require "caramelize/health_checks/orphaned_pages_check"
16
+ require "caramelize/health_checks/page"
17
+ require "caramelize/output_wiki/gollum"
18
+ require "caramelize/services/page_builder"
19
19
 
20
20
  Encoding.default_external = Encoding::UTF_8
21
21
  Encoding.default_internal = Encoding::UTF_8
@@ -4,10 +4,10 @@
4
4
 
5
5
  def input_wiki
6
6
  options = {
7
- host: '0.0.0.0',
8
- username: 'wikiuser',
9
- password: 'example',
10
- database: 'my_wiki',
7
+ host: "0.0.0.0",
8
+ username: "wikiuser",
9
+ password: "example",
10
+ database: "my_wiki",
11
11
  port: 63_645
12
12
  }
13
13
  Caramelize::InputWiki::MediaWiki.new(options)
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Caramelize::ContentTransferer do
6
- describe '#execute' do
7
- context 'with original_wiki' do
8
- pending('test full transfer')
6
+ describe "#execute" do
7
+ context "with original_wiki" do
8
+ pending("test full transfer")
9
9
  end
10
10
  end
11
11
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Caramelize::FilterProcessor do
6
6
  subject(:processor) { described_class.new(input_wiki) }
7
7
 
8
8
  let(:filters) { [] }
9
9
  let(:input_wiki) { double(filters:) } # rubocop:todo RSpec/VerifiedDoubles
10
- let(:body) { 'body' }
10
+ let(:body) { "body" }
11
11
 
12
12
  # rubocop:todo RSpec/LeakyConstantDeclaration
13
13
  class ReverseFilter # rubocop:todo Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration
@@ -21,17 +21,17 @@ describe Caramelize::FilterProcessor do
21
21
  end
22
22
  # rubocop:enable RSpec/LeakyConstantDeclaration
23
23
 
24
- describe '#run' do
25
- context 'without any filters' do
26
- it 'returns same revision body' do
24
+ describe "#run" do
25
+ context "without any filters" do
26
+ it "returns same revision body" do
27
27
  expect(processor.run(body)).to eql body
28
28
  end
29
29
  end
30
30
 
31
- context 'with reverse filter' do
31
+ context "with reverse filter" do
32
32
  let(:filters) { [ReverseFilter] }
33
33
 
34
- it 'returns reversed body' do
34
+ it "returns reversed body" do
35
35
  expect(processor.run(body)).to eql body.reverse
36
36
  end
37
37
  end
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe Caramelize::AddNewlineToPageEnd do
6
- describe '#run' do
6
+ describe "#run" do
7
7
  subject(:run) { filter.run }
8
8
 
9
9
  let(:filter) { described_class.new(body) }
10
10
 
11
- context 'with newline on body end' do
11
+ context "with newline on body end" do
12
12
  let(:body) { "Here is a sample body\n" }
13
13
 
14
- it 'adds no newline character' do
14
+ it "adds no newline character" do
15
15
  expect(run).to eq "Here is a sample body\n"
16
16
  end
17
17
  end
18
18
 
19
- context 'without newline on body end' do
20
- let(:body) { 'Here is a sample body' }
19
+ context "without newline on body end" do
20
+ let(:body) { "Here is a sample body" }
21
21
 
22
- it 'adds newline character' do
22
+ it "adds newline character" do
23
23
  expect(run).to eq "Here is a sample body\n"
24
24
  end
25
25
  end
@@ -1,44 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- # rubocop:todo RSpec/SpecFilePathFormat
6
- describe Caramelize::CamelCaseToWikiLinks do # rubocop:todo RSpec/FilePath, RSpec/SpecFilePathFormat
7
- # rubocop:enable RSpec/SpecFilePathFormat
8
- describe '#run' do
5
+ describe Caramelize::CamelCaseToWikiLinks do # rubocop:todo RSpec/SpecFilePathFormat
6
+ describe "#run" do
9
7
  subject(:run) { filter.run }
10
8
 
11
9
  let(:filter) { described_class.new(body) }
12
10
 
13
- context 'with camel case text' do
14
- let(:body) { 'Hier ein CamelCaseExample, bitte [[DankeDanke]]' }
11
+ context "with camel case text" do
12
+ let(:body) { "Hier ein CamelCaseExample, bitte [[DankeDanke]]" }
15
13
 
16
- it 'does wiki link' do
17
- expect(run).to eq 'Hier ein [[CamelCaseExample]], bitte [[DankeDanke]]'
14
+ it "does wiki link" do
15
+ expect(run).to eq "Hier ein [[CamelCaseExample]], bitte [[DankeDanke]]"
18
16
  end
19
17
  end
20
18
 
21
- context 'with camel case text downcased' do
22
- let(:body) { 'Hier ein camelCaseExample, bitte [[DankeDanke]]' }
19
+ context "with camel case text downcased" do
20
+ let(:body) { "Hier ein camelCaseExample, bitte [[DankeDanke]]" }
23
21
 
24
- it 'does not to wiki link' do
25
- expect(run).to eq 'Hier ein camelCaseExample, bitte [[DankeDanke]]'
22
+ it "does not to wiki link" do
23
+ expect(run).to eq "Hier ein camelCaseExample, bitte [[DankeDanke]]"
26
24
  end
27
25
  end
28
26
 
29
- context 'with camel case text at document end' do
30
- let(:body) { 'Hier ein CamelCaseExample' }
27
+ context "with camel case text at document end" do
28
+ let(:body) { "Hier ein CamelCaseExample" }
31
29
 
32
30
  # NOTE: this is sortof expected behavior - a wiki page should end on a newline in which case this does not happen
33
- it 'cuts last character' do
34
- expect(run).to eq 'Hier ein [[CamelCaseExampl]]e'
31
+ it "cuts last character" do
32
+ expect(run).to eq "Hier ein [[CamelCaseExampl]]e"
35
33
  end
36
34
  end
37
35
 
38
- context 'with camel case text at document end with newline' do
36
+ context "with camel case text at document end with newline" do
39
37
  let(:body) { "Hier ein CamelCaseExample\n" }
40
38
 
41
- it 'does wiki link' do
39
+ it "does wiki link" do
42
40
  expect(run).to eq "Hier ein [[CamelCaseExample]]\n"
43
41
  end
44
42
  end