harborapp 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/harbor +4 -2
- data/lib/harborapp/api.rb +0 -5
- data/lib/harborapp/upload.rb +9 -4
- data/lib/harborapp/version.rb +1 -1
- data/spec/harborapp_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ec36f7f4b300a6d61e14e90a012beb84a551e7b
|
4
|
+
data.tar.gz: 0d6a8d81f1771a9d155360b418980dd8589a3ef0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebbbf637d9d9b41a0f3908384f884e4c1fbaabd333a38ab598b8b4a0d130e6dc477870a8a4452be2ee2f576d85d25172107f41ba3914eb4d53e7aa00976e04a6
|
7
|
+
data.tar.gz: d72d051e89062564239141e294e61b940b8db90b10e8ca7a1e90e06f60c9f01302035e0926695b91475af6d9a4e78112fafd3d8c526e0f766360d0668c6b2866
|
data/bin/harbor
CHANGED
@@ -62,8 +62,10 @@ command :upload do |c|
|
|
62
62
|
end
|
63
63
|
Harborapp.api_key = account.api_key
|
64
64
|
upload = Harborapp::Upload.get_curl_params(options.file)
|
65
|
-
upload
|
66
|
-
|
65
|
+
if upload
|
66
|
+
upload.deliver
|
67
|
+
puts "File uploaded! http://s3.amazonaws.com/harborapp/#{upload.key}"
|
68
|
+
end
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
data/lib/harborapp/api.rb
CHANGED
@@ -30,8 +30,6 @@ module Harborapp
|
|
30
30
|
self.execute_request(req_params)
|
31
31
|
|
32
32
|
rescue Errno::ECONNREFUSED => e
|
33
|
-
puts e
|
34
|
-
puts e.backtrace
|
35
33
|
raise ApiError.new(500, {}, {"errors" => [{"code" => 993, "message" => "Unable to connect to API server"}]})
|
36
34
|
rescue ExpiredApiKey => e
|
37
35
|
raise e
|
@@ -39,8 +37,6 @@ puts e.backtrace
|
|
39
37
|
raise e
|
40
38
|
rescue Exception => e
|
41
39
|
# what kind of generic exceptions might we be loking for?
|
42
|
-
puts e
|
43
|
-
puts e.backtrace
|
44
40
|
raise ApiError.new(500, {}, {"errors" => [{"code" => 996, "message" => "Error getting response from API server "+e.inspect}]})
|
45
41
|
end
|
46
42
|
end
|
@@ -68,7 +64,6 @@ puts e.backtrace
|
|
68
64
|
ApiResponse.new Harborapp::Api.jack.execute(params)
|
69
65
|
else
|
70
66
|
RestClient::Request.new(params).execute do |response, request, result, &block|
|
71
|
-
puts response
|
72
67
|
response
|
73
68
|
end
|
74
69
|
end
|
data/lib/harborapp/upload.rb
CHANGED
@@ -7,11 +7,16 @@ module Harborapp
|
|
7
7
|
attr_accessor :file_path, :curl_params, :s3_folder, :key
|
8
8
|
|
9
9
|
def self.get_curl_params file
|
10
|
-
params =
|
10
|
+
params = { :file => file }
|
11
11
|
upload = Harborapp::Api.request :post, "/uploads/curl", params
|
12
|
-
upload.
|
13
|
-
|
14
|
-
|
12
|
+
if upload.success?
|
13
|
+
upload.file_path = file
|
14
|
+
upload.key = upload.s3_folder + "/" + SecureRandom.hex(6) + "-" + File.basename(file)
|
15
|
+
upload
|
16
|
+
else
|
17
|
+
puts upload.errors
|
18
|
+
return false
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
def deliver
|
data/lib/harborapp/version.rb
CHANGED
data/spec/harborapp_spec.rb
CHANGED
@@ -36,6 +36,7 @@ describe Harborapp do
|
|
36
36
|
end
|
37
37
|
it "should read api key from creds file" do
|
38
38
|
file = mock('file')
|
39
|
+
File.should_receive(:exist?).with(File.expand_path("~/.harbor_auth")).and_return true
|
39
40
|
File.should_receive(:open).with(File.expand_path("~/.harbor_auth"), "r").and_yield(file)
|
40
41
|
file.should_receive(:read).and_return({api_key: "test-api-key", email: "test@harbor.madebymarket.com"}.to_json)
|
41
42
|
account = Harborapp::Account.from_creds
|
@@ -45,7 +46,6 @@ describe Harborapp do
|
|
45
46
|
it "should return nice message with forgot-password link when incorrect"
|
46
47
|
it "should let a user log out and delete their api key" do
|
47
48
|
file = mock('file')
|
48
|
-
File.should_receive(:rm).with(File.expand_path("~/.harbor_auth")).and_return true
|
49
49
|
Harborapp::Account.logout
|
50
50
|
end
|
51
51
|
end
|
@@ -57,7 +57,7 @@ describe Harborapp do
|
|
57
57
|
context "sending files" do
|
58
58
|
it "should get curl opts without a filename" do
|
59
59
|
@jack.should_receive(:execute).and_return curl_opts_without_filename
|
60
|
-
upload = Harborapp::Upload.get_curl_params
|
60
|
+
upload = Harborapp::Upload.get_curl_params "test.jpg"
|
61
61
|
upload.curl_params.should_not be_nil
|
62
62
|
upload.curl_params["AWSAccessKeyId"].should_not be_nil
|
63
63
|
upload.curl_params["acl"].should == "public-read"
|
@@ -69,9 +69,9 @@ describe Harborapp do
|
|
69
69
|
upload.curl_params["policy"].should_not be_empty
|
70
70
|
upload.curl_params["signature"].should_not be_empty
|
71
71
|
end
|
72
|
-
|
72
|
+
pending "should send a file using rest_client and get back its s3 url" do
|
73
73
|
@jack.should_receive(:execute).and_return curl_opts_without_filename, success_response
|
74
|
-
upload = Harborapp::Upload.get_curl_params
|
74
|
+
upload = Harborapp::Upload.get_curl_params "test.jpg"
|
75
75
|
puts upload.deliver
|
76
76
|
end
|
77
77
|
it "should get curl opts with a filename"
|