Sha256: aa8b0e8112a45bb9ced284d877c0314af5864f6907c7bcc38112c8217c014f34

Contents?: true

Size: 1.63 KB

Versions: 21

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require 'thor'

class Scaffolding < Thor::Group
  include Thor::Actions

  argument :name, optional: true
  argument :path, optional: true

  def self.source_root
    "#{File.dirname(__FILE__)}/templates"
  end

  def generate_page
    template('page_object.tt', default_path("page_objects/pages/#{name}.rb", '_page.rb'))
  end

  def generate_feature
    template('feature.tt', default_path("features/#{name}.feature", '.feature'))
  end

  def generate_spec
    template('spec.tt', default_path("spec/#{name}_page_spec.rb", '_spec.rb'))
  end

  def generate_helper
    template('helper.tt', default_path("helpers/#{name}_helper.rb", '_helper.rb'))
  end

  def generate_steps
    template('steps.tt', default_path("features/step_definitions/#{name}_steps.rb", '_steps.rb'))
  end

  def generate_config
    template('../../generators/templates/common/config.tt',
             default_path('config/config.yml', '.yml'))
  end

  def delete_page
    remove_file(default_path("page_objects/pages/#{name}.rb", '_page.rb'))
  end

  def delete_feature
    remove_file(default_path("features/#{name}.feature", '.feature'))
  end

  def delete_spec
    remove_file(default_path("spec/#{name}_page_spec.rb", '_spec.rb'))
  end

  def delete_helper
    remove_file(default_path("helpers/#{name}_helper.rb", '_helper.rb'))
  end

  def delete_steps
    remove_file(default_path("features/step_definitions/#{name}_steps.rb", '_steps.rb'))
  end

  def delete_config
    remove_file(default_path('config/config.yml', '.yml'))
  end

  def default_path(standard_path, file_type)
    path ? "#{path}/#{name}#{file_type}" : standard_path
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
ruby_raider-1.0.8 lib/scaffolding/scaffolding.rb
ruby_raider-1.0.7 lib/scaffolding/scaffolding.rb
ruby_raider-1.0.6 lib/scaffolding/scaffolding.rb
ruby_raider-1.0.5 lib/scaffolding/scaffolding.rb
ruby_raider-1.0.4 lib/scaffolding/scaffolding.rb
ruby_raider-1.0.3 lib/scaffolding/scaffolding.rb
ruby_raider-1.0.2 lib/scaffolding/scaffolding.rb
ruby_raider-1.0.1 lib/scaffolding/scaffolding.rb
ruby_raider-1.0.0 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.9 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.8 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.7 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.6 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.5 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.4 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.3 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.2 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.1 lib/scaffolding/scaffolding.rb
ruby_raider-0.9.0 lib/scaffolding/scaffolding.rb
ruby_raider-0.8.9 lib/scaffolding/scaffolding.rb