Class: Stax::Generators::StackGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/stax/generators/stack/stack_generator.rb

Instance Method Summary collapse

Instance Method Details

#check_argsObject



14
15
16
# File 'lib/stax/generators/stack/stack_generator.rb', line 14

def check_args
  usage! if args.empty?
end

#create_lib_filesObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/stax/generators/stack/stack_generator.rb', line 25

def create_lib_files
  args.each do |s|
    create_file "lib/stack/#{s}.rb" do
      <<~FILE
      module Stax
        class #{s.capitalize} < Stack
          # include Logs

          # no_commands do
          #   def cfn_parameters
          #     super.merge(
          #       # add parameters as a hash here
          #     )
          #   end
          # end
        end
      end
    FILE
    end
  end
end

#create_staxfileObject



18
19
20
21
22
23
# File 'lib/stax/generators/stack/stack_generator.rb', line 18

def create_staxfile
  create_file 'Staxfile' unless File.exist?('Staxfile')
  append_to_file 'Staxfile' do
    args.map { |s| "stack :#{s}" }.join("\n").concat("\n")
  end
end

#create_templatesObject



47
48
49
50
51
52
53
54
55
# File 'lib/stax/generators/stack/stack_generator.rb', line 47

def create_templates
  if options[:json]
    create_json_templates
  elsif options[:yaml]
    create_yaml_templates
  else
    create_cfer_templates
  end
end