chdorner-gdocs-migration 0.0.1 → 0.1.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.
- data/bin/gdocs-migration +9 -0
- data/lib/gdocs-migration.rb +29 -0
- data/lib/gdocs-migration/cli.rb +65 -0
- data/lib/gdocs-migration/migration.rb +62 -0
- metadata +17 -12
- data/.document +0 -5
- data/.gitignore +0 -5
- data/Rakefile +0 -57
- data/VERSION +0 -1
- data/gdocs-migration.gemspec +0 -56
data/bin/gdocs-migration
ADDED
data/lib/gdocs-migration.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (c) 2009 Christof Dorner
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# 'Software'), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
23
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
24
|
+
|
25
|
+
require File.expand_path(File.dirname(__FILE__) + "/gdocs-migration/cli")
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + "/gdocs-migration/migration")
|
27
|
+
|
28
|
+
module GDocsMigration
|
29
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright (c) 2009 Christof Dorner
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# 'Software'), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'optparse'
|
23
|
+
|
24
|
+
module GDocsMigration
|
25
|
+
class CLI
|
26
|
+
def self.execute(stdout, arguments=[])
|
27
|
+
|
28
|
+
# NOTE: the option -p/--path= is given as an example, and should be replaced in your application.
|
29
|
+
|
30
|
+
options = {
|
31
|
+
:from => nil,
|
32
|
+
:to => nil
|
33
|
+
}
|
34
|
+
mandatory_options = %w(from to)
|
35
|
+
|
36
|
+
parser = OptionParser.new do |opts|
|
37
|
+
opts.banner = <<-BANNER.gsub(/^ /,'')
|
38
|
+
GDocsMigration (http://github.com/chdorner/gdocs-migration)
|
39
|
+
|
40
|
+
Usage: #{File.basename($0)} [options]
|
41
|
+
|
42
|
+
Options are:
|
43
|
+
BANNER
|
44
|
+
opts.separator ""
|
45
|
+
opts.on("-f", "--from=FROM", String,
|
46
|
+
"The Google account to use as source.") { |arg| options[:from] = arg }
|
47
|
+
opts.on("-t", "--to=TO", String,
|
48
|
+
"The Google account to use as destination.") { |arg| options[:to] = arg }
|
49
|
+
opts.on("-h", "--help",
|
50
|
+
"Show this help message.") { stdout.puts opts; exit }
|
51
|
+
opts.parse!(arguments)
|
52
|
+
|
53
|
+
if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
|
54
|
+
stdout.puts opts; exit
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
from = options[:from]
|
59
|
+
to = options[:to]
|
60
|
+
|
61
|
+
migration = GDocsMigration::Migration.new from, to
|
62
|
+
migration.migrate
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Copyright (c) 2009 Christof Dorner
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# 'Software'), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'gdata'
|
23
|
+
require 'highline/import'
|
24
|
+
|
25
|
+
module GDocsMigration
|
26
|
+
class Migration
|
27
|
+
def initialize(from, to)
|
28
|
+
@from = from
|
29
|
+
@to = to
|
30
|
+
@from_client = GData::Client::DocList.new
|
31
|
+
@to_client = GData::Client::DocList.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def migrate
|
35
|
+
puts "";puts "**************************"
|
36
|
+
puts "GDocs Migration started...";puts ""
|
37
|
+
|
38
|
+
login
|
39
|
+
|
40
|
+
puts "";puts "Migration complete"
|
41
|
+
puts "";puts "**************************"
|
42
|
+
end
|
43
|
+
|
44
|
+
def login
|
45
|
+
begin
|
46
|
+
from_pass = ask("Password for #{@from}:") { |q| q.echo = "*" }
|
47
|
+
@from_client.clientlogin(@from, from_pass)
|
48
|
+
puts "Successfully logged in to #{@from}";puts ""
|
49
|
+
|
50
|
+
to_pass = ask("Password for #{@to}:") { |q| q.echo ="*" }
|
51
|
+
@to_client.clientlogin(@to, to_pass)
|
52
|
+
puts "Successfully logged in to #{@to}";puts ""
|
53
|
+
rescue GData::Client::AuthorizationError
|
54
|
+
puts("Oops, something went wrong while logging you in. Check the credentials");exit
|
55
|
+
rescue GData::Client::CaptchaError
|
56
|
+
puts("There was an error with loggin you in, try to login to Google Docs in your browser and then try again.");exit
|
57
|
+
rescue SocketError
|
58
|
+
puts("Cannot connect to the Google Docs service, are you connected to the internet?");exit
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chdorner-gdocs-migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chdorner
|
@@ -10,7 +10,7 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
|
12
12
|
date: 2009-09-04 00:00:00 -07:00
|
13
|
-
default_executable:
|
13
|
+
default_executable: gdocs-migration
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thoughtbot-shoulda
|
@@ -32,26 +32,31 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: highline
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
35
45
|
description: Copies all Google Documents from one to another Google account
|
36
46
|
email: christof@chdorner.com
|
37
|
-
executables:
|
38
|
-
|
47
|
+
executables:
|
48
|
+
- gdocs-migration
|
39
49
|
extensions: []
|
40
50
|
|
41
51
|
extra_rdoc_files:
|
42
52
|
- LICENSE
|
43
53
|
- README.rdoc
|
44
54
|
files:
|
45
|
-
- .
|
46
|
-
- .
|
55
|
+
- lib/gdocs-migration.rb
|
56
|
+
- lib/gdocs-migration/cli.rb
|
57
|
+
- lib/gdocs-migration/migration.rb
|
47
58
|
- LICENSE
|
48
59
|
- README.rdoc
|
49
|
-
- Rakefile
|
50
|
-
- VERSION
|
51
|
-
- gdocs-migration.gemspec
|
52
|
-
- lib/gdocs-migration.rb
|
53
|
-
- test/gdocs-migration_test.rb
|
54
|
-
- test/test_helper.rb
|
55
60
|
has_rdoc: false
|
56
61
|
homepage: http://github.com/chdorner/gdocs-migration
|
57
62
|
licenses:
|
data/.document
DELETED
data/Rakefile
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "gdocs-migration"
|
8
|
-
gem.summary = %Q{Migrates GDocs between Google accounts}
|
9
|
-
gem.description = %Q{Copies all Google Documents from one to another Google account}
|
10
|
-
gem.email = "christof@chdorner.com"
|
11
|
-
gem.homepage = "http://github.com/chdorner/gdocs-migration"
|
12
|
-
gem.authors = ["chdorner"]
|
13
|
-
gem.add_development_dependency "thoughtbot-shoulda"
|
14
|
-
gem.add_dependency "gdata"
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
-
end
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'rake/testtask'
|
22
|
-
Rake::TestTask.new(:test) do |test|
|
23
|
-
test.libs << 'lib' << 'test'
|
24
|
-
test.pattern = 'test/**/*_test.rb'
|
25
|
-
test.verbose = true
|
26
|
-
end
|
27
|
-
|
28
|
-
begin
|
29
|
-
require 'rcov/rcovtask'
|
30
|
-
Rcov::RcovTask.new do |test|
|
31
|
-
test.libs << 'test'
|
32
|
-
test.pattern = 'test/**/*_test.rb'
|
33
|
-
test.verbose = true
|
34
|
-
end
|
35
|
-
rescue LoadError
|
36
|
-
task :rcov do
|
37
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
task :test => :check_dependencies
|
42
|
-
|
43
|
-
task :default => :test
|
44
|
-
|
45
|
-
require 'rake/rdoctask'
|
46
|
-
Rake::RDocTask.new do |rdoc|
|
47
|
-
if File.exist?('VERSION')
|
48
|
-
version = File.read('VERSION')
|
49
|
-
else
|
50
|
-
version = ""
|
51
|
-
end
|
52
|
-
|
53
|
-
rdoc.rdoc_dir = 'rdoc'
|
54
|
-
rdoc.title = "gdocs-migration #{version}"
|
55
|
-
rdoc.rdoc_files.include('README*')
|
56
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.1
|
data/gdocs-migration.gemspec
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{gdocs-migration}
|
8
|
-
s.version = "0.0.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["chdorner"]
|
12
|
-
s.date = %q{2009-09-04}
|
13
|
-
s.description = %q{Copies all Google Documents from one to another Google account}
|
14
|
-
s.email = %q{christof@chdorner.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"gdocs-migration.gemspec",
|
27
|
-
"lib/gdocs-migration.rb",
|
28
|
-
"test/gdocs-migration_test.rb",
|
29
|
-
"test/test_helper.rb"
|
30
|
-
]
|
31
|
-
s.homepage = %q{http://github.com/chdorner/gdocs-migration}
|
32
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
-
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = %q{1.3.5}
|
35
|
-
s.summary = %q{Migrates GDocs between Google accounts}
|
36
|
-
s.test_files = [
|
37
|
-
"test/gdocs-migration_test.rb",
|
38
|
-
"test/test_helper.rb"
|
39
|
-
]
|
40
|
-
|
41
|
-
if s.respond_to? :specification_version then
|
42
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
-
s.specification_version = 3
|
44
|
-
|
45
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
-
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
47
|
-
s.add_runtime_dependency(%q<gdata>, [">= 0"])
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
50
|
-
s.add_dependency(%q<gdata>, [">= 0"])
|
51
|
-
end
|
52
|
-
else
|
53
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
54
|
-
s.add_dependency(%q<gdata>, [">= 0"])
|
55
|
-
end
|
56
|
-
end
|