slapshot 0.0.8 → 0.0.9

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/slapshot CHANGED
@@ -50,15 +50,6 @@ command :search do |c|
50
50
  end
51
51
  end
52
52
 
53
- desc 'Describe upload here'
54
- arg_name 'Describe arguments to upload here'
55
- command :upload do |c|
56
- c.action do |global_options,options,args|
57
- puts "upload command ran"
58
- @sc.upload args[0]
59
- end
60
- end
61
-
62
53
  desc 'Login to the API and generate a token'
63
54
  arg_name 'Pass in the username and password to login and generate a token'
64
55
 
@@ -77,8 +68,13 @@ command :login do |c|
77
68
  password = STDIN.noecho(&:gets)
78
69
  puts
79
70
 
80
- token = create_token(url, username, password)
81
- puts "Generated token: #{token} and stored it in #{get_token_file}"
71
+ token = create_token(url, username.strip, password.strip)
72
+
73
+ if token
74
+ puts "Generated token: #{token} and stored it in #{get_token_file}"
75
+ else
76
+ puts "Could not authenticate the given username and password"
77
+ end
82
78
 
83
79
  else
84
80
  puts "Found existing file at #{get_token_file}"
data/lib/slapshot/main.rb CHANGED
@@ -10,7 +10,12 @@ def get_token_file
10
10
  end
11
11
 
12
12
  def create_token(url, username, password)
13
- token = RestClient.get url + '/login', :params => { :u => username, :p => password }
13
+
14
+ begin
15
+ token = RestClient.get url + '/login', :params => { :u => username, :p => password }
16
+ rescue RestClient::BadRequest => e
17
+ return nil
18
+ end
14
19
 
15
20
  File.open(get_token_file, 'w') {|f|
16
21
  f.write(token)
@@ -63,39 +68,6 @@ class Appshot
63
68
 
64
69
  json_response['docs']
65
70
  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
99
71
 
100
72
  def to_table(result)
101
73
  Formatador.display_table(result)
@@ -1,3 +1,3 @@
1
1
  module Slapshot
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
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.8
4
+ version: 0.0.9
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-11-22 00:00:00.000000000 Z
12
+ date: 2012-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake