Module: Boxing::Utils

Included in:
Generator
Defined in:
lib/boxing/utils.rb

Overview

Utility methods

Since:

  • 0.11.0

Instance Method Summary collapse

Instance Method Details

#current_pathString

Get project root

Returns:

  • (String)

Since:

  • 0.11.0



15
16
17
18
19
20
# File 'lib/boxing/utils.rb', line 15

def current_path
  return Hanami.app.root if defined?(Hanami)
  return Rails.root if defined?(Rails)

  Pathname.new(Dir.pwd)
end

#template(destination, template, context: nil) ⇒ Object

Generate file from template

Parameters:

  • destination (String)
  • template (String)
  • context (Binding) (defaults to: nil)

Since:

  • 0.11.0



29
30
31
# File 'lib/boxing/utils.rb', line 29

def template(destination, template, context: nil)
  Generator.new(destination, -> { Template.new(template).render(context) }).execute
end