Sha256: 0fb1c0c13c8e78efe749683e23878234cfef6c96939cb68ee836f12f854cfa3c

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

require 'taza/settings'

module WatirCraft
  # Assumes #site_name and #destination_root and #usage methods are defined.
  module GeneratorHelper
    def site_module
      @site_name.camelize
    end
    protected
    def configured_validated_site
      site = configured_site
      check_if_site_exists site
      site
    end
    def configured_site
      site_name = Taza::Settings.config_file[:site]
    end
    def check_if_site_exists site_name=@site_name
      if site_name.nil?
        raise RubiGen::UsageError, 
          "Error. A site must first be specified in config.yml"
      end
      site_file = File.join(destination_root,'lib',"#{site_name.underscore}.rb")
      unless File.exists?(site_file)
        raise RubiGen::UsageError, 
          "Error. Site file #{site_file} not found. (Check config.yml)"
      end
    end    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bret-watircraft-0.5.0 lib/watircraft/generator_helper.rb