class FlipTheSwitch::Generator::Category
Public Instance Methods
generate()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 7 def generate delete_existing write_files end
Private Instance Methods
camelize(string)
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 78 def camelize(string) string.split('_').each {|s| s.capitalize! }.join('') end
delete_existing()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 14 def delete_existing delete_file(header_file) delete_file(implementation_file) end
delete_file(file)
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 30 def delete_file(file) if File.exists?(file) File.delete(file) end end
file_template(name)
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 64 def file_template(name) File.read(File.expand_path("../#{name}.erb", __FILE__)) end
header()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 44 def header render(header_template) end
header_file()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 36 def header_file File.join(output, 'FTSFlipTheSwitch+Features.h') end
header_template()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 56 def header_template file_template('header.h') end
implementation()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 48 def implementation render(implementation_template) end
implementation_file()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 40 def implementation_file File.join(output, 'FTSFlipTheSwitch+Features.m') end
implementation_template()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 60 def implementation_template file_template('implementation.m') end
lower_camelize(string)
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 68 def lower_camelize(string) str = camelize(string) if str.empty? '' else str[0] = str[0].downcase str end end
render(template)
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 52 def render(template) ERB.new(template, nil, '-').result(binding) end
write_file(file, text)
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 24 def write_file(file, text) File.open(file, 'w') do |f| f.syswrite(text) end end
write_files()
click to toggle source
# File lib/flip_the_switch/generator/category.rb, line 19 def write_files write_file(header_file, header) write_file(implementation_file, implementation) end