aws_clim 1.0.2 → 1.0.4

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
  SHA256:
3
- metadata.gz: c71eb36c809ad34e0682ed8f122ececc8f6a71532d6256c78670cba5ee4c13a8
4
- data.tar.gz: 66d93e4023fdd715499e17ffa9fb47f47b6676af933bfcfc7c1427008b2d59cd
3
+ metadata.gz: b58d1cc08420aea4f5c6c34a6f27272e07d743b80f9a6714bc6be584b602424a
4
+ data.tar.gz: 36946a492c1ef267ae6c410bffaaffb0441f9d5ba92c1c4d67af6b6330fb5e0b
5
5
  SHA512:
6
- metadata.gz: cba3ede4804d99f587ad7c1bda529b16ff752df71aea77497590b697f2787b4b1b03cc51dd7eadd23818b2cc1e0af56e41e1791e357f215814cf50921e0b5dcb
7
- data.tar.gz: 65545875d1c30f02c09e34638e40865606f40de82ff9f4885b5dfe4c2741b78f42fdcf0590c2b95bb530fdd02b81ca3dea9a75ab28feb9f9f93248e84f400ec9
6
+ metadata.gz: 7f5153c491f9aa5f7a21f9750d73f6d85e271114f18aac33767e15f86f120f21cb6b0d40bc88f2e272f67c379580f81343c716d9b120639dfeeecd8f2b1c9955
7
+ data.tar.gz: 398d78d972a507dbc1ec1068b6ecfcce5f2a3a9becef69ab68aee237092aec535b93c8780b350c8531974eb32abaf92db3af81ef2a24696ba633b94e8f393865
data/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # AwsClim
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aws_clim`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ AwsClim is a light wrapper around `aws cli` tool. it adds some convenience when calling the command and
4
+ dealing with the results.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ - Maps all aws services as a method on AwsClim instance.
7
+ - Set format as JSON as default.
8
+ - Deals with arguments as Array, Hash or simply string
9
+ - Parses all results as JSON
10
+ - Returns an `OpenStruct.new(error: true, success: false, data: err)` when error happens.
11
+ - Returns an `OpenStruct.new(error: false, success: true, data: JSON.parse(out, object_class: OpenStruct))` when command returns successfuly.
6
12
 
7
13
  ## Installation
8
14
 
@@ -22,6 +28,17 @@ Or install it yourself as:
22
28
 
23
29
  ## Usage
24
30
 
31
+ ```
32
+ aws = AwsClim.new()
33
+ ```
34
+
35
+ By calling new without parameters AwsClim uses the profile `default`(see https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials_profiles.html to learn about aws profiles).
36
+ To set a different profile use profile argument on new.
37
+
38
+ ```
39
+ aws = AwsClim.new(profile: 'other-profile')
40
+ ```
41
+
25
42
  With a instance of AwsClim call aws services by its name and pass subcommands and options:
26
43
 
27
44
  Examples:
@@ -1,3 +1,3 @@
1
1
  module AwsClim
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.4"
3
3
  end
data/lib/aws_clim.rb CHANGED
@@ -3,7 +3,7 @@ require 'json'
3
3
  require 'open3'
4
4
 
5
5
  class AwsClim
6
- def initialize(profile = 'default', global_options = {})
6
+ def initialize(profile: 'default', global_options: {})
7
7
  @profile = profile
8
8
  @global_options = global_options
9
9
  end
@@ -330,6 +330,10 @@ class AwsClim
330
330
  define_method service_name do |*ps|
331
331
  execute(service_name, ps)
332
332
  end
333
+
334
+ define_method "#{service_name}_help" do
335
+ execute(service_name, 'help').data
336
+ end
333
337
  end
334
338
 
335
339
  def execute(service, options)
@@ -338,7 +342,14 @@ class AwsClim
338
342
  out, err, status = Open3.capture3(cmd)
339
343
 
340
344
  if status.success?
341
- OpenStruct.new(success?: true, error?: false, data: OpenStruct.new(JSON.parse(out)))
345
+ data =
346
+ begin
347
+ JSON.parse(out, object_class: OpenStruct)
348
+ rescue JSON::ParserError => e
349
+ out
350
+ end
351
+
352
+ OpenStruct.new(success?: true, error?: false, data: data)
342
353
  else
343
354
  OpenStruct.new(success?: false, error?: true, data: err)
344
355
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_clim
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew S Aguiar