aws-sdk-code-generator 0.1.0.pre → 0.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +5 -5
  2. data/lib/aws-sdk-code-generator.rb +68 -75
  3. data/lib/aws-sdk-code-generator/api.rb +130 -0
  4. data/lib/aws-sdk-code-generator/apply_docs.rb +15 -2
  5. data/lib/aws-sdk-code-generator/client_constructor.rb +39 -0
  6. data/lib/aws-sdk-code-generator/client_operation_documentation.rb +268 -0
  7. data/lib/aws-sdk-code-generator/client_operation_list.rb +148 -0
  8. data/lib/aws-sdk-code-generator/client_response_structure_example.rb +108 -0
  9. data/lib/aws-sdk-code-generator/code_builder.rb +146 -133
  10. data/lib/aws-sdk-code-generator/crosslink.rb +42 -0
  11. data/lib/aws-sdk-code-generator/docstring.rb +199 -0
  12. data/lib/aws-sdk-code-generator/error_list.rb +77 -0
  13. data/lib/aws-sdk-code-generator/errors.rb +2 -0
  14. data/lib/aws-sdk-code-generator/eventstream_example.rb +220 -0
  15. data/lib/aws-sdk-code-generator/gem_builder.rb +19 -25
  16. data/lib/aws-sdk-code-generator/hash_formatter.rb +5 -2
  17. data/lib/aws-sdk-code-generator/helper.rb +77 -61
  18. data/lib/aws-sdk-code-generator/plugin_list.rb +146 -0
  19. data/lib/aws-sdk-code-generator/resource_action.rb +69 -0
  20. data/lib/aws-sdk-code-generator/resource_action_code.rb +57 -0
  21. data/lib/aws-sdk-code-generator/resource_association.rb +37 -0
  22. data/lib/aws-sdk-code-generator/resource_attribute.rb +76 -0
  23. data/lib/aws-sdk-code-generator/resource_batch_action.rb +56 -0
  24. data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +136 -0
  25. data/lib/aws-sdk-code-generator/resource_batch_action_documentation.rb +108 -0
  26. data/lib/aws-sdk-code-generator/resource_batch_builder.rb +212 -0
  27. data/lib/aws-sdk-code-generator/resource_builder.rb +48 -0
  28. data/lib/aws-sdk-code-generator/resource_client_request.rb +62 -0
  29. data/lib/aws-sdk-code-generator/resource_client_request_documentation.rb +81 -0
  30. data/lib/aws-sdk-code-generator/resource_client_request_params.rb +86 -0
  31. data/lib/aws-sdk-code-generator/resource_data_method.rb +60 -0
  32. data/lib/aws-sdk-code-generator/resource_has_association.rb +117 -0
  33. data/lib/aws-sdk-code-generator/resource_has_many_association.rb +52 -0
  34. data/lib/aws-sdk-code-generator/resource_has_many_association_code.rb +76 -0
  35. data/lib/aws-sdk-code-generator/resource_identifier.rb +44 -0
  36. data/lib/aws-sdk-code-generator/resource_identifiers_method.rb +29 -0
  37. data/lib/aws-sdk-code-generator/resource_load_method.rb +68 -0
  38. data/lib/aws-sdk-code-generator/resource_method.rb +22 -0
  39. data/lib/aws-sdk-code-generator/resource_skip_params.rb +36 -0
  40. data/lib/aws-sdk-code-generator/resource_value_source.rb +68 -0
  41. data/lib/aws-sdk-code-generator/resource_waiter.rb +80 -0
  42. data/lib/aws-sdk-code-generator/service.rb +30 -7
  43. data/lib/aws-sdk-code-generator/shared_example.rb +131 -0
  44. data/lib/aws-sdk-code-generator/syntax_example.rb +60 -0
  45. data/lib/aws-sdk-code-generator/syntax_example_hash.rb +174 -0
  46. data/lib/aws-sdk-code-generator/underscore.rb +10 -5
  47. data/lib/aws-sdk-code-generator/view.rb +33 -0
  48. data/lib/aws-sdk-code-generator/views.rb +2 -0
  49. data/lib/aws-sdk-code-generator/views/apig_endpoint_class.rb +25 -0
  50. data/lib/aws-sdk-code-generator/views/apig_readme.rb +32 -0
  51. data/lib/aws-sdk-code-generator/views/async_client_class.rb +68 -0
  52. data/lib/aws-sdk-code-generator/views/authorizer_class.rb +17 -0
  53. data/lib/aws-sdk-code-generator/views/client_api_module.rb +583 -0
  54. data/lib/aws-sdk-code-generator/views/client_class.rb +93 -0
  55. data/lib/aws-sdk-code-generator/views/docstring.rb +27 -0
  56. data/lib/aws-sdk-code-generator/views/errors_module.rb +32 -0
  57. data/lib/aws-sdk-code-generator/views/event_streams_module.rb +149 -0
  58. data/lib/aws-sdk-code-generator/views/features/env.rb +9 -0
  59. data/lib/aws-sdk-code-generator/views/features/smoke.rb +51 -0
  60. data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +26 -0
  61. data/lib/aws-sdk-code-generator/views/features/step_definitions.rb +2 -0
  62. data/lib/aws-sdk-code-generator/views/gemspec.rb +39 -5
  63. data/lib/aws-sdk-code-generator/views/resource_class.rb +122 -0
  64. data/lib/aws-sdk-code-generator/views/root_resource_class.rb +58 -0
  65. data/lib/aws-sdk-code-generator/views/service_module.rb +30 -14
  66. data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -0
  67. data/lib/aws-sdk-code-generator/views/types_module.rb +294 -0
  68. data/lib/aws-sdk-code-generator/views/version.rb +2 -0
  69. data/lib/aws-sdk-code-generator/views/waiters_module.rb +37 -0
  70. data/lib/aws-sdk-code-generator/waiter.rb +95 -0
  71. data/lib/aws-sdk-code-generator/yard_option_tag.rb +43 -0
  72. metadata +61 -68
  73. data/lib/aws-sdk-code-generator/dsl/access_control_statement.rb +0 -23
  74. data/lib/aws-sdk-code-generator/dsl/attribute_accessor.rb +0 -43
  75. data/lib/aws-sdk-code-generator/dsl/attribute_reader.rb +0 -11
  76. data/lib/aws-sdk-code-generator/dsl/attribute_writer.rb +0 -11
  77. data/lib/aws-sdk-code-generator/dsl/autoload_statement.rb +0 -15
  78. data/lib/aws-sdk-code-generator/dsl/block_param.rb +0 -11
  79. data/lib/aws-sdk-code-generator/dsl/class.rb +0 -27
  80. data/lib/aws-sdk-code-generator/dsl/code_literal.rb +0 -66
  81. data/lib/aws-sdk-code-generator/dsl/code_object.rb +0 -33
  82. data/lib/aws-sdk-code-generator/dsl/docstring.rb +0 -36
  83. data/lib/aws-sdk-code-generator/dsl/eigenclass.rb +0 -15
  84. data/lib/aws-sdk-code-generator/dsl/extend_statement.rb +0 -12
  85. data/lib/aws-sdk-code-generator/dsl/formatter.rb +0 -25
  86. data/lib/aws-sdk-code-generator/dsl/include_statement.rb +0 -17
  87. data/lib/aws-sdk-code-generator/dsl/main.rb +0 -105
  88. data/lib/aws-sdk-code-generator/dsl/method.rb +0 -108
  89. data/lib/aws-sdk-code-generator/dsl/module.rb +0 -167
  90. data/lib/aws-sdk-code-generator/dsl/option_tag.rb +0 -36
  91. data/lib/aws-sdk-code-generator/dsl/param.rb +0 -43
  92. data/lib/aws-sdk-code-generator/dsl/param_list.rb +0 -38
  93. data/lib/aws-sdk-code-generator/dsl/return_tag.rb +0 -19
  94. data/lib/aws-sdk-code-generator/dsl/tag_default.rb +0 -20
  95. data/lib/aws-sdk-code-generator/dsl/tag_docstring.rb +0 -27
  96. data/lib/aws-sdk-code-generator/dsl/tag_type.rb +0 -18
  97. data/lib/aws-sdk-code-generator/generators/client_api_module.rb +0 -334
  98. data/lib/aws-sdk-code-generator/generators/client_class.rb +0 -389
  99. data/lib/aws-sdk-code-generator/generators/client_operation_documentation.rb +0 -166
  100. data/lib/aws-sdk-code-generator/generators/errors_module.rb +0 -25
  101. data/lib/aws-sdk-code-generator/generators/resource/action.rb +0 -88
  102. data/lib/aws-sdk-code-generator/generators/resource/batch_builder.rb +0 -211
  103. data/lib/aws-sdk-code-generator/generators/resource/builder.rb +0 -50
  104. data/lib/aws-sdk-code-generator/generators/resource/client_getter.rb +0 -15
  105. data/lib/aws-sdk-code-generator/generators/resource/client_request.rb +0 -49
  106. data/lib/aws-sdk-code-generator/generators/resource/client_request_docs.rb +0 -97
  107. data/lib/aws-sdk-code-generator/generators/resource/client_request_params.rb +0 -88
  108. data/lib/aws-sdk-code-generator/generators/resource/collection_class.rb +0 -180
  109. data/lib/aws-sdk-code-generator/generators/resource/data_attribute_getter.rb +0 -24
  110. data/lib/aws-sdk-code-generator/generators/resource/data_loaded_method.rb +0 -18
  111. data/lib/aws-sdk-code-generator/generators/resource/data_method.rb +0 -49
  112. data/lib/aws-sdk-code-generator/generators/resource/exists_method.rb +0 -29
  113. data/lib/aws-sdk-code-generator/generators/resource/extract_identifier_method.rb +0 -32
  114. data/lib/aws-sdk-code-generator/generators/resource/has_association.rb +0 -101
  115. data/lib/aws-sdk-code-generator/generators/resource/has_many_association.rb +0 -108
  116. data/lib/aws-sdk-code-generator/generators/resource/identifier_getter.rb +0 -26
  117. data/lib/aws-sdk-code-generator/generators/resource/identifiers_method.rb +0 -28
  118. data/lib/aws-sdk-code-generator/generators/resource/initialize_method.rb +0 -67
  119. data/lib/aws-sdk-code-generator/generators/resource/load_method.rb +0 -65
  120. data/lib/aws-sdk-code-generator/generators/resource/value_source.rb +0 -68
  121. data/lib/aws-sdk-code-generator/generators/resource/waiter_method.rb +0 -61
  122. data/lib/aws-sdk-code-generator/generators/resource_class.rb +0 -325
  123. data/lib/aws-sdk-code-generator/generators/response_structure_example.rb +0 -83
  124. data/lib/aws-sdk-code-generator/generators/root_resource_class.rb +0 -42
  125. data/lib/aws-sdk-code-generator/generators/service_documentation.rb +0 -64
  126. data/lib/aws-sdk-code-generator/generators/shared_example.rb +0 -132
  127. data/lib/aws-sdk-code-generator/generators/structure_type_class.rb +0 -95
  128. data/lib/aws-sdk-code-generator/generators/syntax_example.rb +0 -169
  129. data/lib/aws-sdk-code-generator/generators/types_module.rb +0 -52
  130. data/lib/aws-sdk-code-generator/generators/waiter_class.rb +0 -62
  131. data/lib/aws-sdk-code-generator/generators/waiters_module.rb +0 -20
@@ -1,15 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class AutoloadStatement
4
-
5
- include Dsl::CodeObject
6
-
7
- def initialize(const_name, path)
8
- @lines = ["autoload :#{const_name}, '#{path}'"]
9
- end
10
-
11
- attr_reader :lines
12
-
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class BlockParam < Param
4
-
5
- def initialize(options = {})
6
- super('&block')
7
- end
8
-
9
- end
10
- end
11
- end
@@ -1,27 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Class < Dsl::Module
4
-
5
- # @option options [String, nil] :extends (nil)
6
- def initialize(name, options = {}, &block)
7
- super(name, options, &block)
8
- @extends = options.fetch(:extends, nil)
9
- end
10
-
11
- def open_module
12
- lines = ["class #{@name}"]
13
- if @extends
14
- extends = @extends.lines.to_a
15
- lines[-1] = "#{lines[-1]} < #{extends[0].rstrip}"
16
- extends[1..-1].each do |line|
17
- lines << line.rstrip
18
- end
19
- lines
20
- else
21
- ["class #{@name}"]
22
- end
23
- end
24
-
25
- end
26
- end
27
- end
@@ -1,66 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class CodeLiteral
4
-
5
- include Dsl::CodeObject
6
-
7
- # @param [String] code
8
- # @option options [Integer] :nesting (0)
9
- def initialize(code = nil, options = {}, &block)
10
- @code_objects = []
11
- @nesting = options.fetch(:nesting, 0)
12
- append(code) if code
13
- yield(self) if block
14
- end
15
-
16
- attr_accessor :nesting
17
-
18
- # @param [String, CodeLiteral]
19
- def <<(code)
20
- if CodeLiteral === code || String === code
21
- @code_objects << [@nesting, code]
22
- else
23
- msg = "expected String or CodeLiteral, got #{code.class}"
24
- raise ArgumentError, msg
25
- end
26
- end
27
- alias :append :<<
28
-
29
- def newline
30
- @code_objects << [@nesting, :newline]
31
- end
32
-
33
- def indent(code = nil, &block)
34
- @nesting += 1
35
- code = CodeLiteral.new(code) unless CodeLiteral === code
36
- append(code)
37
- yield(code) if block
38
- @nesting -= 1
39
- code
40
- end
41
-
42
- def lines(pad = '')
43
- lines = []
44
- @code_objects.each do |i, code_obj|
45
- case code_obj
46
- when :newline
47
- lines << :newline
48
- when String
49
- code_obj.lines.each do |line|
50
- line = line.rstrip
51
- if line == ''
52
- lines << :newline
53
- else
54
- lines << "#{pad}#{' ' * i}#{line}"
55
- end
56
- end
57
- when CodeLiteral
58
- lines.concat(code_obj.lines(pad + (' ' * i)))
59
- end
60
- end
61
- lines
62
- end
63
-
64
- end
65
- end
66
- end
@@ -1,33 +0,0 @@
1
- require 'set'
2
-
3
- module AwsSdkCodeGenerator
4
- module Dsl
5
- # @api private
6
- module CodeObject
7
-
8
- def to_s
9
- format(lines)
10
- end
11
-
12
- private
13
-
14
- def underscore(str)
15
- Underscore.underscore(str)
16
- end
17
-
18
- def format(lines, nesting = 0)
19
- i = ' ' * nesting
20
- lines.inject([]) do |code, obj|
21
- case obj
22
- when :newline then code << "\n"
23
- when String then code << "#{i}#{obj}\n"
24
- when CodeObject then code.concat(obj.lines)
25
- when Array, Enumerator then code << format(obj, nesting + 1)
26
- else raise ArgumentError, "got #{obj.class}"
27
- end
28
- end.join
29
- end
30
-
31
- end
32
- end
33
- end
@@ -1,36 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- # @api private
4
- class Docstring
5
-
6
- include Dsl::CodeObject
7
-
8
- # @param [String, nil]
9
- def initialize(docstring = nil, &block)
10
- @lines = []
11
- append(docstring)
12
- yield(self) if block
13
- end
14
-
15
- def append(docstring)
16
- @lines.concat(docstring.to_s.rstrip.lines.map do |line|
17
- if line == "\n"
18
- "#"
19
- else
20
- "# #{line.rstrip}"
21
- end
22
- end)
23
- end
24
- alias :<< :append
25
-
26
- # @return [Array<String>]
27
- attr_reader :lines
28
-
29
- # @return [Boolean]
30
- def empty?
31
- @lines.empty?
32
- end
33
-
34
- end
35
- end
36
- end
@@ -1,15 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Eigenclass < Dsl::Module
4
-
5
- def initialize(&block)
6
- super('self', &block)
7
- end
8
-
9
- def open_module
10
- ["class << self"]
11
- end
12
-
13
- end
14
- end
15
- end
@@ -1,12 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
-
4
- class ExtendStatement < IncludeStatement
5
-
6
- def lines
7
- ["extend #{@module_name}"]
8
- end
9
-
10
- end
11
- end
12
- end
@@ -1,25 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Formatter
4
-
5
- def initialize
6
- @indent = ' '
7
- end
8
-
9
- def format(lines, nesting:0)
10
- i = @indent * nesting
11
- lines.inject([]) do |code, section|
12
- case section
13
- when "\n" then code << "\n" # do not indent blank lines
14
- when CodeObject then code.concat(section.lines)
15
- when String then code << "#{i}#{section}"
16
- when Array then code << format(section, nesting:nesting + 1)
17
- else
18
- raise ArgumentError, "got #{section.class}"
19
- end
20
- end.join
21
- end
22
-
23
- end
24
- end
25
- end
@@ -1,17 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class IncludeStatement
4
-
5
- include Dsl::CodeObject
6
-
7
- def initialize(module_name)
8
- @module_name = module_name
9
- end
10
-
11
- def lines
12
- ["include #{@module_name}"]
13
- end
14
-
15
- end
16
- end
17
- end
@@ -1,105 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Main
4
-
5
- include Dsl::CodeObject
6
-
7
- # @option options [Main, Module] :parent (nil)
8
- def initialize(options = {}, &block)
9
- @comments = Docstring.new(nil)
10
- @top_content = []
11
- @code_objects = []
12
- @parent = options.fetch(:parent, nil)
13
- yield(self) if block
14
- end
15
-
16
- # @return [nil, CodeObject]
17
- attr_accessor :parent
18
-
19
- # @return [nil, CodeObject]
20
- def root
21
- root = self
22
- root = root.parent while root && root.parent
23
- root
24
- end
25
-
26
- def add(*code_objects)
27
- code_objects.each do |code_obj|
28
- @code_objects << code_obj unless code_obj.nil?
29
- end
30
- end
31
-
32
- def code(code = nil, &block)
33
- @code_objects << CodeLiteral.new(code, &block)
34
- end
35
-
36
- def comments(docstring)
37
- @comments = Docstring.new(docstring)
38
- end
39
-
40
- def include_module(module_name)
41
- add(IncludeStatement.new(module_name))
42
- end
43
- alias :include :include_module
44
-
45
- def extend_module(module_name)
46
- add(ExtendStatement.new(module_name))
47
- end
48
- alias :extend :extend_module
49
-
50
- def require_statement(path)
51
- @top_content << "require '#{path}'"
52
- end
53
- alias require require_statement
54
-
55
- # Allows inserting top-of document content.
56
- def top(string)
57
- root.instance_variable_get("@top_content") << string
58
- end
59
-
60
- def require_relative(path)
61
- @top_content << "require_relative '#{path}'"
62
- end
63
-
64
- def method(name, options = {}, &block)
65
- m = Dsl::Method.new(name, options)
66
- yield(m) if block
67
- add(m)
68
- end
69
-
70
- def module(name, &block)
71
- m = Dsl::Module.new(name, parent: self)
72
- yield(m) if block
73
- add(m)
74
- m
75
- end
76
-
77
- def class(name, options = {}, &block)
78
- c = Dsl::Class.new(name, options.merge(parent: self))
79
- yield(c) if block
80
- add(c)
81
- c
82
- end
83
-
84
- def lines
85
-
86
- lines = []
87
-
88
- lines.concat(@comments.lines)
89
- lines << :newline unless @comments.empty?
90
-
91
- @top_content.each do |statement|
92
- lines << statement
93
- end
94
- lines << :newline unless @top_content.empty?
95
-
96
- @code_objects.each.with_index do |code_obj, n|
97
- lines.concat(code_obj.lines)
98
- lines << :newline unless n == @code_objects.size - 1
99
- end
100
- lines
101
- end
102
-
103
- end
104
- end
105
- end
@@ -1,108 +0,0 @@
1
- module AwsSdkCodeGenerator
2
- module Dsl
3
- class Method
4
-
5
- include Dsl::CodeObject
6
-
7
- # @option options [Symbol] :access (:public)
8
- # @option options [String, nil] :docstring (nil)
9
- def initialize(name, options = {}, &block)
10
- @name = name.to_s
11
- @access = options.fetch(:access, :public)
12
- @code_objects = []
13
- @params = []
14
- @option_tags = []
15
- @return_tags = []
16
- @aliases = []
17
- @docstring = Dsl::Docstring.new(options.fetch(:docstring, nil))
18
- @api_private = options.fetch(:api_private, false)
19
- yield(self) if block
20
- end
21
-
22
- attr_reader :name
23
-
24
- attr_reader :access
25
-
26
- attr_reader :aliases
27
-
28
- def param(name, options = {})
29
- @params << Param.new(name, options)
30
- end
31
-
32
- def option(options)
33
- @option_tags << OptionTag.new(options)
34
- end
35
-
36
- def returns(type, options = {})
37
- @return_tags << ReturnTag.new(options.merge(type:type))
38
- end
39
-
40
- def add(*code_objects)
41
- @code_objects.concat(code_objects)
42
- end
43
-
44
- def code(code = nil, &block)
45
- @code_objects << CodeLiteral.new(code, &block)
46
- end
47
-
48
- def empty?
49
- @code_objects.empty?
50
- end
51
-
52
- def docstring(docstring = nil, &block)
53
- @docstring.append(docstring)
54
- yield(@docstring) if block
55
- @docstring
56
- end
57
-
58
- def block_param
59
- @params << BlockParam.new
60
- end
61
-
62
- def alias_as(other_name)
63
- @aliases << other_name.to_s
64
- end
65
-
66
- def lines
67
- code = []
68
- code.concat(yard_docs)
69
- code << method_signature
70
- code << method_body
71
- code << method_end
72
- code.concat(@aliases.map { |a| "alias :#{a} :#{@name}" })
73
- code
74
- end
75
-
76
- private
77
-
78
- def yard_docs
79
- docs = []
80
- docs.concat(@docstring.lines)
81
- tags = []
82
- tags.concat(ParamList.new(@params).tags)
83
- tags.concat(@option_tags)
84
- tags.concat(@return_tags)
85
- tags << "# @api private" if @api_private
86
- tags.each.with_index do |tag, n|
87
- docs.concat(tag.lines.to_a)
88
- end
89
- docs.compact
90
- end
91
-
92
- def method_signature
93
- "def #{@name}#{ParamList.new(@params).signature}"
94
- end
95
-
96
- def method_body
97
- @code_objects.inject([]) do |lines, code_obj|
98
- lines.concat(code_obj.lines)
99
- end
100
- end
101
-
102
- def method_end
103
- "end"
104
- end
105
-
106
- end
107
- end
108
- end