cartodb-tools 0.0.2 → 0.0.3

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/cartodb CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
-
4
3
  require 'thor'
5
4
  require 'cartodb-rb-client'
6
5
  require 'cartodb-tools'
@@ -0,0 +1,20 @@
1
+
2
+ module CartodbTools
3
+ class CLI < Thor
4
+ desc "import", "Import a file into your CartoDB account"
5
+ method_option :file, :aliases => "-f", :desc => "File to upload"
6
+ method_option :table_name, :aliases => '-t', :desc => "Table name to create"
7
+ method_option :geom_type, :aliases => '-g', :desc => "Geometry Type (Point, Line, Polygon, MultiPolygon)"
8
+
9
+ def import
10
+ raise unless File.exists? options[:file]
11
+
12
+ puts CartodbTools::Config.config
13
+ CartoDB::Init.start CartodbTools::Config.config
14
+
15
+ CartoDB::Connection.create_table options[:table_name], File.open(options[:file]), options[:geom_type]
16
+
17
+ puts CartoDB::Connection.table options[:table_name]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+
2
+ module CartodbTools
3
+ class Config
4
+ def self.config
5
+ {}.tap do |config|
6
+ rc_path = "#{ENV['HOME']}/.cartodbrc"
7
+
8
+ config.merge!(YAML.load_file(rc_path)) if File.exists?(rc_path)
9
+
10
+ config_from_env = {}
11
+ config_from_env['host'] = ENV['CARTODB_HOST'] if ENV['CARTODB_HOST']
12
+ config_from_env['oauth_key'] = ENV['CARTODB_OAUTHKEY'] if ENV['CARTODB_OAUTHKEY']
13
+ config_from_env['oauth_secret'] = ENV['CARTODB_OAUTHSECRET'] if ENV['CARTODB_OAUTHSECRET']
14
+ config_from_env['oauth_access_token'] = ENV['CARTODB_OAUTHACCESSTOKEN'] if ENV['CARTODB_OAUTHACCESSTOKEN']
15
+ config_from_env['oauth_access_token_secret'] = ENV['CARTODB_OAUTHACCESSTOKENSECRET'] if ENV['CARTODB_OAUTHACCESSTOKENSECRET']
16
+ config_from_env['username'] = ENV['CARTODB_USERNAME'] if ENV['CARTODB_USERNAME']
17
+ config_from_env['password'] = ENV['CARTODB_PASSWORD'] if ENV['CARTODB_PASSWORD']
18
+
19
+ config.merge!(config_from_env)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module CartodbTools
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartodb-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -56,10 +56,12 @@ files:
56
56
  - LICENSE
57
57
  - README.md
58
58
  - Rakefile
59
+ - bin/cartodb
59
60
  - cartodb-tools.gemspec
60
61
  - lib/cartodb-tools.rb
62
+ - lib/cartodb-tools/cli.rb
63
+ - lib/cartodb-tools/config.rb
61
64
  - lib/cartodb-tools/version.rb
62
- - bin/cartodb
63
65
  homepage: https://github.com/zhm/cartodb-tools
64
66
  licenses: []
65
67
  post_install_message: