zillabyte-cli 0.0.10 → 0.0.11
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/lib/zillabyte-cli/version.rb +1 -1
- data/lib/zillabyte/api.rb +1 -1
- data/lib/zillabyte/api/data.rb +0 -66
- data/lib/zillabyte/auth.rb +79 -43
- data/lib/zillabyte/cli/auth.rb +9 -4
- data/lib/zillabyte/cli/flows.rb +10 -59
- data/lib/zillabyte/cli/help.rb +16 -1
- data/lib/zillabyte/cli/logs.rb +0 -1
- data/lib/zillabyte/cli/query.rb +6 -8
- data/lib/zillabyte/cli/relations.rb +27 -60
- metadata +29 -5
- checksums.yaml +0 -15
data/lib/zillabyte/api.rb
CHANGED
data/lib/zillabyte/api/data.rb
CHANGED
@@ -2,37 +2,9 @@ require 'net/http'
|
|
2
2
|
|
3
3
|
class Zillabyte::API::Data < Zillabyte::API::Base
|
4
4
|
|
5
|
-
|
6
|
-
# # GET /datasets
|
7
|
-
# def list(options = {})
|
8
|
-
#
|
9
|
-
# options = {
|
10
|
-
# # TODO
|
11
|
-
# }.merge(options)
|
12
|
-
#
|
13
|
-
# res = @api.request(
|
14
|
-
# :expects => 200,
|
15
|
-
# :method => :get,
|
16
|
-
# :path => "/datasets"
|
17
|
-
# )
|
18
|
-
#
|
19
|
-
# res.body
|
20
|
-
#
|
21
|
-
# end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
5
|
# GET /datasets/1
|
27
6
|
def get(id, options = {})
|
28
7
|
|
29
|
-
options = {
|
30
|
-
:name => id
|
31
|
-
# rows
|
32
|
-
# schema
|
33
|
-
# relations
|
34
|
-
}.merge(options)
|
35
|
-
|
36
8
|
res = @api.request(
|
37
9
|
:expects => 200,
|
38
10
|
:method => :get,
|
@@ -81,13 +53,6 @@ class Zillabyte::API::Data < Zillabyte::API::Base
|
|
81
53
|
|
82
54
|
# POST /datasets/1/append
|
83
55
|
def append(id, options = {})
|
84
|
-
opts = {:name => id}
|
85
|
-
file = options[:file] if options[:file]
|
86
|
-
if(file)
|
87
|
-
opts[:size] = File.size(file)
|
88
|
-
options.delete(:file)
|
89
|
-
end
|
90
|
-
options = opts.merge(options)
|
91
56
|
|
92
57
|
res = @api.request(
|
93
58
|
:expects => 200,
|
@@ -95,40 +60,9 @@ class Zillabyte::API::Data < Zillabyte::API::Base
|
|
95
60
|
:path => "/relations/#{id}/append",
|
96
61
|
:body => options.to_json
|
97
62
|
)
|
98
|
-
|
99
63
|
hash = res.body
|
100
|
-
if(hash['uri'])
|
101
|
-
uri = URI(hash['uri'])
|
102
|
-
response = nil
|
103
|
-
try_again = 1
|
104
|
-
while(try_again)
|
105
|
-
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
|
106
|
-
request = Net::HTTP::Put.new(uri.request_uri)
|
107
|
-
request.body_stream = Zillabyte::Common::Tar.tar(file, [])
|
108
|
-
request['Content-Length'] = request.body_stream.size
|
109
|
-
request['Content-Type'] = ''
|
110
|
-
response = http.request(request)
|
111
|
-
if response.code.to_i >= 300
|
112
|
-
try_again = 1
|
113
|
-
break
|
114
|
-
end
|
115
|
-
try_again = nil
|
116
|
-
end
|
117
|
-
end
|
118
|
-
hash[:appended] = opts[:size]
|
119
|
-
hash.delete('uri')
|
120
|
-
res = @api.request(
|
121
|
-
:expects => 200,
|
122
|
-
:method => :post,
|
123
|
-
:path => "/relations/#{id}/store",
|
124
|
-
:body => options.to_json
|
125
|
-
)
|
126
|
-
end
|
127
64
|
hash
|
128
65
|
|
129
66
|
end
|
130
|
-
|
131
|
-
|
132
|
-
|
133
67
|
|
134
68
|
end
|
data/lib/zillabyte/auth.rb
CHANGED
@@ -9,17 +9,10 @@ class Zillabyte::Auth
|
|
9
9
|
|
10
10
|
attr_accessor :credentials
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def login
|
21
|
-
delete_credentials
|
22
|
-
get_credentials
|
12
|
+
def login(auth_token)
|
13
|
+
if valid_credentials?(auth_token)
|
14
|
+
write_credentials(auth_token)
|
15
|
+
end
|
23
16
|
end
|
24
17
|
|
25
18
|
def logout
|
@@ -39,10 +32,6 @@ class Zillabyte::Auth
|
|
39
32
|
default_host
|
40
33
|
end
|
41
34
|
|
42
|
-
def reauthorize
|
43
|
-
@credentials = ask_for_and_save_credentials
|
44
|
-
end
|
45
|
-
|
46
35
|
# def user # :nodoc:
|
47
36
|
# get_credentials[0]
|
48
37
|
# end
|
@@ -55,15 +44,10 @@ class Zillabyte::Auth
|
|
55
44
|
get_credentials
|
56
45
|
end
|
57
46
|
|
58
|
-
def get_credentials
|
47
|
+
def get_credentials # :nodoc:
|
59
48
|
@credentials ||= (read_credentials || ask_for_and_save_credentials)
|
60
49
|
end
|
61
50
|
|
62
|
-
def delete_credentials
|
63
|
-
netrc.delete(host)
|
64
|
-
netrc.save
|
65
|
-
@credentials = nil
|
66
|
-
end
|
67
51
|
|
68
52
|
def netrc_path
|
69
53
|
default = Netrc.default_path
|
@@ -78,7 +62,7 @@ class Zillabyte::Auth
|
|
78
62
|
def netrc # :nodoc:
|
79
63
|
@netrc ||= begin
|
80
64
|
Netrc.read(netrc_path)
|
81
|
-
rescue => error
|
65
|
+
rescue Zillabyte::Auth::NetrcError => error
|
82
66
|
if error.message =~ /^Permission bits for/
|
83
67
|
perm = File.stat(netrc_path).mode & 0777
|
84
68
|
abort("Permissions #{perm} for '#{netrc_path}' are too open. You should run `chmod 0600 #{netrc_path}` so that your credentials are NOT accessible by others.")
|
@@ -103,13 +87,42 @@ class Zillabyte::Auth
|
|
103
87
|
end
|
104
88
|
end
|
105
89
|
|
106
|
-
def write_credentials
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
90
|
+
def write_credentials(auth_token)
|
91
|
+
begin
|
92
|
+
FileUtils.mkdir_p(File.dirname(netrc_path))
|
93
|
+
FileUtils.touch(netrc_path)
|
94
|
+
netrc[host] = ["login", auth_token]
|
95
|
+
netrc.save
|
96
|
+
rescue Zillabyte::Auth::NetrcError => error
|
97
|
+
display 'Netrc Read or Save Error'
|
98
|
+
display error.message
|
99
|
+
exit 1
|
100
|
+
end
|
101
|
+
display "Authentication complete"
|
111
102
|
end
|
112
103
|
|
104
|
+
def delete_credentials
|
105
|
+
begin
|
106
|
+
netrc.delete(host)
|
107
|
+
rescue Zillabyte::Auth::NetrcError => error
|
108
|
+
display 'Netrc Delete Error'
|
109
|
+
display error.message
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
|
113
|
+
tries = 0
|
114
|
+
begin
|
115
|
+
netrc.save
|
116
|
+
rescue Zillabyte::Auth::NetrcError => error
|
117
|
+
tries +=1
|
118
|
+
display 'netrc save error'
|
119
|
+
error.message
|
120
|
+
retry if tries <= 3
|
121
|
+
exit 1
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
113
126
|
def echo_off
|
114
127
|
with_tty do
|
115
128
|
system "stty -echo"
|
@@ -122,27 +135,44 @@ class Zillabyte::Auth
|
|
122
135
|
end
|
123
136
|
end
|
124
137
|
|
125
|
-
def
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
print "\n"
|
134
|
-
|
135
|
-
auth_token
|
138
|
+
def valid_credentials?(auth_token)
|
139
|
+
api = Zillabyte::API.new(:api_key => auth_token, :progress => self)
|
140
|
+
response = api.request(
|
141
|
+
:expects => 200,
|
142
|
+
:method => :get,
|
143
|
+
:path => "/cli/login"
|
144
|
+
)
|
145
|
+
response.body != "authentication error"
|
136
146
|
|
137
147
|
end
|
138
148
|
|
139
149
|
def ask_for_and_save_credentials
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
150
|
+
if not read_credentials.nil?
|
151
|
+
display "Your credentials already exist. Re-enter them? [Y/n]"
|
152
|
+
$stdout.flush()
|
153
|
+
if ask == 'Y'
|
154
|
+
|
155
|
+
else
|
156
|
+
exit 1
|
157
|
+
end
|
144
158
|
end
|
145
|
-
|
159
|
+
begin
|
160
|
+
puts "Enter your Zillabyte credentials."
|
161
|
+
print "Auth Token: "
|
162
|
+
$stdout.flush()
|
163
|
+
auth_token = ask
|
164
|
+
print "\n"
|
165
|
+
if not valid_credentials?(auth_token)
|
166
|
+
raise Zillabyte::Auth::InvalidCredentialsException
|
167
|
+
else
|
168
|
+
write_credentials(auth_token)
|
169
|
+
end
|
170
|
+
rescue Zillabyte::Auth::InvalidCredentialsException => e
|
171
|
+
display "Authentication failed."
|
172
|
+
retry if retry_login?
|
173
|
+
exit 1
|
174
|
+
end
|
175
|
+
auth_token
|
146
176
|
end
|
147
177
|
|
148
178
|
def retry_login?
|
@@ -153,3 +183,9 @@ class Zillabyte::Auth
|
|
153
183
|
|
154
184
|
end
|
155
185
|
end
|
186
|
+
|
187
|
+
class Zillabyte::Auth::NetrcError < Netrc::Error
|
188
|
+
end
|
189
|
+
|
190
|
+
class Zillabyte::Auth::InvalidCredentialsException < Exception
|
191
|
+
end
|
data/lib/zillabyte/cli/auth.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require "zillabyte/cli/base"
|
2
|
+
require "optparse"
|
3
|
+
require "pp"
|
2
4
|
|
3
5
|
# manage zillabyte accounts
|
4
6
|
#
|
@@ -9,15 +11,18 @@ class Zillabyte::Command::Auth < Zillabyte::Command::Base
|
|
9
11
|
# auth:login
|
10
12
|
#
|
11
13
|
# Sets the Zillabyte Auth token
|
12
|
-
#
|
14
|
+
#
|
15
|
+
# --auth_token TOKEN # provide the token
|
13
16
|
def login
|
14
|
-
|
17
|
+
if options[:auth_token]
|
18
|
+
Zillabyte::Auth.login( options[:auth_token])
|
19
|
+
else
|
20
|
+
Zillabyte::Auth.ask_for_and_save_credentials
|
21
|
+
end
|
15
22
|
end
|
16
23
|
|
17
24
|
alias_command "login", "auth:login"
|
18
25
|
|
19
|
-
|
20
|
-
|
21
26
|
# auth:logout
|
22
27
|
#
|
23
28
|
# Sets the Zillabyte Auth token
|
data/lib/zillabyte/cli/flows.rb
CHANGED
@@ -10,15 +10,14 @@ require 'securerandom'
|
|
10
10
|
#
|
11
11
|
class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
12
12
|
|
13
|
-
|
14
13
|
# flows
|
15
14
|
#
|
15
|
+
# list custom flows
|
16
16
|
#
|
17
17
|
def index
|
18
18
|
self.list
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
21
|
# flows
|
23
22
|
#
|
24
23
|
# list custom flows
|
@@ -36,34 +35,9 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
36
35
|
end
|
37
36
|
display "flows:\n" + Terminal::Table.new(:headings => headings, :rows => rows).to_s
|
38
37
|
display "Total number of flows: "+rows.length.to_s
|
39
|
-
|
40
|
-
|
41
38
|
end
|
42
|
-
|
43
|
-
alias_command "list", "flows:list"
|
44
39
|
|
45
40
|
|
46
|
-
def status
|
47
|
-
headings = ["name", "implementable", "implemented"]
|
48
|
-
rows = api.flows.list.map do |row|
|
49
|
-
if headings.size == 0
|
50
|
-
headings = row.keys
|
51
|
-
headings.delete("rel_dir")
|
52
|
-
end
|
53
|
-
v = row.values_at *headings
|
54
|
-
v
|
55
|
-
end
|
56
|
-
display "flow status:\n" + Terminal::Table.new(:headings => headings, :rows => rows).to_s
|
57
|
-
display "Total number of flows in queue: "+rows.length.to_s
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
alias_command "status", "flows:status"
|
62
|
-
|
63
|
-
# def status
|
64
|
-
# headings = ["name", "matches", "emits", "implementable?", "implemented", ]
|
65
|
-
# end
|
66
|
-
|
67
41
|
# flows:push [DIR]
|
68
42
|
#
|
69
43
|
# uploads a flow
|
@@ -86,7 +60,6 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
86
60
|
end
|
87
61
|
|
88
62
|
end
|
89
|
-
alias_command "exec:push", "flows:push"
|
90
63
|
alias_command "push", "flows:push"
|
91
64
|
|
92
65
|
|
@@ -127,8 +100,6 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
127
100
|
end
|
128
101
|
|
129
102
|
end
|
130
|
-
|
131
|
-
alias_command "pull_to", "flows:pull"
|
132
103
|
alias_command "pull", "flows:pull"
|
133
104
|
|
134
105
|
|
@@ -177,7 +148,7 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
177
148
|
# flows:init [LANG] [DIR]
|
178
149
|
#
|
179
150
|
# initializes a new executable in DIR
|
180
|
-
# defaults to
|
151
|
+
# [LANG] defaults to ruby, and [DIR] to the current directory
|
181
152
|
#
|
182
153
|
#Examples:
|
183
154
|
#
|
@@ -197,10 +168,8 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
197
168
|
|
198
169
|
|
199
170
|
end
|
200
|
-
alias_command "exec:init", "flows:init"
|
201
171
|
|
202
|
-
|
203
|
-
|
172
|
+
|
204
173
|
|
205
174
|
# flows:test [TEST_DATASET_ID]
|
206
175
|
#
|
@@ -208,8 +177,8 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
208
177
|
#
|
209
178
|
# --config CONFIG_FILE # use the given config file
|
210
179
|
# --output OUTPUT_FILE # writes sink output to a file
|
211
|
-
# --wait MAX
|
212
|
-
# --batches BATCHES
|
180
|
+
# --wait MAX # max time to spend on each operation (default 10 seconds)
|
181
|
+
# --batches BATCHES # number of batches to emit (default 1)
|
213
182
|
#
|
214
183
|
def test
|
215
184
|
|
@@ -529,28 +498,6 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
529
498
|
alias_command "test", "flows:test"
|
530
499
|
|
531
500
|
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
# flows:status ID
|
536
|
-
#
|
537
|
-
# gets the flows status
|
538
|
-
#
|
539
|
-
# --config CONFIG_FILE # use the given config file
|
540
|
-
#
|
541
|
-
def status
|
542
|
-
|
543
|
-
id = options[:id] || shift_argument
|
544
|
-
|
545
|
-
display api.flows.get(id)
|
546
|
-
|
547
|
-
end
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
501
|
# flows:kill ID
|
555
502
|
#
|
556
503
|
# kills the given flow
|
@@ -616,6 +563,7 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
616
563
|
end
|
617
564
|
alias_command "info", "flows:info"
|
618
565
|
|
566
|
+
|
619
567
|
def self.get_info(cmd, info_file, options = {})
|
620
568
|
response = `#{cmd}`
|
621
569
|
if($?.exitstatus == 1)
|
@@ -646,9 +594,12 @@ class Zillabyte::Command::Flows < Zillabyte::Command::Base
|
|
646
594
|
|
647
595
|
flow_info
|
648
596
|
end
|
649
|
-
|
597
|
+
|
598
|
+
|
650
599
|
private
|
651
600
|
|
601
|
+
|
602
|
+
|
652
603
|
|
653
604
|
def command(arg="--execute_live", ignore_stderr = false)
|
654
605
|
|
data/lib/zillabyte/cli/help.rb
CHANGED
@@ -73,6 +73,17 @@ private
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
def summary_for_aliases(command_aliases)
|
77
|
+
a_size = longest(command_aliases.map { |al,al_to| al })
|
78
|
+
a_to_size = longest(command_aliases.map { |al,al_to| al_to })
|
79
|
+
command_aliases.sort_by{|k,v| v}.each do |command_alias, alias_to|
|
80
|
+
if command_alias.include?("-") or command_alias.include?(":")
|
81
|
+
next #skip -h, -help and live-run etc.
|
82
|
+
end
|
83
|
+
puts command_alias.ljust(a_size) + " --> " + alias_to.ljust(a_to_size + 2) + " # " + commands[alias_to][:summary]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
76
87
|
def help_for_root
|
77
88
|
puts "Usage: zillabyte COMMAND [command-specific-options]"
|
78
89
|
puts
|
@@ -84,6 +95,10 @@ private
|
|
84
95
|
puts
|
85
96
|
summary_for_namespaces(additional_namespaces)
|
86
97
|
puts
|
98
|
+
puts "Useful aliases: "
|
99
|
+
puts
|
100
|
+
summary_for_aliases(Zillabyte::Command.command_aliases)
|
101
|
+
puts
|
87
102
|
puts "For help getting started, visit http://docs.zillabyte.com."
|
88
103
|
puts
|
89
104
|
end
|
@@ -134,4 +149,4 @@ private
|
|
134
149
|
error "#{name} is not a zillabyte command. See `zillabyte help`."
|
135
150
|
end
|
136
151
|
end
|
137
|
-
end
|
152
|
+
end
|
data/lib/zillabyte/cli/logs.rb
CHANGED
data/lib/zillabyte/cli/query.rb
CHANGED
@@ -9,8 +9,8 @@ class Zillabyte::Command::Query < Zillabyte::Command::Base
|
|
9
9
|
# executes queries against the zillabyte corpus
|
10
10
|
#
|
11
11
|
# -o, --offset OFFSET # skips to the offset (default: 0)
|
12
|
-
# -l, --limit LIMIT
|
13
|
-
# -t, --tail
|
12
|
+
# -l, --limit LIMIT # sets the result limit (default: 20)
|
13
|
+
# -t, --tail # continuously watches for new results
|
14
14
|
#
|
15
15
|
#Examples:
|
16
16
|
#
|
@@ -76,7 +76,6 @@ class Zillabyte::Command::Query < Zillabyte::Command::Base
|
|
76
76
|
end while (tail && sleep(5))
|
77
77
|
|
78
78
|
end
|
79
|
-
|
80
79
|
alias_command "sxp", "query:sxp"
|
81
80
|
|
82
81
|
|
@@ -87,10 +86,10 @@ class Zillabyte::Command::Query < Zillabyte::Command::Base
|
|
87
86
|
# executes queries against the zillabyte corpus
|
88
87
|
#
|
89
88
|
# -o, --offset OFFSET # skips to the offset (default: 0)
|
90
|
-
# -l, --limit LIMIT
|
91
|
-
# -t, --tail
|
92
|
-
# -s, --since SINCE
|
93
|
-
# --no_truncation
|
89
|
+
# -l, --limit LIMIT # sets the result limit (default: 20)
|
90
|
+
# -t, --tail # continuously watches for new results
|
91
|
+
# -s, --since SINCE # newer records since
|
92
|
+
# --no_truncation # doesn't truncate long strings
|
94
93
|
#
|
95
94
|
#Examples:
|
96
95
|
#
|
@@ -171,7 +170,6 @@ class Zillabyte::Command::Query < Zillabyte::Command::Base
|
|
171
170
|
end while (tail && sleep(5))
|
172
171
|
|
173
172
|
end
|
174
|
-
|
175
173
|
alias_command "sql", "query:sql"
|
176
174
|
|
177
175
|
|
@@ -7,16 +7,18 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
|
|
7
7
|
|
8
8
|
# relations
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# lists your custom relations
|
11
|
+
#
|
11
12
|
def index
|
12
13
|
self.list
|
13
14
|
end
|
15
|
+
|
14
16
|
|
15
17
|
|
16
|
-
# relations
|
17
|
-
#
|
18
|
-
# lists your custom relations
|
18
|
+
# relations
|
19
19
|
#
|
20
|
+
# lists your custom relations
|
21
|
+
#
|
20
22
|
def list
|
21
23
|
|
22
24
|
response = api.request(
|
@@ -36,13 +38,8 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
|
|
36
38
|
display "relations:\n" + Terminal::Table.new(:headings => headings, :rows => rows).to_s
|
37
39
|
display "Total number of relations: "+rows.length.to_s
|
38
40
|
|
39
|
-
|
40
41
|
end
|
41
|
-
|
42
|
-
|
43
|
-
alias_command "list", "relations:list"
|
44
|
-
alias_command "relations:list", "relations:list"
|
45
|
-
alias_command "relation:list", "relations:list"
|
42
|
+
alias_command "rl:list", "relations:list"
|
46
43
|
|
47
44
|
|
48
45
|
# relations:delete ID
|
@@ -72,9 +69,9 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
|
|
72
69
|
|
73
70
|
|
74
71
|
end
|
72
|
+
alias_command "rl:delete", "relations:delete"
|
75
73
|
|
76
|
-
|
77
|
-
# relations:status RELATION
|
74
|
+
# relations:status ID
|
78
75
|
#
|
79
76
|
# shows status of a relation
|
80
77
|
#
|
@@ -118,15 +115,17 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
|
|
118
115
|
|
119
116
|
|
120
117
|
end
|
121
|
-
|
118
|
+
alias_command "rl:status", "relations:status"
|
122
119
|
|
123
120
|
|
124
121
|
# relations:create NAME
|
125
122
|
#
|
126
123
|
# creates a new relation
|
127
124
|
#
|
128
|
-
# --schema SCHEMA
|
129
|
-
# --public
|
125
|
+
# --schema SCHEMA # a JSON array of column types
|
126
|
+
# --public # Make the relation public
|
127
|
+
# --file # A data file
|
128
|
+
# --type # type of data file [csv (default), xlsx]
|
130
129
|
#
|
131
130
|
def create
|
132
131
|
|
@@ -155,11 +154,7 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
|
|
155
154
|
end
|
156
155
|
|
157
156
|
end
|
158
|
-
|
159
|
-
#alias_command "upload", "data:upload"
|
160
|
-
alias_command "relations:upload", "relations:create"
|
161
|
-
alias_command "relation:upload", "relations:create"
|
162
|
-
|
157
|
+
alias_command "rl:create", "relations:create"
|
163
158
|
|
164
159
|
|
165
160
|
# relations:append ID FILE
|
@@ -175,19 +170,20 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
|
|
175
170
|
type = options[:type]
|
176
171
|
|
177
172
|
error "no id given" if id.nil?
|
178
|
-
error "no
|
173
|
+
error "no file given" if file.nil?
|
179
174
|
type ||= File.extname(file).gsub(".", "")
|
180
175
|
|
181
|
-
|
182
|
-
rows = sanity_check_file(file,type,
|
176
|
+
relation = self.api.data.get(id)
|
177
|
+
rows = sanity_check_file(file,type,relation)
|
183
178
|
|
184
|
-
|
185
|
-
res = self.api.data.append(id, {:file => file})
|
179
|
+
res = self.api.data.append(id, {:rows => rows})
|
186
180
|
display "relation #{id} appended"
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
|
181
|
+
|
182
|
+
end
|
183
|
+
alias_command "append", "relations:append"
|
184
|
+
alias_command "rl:append", "relations:append"
|
185
|
+
|
186
|
+
|
191
187
|
# relations:show ID
|
192
188
|
#
|
193
189
|
# shows raw data in a relation. run 'queries' for more elaborate functionality
|
@@ -243,41 +239,12 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
|
|
243
239
|
end
|
244
240
|
|
245
241
|
end
|
246
|
-
|
247
|
-
alias_command "relations:show", "relations:show"
|
248
|
-
alias_command "relation:show", "relations:show"
|
249
|
-
|
250
|
-
# relations:test NAME FILE
|
251
|
-
#
|
252
|
-
# creates test relation NAME and uploads FILE to NAME
|
253
|
-
#
|
254
|
-
def test
|
255
|
-
name = options[:name] || shift_argument
|
256
|
-
error "no name given" if name.nil?
|
257
|
-
|
258
|
-
file = options[:file] || shift_argument
|
259
|
-
error "no file given" if file.nil?
|
242
|
+
alias_command "rl:show", "relations:show"
|
260
243
|
|
261
|
-
schema = options[:schema]
|
262
|
-
relations = options[:relations]
|
263
|
-
is_public = options[:public] || false
|
264
|
-
|
265
|
-
hash = set_relation_properties(schema,relations,is_public)
|
266
|
-
res = api.data.create name, hash
|
267
244
|
|
268
|
-
|
269
|
-
type ||= File.extname(file).gsub(".", "")
|
245
|
+
private
|
270
246
|
|
271
|
-
id = res['id']
|
272
|
-
dataset = self.api.data.get(id)
|
273
|
-
rows = sanity_check_file(file,type,dataset)
|
274
|
-
|
275
|
-
#res = self.api.data.append(id, {:row => rows,:for_test => 1})
|
276
|
-
res = self.api.data.append(id, {:file => file,:for_test => 1})
|
277
|
-
display "relation (for test) #{id} appended"
|
278
|
-
end
|
279
247
|
|
280
|
-
private
|
281
248
|
|
282
249
|
def set_relation_properties(schema,is_public)
|
283
250
|
valid_types=["STRING", "NUMERIC", "FLOAT"]
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zillabyte-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- zillabyte
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-15 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rake
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: netrc
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rest-client
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: excon
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ~>
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: terminal-table
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ~>
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - ~>
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -83,6 +94,7 @@ dependencies:
|
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: activesupport
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - ~>
|
88
100
|
- !ruby/object:Gem::Version
|
@@ -90,6 +102,7 @@ dependencies:
|
|
90
102
|
type: :runtime
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
107
|
- - ~>
|
95
108
|
- !ruby/object:Gem::Version
|
@@ -97,6 +110,7 @@ dependencies:
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: bundler
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
115
|
- - ~>
|
102
116
|
- !ruby/object:Gem::Version
|
@@ -104,6 +118,7 @@ dependencies:
|
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
123
|
- - ~>
|
109
124
|
- !ruby/object:Gem::Version
|
@@ -111,6 +126,7 @@ dependencies:
|
|
111
126
|
- !ruby/object:Gem::Dependency
|
112
127
|
name: colorize
|
113
128
|
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
114
130
|
requirements:
|
115
131
|
- - ~>
|
116
132
|
- !ruby/object:Gem::Version
|
@@ -118,6 +134,7 @@ dependencies:
|
|
118
134
|
type: :runtime
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
121
138
|
requirements:
|
122
139
|
- - ~>
|
123
140
|
- !ruby/object:Gem::Version
|
@@ -125,6 +142,7 @@ dependencies:
|
|
125
142
|
- !ruby/object:Gem::Dependency
|
126
143
|
name: chronic
|
127
144
|
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
128
146
|
requirements:
|
129
147
|
- - ~>
|
130
148
|
- !ruby/object:Gem::Version
|
@@ -132,6 +150,7 @@ dependencies:
|
|
132
150
|
type: :runtime
|
133
151
|
prerelease: false
|
134
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
135
154
|
requirements:
|
136
155
|
- - ~>
|
137
156
|
- !ruby/object:Gem::Version
|
@@ -139,6 +158,7 @@ dependencies:
|
|
139
158
|
- !ruby/object:Gem::Dependency
|
140
159
|
name: ascii_charts
|
141
160
|
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
142
162
|
requirements:
|
143
163
|
- - ~>
|
144
164
|
- !ruby/object:Gem::Version
|
@@ -146,6 +166,7 @@ dependencies:
|
|
146
166
|
type: :runtime
|
147
167
|
prerelease: false
|
148
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
149
170
|
requirements:
|
150
171
|
- - ~>
|
151
172
|
- !ruby/object:Gem::Version
|
@@ -153,6 +174,7 @@ dependencies:
|
|
153
174
|
- !ruby/object:Gem::Dependency
|
154
175
|
name: indentation
|
155
176
|
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
156
178
|
requirements:
|
157
179
|
- - ~>
|
158
180
|
- !ruby/object:Gem::Version
|
@@ -160,6 +182,7 @@ dependencies:
|
|
160
182
|
type: :runtime
|
161
183
|
prerelease: false
|
162
184
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
163
186
|
requirements:
|
164
187
|
- - ~>
|
165
188
|
- !ruby/object:Gem::Version
|
@@ -226,25 +249,26 @@ files:
|
|
226
249
|
homepage: http://www.zillabyte.com
|
227
250
|
licenses:
|
228
251
|
- MIT
|
229
|
-
metadata: {}
|
230
252
|
post_install_message:
|
231
253
|
rdoc_options: []
|
232
254
|
require_paths:
|
233
255
|
- lib
|
234
256
|
required_ruby_version: !ruby/object:Gem::Requirement
|
257
|
+
none: false
|
235
258
|
requirements:
|
236
259
|
- - ! '>='
|
237
260
|
- !ruby/object:Gem::Version
|
238
261
|
version: '0'
|
239
262
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
|
+
none: false
|
240
264
|
requirements:
|
241
265
|
- - ! '>='
|
242
266
|
- !ruby/object:Gem::Version
|
243
267
|
version: '0'
|
244
268
|
requirements: []
|
245
269
|
rubyforge_project:
|
246
|
-
rubygems_version:
|
270
|
+
rubygems_version: 1.8.25
|
247
271
|
signing_key:
|
248
|
-
specification_version:
|
272
|
+
specification_version: 3
|
249
273
|
summary: The Official Zillabyte CLI Gem
|
250
274
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
MjgyYWY1MTY5MmQ1ZTRhZWMyNTEyMzExMWIwODViZjc2NzFjYzZkZQ==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NDNjOTk0MzU3NmNkZDZiMjIzYmEwYmQ1YjQzODM2M2QxZDU1M2E5Yg==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZWU1MTJjZmRhMGIwM2U2YmJlMmIxYjQyOTk1ZmE0Njk3NDZmNzE5OGFhNjZh
|
10
|
-
NjQ4NzM2M2VmOTllYTUxNjNiNGU1MjQxNjIyMjIzM2IzMjI5ODkyNmQ0YTIx
|
11
|
-
ZDkzZjA5OTZlMDdkMDY5MzFjNTllZTBkZWY5MWNhNDk2ZjQxODc=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzIzM2I1OGU0YTA4ZGYwMDYzZDZlMTU0NzBjNTY3N2RjNzc5ZGUxMjNjZTY2
|
14
|
-
MGYwNzAzNDFiYWQwZWYxOTc3YTljNjhlY2NhNjU0NWRhNmIxNzIzMTA4ZWRi
|
15
|
-
MTZkNGUxZjNmNjNmYjI4YzczNzk2MGNmOGJmNTAwMTQ2NDYyZGE=
|