ridley 1.6.0 → 1.7.0

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: 0b0ad1830d01965e26fcc813c5b4ee4357a9734b
4
- data.tar.gz: 747af04209ec46baa7063af405dcf23e87ae3396
3
+ metadata.gz: 216f146a9f80f6c69560dd58c6c8f79a0ccc3a8b
4
+ data.tar.gz: 66c4fed1770ed8d1c2f7493c01280cc01e2f15fe
5
5
  SHA512:
6
- metadata.gz: 45e1c84592692fa67f781d3aa420549a454f77180ac295844be33dbedbb9a9aeffabec72d8ecd08640297217f7bac7a6f5cf42f68326d89692e663b080f12319
7
- data.tar.gz: d2a8d1b0d247cf26ae19f3950a72c9518bbf43cb6fc2ec04fba9749df9ef7e4449bd741005e80f4f085e649b8e6fefc93380d877fd490ca1e0b3836ebef02228
6
+ metadata.gz: 9ec951c99b32ff1588fdc1609f2a1e0bb594f091b0b3bd90757c728ded0a35e154860e66f29ed57c683426c3d188cda1efb963f2e3ab6a31f97ad206382c6b4e
7
+ data.tar.gz: 18d53a050989ae16eae0b8aa6d99c3bc4740b01bffd082bb46cecea04eea05e9e70955c6ee7c34c2d54b8a170ac0c1711f485667cfa294db91ddd3d5f68654a0
@@ -54,5 +54,51 @@ module Ridley
54
54
  attr_hash = Hashie::Mash.from_dotted_path(key, value)
55
55
  self.override_attributes = self.override_attributes.deep_merge(attr_hash)
56
56
  end
57
+
58
+ # Removes a environment default attribute given its dotted path
59
+ # representation. Returns the default attributes of the environment.
60
+ #
61
+ # @param [String] key
62
+ # the dotted path to an attribute
63
+ #
64
+ # @return [Hashie::Mash]
65
+ def delete_default_attribute(key)
66
+ delete_attribute(key, :default)
67
+ end
68
+
69
+ # Removes a environment override attribute given its dotted path
70
+ # representation. Returns the override attributes of the environment.
71
+ #
72
+ # @param [String] key
73
+ # the dotted path to an attribute
74
+ #
75
+ # @return [Hashie::Mash]
76
+ def delete_override_attribute(key)
77
+ delete_attribute(key, :override)
78
+ end
79
+
80
+ private
81
+
82
+ # Deletes an attribute at the given precedence using its dotted-path key.
83
+ #
84
+ # @param [String] key
85
+ # the dotted path to an attribute
86
+ # @param [Symbol] precedence
87
+ # the precedence level to delete the attribute from
88
+ #
89
+ # @return [Hashie::Mash]
90
+ def delete_attribute(key, precedence)
91
+ dotted_path = key.split('.')
92
+ leaf_key = dotted_path.pop
93
+ case precedence
94
+ when :default
95
+ attributes_to_change = self.default_attributes
96
+ when :override
97
+ attributes_to_change = self.override_attributes
98
+ end
99
+ leaf_hash = dotted_path.inject(attributes_to_change) { |hash, element| hash[element] }
100
+ leaf_hash.delete(leaf_key) unless leaf_hash.nil?
101
+ attributes_to_change
102
+ end
57
103
  end
58
104
  end
@@ -210,7 +210,7 @@ module Ridley
210
210
  # @return [Boolean]
211
211
  def connector_port_open?(host, port, wait_time = nil)
212
212
  defer {
213
- timeout(wait_time || PORT_CHECK_TIMEOUT) { Celluloid::IO::TCPSocket.new(host, port).close; true }
213
+ Timeout.timeout(wait_time || PORT_CHECK_TIMEOUT) { Celluloid::IO::TCPSocket.new(host, port).close; true }
214
214
  }
215
215
  rescue Errno::ETIMEDOUT, Timeout::Error, SocketError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::EADDRNOTAVAIL => ex
216
216
  false
@@ -1,3 +1,3 @@
1
1
  module Ridley
2
- VERSION = "1.6.0"
2
+ VERSION = "1.7.0"
3
3
  end
@@ -53,5 +53,51 @@ describe Ridley::EnvironmentObject do
53
53
  subject.default_attributes["deep"]["nested"]["item"].should be_true
54
54
  end
55
55
  end
56
+
57
+ describe "#delete_default_attribute" do
58
+ let(:delete_default_attribute) { subject.delete_default_attribute(attribute_key) }
59
+ let(:attribute_key) { "hello.world" }
60
+
61
+ before do
62
+ subject.set_default_attribute(attribute_key, true)
63
+ end
64
+
65
+ it "removes the default attribute" do
66
+ delete_default_attribute
67
+ expect(subject.default_attributes[:hello][:world]).to be_nil
68
+ end
69
+
70
+ context "when the attribute does not exist" do
71
+ let(:delete_default_attribute) { subject.delete_default_attribute("not.existing") }
72
+
73
+ it "does not delete anything" do
74
+ delete_default_attribute
75
+ expect(subject.default_attributes[:hello][:world]).to be_true
76
+ end
77
+ end
78
+ end
79
+
80
+ describe "#delete_override_attribute" do
81
+ let(:delete_override_attribute) { subject.delete_override_attribute(attribute_key) }
82
+ let(:attribute_key) { "hello.world" }
83
+
84
+ before do
85
+ subject.set_override_attribute(attribute_key, true)
86
+ end
87
+
88
+ it "removes the override attribute" do
89
+ delete_override_attribute
90
+ expect(subject.override_attributes[:hello][:world]).to be_nil
91
+ end
92
+
93
+ context "when the attribute does not exist" do
94
+ let(:delete_override_attribute) { subject.delete_override_attribute("not.existing") }
95
+
96
+ it "does not delete anything" do
97
+ delete_override_attribute
98
+ expect(subject.override_attributes[:hello][:world]).to be_true
99
+ end
100
+ end
101
+ end
56
102
  end
57
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridley
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-14 00:00:00.000000000 Z
12
+ date: 2013-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -452,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
452
452
  version: '0'
453
453
  requirements: []
454
454
  rubyforge_project:
455
- rubygems_version: 2.0.7
455
+ rubygems_version: 2.0.3
456
456
  signing_key:
457
457
  specification_version: 4
458
458
  summary: A reliable Chef API client with a clean syntax