Sha256: 6a0b743d062fca41adb250e32b2af4db96fd58c40bf040c67579c056fff2af8b

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

module Terraforming

  def exist?(file)
    File.exist?(destination_path(file))
  end

  def exemplar?
    options[:exemplar] || options[:exemplar].nil? && exist?('spec/exemplars')
  end

  def factory?
    options[:factory] || options[:factory].nil? && exist?('spec/factories')
  end

  def attributes
    views
    super
  end

  def full_name
    (class_path + [singular_name]).join("_")
  end

  def views
    return @views if @views
    @views = []
    haml = defined?(Haml) ? "haml" : "erb"
    args.delete_if do |arg|
      @views << case arg
        when /^[\w\/]+\.\w+\.\w+$/         then arg
        when /^[\w\/]+$/                   then "#{arg}.html.#{haml}"
        when /^[\w\/]+\.(?:html|fbml)$/    then "#{arg}.#{haml}"
        when /^[\w\/]+\.(?:xml|rss|atom)$/ then "#{arg}.builder"
        when /^[\w\/]+\.js$/               then "#{arg}.rjs"
        when /^[\w\/]+\.\w+$/              then "#{arg}.erb"
        else next
      end
    end
    @views.compact!
    @views
  end

  def actions
    views.map do |arg|
      arg.sub(/\..*$/,'')
    end.uniq.reject do |arg|
      arg =~ /^_/
    end
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
hashrocket-terraformation-0.1.0 rails_generators/terraforming.rb
hashrocket-terraformation-0.1.2 rails_generators/terraforming.rb
terraformation-0.2.2 rails_generators/terraforming.rb
terraformation-0.2.1 rails_generators/terraforming.rb
terraformation-0.2.0 rails_generators/terraforming.rb
terraformation-0.1.3 rails_generators/terraforming.rb
terraformation-0.1.2 rails_generators/terraforming.rb