cloud_powers 0.2.7.11 → 0.2.7.12
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cloud_powers/delegator.rb +1 -1
- data/lib/cloud_powers/helper.rb +52 -5
- data/lib/cloud_powers/self_awareness.rb +1 -1
- data/lib/cloud_powers/storage.rb +1 -1
- data/lib/cloud_powers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26570d7bc524c4cf5a7c02ae036a0c2afdaaae47
|
4
|
+
data.tar.gz: 55a862bf5557492052a629a29348059448a8c8ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03d6a2dc5916be7609680dba92626bcb6406fac862aacdb894207380586ee210728efe5736dde85857ab4d12272cac2858281323bff13b64dcb280ae3bfee04d
|
7
|
+
data.tar.gz: 89cc94d90d75ff5554f9666edb92d4690da0f35a5a8c7440cd87959c54e4fa6165f905e13cc4dffcb6fac86d4f424e1e767cab5c5318e9b50c4595b263d29adf
|
data/Gemfile.lock
CHANGED
data/lib/cloud_powers/helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'logger'
|
2
|
+
require 'fileutils'
|
2
3
|
require 'pathname'
|
3
4
|
require 'uri'
|
4
5
|
require 'syslog/logger'
|
@@ -218,6 +219,27 @@ module Smash
|
|
218
219
|
end
|
219
220
|
end
|
220
221
|
|
222
|
+
# Gives a common home for tasks to live so they can be easily grouped and
|
223
|
+
# found. This method will create nested directories, based on the
|
224
|
+
# <tt>#project_root()</tt> method and an additional 'lib/tasks' directory.
|
225
|
+
# If no project root has been set by the time this method is called, a new
|
226
|
+
# directory will be created relative to the gem's project root.
|
227
|
+
#
|
228
|
+
# Returns
|
229
|
+
# +String+
|
230
|
+
#
|
231
|
+
# Notes
|
232
|
+
# * # If no project root has been set by the time this method is called, a new
|
233
|
+
# directory will be created relative to the gem's project root. This might
|
234
|
+
# have deeper implications than you want to deal with so it's always a good
|
235
|
+
# idea to set your project root as soon as you can.
|
236
|
+
# * TODO: find a way to have this method figure out the actual project's
|
237
|
+
# root, as opposed to just making common <i>"good"</i> assumptions.
|
238
|
+
def task_home
|
239
|
+
string_th = FileUtils.mkdir_p("#{project_root}/lib/tasks/").first
|
240
|
+
@task_home ||= Pathname.new(string_th).realpath.to_s
|
241
|
+
end
|
242
|
+
|
221
243
|
# Gives the path from the project root to lib/tasks[/#{file}.rb]
|
222
244
|
#
|
223
245
|
# Parameters
|
@@ -229,10 +251,30 @@ module Smash
|
|
229
251
|
# * file +String+ if +file+ parameter is not given it will return the <tt>#task_require_path()</tt>
|
230
252
|
#
|
231
253
|
# Notes
|
232
|
-
# * See <tt>#
|
254
|
+
# * See <tt>#task_home</tt>
|
233
255
|
def task_path(file = '')
|
234
|
-
|
235
|
-
Pathname
|
256
|
+
return task_home if file.empty?
|
257
|
+
Pathname.new("#{task_home}/#{file}").to_s
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
# Check if the task file exists in the task directory
|
262
|
+
#
|
263
|
+
# Parameters
|
264
|
+
# * file +String+
|
265
|
+
#
|
266
|
+
# Returns
|
267
|
+
# +Boolean+
|
268
|
+
#
|
269
|
+
# Notes
|
270
|
+
# * See +#task_home()+
|
271
|
+
def task_exist?(file)
|
272
|
+
begin
|
273
|
+
File.new("#{task_home}/#{file}")
|
274
|
+
true
|
275
|
+
rescue Errno::ENOENT => e
|
276
|
+
false
|
277
|
+
end
|
236
278
|
end
|
237
279
|
|
238
280
|
# Gives the path from the project root to lib/tasks[/file]
|
@@ -246,9 +288,14 @@ module Smash
|
|
246
288
|
#
|
247
289
|
# Notes
|
248
290
|
# * Neither path nor file will have a file extension
|
291
|
+
# * See <tt>#task_home</tt>
|
249
292
|
def task_require_path(file_name = '')
|
250
|
-
|
251
|
-
|
293
|
+
begin
|
294
|
+
file_sans_extension = File.basename(file_name, '.*')
|
295
|
+
(Pathname.new(task_home) + file_sans_extension).to_s
|
296
|
+
rescue Errno::ENOENT => e
|
297
|
+
nil
|
298
|
+
end
|
252
299
|
end
|
253
300
|
|
254
301
|
# Change strings into camelCase
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'aws-sdk'
|
2
2
|
Aws.use_bundled_cert!
|
3
3
|
require 'httparty'
|
4
|
+
require 'stubs/aws_stubs'
|
4
5
|
require_relative 'aws_resources'
|
5
6
|
require_relative 'helper'
|
6
7
|
require_relative './synapse/synapse'
|
@@ -127,7 +128,6 @@ module Smash
|
|
127
128
|
metadata_uri = "http://169.254.169.254/latest/meta-data/#{key}"
|
128
129
|
HTTParty.get(metadata_uri).parsed_response.split("\n")
|
129
130
|
else
|
130
|
-
require_relative '../stubs/aws_stubs'
|
131
131
|
stubbed_metadata = Smash::CloudPowers::AwsStubs.instance_metadata_stub
|
132
132
|
|
133
133
|
key.empty? ? stubbed_metadata.keys : stubbed_metadata[to_hyph(key)]
|
data/lib/cloud_powers/storage.rb
CHANGED
@@ -41,7 +41,7 @@ module Smash
|
|
41
41
|
def source_task(file)
|
42
42
|
# TODO: better path management
|
43
43
|
bucket = zfind('task storage')
|
44
|
-
|
44
|
+
if task_path(file).nil?
|
45
45
|
objects = s3.list_objects(bucket: bucket).contents.select do |f|
|
46
46
|
/#{Regexp.escape file}/i =~ f.key
|
47
47
|
end
|
data/lib/cloud_powers/version.rb
CHANGED