class Stax::Generators::StackGenerator
Public Instance Methods
check_args()
click to toggle source
# File lib/stax/generators/stack/stack_generator.rb, line 14 def check_args usage! if args.empty? end
create_lib_files()
click to toggle source
# 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_staxfile()
click to toggle source
# 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_templates()
click to toggle source
# 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
Private Instance Methods
create_cfer_templates()
click to toggle source
# File lib/stax/generators/stack/stack_generator.rb, line 59 def create_cfer_templates args.each do |s| create_file "cf/#{s}.rb" do <<~FILE description '#{s} stack' # parameter :foo, type: :String, default: '' # mappings() # include_template() FILE end end end
create_json_templates()
click to toggle source
# File lib/stax/generators/stack/stack_generator.rb, line 73 def create_json_templates args.each do |s| create_file "cf/#{s}.json" do <<~FILE { "AWSTemplateFormatVersion": "2010-09-09", "Description": "#{s} stack", "Parameters": {}, "Mappings": {}, "Conditions": {}, "Resources": {}, "Outputs": {} } FILE end end end
create_yaml_templates()
click to toggle source
# File lib/stax/generators/stack/stack_generator.rb, line 91 def create_yaml_templates args.each do |s| create_file "cf/#{s}.yaml" do <<~FILE AWSTemplateFormatVersion: '2010-09-09' Description: Stax test stack Parameters: {} Mappings: {} Conditions: {} Resources: Outputs: {} FILE end end end