Skip to content

Commit

Permalink
[API] Fixed the api:code:generate Thor task
Browse files Browse the repository at this point in the history
* Removed invalid documentation instructions, `--input` is needed
* `Dir[@input]` didn't really work...
  • Loading branch information
karmiq committed Jun 11, 2018
1 parent 74c4d1d commit 0310ce6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions elasticsearch-api/utils/thor/generate_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SourceGenerator < Thor

__root = Pathname( File.expand_path('../../..', __FILE__) )

desc "generate <PATH TO JSON SPEC FILES>", "Generate source code and tests from the REST API JSON specification"
desc "generate", "Generate source code and tests from the REST API JSON specification"
method_option :language, default: 'ruby', desc: 'Programming language'
method_option :force, type: :boolean, default: false, desc: 'Overwrite the output'
method_option :verbose, type: :boolean, default: false, desc: 'Output more information'
Expand All @@ -46,7 +46,11 @@ def generate(*files)
# -- Test helper
copy_file "templates/ruby/test_helper.rb", @output.join('test').join('test_helper.rb') if options[:language] == 'ruby'

Dir[@input].each do |file|
files = Dir.entries(@input.to_s).reject { |f| f.start_with?('.') }

files.each do |filepath|
file = @input.join(filepath)

@path = Pathname(file)
@json = MultiJson.load( File.read(@path) )
@spec = @json.values.first
Expand Down

0 comments on commit 0310ce6

Please sign in to comment.