Module: FoobarTemplates::Core::DirToTemplate

Defined in:
lib/foobar_templates/core/dir_to_template.rb

Class Method Summary collapse

Class Method Details

.🧙🪄!(file_enumerator, template_name: "asdf-pkg", dry_run: false) ⇒ Object

Takes in a file_enumerator such as Find.find(‘.’) and performs literal string replacements of project name variants with foo-bar template placeholders



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/foobar_templates/core/dir_to_template.rb', line 12

def 🧙🪄! file_enumerator, template_name: "asdf-pkg", dry_run: false
  # FOO_* composite values contain the project name (e.g. URLs, paths), so
  # they must be substituted BEFORE the name-variant replacements rewrite
  # `good-dog` → `foo-bar` inside them.
  replacements = build_foo_var_replacement_pairs(template_name) + build_replacement_pairs(template_name)
  files_changed = []
  file_enumerator.each do |path|
    next if should_skip?(path)

    conduct_pkg_name_to_template_variable_replacements!(path, replacements) unless dry_run

    files_changed << "Processed: #{path}"
  end      
  files_changed
end