Sha256: 74367ffab7bbd9eb55a6eee832efa4a8f47a85780eafa288801fcb4d2ee22500

Contents?: true

Size: 1.33 KB

Versions: 55

Compression:

Stored size: 1.33 KB

Contents

module Rails
  module Generators
    module Actions

      attr_accessor :stategies
      attr_accessor :recipes
      attr_reader :template_options

      def initialize_templater
        self.recipes = []
        @stategies = []
        @template_options = {}
      end

      def execute_stategies
        stategies.each {|stategy| stategy.call }
      end

      def load_options
        @template_options[:design] = ask("Which design framework? [none(default), compass]: ").downcase
        @template_options[:design] = "none" if @template_options[:design].nil?
      end

      def recipe(name)
        recipes << name
        File.join File.dirname(__FILE__), 'recipes', "#{name}.rb"
      end

      # TODO: Refactor loading of files

      def load_snippet(name, group)
        path = File.expand_path name, snippet_path(group)
        File.read path
      end

      def load_template(name, group, match={})
        path = File.expand_path name, template_path(group)
        contents = File.read path
        match.each do |key, value|
          contents.gsub! "\%#{key.to_s}\%", value
        end
        contents
      end

      def snippet_path(name)
        File.join(File.dirname(__FILE__), 'snippets', name)
      end

      def template_path(name)
        File.join(File.dirname(__FILE__), 'templates', name)
      end

    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
wheels-0.0.18 lib/generators/wheels/core_extensions.rb
wheels-0.0.17 lib/generators/wheels/core_extensions.rb
wheels-0.0.16 lib/generators/wheels/core_extensions.rb
wheels-0.0.15 lib/generators/wheels/core_extensions.rb
wheels-0.0.14 lib/generators/wheels/core_extensions.rb
wheels-0.0.13 lib/generators/wheels/core_extensions.rb
wheels-0.0.11 lib/generators/wheels/core_extensions.rb
wheels-0.0.10 lib/generators/wheels/core_extensions.rb
wheels-0.0.9 lib/generators/wheels/core_extensions.rb
wheels-0.0.8 lib/generators/wheels/core_extensions.rb
wheels-0.0.7 lib/generators/wheels/core_extensions.rb
wheels-0.0.6 lib/generators/wheels/core_extensions.rb
wheels-0.0.5 lib/generators/wheels/core_extensions.rb
wheels-0.0.4 lib/generators/wheels/core_extensions.rb
wheels-0.0.3 lib/generators/wheels/core_extensions.rb