Top Level Namespace
Defined Under Namespace
Modules: Rubycfn Classes: Array, Hash, String, Symbol
Instance Method Summary collapse
- #aws_regions ⇒ Object
- #render(file, vars) ⇒ Object
- #rubycfn_banner(version) ⇒ Object
- #rubycfn_structure(project_name) ⇒ Object
- #scaffold_stack ⇒ Object
Instance Method Details
#aws_regions ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cli_methods.rb', line 6 def aws_regions [ { name: "US East (N. Virginia)", value: "us-east-1" }, { name: "US East (Ohio)", value: "us-east-2" }, { name: "US West (N. California)", value: "us-west-1" }, { name: "US West (Oregon)", value: "us-west-2" }, { name: "Canada (Central)", value: "ca-central-1" }, { name: "EU (Frankfurt)", value: "eu-central-1" }, { name: "EU (Ireland)", value: "eu-west-1" }, { name: "EU (London)", value: "eu-west-2" }, { name: "EU (Paris)", value: "eu-west-3" }, { name: "Asia Pacific (Tokyo)", value: "ap-northeast-1" }, { name: "Asia Pacific (Seoul)", value: "ap-northeast-2" }, { name: "Asia Pacific (Osaka-Local)", value: "ap-northeast-3" }, { name: "Asia Pacific (Singapore)", value: "ap-southeast-1" }, { name: "Asia Pacific (Sydney)", value: "ap-southeast-2" }, { name: "Asia Pacific (Mumbai)", value: "ap-south-1" }, { name: "South America (São Paulo)", value: "sa-east-1" } ] end |
#render(file, vars) ⇒ Object
1 2 3 4 |
# File 'lib/cli_methods.rb', line 1 def render(file, vars) template = File.read(file) ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding }) end |
#rubycfn_banner(version) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cli_methods.rb', line 27 def (version) [ "__________ ____ __________________.___._________ _____________________ ", "\\______ \\ | \\______ \\__ | |\\_ ___ \\\\_ _____/\\______ \\", " | _/ | /| | _// | |/ \\ \\/ | __) | | _/", " | | \\ | / | | \\\\____ |\\ \\____| \\ | | \\", " |____|_ /______/ |______ // ______| \\______ /\\___ / |______ /", " \\/ \\/ \\/ \\/ \\/ \\/ [v#{version}]" ].join("\n") end |
#rubycfn_structure(project_name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cli_methods.rb', line 38 def rubycfn_structure(project_name) [ project_name, project_name + "/build", project_name + "/lib/aws_helper", project_name + "/lib/core", project_name + "/lib/shared_concerns", project_name + "/lib/stacks", project_name + "/lib/stacks/ecs_stack", project_name + "/lib/stacks/parent_stack", project_name + "/lib/stacks/vpc_stack", project_name + "/spec", project_name + "/spec/lib" ] end |
#scaffold_stack ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cli_methods.rb', line 54 def scaffold_stack puts (Rubycfn::VERSION) raise "Run `rubycfn stack` from project root folder" unless File.file? "lib/stacks/parent_stack/parent.rb" prompt = TTY::Prompt.new stack_name = prompt.ask("Stack name?", default: "application") do |q| q.validate(/^([a-zA-Z]*)$/, "Invalid stack name") end stack_name = "#{stack_name.downcase}_stack" raise "Stack already exists" if File.file? "lib/stacks/#{stack_name}.rb" path = File.(File.dirname(File.dirname(__FILE__))) new_stack = render("new_stack.rb", { stack_name: stack_name.split("_").collect(&:capitalize).join }, path) new_concern = render("new_concern.rb", { stack_name: stack_name.split("_").collect(&:capitalize).join }, path) File.open("lib/stacks/#{stack_name}.rb", "w") { |file| file.write(new_stack) } FileUtils.mkdir_p "lib/stacks/#{stack_name}" File.open("lib/stacks/#{stack_name}/my_module.rb", "w") { |file| file.write(new_concern) } puts "Created stack. Don't forget to add it to lib/stacks/parent_stack/parent.rb !" exit end |