harborapp 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 199cd115461389608f5ff97c63560b8f7effd8f8
4
- data.tar.gz: 24dc748ad34b90f80a9b6b3a41fe6c0d16ad0edf
3
+ metadata.gz: 9ec36f7f4b300a6d61e14e90a012beb84a551e7b
4
+ data.tar.gz: 0d6a8d81f1771a9d155360b418980dd8589a3ef0
5
5
  SHA512:
6
- metadata.gz: faa980373e85a076a9911711402a2eb7d9b5b8b74373b54f2be517c5561297cc173c9359e57ba1581faeedd65d4129a6b0ca24f8f17448073a4e1ef29e2f020c
7
- data.tar.gz: 20178141d821e2a330a18bbf8ec262bc9787e468e31dce3bf50dd567e86245554678c1f77a5bb7e9a881577632e063e541b76a3e60847e6b4694aa90afcb5e4f
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.deliver
66
- puts "File uploaded! http://s3.amazonaws.com/harborapp/#{upload.key}"
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
@@ -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 = (file ? {:file => file} : {} )
10
+ params = { :file => file }
11
11
  upload = Harborapp::Api.request :post, "/uploads/curl", params
12
- upload.file_path = file
13
- upload.key = upload.s3_folder + "/" + SecureRandom.hex(6) + "-" + File.basename(file)
14
- upload
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
@@ -1,3 +1,3 @@
1
1
  module Harborapp
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -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
- it "should send a file using rest_client and get back its s3 url" do
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harborapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Thompson