Class: OpenAiCommands
- Inherits:
-
Thor
- Object
- Thor
- OpenAiCommands
- Defined in:
- lib/commands/open_ai_commands.rb
Instance Method Summary collapse
Instance Method Details
#cucumber(name) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/commands/open_ai_commands.rb', line 32 def cucumber(name) feature_path = "features/#{name}.feature" make([:prompt], feature_path) prompt_step = "create cucumber steps for the following scenarios in ruby #{File.read(feature_path)}" make(prompt_step, "features/step_definitions/#{name}_steps.rb") end |
#make(request, path = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/commands/open_ai_commands.rb', line 11 def make(request, path = nil) path ||= [:path] edit_path = [:edit] if edit_path pp 'Editing File...' OpenAi.edit_file(path: edit_path, request: request) pp "File #{edit_path} edited" elsif path pp 'Generating File...' OpenAi.create_file(path: path, request: request) pp "File created in #{path}" else puts OpenAi.output(request: request) end end |
#steps(name) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/commands/open_ai_commands.rb', line 50 def steps(name) path = 'features/step_definitions' input = [:input] if input prompt = [:prompt] || 'create cucumber steps for the following scenarios in ruby' content = "#{prompt} #{File.read(input)}" make(content, "#{path}/#{name}_steps.rb") else make([:open_ai], "#{path}/#{name}_steps.rb") end end |