datapimp 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/datapimp +7 -3
- data/lib/datapimp/cli/list.rb +13 -4
- data/lib/datapimp/cli/sync.rb +6 -1
- data/lib/datapimp/sync/google_drive_folder.rb +37 -1
- data/lib/datapimp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d7e2b49635e76cb47589374bf1909bb93e0a3a2
|
4
|
+
data.tar.gz: ba5f1eb21d0e9755c801cc6ffde1f57224b1b5f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67e296e6b402025e9fa06ababedd0cbc6e5ac9ad04696ef3e0b01d57cb682afcf1ae84b117ecf48bf77fa7b2c1bad9eda4eb984fab5815ade44f8d36fc9b8362
|
7
|
+
data.tar.gz: 7f38981c5eda4cad1968de659483875b878c9f04a2aab9391eeb1298e172932c0261b31f93de2bb044eef49729b21916db391a0b941ee177cdca827ad7752ef9
|
data/bin/datapimp
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require "
|
3
|
+
begin
|
4
|
+
require "bundler"
|
5
|
+
Bundler.require
|
6
|
+
rescue
|
7
|
+
require "rubygems"
|
8
|
+
end
|
5
9
|
|
6
10
|
$:.unshift Pathname(File.dirname(__FILE__)).join("..","lib")
|
7
11
|
|
12
|
+
require "pathname"
|
8
13
|
require "pry"
|
9
|
-
require 'colored'
|
10
14
|
require "commander/import"
|
11
15
|
require 'datapimp'
|
12
16
|
require 'datapimp/cli'
|
data/lib/datapimp/cli/list.rb
CHANGED
@@ -32,18 +32,27 @@ command "list folders" do |c|
|
|
32
32
|
c.description= "lists folders in a remote service"
|
33
33
|
|
34
34
|
c.option '--type SERVICE', String, 'Which service to search: dropbox, google, amazon'
|
35
|
-
c.option '--filter PATTERN',
|
35
|
+
c.option '--filter PATTERN', nil, 'Filter the results matching PATTERN'
|
36
36
|
|
37
37
|
c.action do |args, options|
|
38
38
|
type = options.type.to_sym
|
39
39
|
|
40
40
|
case
|
41
41
|
when type == :dropbox
|
42
|
-
puts
|
42
|
+
puts "Path\n===\n"
|
43
|
+
Datapimp::Sync.dropbox.ls(*([options.filter].compact)).each do |entry|
|
44
|
+
puts entry.path if entry.is_dir
|
45
|
+
end
|
43
46
|
when type == :google
|
44
|
-
puts
|
47
|
+
puts "Collection\n====\n"
|
48
|
+
Datapimp::Sync.google.api.collections.each do |collection|
|
49
|
+
puts collection.title
|
50
|
+
end
|
45
51
|
when type == :amazon
|
46
|
-
puts
|
52
|
+
puts "Bucket\n====\n"
|
53
|
+
Datapimp::Sync.amazon.storage.directories.each do |dir|
|
54
|
+
puts dir.key
|
55
|
+
end
|
47
56
|
end
|
48
57
|
end
|
49
58
|
end
|
data/lib/datapimp/cli/sync.rb
CHANGED
@@ -16,10 +16,15 @@ command "sync folder" do |c|
|
|
16
16
|
when options.type == "dropbox"
|
17
17
|
Datapimp::Sync::DropboxFolder.new(local: local, remote: remote)
|
18
18
|
when options.type == "google"
|
19
|
+
# Return the folders
|
20
|
+
# collection = Datapimp::Sync.google.api.collections.first
|
21
|
+
#
|
22
|
+
# svg = collection.files.first
|
23
|
+
# svg.export_as_file(/download/path, "image/svg+xml")
|
19
24
|
Datapimp::Sync::GoogleDriveFolder.new(local: local, remote: remote)
|
20
25
|
end
|
21
26
|
|
22
|
-
folder.run(options.action)
|
27
|
+
folder.run(options.action, options.to_hash.to_mash)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
@@ -1,5 +1,41 @@
|
|
1
1
|
module Datapimp
|
2
|
-
class Sync::GoogleDriveFolder <
|
2
|
+
class Sync::GoogleDriveFolder < Hashie::Mash
|
3
|
+
def api
|
4
|
+
@api ||= Datapimp::Sync.google.api
|
5
|
+
end
|
3
6
|
|
7
|
+
def local_path
|
8
|
+
Pathname(local)
|
9
|
+
end
|
10
|
+
|
11
|
+
def remote_path
|
12
|
+
api.collection_by_title(remote)
|
13
|
+
end
|
14
|
+
|
15
|
+
def drawings
|
16
|
+
remote_path.files.select {|file| file.mime_type == "application/vnd.google-apps.drawing" }
|
17
|
+
end
|
18
|
+
|
19
|
+
def run(action, options={})
|
20
|
+
action = action.to_sym
|
21
|
+
|
22
|
+
if action == :push
|
23
|
+
|
24
|
+
elsif action == :pull
|
25
|
+
|
26
|
+
elsif action == :svgs
|
27
|
+
drawings.each do |drawing|
|
28
|
+
filename = drawing.title.parameterize + '.svg'
|
29
|
+
local_file = local_path.join(filename)
|
30
|
+
|
31
|
+
if local_file.exist? && !options[:overwrite]
|
32
|
+
puts "== #{ filename } already exists. skipping. pass --overwrite to overwrite"
|
33
|
+
else
|
34
|
+
puts "== Downloading to svg: #{ filename }"
|
35
|
+
drawing.export_as_file(local_path.join(filename), 'image/svg+xml')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
4
40
|
end
|
5
41
|
end
|
data/lib/datapimp/version.rb
CHANGED