droplet_kit 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/droplet_kit/models/droplet.rb +23 -0
- data/lib/droplet_kit/version.rb +1 -1
- data/spec/lib/droplet_kit/models/droplet_spec.rb +32 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a7043fefd42f5297c3f91fa3033c30a47ff86fd
|
4
|
+
data.tar.gz: 2dfc49f1230133e864b1b9373a6caee0c7b9c5e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da1218af357c9a2c1ef5cd2650d583cd2899b4895760747438054e8d353de5c1479a186427ef3711c2f541333d189a19d6c5fc7aff193cd0b08393018514f004
|
7
|
+
data.tar.gz: f37b970dd2c05bad03039fbaadd98736c70e4c889014f9e01a5ddcdf11d3b5150196ba7a6da908f028b104c7232b8089d4b2d3cf3e2b32f0500a8b9032300364
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### Version 1.1.2
|
2
|
+
|
3
|
+
* Add `public_ip` and `private_ip` to easily get the IP address on `DropletKit::Droplet` objects returned.
|
4
|
+
|
5
|
+
### Version 1.1.1
|
6
|
+
|
7
|
+
* Use size_slug instead of size object in droplet mappings.
|
8
|
+
|
1
9
|
### Version 1.1.0
|
2
10
|
|
3
11
|
* Changing kernels is now `client.droplet_actions.change_kernel(kernel: 'name', droplet_id: 123)` instead of `droplet_actions.kernel()`.
|
@@ -13,6 +13,29 @@ module DropletKit
|
|
13
13
|
attribute :ipv6
|
14
14
|
attribute :user_data
|
15
15
|
attribute :private_networking
|
16
|
+
|
17
|
+
def public_ip
|
18
|
+
network = network_for(:v4, 'public')
|
19
|
+
network && network.ip_address
|
20
|
+
end
|
21
|
+
|
22
|
+
def private_ip
|
23
|
+
network = network_for(:v4, 'private')
|
24
|
+
network && network.ip_address
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def network_for(type, publicity)
|
30
|
+
networks = case type
|
31
|
+
when :v4 then self.networks.v4
|
32
|
+
when :v6 then self.networks.v6
|
33
|
+
end
|
34
|
+
|
35
|
+
networks.find do |network|
|
36
|
+
network.type == publicity
|
37
|
+
end
|
38
|
+
end
|
16
39
|
end
|
17
40
|
end
|
18
41
|
|
data/lib/droplet_kit/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe DropletKit::Droplet do
|
4
|
+
let(:droplet_fixture) { api_fixture('droplets/find') }
|
5
|
+
let(:droplet) { DropletKit::DropletMapping.extract_single(droplet_fixture, :read) }
|
6
|
+
|
7
|
+
describe '#public_ip' do
|
8
|
+
it 'returns the public IP for ipv4' do
|
9
|
+
expect(droplet.public_ip).to eq('127.0.0.19')
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when the droplet does not have an IP yet' do
|
13
|
+
it 'returns nil' do
|
14
|
+
droplet.networks.v4.clear
|
15
|
+
expect(droplet.public_ip).to be_nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#private_ip' do
|
21
|
+
it 'returns the public IP for ipv4' do
|
22
|
+
expect(droplet.private_ip).to eq('10.0.0.19')
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the droplet does not have private networking enabled' do
|
26
|
+
it 'returns nil' do
|
27
|
+
droplet.networks.v4.clear
|
28
|
+
expect(droplet.private_ip).to be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droplet_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Ross
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- spec/fixtures/ssh_keys/find.json
|
245
245
|
- spec/fixtures/ssh_keys/update.json
|
246
246
|
- spec/lib/droplet_kit/client_spec.rb
|
247
|
+
- spec/lib/droplet_kit/models/droplet_spec.rb
|
247
248
|
- spec/lib/droplet_kit/paginated_resource_spec.rb
|
248
249
|
- spec/lib/droplet_kit/resources/account_resource_spec.rb
|
249
250
|
- spec/lib/droplet_kit/resources/action_resource_spec.rb
|
@@ -314,6 +315,7 @@ test_files:
|
|
314
315
|
- spec/fixtures/ssh_keys/find.json
|
315
316
|
- spec/fixtures/ssh_keys/update.json
|
316
317
|
- spec/lib/droplet_kit/client_spec.rb
|
318
|
+
- spec/lib/droplet_kit/models/droplet_spec.rb
|
317
319
|
- spec/lib/droplet_kit/paginated_resource_spec.rb
|
318
320
|
- spec/lib/droplet_kit/resources/account_resource_spec.rb
|
319
321
|
- spec/lib/droplet_kit/resources/action_resource_spec.rb
|