Sha256: 20bfafd839b78565ac30280587b7796b2b8027d15eea9028c831ac37df159674

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'thor/group'
require 'git'
require 'active_support/inflector'
require 'data_magic/standard_translation'

module WatirInstall
  module Generators
    class Data < Thor::Group
      include Thor::Actions

      TRANSLATIONS = %i(full_name first_name last_name name_prefix name_suffix
      title street_address secondary_address city state state_abbr zip_code
      country company_name catch_phrase credit_card_number credit_card_type
      words sentence sentences paragraphs characters email_address domain_name
      url user_name phone_number cell_phone password).freeze

      argument :klass, type: :string, desc: 'The data object being created'
      argument :keys, required: false, default: [], type: :array, desc: 'These are keys for data'

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

      def git
        @git = Git.open('./') if Dir.entries('./').include?('.git')
      end

      def name
        Dir.pwd[/[^\/]*$/]
      end

      def data_files
        file = "#{Dir.pwd}/spec/support/data/#{klass.downcase}.rb"
        template "spec/support/data/data.rb.tt", file
        @git.add(file) if @git
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir_install-0.3.1 lib/watir_install/generators/data.rb