Class: FileGenerator
- Inherits:
-
Object
- Object
- FileGenerator
- Defined in:
- lib/yesman/file_generator.rb
Instance Attribute Summary collapse
-
#class_path ⇒ Object
readonly
Returns the value of attribute class_path.
-
#gtest_main_path ⇒ Object
readonly
Returns the value of attribute gtest_main_path.
-
#header_path ⇒ Object
readonly
Returns the value of attribute header_path.
-
#main_path ⇒ Object
readonly
Returns the value of attribute main_path.
-
#rake_file_path ⇒ Object
readonly
Returns the value of attribute rake_file_path.
-
#templates_path ⇒ Object
readonly
Returns the value of attribute templates_path.
-
#test_path ⇒ Object
readonly
Returns the value of attribute test_path.
Instance Method Summary collapse
- #create_build_file ⇒ Object
- #create_class_files(input) ⇒ Object
- #create_gtest_main ⇒ Object
- #create_main ⇒ Object
-
#initialize ⇒ FileGenerator
constructor
A new instance of FileGenerator.
Constructor Details
#initialize ⇒ FileGenerator
Returns a new instance of FileGenerator.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yesman/file_generator.rb', line 18 def initialize @templates_path = "#{Dir.home}/.yesman/templates/" @header_path = create_path "header.cxx.erb" @class_path = create_path "class.cxx.erb" @test_path = create_path "test.cxx.erb" @main_path = create_path "main.cxx.erb" @gtest_main_path = create_path "gtest_main.cxx.erb" @rake_file_path = create_path "rakefile.erb" @templater = Templater.new @log = Logger.new end |
Instance Attribute Details
#class_path ⇒ Object (readonly)
Returns the value of attribute class_path.
12 13 14 |
# File 'lib/yesman/file_generator.rb', line 12 def class_path @class_path end |
#gtest_main_path ⇒ Object (readonly)
Returns the value of attribute gtest_main_path.
15 16 17 |
# File 'lib/yesman/file_generator.rb', line 15 def gtest_main_path @gtest_main_path end |
#header_path ⇒ Object (readonly)
Returns the value of attribute header_path.
11 12 13 |
# File 'lib/yesman/file_generator.rb', line 11 def header_path @header_path end |
#main_path ⇒ Object (readonly)
Returns the value of attribute main_path.
14 15 16 |
# File 'lib/yesman/file_generator.rb', line 14 def main_path @main_path end |
#rake_file_path ⇒ Object (readonly)
Returns the value of attribute rake_file_path.
16 17 18 |
# File 'lib/yesman/file_generator.rb', line 16 def rake_file_path @rake_file_path end |
#templates_path ⇒ Object (readonly)
Returns the value of attribute templates_path.
10 11 12 |
# File 'lib/yesman/file_generator.rb', line 10 def templates_path @templates_path end |
#test_path ⇒ Object (readonly)
Returns the value of attribute test_path.
13 14 15 |
# File 'lib/yesman/file_generator.rb', line 13 def test_path @test_path end |
Instance Method Details
#create_build_file ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/yesman/file_generator.rb', line 58 def create_build_file rake_data = RakeGenData.new file_contents = @templater.merge rake_data, rake_file_path file_path = "Rakefile" FileUtil.write_to_file file_path, file_contents @log.log_creation "created", file_path end |
#create_class_files(input) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yesman/file_generator.rb', line 31 def create_class_files input c = create_class_type input files = [header_path, class_path, test_path] files.each do |path| file_contents = @templater.merge c, path file_name = create_file_name(c,path) FileUtil.write_to_file file_name, file_contents @log.log_creation "created", file_name end end |
#create_gtest_main ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/yesman/file_generator.rb', line 50 def create_gtest_main c = create_class_type "GTestMain" file_contents = @templater.merge c, gtest_main_path file_path = "#{params[:tests]}/#{params[:project_name]}Tests.#{params[:extension]}" FileUtil.write_to_file file_path , file_contents @log.log_creation "created", file_path end |
#create_main ⇒ Object
43 44 45 46 47 48 |
# File 'lib/yesman/file_generator.rb', line 43 def create_main c = create_class_type "Main" output_file_path = "#{params[:source]}/#{params[:project_name]}.#{params[:extension]}" FileUtil.write_to_file( output_file_path, ( @templater.merge c, main_path) ) @log.log_creation "created", output_file_path end |