Sha256: 400dc2973f6ae3144f9d8bd233596b0c8a943aa0faf06232df2480e33cc71f4c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Gambiarra
  module UI
    class CreateView < BaseView
      questions(view_name: {
        statement: 'Type the view name in a human way. Ex: "cook rice"' }
      )

      def render
        view = params[:view_name].gsub(/ |_|-/, '_').downcase
        thor.create_file("lib/#{project_name}/ui/views/#{view}.rb", <<~RUBY)
          module #{project_constant}
            module UI
              # you can also inherit from your other views, questions will be merged
              # assign them to nil to erase them
              class #{view.camelize} < BaseView
                questions({
                  question_name: {
                    statement: 'Welcome to #{project_name.titleize}',
                    options: ['exit'] # delete options to make this free form
                  }
                })

                def render
                  # might want render something here after questions are answered
                end
              end
            end
          end

        RUBY
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gambiarra-0.0.3 lib/gambiarra/ui/views/create_view.rb