Class: GemStrings
- Inherits:
-
Object
- Object
- GemStrings
- Defined in:
- lib/cmaker/strings.rb
Class Method Summary collapse
- .code_dir_cmake_content(dir_name, header_file_name, cpp_file_name) ⇒ Object
- .empty_cpp_contents ⇒ Object
- .empty_header_contents ⇒ Object
- .empty_test_file_content ⇒ Object
- .gem_description ⇒ Object
- .main_file_content ⇒ Object
- .no_project_name_error ⇒ Object
- .project_dir_cmake_content(project_name, executable_name, code_dir_name, test_dir_name) ⇒ Object
- .test_dir_cmake_content(dir_name, gtest_dir_name, tests_dir_name) ⇒ Object
- .tests_dir_cmake_content(test_executable_name, empty_test_file_name, code_dir_name) ⇒ Object
Class Method Details
.code_dir_cmake_content(dir_name, header_file_name, cpp_file_name) ⇒ Object
25 26 27 28 |
# File 'lib/cmaker/strings.rb', line 25 def self.code_dir_cmake_content(dir_name, header_file_name, cpp_file_name) return "project(#{dir_name})\n\n" \ "add_library(#{dir_name} #{header_file_name} #{cpp_file_name})\n" end |
.empty_cpp_contents ⇒ Object
63 64 65 66 |
# File 'lib/cmaker/strings.rb', line 63 def self.empty_cpp_contents() return "" # return "#include \"" + empty_header_name + "\"\n" end |
.empty_header_contents ⇒ Object
58 59 60 61 |
# File 'lib/cmaker/strings.rb', line 58 def self.empty_header_contents() return "" # return "#ifndef "EMPTYPROJECT"_"MYPROJECT"_H\n" end |
.empty_test_file_content ⇒ Object
51 52 53 54 55 56 |
# File 'lib/cmaker/strings.rb', line 51 def self.empty_test_file_content() return "#include \"gtest/gtest.h\"\n\n" \ "TEST(test_functionality, test_pass) {\n" \ "\tEXPECT_EQ(1, 1);\n" \ "}\n" end |
.gem_description ⇒ Object
2 3 4 5 6 |
# File 'lib/cmaker/strings.rb', line 2 def self.gem_description() return "Usage:\n\n\t$ #{GEM_NAME} COMMAND\n\n" \ "Commands:\n\n\t+ #{MAKE_PROJECT_COMMAND} [NAME]\t" \ "Creates a C++ project integrated with CMake and Google Test" end |
.main_file_content ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/cmaker/strings.rb', line 43 def self.main_file_content() return "#include <iostream>\n\n" \ "int main() {\n" \ "\tstd::cout << \"Hello, World!\" << std::endl;\n" \ "\treturn 0;\n" \ "}\n" end |
.no_project_name_error ⇒ Object
8 9 10 11 |
# File 'lib/cmaker/strings.rb', line 8 def self.no_project_name_error() return "Please supply a name for the project, like so:\n\n" \ "\t$ #{GEM_NAME} #{MAKE_PROJECT_COMMAND} [NAME]" end |
.project_dir_cmake_content(project_name, executable_name, code_dir_name, test_dir_name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cmaker/strings.rb', line 13 def self.project_dir_cmake_content(project_name, executable_name, code_dir_name, test_dir_name) return "cmake_minimum_required(VERSION 3.6)\n" \ "project(#{project_name})\n\n" \ "set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\n\n" \ "set(SOURCE_FILES main.cpp)\n" \ "add_executable(#{executable_name} ${SOURCE_FILES})\n\n" \ "include_directories(#{code_dir_name})\n\n" \ "add_subdirectory(#{code_dir_name})\n" \ "add_subdirectory(#{test_dir_name})\n\n" \ "target_link_libraries(#{executable_name} #{code_dir_name})\n" end |
.test_dir_cmake_content(dir_name, gtest_dir_name, tests_dir_name) ⇒ Object
30 31 32 33 34 |
# File 'lib/cmaker/strings.rb', line 30 def self.test_dir_cmake_content(dir_name, gtest_dir_name, tests_dir_name) return "project(#{dir_name})\n\n" \ "add_subdirectory(#{gtest_dir_name})\n" \ "add_subdirectory(#{tests_dir_name})\n" end |
.tests_dir_cmake_content(test_executable_name, empty_test_file_name, code_dir_name) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/cmaker/strings.rb', line 36 def self.tests_dir_cmake_content(test_executable_name, empty_test_file_name, code_dir_name) return "include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})\n\n" \ "add_executable(#{test_executable_name} #{empty_test_file_name})\n\n" \ "target_link_libraries(#{test_executable_name} gtest gtest_main)\n" \ "target_link_libraries(#{test_executable_name} #{code_dir_name})\n" end |