slapshot 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/slapshot +10 -14
- data/lib/slapshot/main.rb +33 -0
- data/lib/slapshot/version.rb +1 -1
- metadata +2 -2
data/bin/slapshot
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'gli'
|
3
3
|
require 'slapshot'
|
4
|
+
require 'io/console'
|
4
5
|
|
5
6
|
include GLI::App
|
6
7
|
|
@@ -54,6 +55,7 @@ arg_name 'Describe arguments to upload here'
|
|
54
55
|
command :upload do |c|
|
55
56
|
c.action do |global_options,options,args|
|
56
57
|
puts "upload command ran"
|
58
|
+
@sc.upload args[0]
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
@@ -62,23 +64,20 @@ arg_name 'Pass in the username and password to login and generate a token'
|
|
62
64
|
|
63
65
|
command :login do |c|
|
64
66
|
|
65
|
-
c.desc 'Username (required)'
|
66
|
-
c.flag :u
|
67
|
-
|
68
|
-
c.desc 'Password (required)'
|
69
|
-
c.flag :p
|
70
|
-
|
71
67
|
c.action do |global_options,options,args|
|
72
68
|
|
73
69
|
url = global_options[:url] || ENV['APPSHOT_URL'] || "https://api.appshot.com"
|
74
70
|
|
75
|
-
if !options[:u] or !options[:p]
|
76
|
-
raise "When logging in you need to pass in both a username and a password"
|
77
|
-
end
|
78
|
-
|
79
71
|
if !File.exists? get_token_file
|
80
72
|
|
81
|
-
|
73
|
+
print "Username: "
|
74
|
+
username = gets
|
75
|
+
|
76
|
+
print "Password: "
|
77
|
+
password = STDIN.noecho(&:gets)
|
78
|
+
puts
|
79
|
+
|
80
|
+
token = create_token(url, username, password)
|
82
81
|
puts "Generated token: #{token} and stored it in #{get_token_file}"
|
83
82
|
|
84
83
|
else
|
@@ -134,9 +133,6 @@ end
|
|
134
133
|
on_error do |exception|
|
135
134
|
# Error logic here
|
136
135
|
# return false to skip default error handling
|
137
|
-
|
138
|
-
#puts "exception #{exception.http_body}"
|
139
|
-
|
140
136
|
true
|
141
137
|
end
|
142
138
|
|
data/lib/slapshot/main.rb
CHANGED
@@ -63,6 +63,39 @@ class Appshot
|
|
63
63
|
|
64
64
|
json_response['docs']
|
65
65
|
end
|
66
|
+
|
67
|
+
def upload(file)
|
68
|
+
@api["v1/upload"].put FileStreamer.new(file)
|
69
|
+
end
|
70
|
+
|
71
|
+
class FileStreamer
|
72
|
+
|
73
|
+
def initialize(file)
|
74
|
+
@file = File.open(file)
|
75
|
+
@done = 0
|
76
|
+
end
|
77
|
+
|
78
|
+
def read(n)
|
79
|
+
puts caller
|
80
|
+
@done += n
|
81
|
+
puts done
|
82
|
+
puts @file.size
|
83
|
+
Formatador.redisplay_progressbar(@done, @file.size)
|
84
|
+
end
|
85
|
+
|
86
|
+
def size
|
87
|
+
@file.size
|
88
|
+
end
|
89
|
+
|
90
|
+
def closed?
|
91
|
+
@file.closed?
|
92
|
+
end
|
93
|
+
|
94
|
+
def close
|
95
|
+
@file.close
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
66
99
|
|
67
100
|
def to_table(result)
|
68
101
|
Formatador.display_table(result)
|
data/lib/slapshot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|