Skip to content

Commit 0fd7cfb

Browse files
committed
[API] Generator: Remove noise by hardcoding ruby
1 parent 43957a8 commit 0fd7cfb

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

elasticsearch-api/utils/thor/generate_source.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ module API
2323
# module namespace, method names, and RDoc documentation,
2424
# as well as test files for each endpoint.
2525
#
26-
# Currently it only generates Ruby source, but can easily be
27-
# extended and adapted to generate source code for other
28-
# programming languages.
29-
#
3026
class SourceGenerator < Thor
3127
namespace 'api:code'
3228

@@ -36,7 +32,6 @@ class SourceGenerator < Thor
3632
__root = Pathname( File.expand_path('../../..', __FILE__) )
3733

3834
desc "generate", "Generate source code and tests from the REST API JSON specification"
39-
method_option :language, default: 'ruby', desc: 'Programming language'
4035
method_option :force, type: :boolean, default: false, desc: 'Overwrite the output'
4136
method_option :verbose, type: :boolean, default: false, desc: 'Output more information'
4237
method_option :input, default: File.expand_path(SRC_PATH, __FILE__), desc: 'Path to directory with JSON API specs'
@@ -49,7 +44,7 @@ def generate(*files)
4944
@output = Pathname(options[:output])
5045

5146
# -- Test helper
52-
copy_file "templates/ruby/test_helper.rb", @output.join('test').join('test_helper.rb') if options[:language] == 'ruby'
47+
copy_file "templates/test_helper.rb", @output.join('test').join('test_helper.rb')
5348

5449
# Remove unwanted files
5550
files = Dir.entries(@input.to_s).reject do |f|
@@ -99,12 +94,12 @@ def generate(*files)
9994

10095
empty_directory @output.join('api').join( @module_namespace.join('/') )
10196

102-
template "templates/#{options[:language]}/method.erb", @path_to_file
97+
template "templates/method.erb", @path_to_file
10398

10499
if options[:verbose]
105100
colorized_output = CodeRay.scan_file(@path_to_file, :ruby).terminal
106101
lines = colorized_output.split("\n")
107-
say_status options[:language].downcase,
102+
say_status 'ruby',
108103
lines.first + "\n" + lines[1, lines.size].map { |l| ' '*14 + l }.join("\n"),
109104
:yellow
110105
end
@@ -115,12 +110,12 @@ def generate(*files)
115110
@test_file = @test_directory.join("#{@method_name}_test.rb")
116111

117112
empty_directory @test_directory
118-
template "templates/#{options[:language]}/test.erb", @test_file
113+
template "templates/test.erb", @test_file
119114

120115
if options[:verbose]
121116
colorized_output = colorized_output = CodeRay.scan_file(@test_file, :ruby).terminal
122117
lines = colorized_output.split("\n")
123-
say_status options[:language].downcase,
118+
say_status 'ruby',
124119
lines.first + "\n" + lines[1, lines.size].map { |l| ' '*14 + l }.join("\n"),
125120
:yellow
126121
say '▬'*terminal_width

0 commit comments

Comments
 (0)