Class: Gambiarra::UI::Install
- Defined in:
- lib/gambiarra/ui/views/install.rb
Instance Attribute Summary
Attributes inherited from View
Instance Method Summary collapse
Methods inherited from BaseView
#project_constant, #project_name, #thor
Methods inherited from View
#ensure_param, #go_to, inherited, #initialize, #output, questions, render, respond, set_path
Constructor Details
This class inherits a constructor from Gambiarra::View
Instance Method Details
#render ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/gambiarra/ui/views/install.rb', line 14 def render exit if params[:confirm_installation] == 'exit' thor.empty_directory("lib/#{project_name}/ui/views") thor.create_file("lib/#{project_name}/ui.rb", <<~RUBY) require('gambiarra') require File.('../ui/base_view', __FILE__) views = Dir[File.('../ui/views/*', __FILE__)].each do |view| require(view) end RUBY thor.create_file("lib/#{project_name}/ui/base_view.rb", <<~RUBY) module #{project_constant} module UI class BaseView < Gambiarra::View def render(view) view.render end end end end RUBY thor.create_file("lib/#{project_name}/ui/views/index.rb", <<~RUBY) module #{project_constant} module UI class Index < BaseView questions({ path: { statement: 'Welcome to #{project_name.titleize}', options: [ 'an option', 'exit' ] } }) end end end RUBY thor.create_file("exe/#{project_name.gsub('_', '-')}", <<~RUBY) #!/usr/bin/env ruby # frozen_string_literal: true $LOAD_PATH.unshift(File.('../../lib', __FILE__)) require '#{project_name}/ui' module #{project_constant} module UI class App < Gambiarra::App def setup # you can setup stuff here end end end end #{project_constant}::UI::App.start(ARGV.join(' ')) RUBY thor.chmod("exe/#{project_name.gsub('_', '-')}", '+x') "Installed Gambiarra in #{Dir.pwd}" end |