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
31 32 33 34 35 36 |
# File 'lib/commands/open_ai_commands.rb', line 31 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 |
# File 'lib/commands/open_ai_commands.rb', line 11 def make(request, path = nil) path ||= [:path] if [:edit] pp 'Editing File...' OpenAi.edit_file([:edit], request) pp "File #{[:edit]} edited" elsif path pp 'Generating File...' OpenAi.create_file(path, request) pp "File created in #{path}" else puts OpenAi.output(request) end end |
#steps(name) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/commands/open_ai_commands.rb', line 49 def steps(name) path = 'features/step_definitions' 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 |