cartodb-tools 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cartodb-tools/cli.rb +33 -0
- data/lib/cartodb-tools/version.rb +1 -1
- metadata +1 -1
data/lib/cartodb-tools/cli.rb
CHANGED
@@ -12,5 +12,38 @@ module CartodbTools
|
|
12
12
|
CartoDB::Init.start CartodbTools::Config.config
|
13
13
|
CartoDB::Connection.create_table options[:table_name], File.open(options[:file]), options[:geom_type]
|
14
14
|
end
|
15
|
+
|
16
|
+
desc "ls", "List the tables in your CartoDB account"
|
17
|
+
method_option :all, :aliases => "-a", :desc => "Show detailed information", :default => false
|
18
|
+
def ls
|
19
|
+
CartoDB::Init.start CartodbTools::Config.config
|
20
|
+
|
21
|
+
CartoDB::Connection.tables[:tables].each do |table|
|
22
|
+
lines = table[:name]
|
23
|
+
lines = lines.concat(table[:schema].map {|item| " #{item[0]} #{item[1]}" }) if options[:all]
|
24
|
+
end
|
25
|
+
|
26
|
+
puts lines.join("\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "show", "Show the details of a table in your CartoDB account"
|
30
|
+
method_option :table_name, :aliases => "-t", :desc => "Table name"
|
31
|
+
def show
|
32
|
+
raise unless options[:table_name]
|
33
|
+
|
34
|
+
CartoDB::Init.start CartodbTools::Config.config
|
35
|
+
|
36
|
+
CartoDB::Connection.table(options[:table_name]).tap do |table|
|
37
|
+
puts [].tap do |lines|
|
38
|
+
lines << "-------------------------"
|
39
|
+
lines << "id : #{table[:id]}"
|
40
|
+
lines << "name : #{table[:name]}"
|
41
|
+
lines << "privacy : #{table[:privacy]}"
|
42
|
+
lines << "tags : #{table[:tags]}"
|
43
|
+
lines << "-------------------------"
|
44
|
+
lines = lines.concat(table[:schema].map {|item| "#{item[0]} #{item[1]}" })
|
45
|
+
end.join("\n")
|
46
|
+
end
|
47
|
+
end
|
15
48
|
end
|
16
49
|
end
|