Class: Pah::Template

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/pah/template.rb

Instance Method Summary collapse

Instance Method Details

#ask_unless_test(*params) ⇒ Object



24
25
26
# File 'lib/pah/template.rb', line 24

def ask_unless_test(*params)
  ask(*params)
end

#copy_static_file(path) ⇒ Object



7
8
9
10
# File 'lib/pah/template.rb', line 7

def copy_static_file(path)
  remove_file path
  create_file path, File.read(File.join(static_files, path))
end

#git_commit(message) ⇒ Object



28
29
30
31
# File 'lib/pah/template.rb', line 28

def git_commit(message)
  message = "#{message}\n\nGenerated by pah version #{Pah::VERSION}"
  git commit: "-m '#{message}' -q"
end

#static_filesObject



3
4
5
# File 'lib/pah/template.rb', line 3

def static_files
  File.join(TEMPLATE_ROOT, 'files')
end

#will_you_like_to?(question) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pah/template.rb', line 12

def will_you_like_to?(question)
  answer = ask("Will you like to #{question} [y,n]".green)
  case answer.downcase
  when 'yes', 'y'
    true
  when 'no', 'n'
    false
  else
    will_you_like_to?(question)
  end
end