cloudit 0.0.3 → 0.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
  SHA1:
3
- metadata.gz: c668f56969001a73c0ca0df7d5c5d9336b8d3bb2
4
- data.tar.gz: b882f0ad4625a9eff7de0b394ad688bf15ca252b
3
+ metadata.gz: 9698e9e003bc1317857063ac382f2e1054ad0fca
4
+ data.tar.gz: fb1f1b669dac2d26ed3f06a502c3127969c34e37
5
5
  SHA512:
6
- metadata.gz: 316d6063727d2cdc87612764a3a6a995f58d7b14592fe9be4a942b4acd78eb9c61cc0321ecdaed3d7881924a4c696a539182fc7996bb3970321031cd46ab1039
7
- data.tar.gz: 827c215133829429b81ab3cd49f53e9ef005c3d4f6b627830a8c196dd09b07dd6e7d56b5cf3bf90a0ed47287dfd094038ab17a971e488ad0e82a8d32f3a2fbd8
6
+ metadata.gz: fafa4668b2e3640249ce14c4f3713f2e2e70f98c87a585f219ffc65449a18b542d63ffe8ceb3d32c542d04a6c7516e924d424a45403c9aabdc5c09e941ffbdb9
7
+ data.tar.gz: e35911cc498ead53dc55942d98be95e2e62b1690eb9846ce9525753840a0ccf96de1ccd2e23a679dfe72629f1672781175c653aec568af26e14bd28c1833f4ce
@@ -1,21 +1,23 @@
1
1
  require 'slop'
2
- require 'byebug'
3
2
 
4
3
  class Cloudit::Command::Base
5
4
  class << self
6
5
  attr_accessor :parser, :slop_opts
7
6
  end
8
7
 
8
+ attr_accessor :commands
9
+
9
10
  VALID_METHODS = []
10
11
  OPTION_NAME_OFFSET = 6
11
12
 
12
- def initialize(args=[])
13
+ def initialize(args=[], commands)
13
14
  @method = if args[0].is_a?(String) && args[0].include?('-')
14
15
  nil
15
16
  else
16
17
  args.shift.strip rescue nil
17
18
  end
18
19
  @opts = parser.parse(args)
20
+ @commands = commands
19
21
  end
20
22
 
21
23
  def execute
@@ -6,6 +6,7 @@ require 'json'
6
6
  class Cloudit::Command::Generate < Cloudit::Command::Base
7
7
  VALID_METHODS = ['help']
8
8
  SECTIONS = ['Metadata', 'Parameters', 'Mappings', 'Conditions', 'Resources', 'Outputs']
9
+ DESCRIPTION = 'Build YAML files into Cloudformation template'
9
10
  DEFAULT_OUT_FILE = 'out.json'
10
11
  DEFAULT_MAIN_CFN_EXTENSION = 'cfn.yml'
11
12
  DEFAULT_DIRECTORY = './'
@@ -1,16 +1,7 @@
1
1
  require 'cloudit/version'
2
2
  require 'cloudit/command/base'
3
3
 
4
- require 'byebug'
5
-
6
4
  class Cloudit::Command::Index < Cloudit::Command::Base
7
- class << self
8
- attr_accessor :usage
9
- end
10
-
11
- def usage
12
- self.class.usage
13
- end
14
5
 
15
6
  def index
16
7
  if @opts.version?
@@ -25,12 +16,14 @@ class Cloudit::Command::Index < Cloudit::Command::Base
25
16
 
26
17
  private
27
18
 
28
- def self.build_usage
19
+ def usage
29
20
  str = slop_opts.to_s
30
- Cloudit::Command.commands.each do |command|
31
- str += command
21
+ str += "\nCommands:"
22
+ Cloudit::Command.descriptions.each do |command|
23
+ str += "\n#{command[:command]} #{command[:description]}"
32
24
  end
33
- self.usage = str
25
+ str += "\n\nRun 'cloudit COMMAND --help' for more information on a command."
26
+ str
34
27
  end
35
28
 
36
29
  def self.setup_options
@@ -46,5 +39,4 @@ class Cloudit::Command::Index < Cloudit::Command::Base
46
39
  end
47
40
 
48
41
  setup_options
49
- build_usage
50
42
  end
@@ -1,15 +1,22 @@
1
1
  module Cloudit
2
2
  module Command
3
3
  class << self
4
- attr_accessor :commands
4
+ attr_accessor :commands, :descriptions
5
5
  end
6
6
 
7
7
  @commands = []
8
+ @descriptions = []
8
9
 
9
10
  def self.load
10
11
  Dir[File.join(File.dirname(__FILE__), "command", "*.rb")].each do |file|
11
- self.commands << file.split('/')[-1].chomp('.rb')
12
12
  require file
13
+ com = file.split('/')[-1].chomp('.rb')
14
+ if com == 'index' || com == 'base'
15
+ next
16
+ end
17
+ desc = Object.const_get("Cloudit::Command::#{com.capitalize}::DESCRIPTION")
18
+ self.commands << com
19
+ self.descriptions << {command: com, description: desc}
13
20
  end
14
21
  end
15
22
 
@@ -33,5 +40,9 @@ module Cloudit
33
40
  self.class.commands
34
41
  end
35
42
 
43
+ def descriptions
44
+ self.class.descriptions
45
+ end
46
+
36
47
  end
37
48
  end
@@ -1,3 +1,3 @@
1
1
  module Cloudit
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Chai