Method: Fones::Builder#copy_functions

Defined in:
lib/fones/builder.rb

#copy_functionsObject



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/fones/builder.rb', line 98

def copy_functions
  functions_erb_path = File.join(@functions_path, 'functions.php.erb')
  functions_php_path = File.join(@functions_path, 'functions.php')

  if File.exists?(functions_erb_path)
    destination = File.join(@project.build_path, 'functions.php')
    write_erb(functions_erb_path, destination)
  elsif File.exists?(functions_php_path)
    FileUtils.cp functions_php_path, @project.build_path
  end

  library_paths = Dir.glob(File.join(@functions_path, '*')).reject do |filename|
    [functions_erb_path, functions_php_path].include?(filename)
  end

  unless library_paths.empty?

    # Iterate over all files in source/library, skipping the actual functions.php file
    paths = Dir.glob(File.join(@functions_path, '**', '*')).reject do |filename|
      [functions_erb_path, functions_php_path].include?(filename)
    end

    copy_paths_with_erb(paths, @functions_path, @project.build_path)
  end
end