Class: Marv::Project::Templates

Inherits:
Object
  • Object
show all
Defined in:
lib/marv/project/builder/templates.rb

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ Templates

Initialize templates builder



6
7
8
9
10
11
# File 'lib/marv/project/builder/templates.rb', line 6

def initialize(builder)
  @builder = builder
  @task = builder.task
  @project = builder.project
  @config = builder.project.config
end

Instance Method Details

#clean_templatesObject

Clean Templates



14
15
16
17
18
19
20
21
22
# File 'lib/marv/project/builder/templates.rb', line 14

def clean_templates
  @task.shell.mute do
    ::Dir.glob(::File.join(@project.build_path, '*.php')).each do |file|
      unless file.include?('functions.php') || file.include?(::File.basename(@project.plugin_file))
        @task.remove_file file
      end
    end
  end
end

#copy_templatesObject

Copy templates



25
26
27
28
29
30
31
32
33
# File 'lib/marv/project/builder/templates.rb', line 25

def copy_templates
  @task.shell.mute do
    ::Dir.glob(::File.join(@project.templates_path, '**', '*')).each do |file|
      target = ::File.join(@project.build_path, ::File.basename(file))

      @task.copy_file file, target, :force => true unless ::File.directory?(file)
    end
  end
end