datapimp 1.0.14 → 1.0.15
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 +4 -4
 - data/datapimp.gemspec +1 -1
 - data/lib/datapimp/clients/amazon.rb +5 -0
 - data/lib/datapimp/clients/dropbox.rb +26 -11
 - data/lib/datapimp/clients/google.rb +13 -5
 - data/lib/datapimp/version.rb +1 -1
 - metadata +12 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0c51cdbb1f0199b7e2103dacab3a00589f1260d8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 61106a508c649acb572873e0ab67352223c405bf
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9ddc5e9d47cdb12ef0635419c0df7898484b76c77507f26fa4139ae2783cf68a786337236002b3b3f5c040a0059a8893d1762e48d79ea8ab1dfa0d890017b266
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 745fd6304639db2849f52cc2ba359ec3b4f8d9c8e6e185ee11cfcc94f38219862bf0444379b84b64b41d3ebfc36a018610d830248111b1b4cbfb1a6743e5bb51
         
     | 
    
        data/datapimp.gemspec
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       18 
18 
     | 
    
         
             
              spec.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              spec.add_dependency 'pry', '~> 0.10'
         
     | 
| 
       21 
     | 
    
         
            -
              spec.add_dependency 'hashie', ' 
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_dependency 'hashie', '>= 2.0', '< 3.0' 
         
     | 
| 
       22 
22 
     | 
    
         
             
              spec.add_dependency 'commander', '~> 4.3'
         
     | 
| 
       23 
23 
     | 
    
         
             
              spec.add_dependency 'terminal-table'
         
     | 
| 
       24 
24 
     | 
    
         
             
              spec.add_dependency 'fog-aws', '~> 0.1'
         
     | 
| 
         @@ -13,6 +13,10 @@ module Datapimp 
     | 
|
| 
       13 
13 
     | 
    
         
             
                    options[:aws_secret_access_key] || options[:secret_access_key] || Datapimp.config.aws_secret_access_key
         
     | 
| 
       14 
14 
     | 
    
         
             
                  end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
      
 16 
     | 
    
         
            +
                  def aws_region
         
     | 
| 
      
 17 
     | 
    
         
            +
                    options[:aws_region] || options[:region] || Datapimp.config.aws_region || "us-west-1"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
       16 
20 
     | 
    
         
             
                  def storage
         
     | 
| 
       17 
21 
     | 
    
         
             
                    return @storage if @storage
         
     | 
| 
       18 
22 
     | 
    
         | 
| 
         @@ -25,6 +29,7 @@ module Datapimp 
     | 
|
| 
       25 
29 
     | 
    
         
             
                      provider: 'AWS',
         
     | 
| 
       26 
30 
     | 
    
         
             
                      aws_access_key_id: aws_access_key_id,
         
     | 
| 
       27 
31 
     | 
    
         
             
                      aws_secret_access_key: aws_secret_access_key,
         
     | 
| 
      
 32 
     | 
    
         
            +
                      region: aws_region,
         
     | 
| 
       28 
33 
     | 
    
         
             
                      path_style: true
         
     | 
| 
       29 
34 
     | 
    
         
             
                    })
         
     | 
| 
       30 
35 
     | 
    
         | 
| 
         @@ -112,6 +112,28 @@ module Datapimp 
     | 
|
| 
       112 
112 
     | 
    
         
             
                    interactive_setup(options)
         
     | 
| 
       113 
113 
     | 
    
         
             
                  end
         
     | 
| 
       114 
114 
     | 
    
         | 
| 
      
 115 
     | 
    
         
            +
                  def browser_authorization_url
         
     | 
| 
      
 116 
     | 
    
         
            +
                    @browser_authorization_url ||= begin
         
     | 
| 
      
 117 
     | 
    
         
            +
                                                     consumer = ::Dropbox::API::OAuth.consumer(:authorize)
         
     | 
| 
      
 118 
     | 
    
         
            +
                                                     consumer.get_request_token.authorize_url
         
     | 
| 
      
 119 
     | 
    
         
            +
                                                   end
         
     | 
| 
      
 120 
     | 
    
         
            +
                  end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                  def consume_auth_client_code code=nil
         
     | 
| 
      
 123 
     | 
    
         
            +
                    if code.nil?
         
     | 
| 
      
 124 
     | 
    
         
            +
                      query  = browser_authorization_url.split('?').last
         
     | 
| 
      
 125 
     | 
    
         
            +
                      params = CGI.parse(query)
         
     | 
| 
      
 126 
     | 
    
         
            +
                      code  = params['oauth_token'].first
         
     | 
| 
      
 127 
     | 
    
         
            +
                    end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                    access_token  = request_token.get_access_token(:oauth_verifier => token)
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                    Datapimp.config.set 'dropbox_client_token', access_token.token
         
     | 
| 
      
 132 
     | 
    
         
            +
                    Datapimp.config.set 'dropbox_client_secret', access_token.secret
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                    true
         
     | 
| 
      
 135 
     | 
    
         
            +
                  end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
       115 
137 
     | 
    
         
             
                  def interactive_setup(options={})
         
     | 
| 
       116 
138 
     | 
    
         
             
                    if requires_setup?
         
     | 
| 
       117 
139 
     | 
    
         
             
                      if dropbox_app_key.length == 0
         
     | 
| 
         @@ -129,22 +151,15 @@ module Datapimp 
     | 
|
| 
       129 
151 
     | 
    
         
             
                    ::Dropbox::API::Config.app_key    = Datapimp.config.dropbox_app_key
         
     | 
| 
       130 
152 
     | 
    
         
             
                    ::Dropbox::API::Config.app_secret = Datapimp.config.dropbox_app_secret
         
     | 
| 
       131 
153 
     | 
    
         | 
| 
       132 
     | 
    
         
            -
                     
     | 
| 
       133 
     | 
    
         
            -
                    request_token = consumer.get_request_token
         
     | 
| 
      
 154 
     | 
    
         
            +
                    auth_url = browser_authorization_url
         
     | 
| 
       134 
155 
     | 
    
         
             
                    puts "\nGo to this url and click 'Authorize' to get the token:"
         
     | 
| 
       135 
     | 
    
         
            -
                    puts  
     | 
| 
       136 
     | 
    
         
            -
                    Launchy.open( 
     | 
| 
      
 156 
     | 
    
         
            +
                    puts auth_url
         
     | 
| 
      
 157 
     | 
    
         
            +
                    Launchy.open(auth_url)
         
     | 
| 
       137 
158 
     | 
    
         | 
| 
       138 
     | 
    
         
            -
                    query  = request_token.authorize_url.split('?').last
         
     | 
| 
       139 
     | 
    
         
            -
                    params = CGI.parse(query)
         
     | 
| 
       140 
     | 
    
         
            -
                    token  = params['oauth_token'].first
         
     | 
| 
       141 
159 
     | 
    
         
             
                    print "\nOnce you authorize the app on Dropbox, press enter... "
         
     | 
| 
       142 
160 
     | 
    
         
             
                    STDIN.gets.chomp
         
     | 
| 
       143 
161 
     | 
    
         | 
| 
       144 
     | 
    
         
            -
                     
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
                    Datapimp.config.set 'dropbox_client_token', access_token.token
         
     | 
| 
       147 
     | 
    
         
            -
                    Datapimp.config.set 'dropbox_client_secret', access_token.secret
         
     | 
| 
      
 162 
     | 
    
         
            +
                    consume_auth_client_code()
         
     | 
| 
       148 
163 
     | 
    
         | 
| 
       149 
164 
     | 
    
         
             
                    puts "\nAuthorization complete!:\n\n"
         
     | 
| 
       150 
165 
     | 
    
         
             
                    puts "  Dropbox::API::Config.app_key    = '#{consumer.key}'"
         
     | 
| 
         @@ -27,6 +27,17 @@ module Datapimp 
     | 
|
| 
       27 
27 
     | 
    
         
             
                    has_application_keys? && has_refresh_token?
         
     | 
| 
       28 
28 
     | 
    
         
             
                  end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
      
 30 
     | 
    
         
            +
                  def browser_authorization_url
         
     | 
| 
      
 31 
     | 
    
         
            +
                    auth_client.authorization_uri
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def consume_auth_client_code code
         
     | 
| 
      
 35 
     | 
    
         
            +
                    auth_client.code = code
         
     | 
| 
      
 36 
     | 
    
         
            +
                    auth_client.fetch_access_token!
         
     | 
| 
      
 37 
     | 
    
         
            +
                    Datapimp.config.set "google_refresh_token", auth_client.refresh_token
         
     | 
| 
      
 38 
     | 
    
         
            +
                    Datapimp.config.set "google_access_token", auth_client.access_token
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       30 
41 
     | 
    
         
             
                  # Runs through an interactive session where we get the
         
     | 
| 
       31 
42 
     | 
    
         
             
                  # necessary tokens needed to integrate with google drive.
         
     | 
| 
       32 
43 
     | 
    
         
             
                  def setup(options={})
         
     | 
| 
         @@ -43,12 +54,9 @@ module Datapimp 
     | 
|
| 
       43 
54 
     | 
    
         
             
                    if has_refresh_token?
         
     | 
| 
       44 
55 
     | 
    
         
             
                      refresh_access_token!
         
     | 
| 
       45 
56 
     | 
    
         
             
                    elsif respond_to?(:ask)
         
     | 
| 
       46 
     | 
    
         
            -
                      Launchy.open( 
     | 
| 
      
 57 
     | 
    
         
            +
                      Launchy.open(browser_authorization_url)
         
     | 
| 
       47 
58 
     | 
    
         
             
                      say("\n1. Open this page:\n%s\n\n" % auth_client.authorization_uri)
         
     | 
| 
       48 
     | 
    
         
            -
                       
     | 
| 
       49 
     | 
    
         
            -
                      auth_client.fetch_access_token!
         
     | 
| 
       50 
     | 
    
         
            -
                      Datapimp.config.set "google_refresh_token", auth_client.refresh_token
         
     | 
| 
       51 
     | 
    
         
            -
                      Datapimp.config.set "google_access_token", auth_client.access_token
         
     | 
| 
      
 59 
     | 
    
         
            +
                      consume_auth_client_code ask("2. Enter the authorization code shown in the page: ", String)
         
     | 
| 
       52 
60 
     | 
    
         
             
                    end
         
     | 
| 
       53 
61 
     | 
    
         
             
                  end
         
     | 
| 
       54 
62 
     | 
    
         | 
    
        data/lib/datapimp/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: datapimp
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.15
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jonathan Soeder
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-05-29 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: pry
         
     | 
| 
         @@ -28,16 +28,22 @@ dependencies: 
     | 
|
| 
       28 
28 
     | 
    
         
             
              name: hashie
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - - " 
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: 2.0 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 34 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 35 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 36 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
       34 
37 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
38 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
39 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
40 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - - " 
     | 
| 
      
 41 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       39 
42 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version: 2.0 
     | 
| 
      
 43 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 44 
     | 
    
         
            +
                - - "<"
         
     | 
| 
      
 45 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 46 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
       41 
47 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
48 
     | 
    
         
             
              name: commander
         
     | 
| 
       43 
49 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |