bunto-import 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.markdown +33 -33
  4. data/lib/bunto-import.rb +49 -49
  5. data/lib/bunto-import/importer.rb +26 -26
  6. data/lib/bunto-import/importers.rb +10 -10
  7. data/lib/bunto-import/importers/behance.rb +80 -80
  8. data/lib/bunto-import/importers/blogger.rb +330 -264
  9. data/lib/bunto-import/importers/csv.rb +96 -96
  10. data/lib/bunto-import/importers/drupal6.rb +53 -139
  11. data/lib/bunto-import/importers/drupal7.rb +54 -111
  12. data/lib/bunto-import/importers/drupal_common.rb +157 -0
  13. data/lib/bunto-import/importers/easyblog.rb +96 -96
  14. data/lib/bunto-import/importers/enki.rb +74 -74
  15. data/lib/bunto-import/importers/ghost.rb +68 -68
  16. data/lib/bunto-import/importers/google_reader.rb +64 -64
  17. data/lib/bunto-import/importers/joomla.rb +92 -90
  18. data/lib/bunto-import/importers/joomla3.rb +91 -91
  19. data/lib/bunto-import/importers/jrnl.rb +125 -125
  20. data/lib/bunto-import/importers/marley.rb +72 -72
  21. data/lib/bunto-import/importers/mephisto.rb +99 -99
  22. data/lib/bunto-import/importers/mt.rb +257 -257
  23. data/lib/bunto-import/importers/posterous.rb +130 -130
  24. data/lib/bunto-import/importers/rss.rb +62 -62
  25. data/lib/bunto-import/importers/s9y.rb +60 -60
  26. data/lib/bunto-import/importers/s9y_database.rb +363 -0
  27. data/lib/bunto-import/importers/textpattern.rb +70 -70
  28. data/lib/bunto-import/importers/tumblr.rb +300 -289
  29. data/lib/bunto-import/importers/typo.rb +88 -88
  30. data/lib/bunto-import/importers/wordpress.rb +372 -372
  31. data/lib/bunto-import/importers/wordpressdotcom.rb +207 -207
  32. data/lib/bunto-import/util.rb +76 -76
  33. data/lib/bunto-import/version.rb +3 -3
  34. data/lib/bunto/commands/import.rb +79 -79
  35. metadata +84 -54
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecc70a4d2f9f17b709832b4e82eb78f492ed4bd4
4
- data.tar.gz: 3eb1f3dbcc165a704377f8ff0e0b544f12e9f564
3
+ metadata.gz: 8d44ab513c3fff1cf9e032de4f22330f4c02e7c3
4
+ data.tar.gz: cfacd4ea5f5784da123be72c02c17fbd2e7e6fd6
5
5
  SHA512:
6
- metadata.gz: 77112921b75c019bbcdb03dcc1a17d26a16677203babb7881e83b8a77dc232727e6d6c83a9efd94c12caa9b626406ac6540be21e8d40dbe787c7c06add558323
7
- data.tar.gz: 90920ce711231de39a8f12cec58bbbd4f6846dafbed1a02cfb8aac4810b293b65cb87f1fa734ced264545d2f6629307456fc06f44ec753258861fa5a83ed1ba7
6
+ metadata.gz: 48e63850a82509c11ad4cc93b945f29d3df0cbc53a771e604f261d2244c12ccf04e673cbc02c540bcf2e9d54abc6605f93f6a0d3c539218016a1d61bfa01cff2
7
+ data.tar.gz: 61044c86c4d03105c5dab0bb2c74b24e4a2ef6c08a16471014aee0b77e00aa10e3dbfb19fd7e135c861ae2c414e684b794409e9ccc34fda3595b9fcc509e606d
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016-present Tom Preston-Werner
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016-present Suriyaa Kudo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,33 +1,33 @@
1
- # bunto-import
2
-
3
- [![Build Status](https://travis-ci.org/bunto/bunto-import.svg?branch=master)](https://travis-ci.org/bunto/bunto-import)
4
- [![Security](https://hakiri.io/github/bunto/bunto-import/master.svg)](https://hakiri.io/github/bunto/bunto-import/master)
5
-
6
- The new __Bunto__ command for importing from various blogs to Bunto format.
7
-
8
- **Note: _migrators_ are now called _importers_ and are only available if one installs the `bunto-import` _gem_.**
9
-
10
- ## How `bunto-import` works:
11
-
12
- ### Bunto v2.x and higher
13
-
14
- 1. Install the _rubygem_ with `gem install bunto-import`.
15
- 2. Run `bunto import IMPORTER [options]`
16
-
17
- ### Bunto v1.x
18
-
19
- Launch IRB:
20
-
21
- ```ruby
22
- # 1. Require bunto-import
23
- irb> require 'bunto-import'
24
- # 2. Choose the importer you'd like to use.
25
- irb> importer_class = "Behance" # an example, there are many others!
26
- # 3. Run it!
27
- irb> BuntoImport::Importers.const_get(importer_class).run(options_hash)
28
- ```
29
-
30
- ## Documentation
31
-
32
- bunto-import has its own documentation site, found at https://bunto.github.io/.
33
- Dedicated [documentation for each migrator](https://bunto.github.io/import/docs/home/) is available there.
1
+ # bunto-import
2
+
3
+ [![Build Status](https://travis-ci.org/bunto/bunto-import.svg?branch=master)](https://travis-ci.org/bunto/bunto-import)
4
+ [![Security](https://hakiri.io/github/bunto/bunto-import/master.svg)](https://hakiri.io/github/bunto/bunto-import/master)
5
+
6
+ The new __Bunto__ command for importing from various blogs to Bunto format.
7
+
8
+ **Note: _migrators_ are now called _importers_ and are only available if one installs the `bunto-import` _gem_.**
9
+
10
+ ## How `bunto-import` works:
11
+
12
+ ### Bunto v2.x and higher
13
+
14
+ 1. Install the _rubygem_ with `gem install bunto-import`.
15
+ 2. Run `bunto import IMPORTER [options]`
16
+
17
+ ### Bunto v1.x
18
+
19
+ Launch IRB:
20
+
21
+ ```ruby
22
+ # 1. Require bunto-import
23
+ irb> require 'bunto-import'
24
+ # 2. Choose the importer you'd like to use.
25
+ irb> importer_class = "Behance" # an example, there are many others!
26
+ # 3. Run it!
27
+ irb> BuntoImport::Importers.const_get(importer_class).run(options_hash)
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ bunto-import has its own documentation site, found at https://bunto-import.tk/.
33
+ Dedicated [documentation for each migrator](https://bunto-import.tk/docs/home/) is available there.
@@ -1,49 +1,49 @@
1
- $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
2
- require 'rubygems'
3
- require 'bunto'
4
- require 'bunto/commands/import'
5
- require 'colorator'
6
-
7
- require 'bunto-import/importer'
8
- require 'bunto-import/importers'
9
- require 'bunto-import/util'
10
-
11
- module BuntoImport
12
- # Public: Add the subcommands for each importer
13
- #
14
- # cmd - the instance of Mercenary::Command from the
15
- #
16
- # Returns a list of valid subcommands
17
- def self.add_importer_commands(cmd)
18
- commands = []
19
- BuntoImport::Importer.subclasses.each do |importer|
20
- name = importer.to_s.split("::").last.downcase
21
- commands << name
22
- cmd.command(name.to_sym) do |c|
23
- c.syntax "#{name} [options]"
24
- importer.specify_options(c)
25
- c.action do |_, options|
26
- importer.run(options)
27
- end
28
- end
29
- end
30
- commands
31
- end
32
-
33
- def self.require_with_fallback(gems)
34
- Array[gems].flatten.each do |gem|
35
- begin
36
- require gem
37
- rescue LoadError
38
- Bunto.logger.error "Whoops! Looks like you need to install '#{gem}' before you can use this importer."
39
- Bunto.logger.error ""
40
- Bunto.logger.error "If you're using bundler:"
41
- Bunto.logger.error " 1. Add 'gem \"#{gem}\"' to your Gemfile"
42
- Bunto.logger.error " 2. Run 'bundle install'"
43
- Bunto.logger.error ""
44
- Bunto.logger.error "If you're not using bundler:"
45
- Bunto.logger.abort_with " 1. Run 'gem install #{gem}'."
46
- end
47
- end
48
- end
49
- end
1
+ $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
2
+ require 'rubygems'
3
+ require 'bunto'
4
+ require 'bunto/commands/import'
5
+ require 'colorator'
6
+
7
+ require 'bunto-import/importer'
8
+ require 'bunto-import/importers'
9
+ require 'bunto-import/util'
10
+
11
+ module BuntoImport
12
+ # Public: Add the subcommands for each importer
13
+ #
14
+ # cmd - the instance of Mercenary::Command from the
15
+ #
16
+ # Returns a list of valid subcommands
17
+ def self.add_importer_commands(cmd)
18
+ commands = []
19
+ BuntoImport::Importer.subclasses.each do |importer|
20
+ name = importer.to_s.split("::").last.downcase
21
+ commands << name
22
+ cmd.command(name.to_sym) do |c|
23
+ c.syntax "#{name} [options]"
24
+ importer.specify_options(c)
25
+ c.action do |_, options|
26
+ importer.run(options)
27
+ end
28
+ end
29
+ end
30
+ commands
31
+ end
32
+
33
+ def self.require_with_fallback(gems)
34
+ Array[gems].flatten.each do |gem|
35
+ begin
36
+ require gem
37
+ rescue LoadError
38
+ Bunto.logger.error "Whoops! Looks like you need to install '#{gem}' before you can use this importer."
39
+ Bunto.logger.error ""
40
+ Bunto.logger.error "If you're using bundler:"
41
+ Bunto.logger.error " 1. Add 'gem \"#{gem}\"' to your Gemfile"
42
+ Bunto.logger.error " 2. Run 'bundle install'"
43
+ Bunto.logger.error ""
44
+ Bunto.logger.error "If you're not using bundler:"
45
+ Bunto.logger.abort_with " 1. Run 'gem install #{gem}'."
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,26 +1,26 @@
1
- module BuntoImport
2
- class Importer
3
- def self.inherited(base)
4
- subclasses << base
5
- end
6
-
7
- def self.subclasses
8
- @subclasses ||= []
9
- end
10
-
11
- def self.stringify_keys(hash)
12
- the_hash = hash.clone
13
- the_hash.keys.each do |key|
14
- the_hash[(key.to_s rescue key) || key] = the_hash.delete(key)
15
- end
16
- the_hash
17
- end
18
-
19
- def self.run(options = {})
20
- opts = stringify_keys(options)
21
- self.require_deps
22
- self.validate(opts) if self.respond_to?(:validate)
23
- self.process(opts)
24
- end
25
- end
26
- end
1
+ module BuntoImport
2
+ class Importer
3
+ def self.inherited(base)
4
+ subclasses << base
5
+ end
6
+
7
+ def self.subclasses
8
+ @subclasses ||= []
9
+ end
10
+
11
+ def self.stringify_keys(hash)
12
+ the_hash = hash.clone
13
+ the_hash.keys.each do |key|
14
+ the_hash[(key.to_s rescue key) || key] = the_hash.delete(key)
15
+ end
16
+ the_hash
17
+ end
18
+
19
+ def self.run(options = {})
20
+ opts = stringify_keys(options)
21
+ self.require_deps
22
+ self.validate(opts) if self.respond_to?(:validate)
23
+ self.process(opts)
24
+ end
25
+ end
26
+ end
@@ -1,10 +1,10 @@
1
- module BuntoImport
2
- module Importers
3
- Dir.chdir(File.expand_path(File.join("importers"), File.dirname(__FILE__))) do
4
- Dir.entries(".").each do |f|
5
- next if f[0..0].eql?(".")
6
- require "bunto-import/importers/#{f}"
7
- end
8
- end
9
- end
10
- end
1
+ module BuntoImport
2
+ module Importers
3
+ Dir.chdir(File.expand_path(File.join("importers"), File.dirname(__FILE__))) do
4
+ Dir.entries(".").each do |f|
5
+ next if f[0..0].eql?(".")
6
+ require "bunto-import/importers/#{f}"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,80 +1,80 @@
1
- module BuntoImport
2
- module Importers
3
- class Behance < Importer
4
- def self.require_deps
5
- BuntoImport.require_with_fallback(%w[
6
- fileutils
7
- safe_yaml
8
- date
9
- time
10
- behance
11
- ])
12
- end
13
-
14
- def self.specify_options(c)
15
- c.option 'user', '--user NAME', 'The username of the account'
16
- c.option 'api_token', '--api_token TOKEN', 'The API access token for the account'
17
- end
18
-
19
- def self.validate(options)
20
- %w[user api_token].each do |option|
21
- if options[option].nil?
22
- abort "Missing mandatory option --#{option}."
23
- end
24
- end
25
- end
26
-
27
- # Process the import.
28
- #
29
- # user - the behance user to retrieve projects (ID or username)
30
- # api_token - your developer API Token
31
- #
32
- # Returns nothing.
33
- def self.process(options)
34
- user = options.fetch('user')
35
- token = options.fetch('api_token')
36
-
37
- client = fetch_behance(token)
38
-
39
- user_projects = client.user_projects(user)
40
-
41
- puts "#{user_projects.length} project(s) found. Importing now..."
42
-
43
- user_projects.each do |project|
44
-
45
- details = client.project(project['id'])
46
- title = project['name'].to_s
47
- formatted_date = Time.at(project['published_on'].to_i).to_date.to_s
48
-
49
- post_name = title.split(%r{ |!|/|:|&|-|$|,}).map do |character|
50
- character.downcase unless character.empty?
51
- end.compact.join('-')
52
-
53
- name = "#{formatted_date}-#{post_name}"
54
-
55
- header = {
56
- "layout" => "post",
57
- "title" => title,
58
- "details" => details
59
- }
60
-
61
- FileUtils.mkdir_p("_posts")
62
-
63
- File.open("_posts/#{name}.md", "w") do |f|
64
- f.puts header.to_yaml
65
- f.puts "---\n\n"
66
- f.puts details['description'].to_s
67
- end
68
- end
69
-
70
- puts "Finished importing."
71
- end
72
-
73
- private
74
-
75
- def self.fetch_behance(token)
76
- ::Behance::Client.new(access_token: token)
77
- end
78
- end
79
- end
80
- end
1
+ module BuntoImport
2
+ module Importers
3
+ class Behance < Importer
4
+ def self.require_deps
5
+ BuntoImport.require_with_fallback(%w[
6
+ fileutils
7
+ safe_yaml
8
+ date
9
+ time
10
+ behance
11
+ ])
12
+ end
13
+
14
+ def self.specify_options(c)
15
+ c.option 'user', '--user NAME', 'The username of the account'
16
+ c.option 'api_token', '--api_token TOKEN', 'The API access token for the account'
17
+ end
18
+
19
+ def self.validate(options)
20
+ %w[user api_token].each do |option|
21
+ if options[option].nil?
22
+ abort "Missing mandatory option --#{option}."
23
+ end
24
+ end
25
+ end
26
+
27
+ # Process the import.
28
+ #
29
+ # user - the behance user to retrieve projects (ID or username)
30
+ # api_token - your developer API Token
31
+ #
32
+ # Returns nothing.
33
+ def self.process(options)
34
+ user = options.fetch('user')
35
+ token = options.fetch('api_token')
36
+
37
+ client = fetch_behance(token)
38
+
39
+ user_projects = client.user_projects(user)
40
+
41
+ puts "#{user_projects.length} project(s) found. Importing now..."
42
+
43
+ user_projects.each do |project|
44
+
45
+ details = client.project(project['id'])
46
+ title = project['name'].to_s
47
+ formatted_date = Time.at(project['published_on'].to_i).to_date.to_s
48
+
49
+ post_name = title.split(%r{ |!|/|:|&|-|$|,}).map do |character|
50
+ character.downcase unless character.empty?
51
+ end.compact.join('-')
52
+
53
+ name = "#{formatted_date}-#{post_name}"
54
+
55
+ header = {
56
+ "layout" => "post",
57
+ "title" => title,
58
+ "details" => details
59
+ }
60
+
61
+ FileUtils.mkdir_p("_posts")
62
+
63
+ File.open("_posts/#{name}.md", "w") do |f|
64
+ f.puts header.to_yaml
65
+ f.puts "---\n\n"
66
+ f.puts details['description'].to_s
67
+ end
68
+ end
69
+
70
+ puts "Finished importing."
71
+ end
72
+
73
+ private
74
+
75
+ def self.fetch_behance(token)
76
+ ::Behance::Client.new(access_token: token)
77
+ end
78
+ end
79
+ end
80
+ end