Class: ScaffoldingCommands
- Inherits:
-
Thor
- Object
- Thor
- ScaffoldingCommands
- Defined in:
- lib/commands/scaffolding_commands.rb
Instance Method Summary collapse
- #component(name) ⇒ Object
- #destroy(*names) ⇒ Object
- #feature(name) ⇒ Object
- #from_url(url) ⇒ Object
- #helper(name) ⇒ Object
- #page(name) ⇒ Object
- #scaffold(*names) ⇒ Object
- #spec(name) ⇒ Object
- #steps(name) ⇒ Object
Instance Method Details
#component(name) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/commands/scaffolding_commands.rb', line 96 def component(name) return delete_scaffolding(name, 'component') if [:delete] return dry_run_preview(name, 'component') if [:dry_run] generate_scaffolding(name, 'component', [:path]) end |
#destroy(*names) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/commands/scaffolding_commands.rb', line 129 def destroy(*names) if names.empty? say 'Please provide at least one name to destroy', :red return end names.each { |name| destroy_scaffold(name, [:with]) } end |
#feature(name) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/commands/scaffolding_commands.rb', line 37 def feature(name) return delete_scaffolding(name, 'feature') if [:delete] return dry_run_preview(name, 'feature') if [:dry_run] generate_scaffolding(name, 'feature', [:path]) end |
#from_url(url) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/commands/scaffolding_commands.rb', line 146 def from_url(url) require_relative '../scaffolding/url_analyzer' analyzer = UrlAnalyzer.new(url, name_override: [:name], ai: [:ai]) analysis = analyzer.analyze.to_h page_name = analysis[:page_name] if [:dry_run] DryRunPresenter.preview([ "page_objects/pages/#{page_name}.rb", "spec/#{page_name}_spec.rb" ]) return end Scaffolding.new([page_name]).generate_page_from_url(analysis) Scaffolding.new([page_name]).generate_spec_from_url(analysis) say "Generated page object and spec for #{url}" end |
#helper(name) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/commands/scaffolding_commands.rb', line 70 def helper(name) return delete_scaffolding(name, 'helper') if [:delete] return dry_run_preview(name, 'helper') if [:dry_run] generate_scaffolding(name, 'helper', [:path]) end |
#page(name) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/commands/scaffolding_commands.rb', line 24 def page(name) return delete_scaffolding(name, 'page') if [:delete] return dry_run_preview(name, 'page') if [:dry_run] generate_scaffolding(name, 'page', [:path], uses: [:uses]) end |
#scaffold(*names) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/commands/scaffolding_commands.rb', line 111 def scaffold(*names) return interactive_scaffold if names.empty? names.each do |name| if [:crud] generate_crud(name) elsif [:with] generate_selected_components(name, [:with]) else generate_default_scaffold(name) end end end |
#spec(name) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/commands/scaffolding_commands.rb', line 56 def spec(name) return delete_scaffolding(name, 'spec') if [:delete] return dry_run_preview(name, 'spec') if [:dry_run] return generate_spec_from_page(name, [:from], ai: [:ai]) if [:from] generate_scaffolding(name, 'spec', [:path], uses: [:uses]) end |
#steps(name) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/commands/scaffolding_commands.rb', line 83 def steps(name) return delete_scaffolding(name, 'steps') if [:delete] return dry_run_preview(name, 'steps') if [:dry_run] generate_scaffolding(name, 'steps', [:path]) end |