Class: Pod::Helper::TemplateFile
- Inherits:
-
Object
- Object
- Pod::Helper::TemplateFile
show all
- Defined in:
- lib/pod/helper/template_file.rb
Instance Method Summary
collapse
Constructor Details
#initialize(project_name, project_prefix) ⇒ TemplateFile
Returns a new instance of TemplateFile.
7
8
9
10
11
12
|
# File 'lib/pod/helper/template_file.rb', line 7
def initialize(project_name,project_prefix)
@project_name = project_name
@project_prefix = project_prefix
@project_year = Date.today.strftime('%Y')
@project_identifier = "com.icemobile.#{project_name.downcase}"
end
|
Instance Method Details
#exists? ⇒ Boolean
26
27
28
|
# File 'lib/pod/helper/template_file.rb', line 26
def exists?
File.exists?(name)
end
|
#file ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/pod/helper/template_file.rb', line 36
def file
if exists?
File.read(name)
else
write
end
end
|
#fixture_path ⇒ Object
14
15
16
|
# File 'lib/pod/helper/template_file.rb', line 14
def fixture_path
File.join(File.dirname(File.expand_path(__FILE__)), '../../../fixtures')
end
|
#name ⇒ Object
32
33
34
|
# File 'lib/pod/helper/template_file.rb', line 32
def name
"TemplateFile"
end
|
#template ⇒ Object
44
45
46
|
# File 'lib/pod/helper/template_file.rb', line 44
def template
ERB.new(File.read("#{fixture_path}/#{template_name}.erb"))
end
|
#template_name ⇒ Object
48
49
50
|
# File 'lib/pod/helper/template_file.rb', line 48
def template_name
name
end
|
#write ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/pod/helper/template_file.rb', line 18
def write
output_file = nil
File.open(name, 'w') do |output_file|
output_file.puts template.result binding
end
output_file
end
|