Class: FillHelpers

Inherits:
Object
  • Object
show all
Defined in:
lib/makeme/fill_helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(working_directory, absolute_file_path, guess_data) ⇒ FillHelpers

Returns a new instance of FillHelpers.



2
3
4
5
6
# File 'lib/makeme/fill_helpers.rb', line 2

def initialize(working_directory, absolute_file_path, guess_data)
  @working_directory = working_directory
  @absolute_file_path = absolute_file_path
  @guess_data = guess_data
end

Instance Method Details

#get_bindingObject



8
9
10
# File 'lib/makeme/fill_helpers.rb', line 8

def get_binding
  binding
end

#heuristic_projectObject



26
27
28
# File 'lib/makeme/fill_helpers.rb', line 26

def heuristic_project
  parent_directory
end

#heuristic_usernameObject



30
31
32
# File 'lib/makeme/fill_helpers.rb', line 30

def heuristic_username
  Etc.getlogin
end

#parent_directoryObject



16
17
18
19
20
21
22
23
24
# File 'lib/makeme/fill_helpers.rb', line 16

def parent_directory
  parent = Pathname.new(@absolute_file_path).parent.basename

  if parent
    parent.to_s
  else
    nil
  end
end

#placeholder(text) ⇒ Object



12
13
14
# File 'lib/makeme/fill_helpers.rb', line 12

def placeholder(text)
  text.upcase
end

#projectObject



34
# File 'lib/makeme/fill_helpers.rb', line 34

def project;  heuristic_project  || placeholder("myproject"); end

#usernameObject



35
# File 'lib/makeme/fill_helpers.rb', line 35

def username; heuristic_username || placeholder("username");  end