garcun 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/garcon/chef/chef_helpers.rb +9 -12
- data/lib/garcon/chef/coerce/coercer.rb +3 -0
- data/lib/garcon/chef/node.rb +7 -5
- data/lib/garcon/chef/provider/download.rb +2 -30
- data/lib/garcon/chef/resource/base_dsl.rb +53 -0
- data/lib/garcon/chef/secret_bag.rb +2 -1
- data/lib/garcon/chef_inclusions.rb +1 -9
- data/lib/garcon/core_ext/array.rb +1 -1
- data/lib/garcon/core_ext/binding.rb +0 -1
- data/lib/garcon/core_ext/boolean.rb +2 -0
- data/lib/garcon/core_ext/hash.rb +1 -2
- data/lib/garcon/core_ext/kernel.rb +0 -2
- data/lib/garcon/core_ext/module.rb +0 -1
- data/lib/garcon/core_ext/object.rb +0 -3
- data/lib/garcon/core_ext/string.rb +9 -15
- data/lib/garcon/core_ext/struct.rb +0 -1
- data/lib/garcon/core_ext/symbol.rb +0 -1
- data/lib/garcon/core_ext/time.rb +0 -1
- data/lib/garcon/core_ext.rb +0 -4
- data/lib/garcon/exceptions.rb +0 -35
- data/lib/garcon/task/executor.rb +0 -1
- data/lib/garcon/task/ivar.rb +0 -2
- data/lib/garcon/utility/file_helper.rb +88 -1
- data/lib/garcon/utility/retry.rb +0 -3
- data/lib/garcon/utility/timeout.rb +0 -3
- data/lib/garcon/utils.rb +0 -1
- data/lib/garcon/version.rb +1 -1
- data/lib/garcon.rb +1 -4
- data/lib/garcun.rb +1 -3
- metadata +2 -11
- data/lib/garcon/chef/handler/devreporter.rb +0 -127
- data/lib/garcon/chef/resource/resource_name.rb +0 -109
- data/lib/garcon/core_ext/file.rb +0 -127
- data/lib/garcon/core_ext/filetest.rb +0 -62
- data/lib/garcon/core_ext/lazy.rb +0 -222
- data/lib/garcon/core_ext/process.rb +0 -41
- data/lib/garcon/utility/ansi.rb +0 -199
- data/lib/garcon/utility/equalizer.rb +0 -146
- data/lib/garcon/utility/msg_from_god.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2827b045552795cc5a3934823fc34bc6d7c3b1bf
|
4
|
+
data.tar.gz: bf3026b6fdd4ca118e727db751c39f256a66dcae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3858d4a7601ff6afbc09a4a6c1765bad36cccf0c6c9b0ed39e52c098fcf4fceb465172dd49ce54c0249bdce98ff8877fbe4215a971337690fd9b2fe27c7e44f4
|
7
|
+
data.tar.gz: 0bfd59282111449b3c6dfffff1fb696b9711f2f30bb16c5759a4bcd0ab23a77788f9b3350feed5ba675bb80d9492ecdb9b60692ba5ac5aee6ce74070a93dd944
|
@@ -25,19 +25,16 @@ module Garcon
|
|
25
25
|
extend self
|
26
26
|
|
27
27
|
include Chef::Mixin::ShellOut
|
28
|
-
include Garcon::Exceptions
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# node
|
40
|
-
# end
|
29
|
+
def chef_run_context
|
30
|
+
::Chef::RunContext.new(chef_node, nil, nil)
|
31
|
+
end
|
32
|
+
|
33
|
+
def chef_node
|
34
|
+
node = ::Chef::Node.new
|
35
|
+
node.consume_external_attrs(nil, ohai)
|
36
|
+
node
|
37
|
+
end
|
41
38
|
|
42
39
|
# Boolean indicating if the given Ruby Gem is installed.
|
43
40
|
#
|
@@ -30,6 +30,8 @@ module Garcon
|
|
30
30
|
end
|
31
31
|
|
32
32
|
class Coercer
|
33
|
+
# Coerces objects based on the definitions that are registered.
|
34
|
+
#
|
33
35
|
def initialize
|
34
36
|
@coercions = Hash.new do |hash, origin|
|
35
37
|
hash[origin] = Hash.new do |h, target|
|
@@ -101,6 +103,7 @@ module Garcon
|
|
101
103
|
# Calls the coercion.
|
102
104
|
#
|
103
105
|
# @return [Object]
|
106
|
+
#
|
104
107
|
def call(object)
|
105
108
|
@block.call(object, @target)
|
106
109
|
end
|
data/lib/garcon/chef/node.rb
CHANGED
@@ -55,20 +55,22 @@ class Chef
|
|
55
55
|
# not exist, otherwise UndefinedAttributeError is raised.
|
56
56
|
#
|
57
57
|
# @param [Array<String, Symbol>] keys
|
58
|
-
#
|
58
|
+
# The list of keys to kdeep fetch
|
59
59
|
#
|
60
60
|
# @yield optional block to execute if no value is found
|
61
61
|
#
|
62
|
+
# @raise UndefinedAttributeError
|
63
|
+
#
|
62
64
|
# @return [Object]
|
63
65
|
#
|
64
66
|
# @api public
|
65
67
|
def get(*keys, &block)
|
66
|
-
|
68
|
+
keys.reduce(self) do |obj, key|
|
67
69
|
begin
|
68
|
-
|
69
|
-
obj.fetch(
|
70
|
+
key = Integer(key) if obj.is_a? Array
|
71
|
+
obj.fetch(key)
|
70
72
|
rescue ArgumentError, IndexError, NoMethodError
|
71
|
-
break block.call(
|
73
|
+
break block.call(key) if block
|
72
74
|
raise UndefinedAttributeError
|
73
75
|
end
|
74
76
|
end
|
@@ -227,34 +227,6 @@ class Chef
|
|
227
227
|
|
228
228
|
private # P R O P R I E T À P R I V A T A Vietato L'accesso
|
229
229
|
|
230
|
-
# Handle the download action.
|
231
|
-
#
|
232
|
-
# @return [undefined]
|
233
|
-
#
|
234
|
-
# @api private
|
235
|
-
def do_create
|
236
|
-
if @current_resource.exist? && !access_controls.requires_changes?
|
237
|
-
Chef::Log.debug "#{r.path} already exists - nothing to do"
|
238
|
-
|
239
|
-
elsif @current_resource.exist? && access_controls.requires_changes?
|
240
|
-
converge_by(access_controls.describe_changes) do
|
241
|
-
access_controls.set_all
|
242
|
-
end
|
243
|
-
r.updated_by_last_action(true)
|
244
|
-
|
245
|
-
else
|
246
|
-
converge_by "Download #{r.path}" do
|
247
|
-
backup unless ::File.symlink?(r.path)
|
248
|
-
do_download
|
249
|
-
end
|
250
|
-
do_acl_changes
|
251
|
-
load_resource_attributes_from_file(r)
|
252
|
-
r.updated_by_last_action(true)
|
253
|
-
load_new_resource_state
|
254
|
-
r.exist = true
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
230
|
# Change file ownership and mode.
|
259
231
|
#
|
260
232
|
# @return [undefined]
|
@@ -331,9 +303,9 @@ class Chef
|
|
331
303
|
|
332
304
|
def handle_prerequisites
|
333
305
|
package 'gnutls', :install
|
334
|
-
yumrepo
|
306
|
+
yumrepo(:create) if node.platform_family == 'rhel'
|
335
307
|
package 'aria2', :install
|
336
|
-
wipe_repo
|
308
|
+
wipe_repo if node.platform_family == 'rhel'
|
337
309
|
end
|
338
310
|
|
339
311
|
def package(name, action = :nothing)
|
@@ -25,6 +25,54 @@ module Garcon
|
|
25
25
|
#
|
26
26
|
module BaseDSL
|
27
27
|
module ClassMethods
|
28
|
+
# Maps a resource/provider (and optionally a platform and version) to a
|
29
|
+
# Chef resource/provider. This allows finer grained per platform
|
30
|
+
# resource attributes and the end of overloaded resource definitions.
|
31
|
+
#
|
32
|
+
# @note
|
33
|
+
# The provides method must be defined in both the custom resource and
|
34
|
+
# custom provider files and both files must have identical provides
|
35
|
+
# statement(s).
|
36
|
+
#
|
37
|
+
# @param [Symbol] name
|
38
|
+
# Name of a Chef resource/provider to map to.
|
39
|
+
#
|
40
|
+
# @return [undefined]
|
41
|
+
#
|
42
|
+
def provides(name)
|
43
|
+
if self.name && respond_to?(:constantize)
|
44
|
+
old_constantize = instance_method(:constantize)
|
45
|
+
define_singleton_method(:constantize) do |name|
|
46
|
+
name == self.name ? self : old_constantize.bind(self).call(name)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
@provides_name = name
|
50
|
+
super if defined?(super)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Return the Snake case name of the current resource class. If not set
|
54
|
+
# explicitly it will be introspected based on the class name.
|
55
|
+
#
|
56
|
+
# @param [Boolean] auto
|
57
|
+
# Try to auto-detect based on class name.
|
58
|
+
#
|
59
|
+
# @return [Symbol]
|
60
|
+
#
|
61
|
+
def resource_name(auto = true)
|
62
|
+
return @provides_name if @provides_name
|
63
|
+
@provides_name || if name && name.start_with?('Chef::Resource')
|
64
|
+
Garcon::Inflections.snakeify(name, 'Chef::Resource').to_sym
|
65
|
+
elsif name
|
66
|
+
Garcon::Inflections.snakeify(name.split('::').last).to_sym
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Used by Resource#to_text to find the human name for the resource.
|
71
|
+
#
|
72
|
+
def dsl_name
|
73
|
+
resource_name.to_s
|
74
|
+
end
|
75
|
+
|
28
76
|
# Imitate the behavior of the `Chef::Resource::LWRPBase` DSL providing
|
29
77
|
# a `default_action` method.
|
30
78
|
#
|
@@ -134,6 +182,11 @@ module Garcon
|
|
134
182
|
#
|
135
183
|
def initialize(*args)
|
136
184
|
super
|
185
|
+
if self.class.resource_name(false)
|
186
|
+
@resource_name = self.class.resource_name
|
187
|
+
else
|
188
|
+
@resource_name ||= self.class.resource_name
|
189
|
+
end
|
137
190
|
@action = self.class.default_action if @action == :nothing
|
138
191
|
(@allowed_actions << self.class.actions).flatten!.uniq!
|
139
192
|
end
|
@@ -45,7 +45,8 @@ module Garcon
|
|
45
45
|
# The mysql_passwd will == 'eazypass'
|
46
46
|
#
|
47
47
|
module SecretBag
|
48
|
-
|
48
|
+
InvalidDataBagTypeError = Class.new(RuntimeError)
|
49
|
+
DataBagEncryptionError = Class.new(RuntimeError)
|
49
50
|
|
50
51
|
def secret(bag_name, index)
|
51
52
|
if node[:garcon][:devmode]
|
@@ -18,7 +18,6 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require_relative 'chef/chef_helpers'
|
21
|
-
require_relative 'chef/log'
|
22
21
|
require_relative 'chef/node'
|
23
22
|
require_relative 'chef/secret_bag'
|
24
23
|
require_relative 'chef/validations'
|
@@ -27,7 +26,6 @@ require_relative 'chef/resource/attribute'
|
|
27
26
|
require_relative 'chef/resource/base_dsl'
|
28
27
|
require_relative 'chef/resource/blender'
|
29
28
|
require_relative 'chef/resource/lazy_eval'
|
30
|
-
require_relative 'chef/resource/resource_name'
|
31
29
|
|
32
30
|
module Garcon
|
33
31
|
# Extend Resource with class and instance methods.
|
@@ -36,7 +34,6 @@ module Garcon
|
|
36
34
|
include BaseDSL
|
37
35
|
include LazyEval
|
38
36
|
include Validations
|
39
|
-
include ResourceName
|
40
37
|
include Garcon::UrlHelper
|
41
38
|
include Garcon::FileHelper
|
42
39
|
|
@@ -138,14 +135,9 @@ unless Chef::Recipe.ancestors.include?(Garcon::Interpolation)
|
|
138
135
|
Chef::Provider.send(:include, Garcon::Interpolation)
|
139
136
|
end
|
140
137
|
|
141
|
-
unless Chef::Resource.method_defined?(:run_now)
|
142
|
-
Chef::Resource.send(:include, Garcon::RunNow::Mixin)
|
143
|
-
end
|
144
|
-
|
145
138
|
require_relative 'chef/provider/civilize'
|
139
|
+
require_relative 'chef/provider/development'
|
146
140
|
require_relative 'chef/provider/download'
|
147
141
|
require_relative 'chef/provider/house_keeping'
|
148
142
|
require_relative 'chef/provider/node_cache'
|
149
|
-
require_relative 'chef/provider/partial'
|
150
|
-
require_relative 'chef/provider/recovery'
|
151
143
|
require_relative 'chef/provider/zip_file'
|
@@ -18,6 +18,7 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
# Add #blank? method to TrueClass class.
|
21
|
+
#
|
21
22
|
class TrueClass
|
22
23
|
# True is never blank.
|
23
24
|
#
|
@@ -42,6 +43,7 @@ class TrueClass
|
|
42
43
|
end
|
43
44
|
|
44
45
|
# Add #blank? method to FalseClass class.
|
46
|
+
#
|
45
47
|
class FalseClass
|
46
48
|
# False is always blank.
|
47
49
|
#
|
data/lib/garcon/core_ext/hash.rb
CHANGED
@@ -18,7 +18,6 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
class Hash
|
21
|
-
|
22
21
|
# Turn a hash into a method arguments.
|
23
22
|
#
|
24
23
|
# h = { :list => [1,2], :base => "HI" }
|
@@ -55,7 +54,7 @@ class Hash
|
|
55
54
|
# Get or set state of object. You can think of #object_state as an in-code
|
56
55
|
# form of marshalling.
|
57
56
|
#
|
58
|
-
def object_state(data=nil)
|
57
|
+
def object_state(data = nil)
|
59
58
|
data ? replace(data) : dup
|
60
59
|
end
|
61
60
|
|
@@ -17,21 +17,18 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
# Adds `#contains?`, `#blank?` and `#shatter` methods to strings
|
21
|
-
#
|
22
20
|
class String
|
23
|
-
|
24
21
|
# Get or set state of object. You can think of #object_state as an in-code
|
25
22
|
# form of marshalling.
|
26
23
|
#
|
27
|
-
def object_state(data=nil)
|
24
|
+
def object_state(data = nil)
|
28
25
|
data ? replace(data) : dup
|
29
26
|
end
|
30
27
|
|
31
|
-
# Common Unix cryptography method.
|
32
|
-
#
|
28
|
+
# Common Unix cryptography method. This adds a default salt to the built-in
|
29
|
+
# crypt method.
|
33
30
|
#
|
34
|
-
def crypt(salt=nil)
|
31
|
+
def crypt(salt = nil)
|
35
32
|
salt ||= ((SecureRandom.random_number(26) +
|
36
33
|
(SecureRandom.random_number(2) == 0 ? 65 : 97)).chr +
|
37
34
|
(SecureRandom.random_number(26) +
|
@@ -56,7 +53,7 @@ class String
|
|
56
53
|
#
|
57
54
|
# "a?".to_re #=> /a?/
|
58
55
|
#
|
59
|
-
def to_re(esc=false)
|
56
|
+
def to_re(esc = false)
|
60
57
|
Regexp.new((esc ? Regexp.escape(self) : self))
|
61
58
|
end
|
62
59
|
|
@@ -66,21 +63,18 @@ class String
|
|
66
63
|
#
|
67
64
|
# "[".to_rx #=> /\[/
|
68
65
|
#
|
69
|
-
def to_rx(esc=true)
|
66
|
+
def to_rx(esc = true)
|
70
67
|
Regexp.new((esc ? Regexp.escape(self) : self))
|
71
68
|
end
|
72
69
|
|
73
70
|
# Strips out whitespace then tests if the string is empty.
|
74
71
|
#
|
75
|
-
#
|
76
|
-
# "".blank?
|
77
|
-
# "
|
78
|
-
# " sup? ".blank? # => false
|
72
|
+
# "".blank? #=> true
|
73
|
+
# " ".blank? #=> true
|
74
|
+
# " hey ho ".blank? #=> false
|
79
75
|
#
|
80
76
|
# @return [Boolean]
|
81
|
-
# True if blank, else false.
|
82
77
|
#
|
83
|
-
# @api public
|
84
78
|
def blank?
|
85
79
|
strip.empty?
|
86
80
|
end
|
data/lib/garcon/core_ext/time.rb
CHANGED
data/lib/garcon/core_ext.rb
CHANGED
@@ -21,17 +21,13 @@ require_relative 'core_ext/array'
|
|
21
21
|
require_relative 'core_ext/binding'
|
22
22
|
require_relative 'core_ext/boolean'
|
23
23
|
require_relative 'core_ext/enumerable'
|
24
|
-
require_relative 'core_ext/file'
|
25
|
-
require_relative 'core_ext/filetest'
|
26
24
|
require_relative 'core_ext/hash'
|
27
25
|
require_relative 'core_ext/kernel'
|
28
|
-
require_relative 'core_ext/lazy'
|
29
26
|
require_relative 'core_ext/method_access'
|
30
27
|
require_relative 'core_ext/nil'
|
31
28
|
require_relative 'core_ext/numeric'
|
32
29
|
require_relative 'core_ext/object'
|
33
30
|
require_relative 'core_ext/pathname'
|
34
|
-
require_relative 'core_ext/process'
|
35
31
|
require_relative 'core_ext/random'
|
36
32
|
require_relative 'core_ext/string'
|
37
33
|
require_relative 'core_ext/struct'
|
data/lib/garcon/exceptions.rb
CHANGED
@@ -62,40 +62,5 @@ module Garcon
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
|
-
# Raised when errors occur during configuration.
|
67
|
-
ConfigurationError = Class.new(StandardError)
|
68
|
-
|
69
|
-
# Raised when an object's methods are called when it has not been
|
70
|
-
# properly initialized.
|
71
|
-
InitializationError = Class.new(StandardError)
|
72
|
-
|
73
|
-
# If the maximum number of ReadWriteLock readers or writers is exceeded.
|
74
|
-
ResourceLimitError = Class.new(StandardError)
|
75
|
-
|
76
|
-
# Raised by an `Executor` when it is unable to process a given task,
|
77
|
-
# possibly because of a reject policy or other internal error.
|
78
|
-
RejectedExecutionError = Class.new(StandardError)
|
79
|
-
|
80
|
-
# Raised when an operation times out.
|
81
|
-
TimeoutError = Class.new(StandardError)
|
82
|
-
PollingError = Class.new(StandardError)
|
83
|
-
|
84
|
-
# Raised when node[:garcon][:databag_type] is not valid.
|
85
|
-
InvalidDataBagTypeError = Class.new(RuntimeError)
|
86
|
-
|
87
|
-
# Raised when cipher direction is invalid.
|
88
|
-
InvalidCipherError = Class.new(RuntimeError)
|
89
|
-
|
90
|
-
# Raised when no encryption key password is specified.
|
91
|
-
MissingEncryptionPasswordError = Class.new(RuntimeError)
|
92
|
-
|
93
|
-
ResourceNotFoundError = Class.new(RuntimeError)
|
94
|
-
InvalidStateError = Class.new(RuntimeError)
|
95
|
-
InvalidTransitionError = Class.new(RuntimeError)
|
96
|
-
InvalidCallbackError = Class.new(RuntimeError)
|
97
|
-
TransitionFailedError = Class.new(RuntimeError)
|
98
|
-
TransitionConflictError = Class.new(RuntimeError)
|
99
|
-
GuardFailedError = Class.new(RuntimeError)
|
100
65
|
end
|
101
66
|
end
|
data/lib/garcon/task/executor.rb
CHANGED
data/lib/garcon/task/ivar.rb
CHANGED
@@ -17,6 +17,10 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
+
require 'thread'
|
21
|
+
require 'tempfile'
|
22
|
+
require 'fileutils'
|
23
|
+
|
20
24
|
module Garcon
|
21
25
|
# Class methods that are added when you include Garcon
|
22
26
|
#
|
@@ -93,7 +97,7 @@ module Garcon
|
|
93
97
|
end
|
94
98
|
end
|
95
99
|
end
|
96
|
-
|
100
|
+
|
97
101
|
dirs.empty? ? nil : dirs
|
98
102
|
end
|
99
103
|
|
@@ -166,5 +170,88 @@ module Garcon
|
|
166
170
|
def normalize_path(path)
|
167
171
|
path.sub(%r{^/}, '').tr('', '')
|
168
172
|
end
|
173
|
+
|
174
|
+
def atomic_id
|
175
|
+
@atomic_id ||= 0
|
176
|
+
@atomic_id += 1
|
177
|
+
end
|
178
|
+
|
179
|
+
# Same as `File.open`, but acts on a temporary copy of named
|
180
|
+
# file, copying the file back to the original on completion.
|
181
|
+
#
|
182
|
+
# @uncommon
|
183
|
+
# require 'facets/fileutils/atomic_open'
|
184
|
+
#
|
185
|
+
def atomic_open(file, mode='r', temp_dir = nil, &block)
|
186
|
+
temp_dir = temp_dir || Dir.tmpdir
|
187
|
+
temp_file = Tempfile.new("#{aomtic_id}-" + File.basename(file), temp_dir)
|
188
|
+
FileUtils.cp(file, temp_file) if File.exist?(file)
|
189
|
+
File.open(temp_file, mode, &block)
|
190
|
+
FileUtils.cp(temp_file, file)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Write to a file atomically. Useful for situations where you don't
|
194
|
+
# want other processes or threads to see half-written files.
|
195
|
+
#
|
196
|
+
# File.atomic_write("important.txt") do |file|
|
197
|
+
# file.write("hello")
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
# If your temporary directory is not on the same filesystem as the file
|
201
|
+
# you're trying to write, you can provide a different temporary directory.
|
202
|
+
#
|
203
|
+
# File.atomic_write("important.txt", "tmp") do |file|
|
204
|
+
# file.write("hello")
|
205
|
+
# end
|
206
|
+
#
|
207
|
+
def atomic_write(file, temp_dir = nil)
|
208
|
+
temp_dir = temp_dir || Dir.tmpdir
|
209
|
+
temp_file = Tempfile.new(File.basename(file), temp_dir)
|
210
|
+
|
211
|
+
yield temp_file
|
212
|
+
temp_file.close
|
213
|
+
|
214
|
+
begin
|
215
|
+
old_stat = File.stat(file)
|
216
|
+
rescue Errno::ENOENT
|
217
|
+
ext = "#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}"
|
218
|
+
check_name = File.join(File.dirname(file), ".permissions_check.#{ext}")
|
219
|
+
File.open(check_name, "w") { }
|
220
|
+
old_stat = File.stat(check_name)
|
221
|
+
File.unlink(check_name)
|
222
|
+
end
|
223
|
+
|
224
|
+
FileUtils.mv(temp_file.path, file)
|
225
|
+
File.chown(old_stat.uid, old_stat.gid, file)
|
226
|
+
File.chmod(old_stat.mode, file)
|
227
|
+
end
|
228
|
+
|
229
|
+
# Reads in a file, removes blank lines and removes lines starting
|
230
|
+
# with '#' and then returns an array of all the remaining lines.
|
231
|
+
#
|
232
|
+
# Thr remark indicator can be overridden via the +:omit:+ option, which
|
233
|
+
# can be a regualar expression or a string that is match against the
|
234
|
+
# start of a line.
|
235
|
+
#
|
236
|
+
def read_list(filepath, options={})
|
237
|
+
chomp = options[:chomp]
|
238
|
+
omit = case options[:omit]
|
239
|
+
when Regexp
|
240
|
+
omit
|
241
|
+
when nil
|
242
|
+
/^\s*\#/
|
243
|
+
else
|
244
|
+
/^\s*#{Regexp.escape(omit)}/
|
245
|
+
end
|
246
|
+
|
247
|
+
list = []
|
248
|
+
readlines(filepath).each do |line|
|
249
|
+
line = line.strip.chomp(chomp)
|
250
|
+
next if line.empty?
|
251
|
+
next if omit === line
|
252
|
+
list << line
|
253
|
+
end
|
254
|
+
list
|
255
|
+
end
|
169
256
|
end
|
170
257
|
end
|
data/lib/garcon/utility/retry.rb
CHANGED
@@ -18,7 +18,6 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require_relative 'timeout'
|
21
|
-
require_relative '../exceptions'
|
22
21
|
|
23
22
|
module Garcon
|
24
23
|
# Class methods that are added when you include Garcon::Retry
|
@@ -27,8 +26,6 @@ module Garcon
|
|
27
26
|
# Methods are also available as module-level methods as well as a mixin.
|
28
27
|
extend self
|
29
28
|
|
30
|
-
include Garcon::Exceptions
|
31
|
-
|
32
29
|
# Runs a code block, and retries it when an exception occurs. It is
|
33
30
|
# configured using four optional parameters `:tries`, `:on`, `:sleep`,
|
34
31
|
# `:match`, `:ensure` and runs the passed block. Should an exception
|
@@ -18,7 +18,6 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'thread'
|
21
|
-
require_relative '../exceptions'
|
22
21
|
|
23
22
|
module Garcon
|
24
23
|
# Class methods that are added when you include Garcon::Timeout
|
@@ -27,8 +26,6 @@ module Garcon
|
|
27
26
|
# Methods are also available as module-level methods as well as a mixin.
|
28
27
|
extend self
|
29
28
|
|
30
|
-
include Garcon::Exceptions
|
31
|
-
|
32
29
|
# Wait the given number of seconds for the block operation to complete.
|
33
30
|
# Intended to be a simpler and more reliable replacement to the Ruby
|
34
31
|
# standard library `Timeout::timeout` method.
|
data/lib/garcon/utils.rb
CHANGED
@@ -23,7 +23,6 @@ require_relative 'utility/file_helper'
|
|
23
23
|
require_relative 'utility/hookers'
|
24
24
|
require_relative 'utility/interpolation'
|
25
25
|
require_relative 'utility/memstash'
|
26
|
-
require_relative 'utility/msg_from_god'
|
27
26
|
require_relative 'utility/retry'
|
28
27
|
require_relative 'utility/timeout'
|
29
28
|
require_relative 'utility/url_helper'
|