Sha256: 74677d3b58e8eeed38b2d5548ea600ae96452fe11713e54740c91b3728cf0a78

Contents?: true

Size: 1.49 KB

Versions: 32

Compression:

Stored size: 1.49 KB

Contents

module Templater
  module Actions
    class EmptyDirectory < Action

      # Builds a new Directory
      # 
      # === Parameters
      # generator<Object>:: The generator
      # name<Symbol>:: The name of this directory
      # destination<String>:: Full path to the destination of this directory
      # options<Hash{Symbol=>Symbol}:: Options, including callbacks.
      def initialize(generator, name, destination, options={})
        self.generator = generator
        self.name = name
        self.destination = destination
        self.options = options
      end

      # Returns an empty String: there's nothing to read from.
      #
      # === Returns
      # String:: The source file.
      def render
        ''
      end

      # Checks if the destination file already exists.
      #
      # === Returns
      # Boolean:: true if the file exists, false otherwise.
      def exists?
        ::File.exists?(destination)
      end
  
      # For empty directory this is in fact alias for exists? method.
      # 
      # === Returns
      # Boolean:: true if it is identical, false otherwise.
      def identical?
        exists?
      end
  
      # Renders the template and copies it to the destination.
      def invoke!
        callback(:before)
        ::FileUtils.mkdir_p(destination)
        callback(:after)
      end
    
      # removes the destination file
      def revoke!
        ::FileUtils.rm_rf(::File.expand_path(destination))
      end

    end # EmptyDirectory
  end # Actions
end # Templater

Version data entries

32 entries across 31 versions & 3 rubygems

Version Path
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
ginst-2009.12.8 vendor/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
ginst-2009.11.24 vendor/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
ginst-2009.11.23 vendor/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.10.17 vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.10.16 vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.10.15 vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
middleman-0.10.14 vendor/gems/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
ginst-2.0.1 vendor/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
ginst-2.0.0 vendor/gems/templater-1.0.0/lib/templater/actions/empty_directory.rb
templater-1.0.0 lib/templater/actions/empty_directory.rb
templater-0.2.2 lib/templater/actions/empty_directory.rb
templater-0.3.4 lib/templater/actions/empty_directory.rb
templater-0.3.3 lib/templater/actions/empty_directory.rb