cloud_powers 0.2.7.11 → 0.2.7.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 433e7363833584c40d5acfa7fef7df2287a384e5
4
- data.tar.gz: 152c9ac636ba72ab17e5def02852276bc30b01ab
3
+ metadata.gz: 26570d7bc524c4cf5a7c02ae036a0c2afdaaae47
4
+ data.tar.gz: 55a862bf5557492052a629a29348059448a8c8ca
5
5
  SHA512:
6
- metadata.gz: 9df5ddd0962f8c80fe86f6858a9cac3fa6d3e4e79e14a5f7f8b1cff3bf2839dca2408cc6ade744838d39b3d676ac0672030833226b0c0d78bc3305c0c23f7afd
7
- data.tar.gz: c37a1b305fa7bd31b45ababdfd3c6819a290267822672566fc48ff496c9a0691c4e68c591a6197e0fecd2312db5e307c37caa43549f4ef748accdd0689fc0f73
6
+ metadata.gz: 03d6a2dc5916be7609680dba92626bcb6406fac862aacdb894207380586ee210728efe5736dde85857ab4d12272cac2858281323bff13b64dcb280ae3bfee04d
7
+ data.tar.gz: 89cc94d90d75ff5554f9666edb92d4690da0f35a5a8c7440cd87959c54e4fa6165f905e13cc4dffcb6fac86d4f424e1e767cab5c5318e9b50c4595b263d29adf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloud_powers (0.2.7.11)
4
+ cloud_powers (0.2.7.12)
5
5
  activesupport-core-ext (~> 4)
6
6
  aws-sdk (~> 2)
7
7
  dotenv (~> 2.1)
@@ -102,7 +102,7 @@ module Smash
102
102
  if msg.respond_to? :body
103
103
  decipher_message(msg.body)
104
104
  else
105
- msg.kind_of?(Hash) ? msg : JSON.parse(msg.to_s)
105
+ msg.kind_of?(Hash) ? msg : JSON.parse(msg)
106
106
  end
107
107
  rescue Exception
108
108
  { task: to_snake(msg.to_s) }
@@ -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>#task_require_path()</tt>
254
+ # * See <tt>#task_home</tt>
233
255
  def task_path(file = '')
234
- return task_require_path if file.empty?
235
- Pathname(__FILE__).parent.dirname + 'tasks' + to_ruby_file_name(file)
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
- file = File.basename(file_name, File.extname(file_name))
251
- Pathname(__FILE__).parent.dirname + 'tasks' + file
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)]
@@ -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
- unless task_path(file).exist?
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
@@ -1,3 +1,3 @@
1
1
  module CloudPowers
2
- VERSION = "0.2.7.11"
2
+ VERSION = "0.2.7.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_powers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7.11
4
+ version: 0.2.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Phillipps