datapimp 1.0.4 → 1.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f57c91a53179b365245d1084b37e7baedb92b66
4
- data.tar.gz: ca8380235f3c48f8efb7bebb3a27d27de34a0f88
3
+ metadata.gz: 4d7e2b49635e76cb47589374bf1909bb93e0a3a2
4
+ data.tar.gz: ba5f1eb21d0e9755c801cc6ffde1f57224b1b5f0
5
5
  SHA512:
6
- metadata.gz: 87d24bb7f62b25374bdd979ca767c403e8af8c594c23a3116b424f0db64d3816ccbcdfd9dab61ff8f4cb7089c3b996099bae8a46317fbb61adde2ce3f5e8d8fe
7
- data.tar.gz: 030dc4f4480aec9b55921aa009dadf82d378ff232a06ad70799812a8068fbea84f064bc8acd8f07b0986f07551bd710f950d58da28e4cdba237ab4bc22e59ced
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
- require "rubygems"
4
- require "pathname"
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'
@@ -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', String, 'Filter the results matching 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 Datapimp::Sync.dropbox.ls
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 Datapimp::Sync.google.api
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 Datapimp::Sync.amazon.storage
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
@@ -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 < OpenStruct
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
@@ -1,3 +1,3 @@
1
1
  module Datapimp
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datapimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder