caramelize 0.1.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -53
  3. data/.travis.yml +5 -0
  4. data/CODE_OF_CONDUCT.md +76 -0
  5. data/Gemfile +3 -3
  6. data/LICENSE.md +1 -1
  7. data/README.md +48 -46
  8. data/Rakefile +8 -7
  9. data/bin/caramelize +73 -10
  10. data/caramelize.gemspec +28 -24
  11. data/lib/caramelize.rb +14 -0
  12. data/lib/caramelize/caramel.rb +48 -44
  13. data/lib/caramelize/content_transferer.rb +126 -69
  14. data/lib/caramelize/database_connector.rb +3 -6
  15. data/lib/caramelize/filter_processor.rb +27 -0
  16. data/lib/caramelize/filters/remove_table_tab_line_endings.rb +15 -0
  17. data/lib/caramelize/filters/swap_wiki_links.rb +26 -0
  18. data/lib/caramelize/filters/wikka_to_markdown.rb +67 -0
  19. data/lib/caramelize/health_check.rb +85 -0
  20. data/lib/caramelize/input_wiki/redmine_wiki.rb +120 -0
  21. data/lib/caramelize/input_wiki/wiki.rb +59 -0
  22. data/lib/caramelize/input_wiki/wikkawiki.rb +69 -0
  23. data/lib/caramelize/output_wiki/gollum.rb +80 -0
  24. data/lib/caramelize/page.rb +38 -14
  25. data/lib/caramelize/services/page_builder.rb +20 -0
  26. data/lib/caramelize/version.rb +1 -1
  27. data/spec/fixtures/markup/swap-links-input.textile +57 -0
  28. data/spec/fixtures/markup/swap-links-output.textile +57 -0
  29. data/spec/fixtures/markup/table-tab-line-endings-input.textile +145 -0
  30. data/spec/fixtures/markup/table-tab-line-endings-output.textile +145 -0
  31. data/spec/lib/caramelize/content_transferer_spec.rb +9 -0
  32. data/spec/lib/caramelize/filter_processor_spec.rb +34 -0
  33. data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +49 -0
  34. data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +49 -0
  35. data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +198 -0
  36. data/spec/lib/caramelize/input_wiki/wiki_spec.rb +57 -0
  37. data/spec/lib/caramelize/output_wiki/gollum_spec.rb +113 -0
  38. data/spec/lib/caramelize/page_spec.rb +67 -0
  39. data/spec/lib/caramelize/services/page_builder.rb +29 -0
  40. data/spec/spec_helper.rb +8 -0
  41. metadata +165 -54
  42. data/lib/caramelize/author.rb +0 -8
  43. data/lib/caramelize/cli.rb +0 -80
  44. data/lib/caramelize/cli/create_command.rb +0 -52
  45. data/lib/caramelize/cli/run_command.rb +0 -33
  46. data/lib/caramelize/ext.rb +0 -17
  47. data/lib/caramelize/gollum_output.rb +0 -56
  48. data/lib/caramelize/wiki/redmine_wiki.rb +0 -60
  49. data/lib/caramelize/wiki/trac_converter.rb +0 -82
  50. data/lib/caramelize/wiki/wiki.rb +0 -41
  51. data/lib/caramelize/wiki/wikka_converter.rb +0 -38
  52. data/lib/caramelize/wiki/wikkawiki.rb +0 -55
  53. data/test/helper.rb +0 -18
  54. data/test/test_caramelize.rb +0 -7
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 033fa149f2fd6a1823143125c966ea4ce7ea45b4106dec98762f4764db0b3c09
4
+ data.tar.gz: 80c47ef70453d79d01979f9fada6987d4f91cc4101aae488d4b5cba21841016e
5
+ SHA512:
6
+ metadata.gz: aed7b973e815bc6680210aef38f3519e6d46d45c10efd095126cce67edcd6d64cbd46bfd31b03cc68abf0f60bd8be57bf948d687f874a78fc8e37cb9a4a812a1
7
+ data.tar.gz: f9e3d0d1c1ba24c73d7f13699f71fb9d1abfb0022c9b42a5ed94a241bd88a09aab93f43bb69ba622f8e03a0ba1d85b92b97c7be1a7545a50886ce06536891203
data/.gitignore CHANGED
@@ -1,55 +1,23 @@
1
- wiki.git
2
-
3
- # rcov generated
4
- coverage
5
-
6
- # rdoc generated
7
- rdoc
8
-
9
- # yard generated
10
- doc
11
- .yardoc
12
-
13
- # bundler
1
+ *.gem
2
+ *.rbc
14
3
  .bundle
4
+ .config
5
+ .yardoc
15
6
  Gemfile.lock
16
- *.gem
17
-
18
- # jeweler generated
19
- pkg/*
20
-
21
- # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
22
- #
23
- # * Create a file at ~/.gitignore
24
- # * Include files you want ignored
25
- # * Run: git config --global core.excludesfile ~/.gitignore
26
- #
27
- # After doing this, these files will be ignored in all your git projects,
28
- # saving you from having to 'pollute' every project you touch with them
29
- #
30
- # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
31
- #
32
- # For MacOS:
33
- #
34
- .DS_Store
35
-
36
- # For TextMate
37
- #*.tmproj
38
- #tmtags
39
-
40
- # For Komodo Edit
41
- #*.komodoproject
42
-
43
- # For emacs:
44
- #*~
45
- #\#*
46
- #.\#*
47
-
48
- # For vim:
49
- #*.swp
50
-
51
- # For redcar:
52
- #.redcar
53
-
54
- # For rubinius:
55
- #*.rbc
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ wiki.git
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.6
4
+ before_install:
5
+ - gem install bundler
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at public@danielsenff.de. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in caramelize.gemspec
4
- gemspec
3
+ # Specify your gem's dependencies in testgem.gemspec
4
+ gemspec
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Daniel Senff
1
+ Copyright (c) 2015 Daniel Senff
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
data/README.md CHANGED
@@ -1,33 +1,40 @@
1
- # caramelize
1
+ # Caramelize
2
2
 
3
- 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](gollum)-wiki retaining all your history and gaining the most flexible access to your wiki content.
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)
4
4
 
5
- In the future more target wikis may be added. For the moment migration is supported for [WikkaWiki](wikka) and [Redmine](redmine)-Wiki.
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
+
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.
6
8
 
7
9
  ## Usage
8
10
 
9
11
  ### Installation
10
12
 
11
13
  $ gem install caramelize
12
-
14
+
13
15
  Install the latest release of caramelize using RubyGems.
14
16
 
15
17
  ### Use
16
18
 
17
- $ caramelize create
19
+ $ caramelize create
18
20
 
19
21
  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.
20
22
 
21
- $ caramelize run
22
-
23
+ $ caramelize run
24
+
23
25
  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.
24
26
 
27
+ $ caramelize doctor
28
+
29
+ Can be used to assess the quality of your wiki conversion. It'll help you see
30
+ how many wiki links may be broken and how many pages were orphaned.
31
+
25
32
  $ caramelize help
26
-
33
+
27
34
  Returns help information.
28
35
 
29
36
  $ caramelize version
30
-
37
+
31
38
  Returns version and release information.
32
39
 
33
40
  ### Options
@@ -41,23 +48,22 @@ Creates an example configuration by the given name.
41
48
  Executes the given configuration.
42
49
 
43
50
  $ caramelize --verbose [command]
44
- $ caramelize -v [command]
45
-
51
+
46
52
  Displays more verbose output to the command line.
47
53
 
48
54
  ## Content migration
49
55
 
50
56
  ### Wiki support
51
57
 
52
- Caramelize comes with direct support for [WikkaWiki](wikka) and [Redmine](redmine)-Wiki.
53
- More custom wikis can be supported by creating a suitable configuration file.
58
+ Caramelize comes with direct support for [WikkaWiki](http://wikkawiki.org/) and [Redmine](http://www.redmine.org/)-Wiki.
59
+ More custom wikis can be supported by creating a suitable configuration file.
54
60
 
55
- Any imported wiki exports into a [gollum](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.
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.
56
62
 
57
63
  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.
58
64
 
59
65
  * Page meta data
60
- * title
66
+ * title
61
67
  * content body
62
68
  * author name
63
69
  * author email address
@@ -65,7 +71,7 @@ Since wiki software may have special features, that are not common among other w
65
71
  * revisions
66
72
  * Markup conversion to markdown
67
73
  * limited to "simple" formatting, excluding complex formats such as tables
68
- * conversion using regular expressions -> somewhat easy to learn and extend
74
+ * conversion using regular expressions -> somewhat easy to learn and extend
69
75
 
70
76
  ### Configuration recipes
71
77
 
@@ -76,42 +82,42 @@ Custom import allows you to import data from wikis that are not natively support
76
82
 
77
83
  For a custom wiki you need to create a `wiki` instance object, that receives the necessary database creditials.
78
84
 
79
- wiki = Caramelize::Wiki.new({:host => "localhost",
80
- :username => "user",
81
- :database => "database_name",
82
- :password => 'monkey',
83
- :markup => :wikka})
85
+ wiki = Caramelize::InputWiki::Wiki.new(host: "localhost",
86
+ username: "user",
87
+ database: "database_name",
88
+ password: 'monkey',
89
+ markup: :wikka})
84
90
 
85
- This example ignores custom markup conversion and assumes WikkaWiki-markup.
91
+ This example ignores custom markup conversion and assumes WikkaWiki-markup.
86
92
 
87
93
  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.
88
94
 
89
95
  wiki.instance_eval do
90
96
  def read_pages
91
97
  sql = "SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;"
92
- @revisions, @titles = [], []
98
+ revisions, titles = [], []
93
99
  results = database.query(sql)
94
100
  results.each do |row|
95
- @titles << row["tag"]
96
- author = @authors[row["user"]]
97
- page = Page.new({:id => row["id"],
98
- :title => row["tag"],
99
- :body => row["body"],
100
- :markup => 'wikka',
101
- :latest => row["latest"] == "Y",
102
- :time => row["time"],
103
- :message => row["note"],
104
- :author => author,
105
- :author_name => row["user"]})
106
- @revisions << page
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
+ author_name: row["user"]})
112
+ revisions << page
107
113
  end
108
114
  # titles is the list of all unique page titles contained in the wiki
109
- @titles.uniq!
115
+ titles.uniq!
110
116
  # revisions is the list of all revisions ordered by date
111
- @revisions
117
+ revisions
112
118
  end
113
119
 
114
- In the end the `wiki` instance needs the `@titles` and `@revisions` filled.
120
+ In the end the `wiki` instance needs the `titles` and `revisions` filled.
115
121
 
116
122
  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.**
117
123
 
@@ -127,8 +133,8 @@ Clone or fork this repository and start building.
127
133
 
128
134
  $ git clone git@github.com:Dahie/caramelize.git
129
135
  $ gem build caramelize.gemspec
130
-
131
- Now to build and package the gem do
136
+
137
+ Now to build and package the gem do
132
138
 
133
139
  $ rake build
134
140
 
@@ -139,7 +145,7 @@ or
139
145
  to install the new gem right to your system.
140
146
 
141
147
  ## Contributing to caramelize
142
-
148
+
143
149
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
144
150
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
145
151
  * Fork the project
@@ -150,8 +156,4 @@ to install the new gem right to your system.
150
156
 
151
157
  ## Copyright
152
158
 
153
- Copyright (c) 2011-2013 Daniel Senff. See LICENSE.md for further details.
154
-
155
- [wikka]: http://wikkawiki.org/
156
- [gollum]: https://github.com/github/gollum
157
- [redmine]: http://www.redmine.org/
159
+ Copyright (c) 2011-2015 Daniel Senff. See LICENSE.md for further details.
data/Rakefile CHANGED
@@ -1,9 +1,10 @@
1
- require 'bundler'
2
- require 'rdoc/task'
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
3
 
4
- Bundler::GemHelper.install_tasks
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color', '--format', 'documentation']
8
+ end
5
9
 
6
- Rake::RDocTask.new do |rd|
7
- rd.main = "README.rdoc"
8
- rd.rdoc_files.include( "lib/**/*.rb")
9
- end
10
+ task :default => :spec
@@ -1,12 +1,75 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # If we are given filenames, convert each file
4
-
5
- require 'caramelize/cli'
6
- begin
7
- Caramelize::CLI::CommandParser.new.parse
8
- rescue
9
- puts "An error has occurred:\n " + $!.message
10
- puts $!.backtrace if $DEBUG
11
- exit(-1)
12
- end
3
+ require 'caramelize'
4
+ require 'commander/import'
5
+
6
+ # :name is optional, otherwise uses the basename of this executable
7
+ program :name, 'caramelize'
8
+ program :version, Caramelize::VERSION
9
+ program :description, 'With Caramelize you can migrate any wiki to git-based Gollum wiki repositories.'
10
+ program :help, 'Author', 'Daniel Senff <public@danielsenff.de>'
11
+
12
+ default_command :run
13
+
14
+ global_option '--verbose'
15
+
16
+ command :new do |c|
17
+ c.syntax = 'caramelize create [options]'
18
+ c.summary = 'Create new configuration'
19
+ c.description = 'Create a fresh configuration file for caramelize'
20
+ c.option '--config STRING', String, 'The config file (default: caramel.rb)'
21
+ c.example 'Create a fresh config file as "caramel.rb"', 'caramelize create'
22
+ 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')
25
+ options.default({ config: 'caramel.rb' })
26
+ FileUtils.cp(File.dirname(__FILE__) + '/../lib/caramelize/caramel.rb',
27
+ options.config)
28
+ say "Created new configuration file: #{options.config}"
29
+ end
30
+ end
31
+ alias_command :create, :new
32
+
33
+ command :run do |c|
34
+ c.syntax = 'caramelize run [options]'
35
+ c.summary = 'Run wiki transfer'
36
+ c.description = 'Run the wiki content transfer based on the given configuration file'
37
+ c.option '--config STRING', String, 'The config file (default: caramel.rb)'
38
+ c.example 'Run transfer for "caramel.rb"', 'caramelize run'
39
+ c.example 'Run transfer for "config.rb"', 'caramelize run --config config.rb'
40
+ c.action do |args, options|
41
+ time_start = Time.now
42
+ options.default({ config: 'caramel.rb', target: 'wiki-export' })
43
+
44
+ instance_eval(File.read(options.config))
45
+
46
+ target = options.target
47
+
48
+ if File.exists?(target)
49
+ answer = agree("#{target} already exists. Overwrite with fresh repository?")
50
+ FileUtils.rm_rf(target) if answer
51
+ end
52
+
53
+ wiki_options = input_wiki.options.merge(verbose: options.verbose,
54
+ target: options.target)
55
+ Caramelize::ContentTransferer.new(input_wiki, wiki_options).execute
56
+ say "Time required: #{Time.now - time_start} s"
57
+ end
58
+ end
59
+
60
+ command :doctor do |c|
61
+ c.syntax = 'caramelize doctor [options]'
62
+ c.summary = 'Run wiki transfer'
63
+ c.description = 'Run health-check'
64
+ c.option '--target STRING', String, 'The target path to Gollum git repository (default: wiki-export)'
65
+ c.example 'Run transfer for "caramel.rb"', 'caramelize doctor'
66
+ c.action do |args, options|
67
+ options.default(target: 'wiki-export')
68
+
69
+ if File.exists?(options.target)
70
+ Caramelize::HealthCheck.new(options.target).execute
71
+ else
72
+ say("No wiki repositry found in directory #{options.target}")
73
+ end
74
+ end
75
+ end