Class: Awspec::Generator::Template
- Inherits:
-
Object
- Object
- Awspec::Generator::Template
- Defined in:
- lib/awspec/generator/template.rb
Class Method Summary collapse
- .file_check_and_puts(path, content) ⇒ Object
- .generate(type) ⇒ Object
- .generate_generator_doc ⇒ Object
- .generate_resource_type_doc ⇒ Object
- .generate_stub ⇒ Object
- .generate_type ⇒ Object
- .generate_type_spec ⇒ Object
- .put_message ⇒ Object
Class Method Details
.file_check_and_puts(path, content) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/awspec/generator/template.rb', line 97 def self.file_check_and_puts(path, content) if File.exist? @root_path + path $stderr.puts "!! #{path} already exists" else File.open(@root_path + path, 'w') do |f| f.puts content end puts " + #{path}" end end |
.generate(type) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/awspec/generator/template.rb', line 3 def self.generate(type) @type = type @root_path = File.dirname(__FILE__) + '/../../../' generate_stub generate_type generate_type_spec generate_generator_doc generate_resource_type_doc end |
.generate_generator_doc ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/awspec/generator/template.rb', line 55 def self.generate_generator_doc path = 'lib/awspec/generator/doc/type/' + @type.underscore + '.rb' content = <<-"EOF" module Awspec::Generator module Doc module Type class #{@type.camelize} < Base def initialize super @type_name = '#{@type.camelize}' @type = Awspec::Type::#{@type.camelize}.new('my-#{@type.underscore.tr('_', '-')}') @ret = @type.resource_via_client @matchers = [] @ignore_matchers = [] @describes = [] end end end end end EOF self.file_check_and_puts(path, content) end |
.generate_resource_type_doc ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/awspec/generator/template.rb', line 79 def self.generate_resource_type_doc path = 'doc/_resource_types/' + @type.underscore + '.md' content = <<-"EOF" # exist EOF self.file_check_and_puts(path, content) end |
.generate_stub ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/awspec/generator/template.rb', line 32 def self.generate_stub path = 'lib/awspec/stub/' + @type.underscore + '.rb' content = <<-"EOF" # Aws.config[:ec2] = { # stub_responses: true # } EOF self.file_check_and_puts(path, content) end |
.generate_type ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/awspec/generator/template.rb', line 14 def self.generate_type path = 'lib/awspec/type/' + @type.underscore + '.rb' content = <<-"EOF" module Awspec::Type class #{@type.camelize} < Base def resource_via_client @resource_via_client ||= # FIXME end def id @id ||= # FIXME end end end EOF self.file_check_and_puts(path, content) end |
.generate_type_spec ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/awspec/generator/template.rb', line 42 def self.generate_type_spec path = 'spec/type/' + @type.underscore + '_spec.rb' content = <<-"EOF" require 'spec_helper' Awspec::Stub.load '#{@type.underscore}' describe #{@type.underscore}('my-#{@type.underscore.tr('_', '-')}') do it { should exist } end EOF self.file_check_and_puts(path, content) end |
.put_message ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/awspec/generator/template.rb', line 87 def self. content = <<-"EOF" Genarate #{@type.camelize} template files. * !! AND add '#{@type.underscore}' to Awspec::Helper::Type::TYPES in lib/awspec/helper/type.rb * EOF end |