big-panda 0.0.1 → 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 65945288a6318aa67f91cde206b2e3ec94164ab5
4
+ data.tar.gz: 6a088f6fdb3336b07732f878e01aa6ccd978d4b6
5
+ SHA512:
6
+ metadata.gz: 8afde04d3d10fe58119ffab06569cdb40c85fd6deaa7ddb2e2befe12a3f5a154b30ba0f9d8bd137f9d5125cc9983f6da1b2cb1aa223f40e66d0de119b0a34df9
7
+ data.tar.gz: 45ae0bd778d9b55983ad992da28c8d9809739c51441a24f6f614c29c3dff184641c4062d6147875f6eb01c1bb43c04d1d692fc1181ada12b0f98d5a438c937be
data/.rvmrc CHANGED
@@ -6,7 +6,7 @@
6
6
  # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
7
  # Only full ruby name is supported here, for short names use:
8
8
  # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p327@bigp_anda"
9
+ environment_id="ruby-1.9.3-p392@big_panda"
10
10
 
11
11
  # Uncomment the following lines if you want to verify rvm version per project
12
12
  # rvmrc_rvm_version="1.17.0 (master)" # 1.10.1 seams as a safe start
data/README.md CHANGED
@@ -58,6 +58,22 @@ panda.finish_deployment({ component: 'html-editor', version: '123',
58
58
  # => {"status"=>"created", "id"=>"513383e021e4d3fc5800d02d"}
59
59
  ```
60
60
 
61
+ ### SSL Options
62
+ You can pass ssl options to BigPanda::Client.new
63
+ ```ruby
64
+ BigPanda::Client.new(access_token: 'my-access-token', ssl: {ssl: {ca_file: '/my/cert.pem'}})
65
+ ```
66
+ Avalible SSL options (same as in net/http):
67
+ ```
68
+ :client_cert
69
+ :client_key
70
+ :ca_file
71
+ :ca_path
72
+ :verify_depth
73
+ :version
74
+ ```
75
+
76
+
61
77
 
62
78
  ## Contributing
63
79
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["man.gregory@gmail.com"]
11
11
  gem.description = %q{A Ruby interface to the Big Panda API}
12
12
  gem.summary = gem.description
13
- gem.homepage = ""
13
+ gem.homepage = "https://github.com/gregory-m/big-panda"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,5 +1,6 @@
1
1
  require 'big_panda/client/connection'
2
2
  require 'big_panda/client/request'
3
+ require 'big_panda/client/errors'
3
4
  require 'big_panda/client/deployment'
4
5
 
5
6
  module BigPanda
@@ -9,7 +10,7 @@ module BigPanda
9
10
  include Request
10
11
  include Deployment
11
12
 
12
- attr_reader :access_token, :target_url
13
+ attr_reader :access_token, :target_url, :ssl
13
14
 
14
15
  def initialize(options={})
15
16
  @target_url = BigPanda::DEFAULT_TARGET_URL
@@ -17,7 +18,7 @@ module BigPanda
17
18
  mandatory_options = [ :access_token ]
18
19
  check_mandatory_options(options, mandatory_options)
19
20
  @access_token = options[:access_token]
20
-
21
+ @ssl = options[:ssl] ? options[:ssl] : {}
21
22
  end
22
23
  end
23
24
  end
@@ -6,9 +6,9 @@ module BigPanda
6
6
  private
7
7
 
8
8
  def connection
9
- Faraday.new(url: target_url) do |faraday|
9
+ Faraday.new(url: target_url, ssl: self.ssl) do |faraday|
10
10
  faraday.use FaradayMiddleware::EncodeJson
11
- faraday.use FaradayMiddleware::ParseJson
11
+ faraday.use FaradayMiddleware::ParseJson, content_type: 'application/json'
12
12
  faraday.adapter Faraday.default_adapter
13
13
  end
14
14
  end
@@ -0,0 +1,5 @@
1
+ module BigPanda
2
+ class Client
3
+ class Unauthorized < RuntimeError; end
4
+ end
5
+ end
@@ -14,6 +14,8 @@ module BigPanda
14
14
  request.headers['Accept'] = "application/json"
15
15
  end
16
16
 
17
+ raise Unauthorized if response.status == 401
18
+
17
19
  response.body
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module BigPanda
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe BigPanda::Client::Connection do
4
+ let(:access_token) { 'my-access-token' }
5
+
6
+ context "With ssl options" do
7
+ let(:options) { { access_token: access_token, ssl: ssl_options } }
8
+ let(:ssl_options) { { ca_file: '/tmp/my.pem' } }
9
+
10
+ subject { BigPanda::Client.new(options) }
11
+
12
+
13
+ it "Pass SSL options to faraday" do
14
+ conection = subject.send(:connection)
15
+ conection.ssl.should eq(ssl_options)
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+ describe BigPanda::Client::Deployment do
3
+ let(:access_token) { 'bad-access-token' }
4
+ subject { BigPanda::Client.new(access_token: access_token) }
5
+
6
+ describe ".post" do
7
+ context "on Unauthorized response", vcr: { cassette_name: 'unauthorized' } do
8
+ it "raise BigPanda::Client::Unauthorized" do
9
+ expect {
10
+ subject.post('/test')
11
+ }.to raise_error(BigPanda::Client::Unauthorized)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.bigpanda.io/test
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.6
12
+ Authorization:
13
+ - Bearer bad-access-token
14
+ Accept:
15
+ - application/json
16
+ Content-Length:
17
+ - '0'
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ Server:
26
+ - nginx/1.2.7
27
+ Date:
28
+ - Sat, 16 Mar 2013 22:03:50 GMT
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ X-Powered-By:
34
+ - Express
35
+ Www-Authenticate:
36
+ - Bearer realm="Users", error="invalid_token"
37
+ body:
38
+ encoding: UTF-8
39
+ string: Unauthorized
40
+ http_version:
41
+ recorded_at: Sat, 16 Mar 2013 22:03:50 GMT
42
+ recorded_with: VCR 2.4.0
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: big-panda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gregory Man
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-03 00:00:00.000000000 Z
11
+ date: 2013-03-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: multi_json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: faraday_middleware
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: webmock
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: vcr
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -111,53 +100,53 @@ files:
111
100
  - lib/big_panda/client.rb
112
101
  - lib/big_panda/client/connection.rb
113
102
  - lib/big_panda/client/deployment.rb
103
+ - lib/big_panda/client/errors.rb
114
104
  - lib/big_panda/client/request.rb
115
105
  - lib/big_panda/helper.rb
116
106
  - lib/big_panda/version.rb
107
+ - spec/big_panda/client/connection_spec.rb
117
108
  - spec/big_panda/client/deployment_spec.rb
109
+ - spec/big_panda/client/request_spec.rb
118
110
  - spec/big_panda/client_spec.rb
119
111
  - spec/big_panda/helper_spec.rb
120
112
  - spec/fixtures/cassettes/finish_deployment.yml
121
113
  - spec/fixtures/cassettes/finish_deployment_with_optional.yml
122
114
  - spec/fixtures/cassettes/start_deployment.yml
123
115
  - spec/fixtures/cassettes/start_deployment_with_optional.yml
116
+ - spec/fixtures/cassettes/unauthorized.yml
124
117
  - spec/spec_helper.rb
125
- homepage: ''
118
+ homepage: https://github.com/gregory-m/big-panda
126
119
  licenses: []
120
+ metadata: {}
127
121
  post_install_message:
128
122
  rdoc_options: []
129
123
  require_paths:
130
124
  - lib
131
125
  required_ruby_version: !ruby/object:Gem::Requirement
132
- none: false
133
126
  requirements:
134
- - - ! '>='
127
+ - - '>='
135
128
  - !ruby/object:Gem::Version
136
129
  version: '0'
137
- segments:
138
- - 0
139
- hash: -4393814194179670104
140
130
  required_rubygems_version: !ruby/object:Gem::Requirement
141
- none: false
142
131
  requirements:
143
- - - ! '>='
132
+ - - '>='
144
133
  - !ruby/object:Gem::Version
145
134
  version: '0'
146
- segments:
147
- - 0
148
- hash: -4393814194179670104
149
135
  requirements: []
150
136
  rubyforge_project:
151
- rubygems_version: 1.8.24
137
+ rubygems_version: 2.0.3
152
138
  signing_key:
153
- specification_version: 3
139
+ specification_version: 4
154
140
  summary: A Ruby interface to the Big Panda API
155
141
  test_files:
142
+ - spec/big_panda/client/connection_spec.rb
156
143
  - spec/big_panda/client/deployment_spec.rb
144
+ - spec/big_panda/client/request_spec.rb
157
145
  - spec/big_panda/client_spec.rb
158
146
  - spec/big_panda/helper_spec.rb
159
147
  - spec/fixtures/cassettes/finish_deployment.yml
160
148
  - spec/fixtures/cassettes/finish_deployment_with_optional.yml
161
149
  - spec/fixtures/cassettes/start_deployment.yml
162
150
  - spec/fixtures/cassettes/start_deployment_with_optional.yml
151
+ - spec/fixtures/cassettes/unauthorized.yml
163
152
  - spec/spec_helper.rb