Sha256: 79ffd4d128ed53d3feddb7c6d6b0328c9e522fb40c1f2477aaf5c3adb5d5761a

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require_relative 'sass_generator.rb'
require_relative 'coffee_generator.rb'
require_relative 'haml_generator.rb'
require_relative 'structure_generator.rb'


module Generator
  SassGenerator::add_load_path('./dev_root/shared/sass')

  class Generator
    def initialize
      @generators = [ StructureGenerator.new,
                      CoffeeGenerator.new,
                      SassGenerator.new,
                      HamlGenerator.new ]
    end

    def web_root
      return 'web_root'
    end

    def dev_root
      return 'dev_root'
    end

    def projects_folder
      Dir.glob("#{dev_root}/*")
    end

    def project_name project_folder
      project_folder.split('/')[-1]
    end

    def project_web_folder project
      "#{web_root}/#{project}"
    end

    def generate(path=nil)
      if path
        files = [File.dirname(path)]
      else
        files = projects_folder
      end

      files.each do |project_folder|
        next unless File.directory? project_folder
        next if project_folder.include? 'shared'

        project_name = project_folder.split('/')[-1]
        project_output_folder = project_web_folder(project_name)

        puts "generating: \e[32m#{project_output_folder}\e[0m"
        @generators.each do |generator|
          generator.generate(project_folder, project_output_folder)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
easy_html_creator-1.3.2 lib/generator/generator.rb
easy_html_creator-1.3.1 lib/generator/generator.rb
easy_html_creator-1.3.0 lib/generator/generator.rb