ritsu 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. data/README.md +96 -0
  2. data/Thorfile +95 -0
  3. data/VERSION +1 -0
  4. data/bin/ritsu +32 -0
  5. data/lib/ritsu/block.rb +259 -0
  6. data/lib/ritsu/ext/test_case.rb +20 -0
  7. data/lib/ritsu/external_library.rb +47 -0
  8. data/lib/ritsu/project.rb +89 -0
  9. data/lib/ritsu/project_generator.rb +34 -0
  10. data/lib/ritsu/project_generators/default_generator.rb +73 -0
  11. data/lib/ritsu/project_generators/default_generator_files/Thorfile.erb +9 -0
  12. data/lib/ritsu/project_generators/default_generator_files/meta/project.rb.erb +9 -0
  13. data/lib/ritsu/project_generators.rb +1 -0
  14. data/lib/ritsu/src_file.rb +76 -0
  15. data/lib/ritsu/src_files/cpp_file.rb +33 -0
  16. data/lib/ritsu/src_files/cpp_file_mixin.rb +13 -0
  17. data/lib/ritsu/src_files/executable_cmake_lists.rb +40 -0
  18. data/lib/ritsu/src_files/header_file.rb +46 -0
  19. data/lib/ritsu/src_files/header_file_mixin.rb +20 -0
  20. data/lib/ritsu/src_files/project_cmake_lists.rb +110 -0
  21. data/lib/ritsu/src_files/project_config_header_file.rb +15 -0
  22. data/lib/ritsu/src_files/project_config_header_template_file.rb +46 -0
  23. data/lib/ritsu/src_files/shared_library_cmake_lists.rb +40 -0
  24. data/lib/ritsu/src_files/static_library_cmake_lists.rb +40 -0
  25. data/lib/ritsu/src_files/target_cmake_lists.rb +159 -0
  26. data/lib/ritsu/src_files/templated_src_file.rb +44 -0
  27. data/lib/ritsu/src_files.rb +14 -0
  28. data/lib/ritsu/target.rb +134 -0
  29. data/lib/ritsu/targets/executable.rb +45 -0
  30. data/lib/ritsu/targets/library.rb +29 -0
  31. data/lib/ritsu/targets/shared_library.rb +39 -0
  32. data/lib/ritsu/targets/static_library.rb +33 -0
  33. data/lib/ritsu/targets.rb +4 -0
  34. data/lib/ritsu/template.rb +69 -0
  35. data/lib/ritsu/template_policies.rb +133 -0
  36. data/lib/ritsu/test_helpers.rb +124 -0
  37. data/lib/ritsu/thors/default_thor.rb +57 -0
  38. data/lib/ritsu/thors.rb +1 -0
  39. data/lib/ritsu/utility/accessors.rb +30 -0
  40. data/lib/ritsu/utility/check_upon_add_set.rb +35 -0
  41. data/lib/ritsu/utility/file_robot.rb +129 -0
  42. data/lib/ritsu/utility/files.rb +13 -0
  43. data/lib/ritsu/utility/instance_dependencies.rb +113 -0
  44. data/lib/ritsu/utility/instance_set.rb +29 -0
  45. data/lib/ritsu/utility/platform.rb +21 -0
  46. data/lib/ritsu/utility/simple_io.rb +65 -0
  47. data/lib/ritsu/utility/single_instance.rb +34 -0
  48. data/lib/ritsu/utility/strings.rb +41 -0
  49. data/lib/ritsu/utility.rb +8 -0
  50. data/lib/ritsu.rb +17 -0
  51. data/test/ritsu/block_test.rb +197 -0
  52. data/test/ritsu/external_library_test.rb +42 -0
  53. data/test/ritsu/project_generators/default_generator_test.rb +34 -0
  54. data/test/ritsu/project_test.rb +128 -0
  55. data/test/ritsu/src_file_test.rb +70 -0
  56. data/test/ritsu/src_files/cpp_file_test.rb +43 -0
  57. data/test/ritsu/src_files/executable_cmake_lists_test.rb +52 -0
  58. data/test/ritsu/src_files/header_file_test.rb +58 -0
  59. data/test/ritsu/src_files/project_cmake_lists_test.rb +152 -0
  60. data/test/ritsu/src_files/shared_library_cmake_lists_test.rb +52 -0
  61. data/test/ritsu/src_files/static_library_cmake_lists_test.rb +52 -0
  62. data/test/ritsu/src_files/target_cmake_lists_test.rb +16 -0
  63. data/test/ritsu/target_test.rb +106 -0
  64. data/test/ritsu/targets/executable_test.rb +11 -0
  65. data/test/ritsu/targets/shared_library_test.rb +11 -0
  66. data/test/ritsu/targets/static_library_test.rb +11 -0
  67. data/test/ritsu/template_policies_test.rb +0 -0
  68. data/test/ritsu/utility/accessors_test.rb +15 -0
  69. data/test/ritsu/utility/check_upon_add_set_test.rb +32 -0
  70. data/test/ritsu/utility/file_robot_test.rb +176 -0
  71. data/test/ritsu/utility/strings_test.rb +29 -0
  72. data/test/test_helpers.rb +4 -0
  73. metadata +209 -0
@@ -0,0 +1,176 @@
1
+ require File.dirname(__FILE__) + "/../../test_helpers"
2
+
3
+ class FileRobotTest < Test::Unit::TestCase
4
+ include Ritsu::Utility
5
+ include Ritsu::TestCaseWithFileTestData
6
+
7
+ def data_dir; File.dirname(__FILE__) + "/" + File.basename(__FILE__, ".rb") end
8
+
9
+ def setup
10
+ init_data_dir
11
+ @input = StringIO.new
12
+ @output = StringIO.new
13
+ FileRobot.input = @input
14
+ FileRobot.output = @output
15
+ end
16
+
17
+ def provide_input(string)
18
+ @input << string
19
+ @input.rewind
20
+ end
21
+
22
+ def expect_output(string)
23
+ assert_equal string, @output.string
24
+ end
25
+
26
+ must "force must be initially false" do
27
+ assert !FileRobot.force
28
+ end
29
+
30
+ must "quiet must be initially false" do
31
+ assert !FileRobot.quiet
32
+ end
33
+
34
+ file_test "create empty file" do
35
+ FileRobot.create_file(output_path("abc.txt"))
36
+ assert_output_file_exists "abc.txt"
37
+ assert_output_file_content "", "abc.txt"
38
+ expect_output(" create #{output_dir}/abc.txt\n")
39
+ end
40
+
41
+ file_test "create file with content" do
42
+ FileRobot.create_file(output_path("abc.txt"), "def")
43
+ assert_output_file_content "def", "abc.txt"
44
+ expect_output(" create #{output_dir}/abc.txt\n")
45
+ end
46
+
47
+ file_test "create parent directories when creating a file" do
48
+ FileRobot.create_file(output_path("a/b/c/def.txt"), "def")
49
+ assert_output_file_exists "a/b/c/def.txt"
50
+ expect_output(
51
+ " create #{output_dir}/a/b/c\n" +
52
+ " create #{output_dir}/a/b/c/def.txt\n"
53
+ )
54
+ end
55
+
56
+ file_test "create directory" do
57
+ FileRobot.create_dir(output_path("abc/def/ghi"))
58
+ assert_file_exists(output_path("abc/def/ghi"))
59
+ expect_output(" create #{output_dir}/abc/def/ghi\n")
60
+ end
61
+
62
+ file_test "display exist message when dir already exist" do
63
+ FileRobot.create_dir(output_path("abc"))
64
+ FileRobot.create_dir(output_path("abc"))
65
+ expect_output(
66
+ " create #{output_dir}/abc\n" +
67
+ " exist #{output_dir}/abc\n"
68
+ )
69
+ end
70
+
71
+ ['no', 'n', 'N', 'NO'].each do |answer|
72
+ file_test "ask user when file exist and do nothing when user says #{answer}" do
73
+ provide_input(answer)
74
+ FileRobot.create_file(output_path("abc.txt"), "abc")
75
+ FileRobot.create_file(output_path("abc.txt"), "def")
76
+ expect_output(
77
+ " create #{output_dir}/abc.txt\n" +
78
+ "overwrite #{output_dir}/abc.txt? (yes/no/all): " +
79
+ " exist #{output_dir}/abc.txt\n"
80
+ )
81
+ assert_output_file_content "abc", "abc.txt"
82
+ end
83
+ end
84
+
85
+ ['yes', 'y', 'YES', 'Yes', 'Y'].each do |answer|
86
+ file_test "ask user when file exist and overwrite when user says #{answer}" do
87
+ provide_input(answer)
88
+ FileRobot.create_file(output_path("abc.txt"), "abc")
89
+ FileRobot.create_file(output_path("abc.txt"), "def")
90
+ expect_output(
91
+ " create #{output_dir}/abc.txt\n" +
92
+ "overwrite #{output_dir}/abc.txt? (yes/no/all): " +
93
+ " overwrite #{output_dir}/abc.txt\n"
94
+ )
95
+ assert_output_file_content "def", "abc.txt"
96
+ end
97
+ end
98
+
99
+ ['ye', 'non', 'Nevar', 'programming'].each do |answer|
100
+ file_test "ask user when file exist and ask again when user says #{answer}" do
101
+ provide_input(answer + "\nno")
102
+ FileRobot.create_file(output_path("abc.txt"), "abc")
103
+ FileRobot.create_file(output_path("abc.txt"), "def")
104
+ expect_output(
105
+ " create #{output_dir}/abc.txt\n" +
106
+ "overwrite #{output_dir}/abc.txt? (yes/no/all): " +
107
+ "overwrite #{output_dir}/abc.txt? (yes/no/all): " +
108
+ " exist #{output_dir}/abc.txt\n"
109
+ )
110
+ assert_output_file_content "abc", "abc.txt"
111
+ end
112
+ end
113
+
114
+ file_test "remove file" do
115
+ FileRobot.create_file(output_path("abc.txt"), "abc")
116
+ assert_output_file_exists("abc.txt")
117
+ FileRobot.remove_file(output_path("abc.txt"))
118
+ assert_output_file_not_exist("abc.txt")
119
+ end
120
+
121
+ file_test "write a message if file to remove does not exist" do
122
+ FileRobot.remove_file(output_path("abc.txt"))
123
+ expect_output(
124
+ " not exist #{output_dir}/abc.txt\n"
125
+ )
126
+ end
127
+
128
+ file_test "write a message if file to remove is not a file" do
129
+ FileRobot.create_dir(output_path("abc.txt"))
130
+ assert_output_file_exists("abc.txt")
131
+ FileRobot.remove_file(output_path("abc.txt"))
132
+ expect_output(
133
+ " create #{output_dir}/abc.txt\n" +
134
+ " not file #{output_dir}/abc.txt\n"
135
+ )
136
+ assert_output_file_exists("abc.txt")
137
+ end
138
+
139
+ file_test "remove dir" do
140
+ FileRobot.create_dir(output_path("abc"))
141
+ assert_output_file_exists("abc")
142
+ FileRobot.remove_dir(output_path("abc"))
143
+ assert_output_file_not_exist("abc")
144
+ end
145
+
146
+ file_test "write a message if dir to remove does not exist" do
147
+ FileRobot.remove_file(output_path("abc"))
148
+ expect_output(
149
+ " not exist #{output_dir}/abc\n"
150
+ )
151
+ end
152
+
153
+ file_test "write a message if dir to remove is not a dir" do
154
+ FileRobot.create_file(output_path("abc"), "")
155
+ assert_output_file_exists("abc")
156
+ FileRobot.remove_dir(output_path("abc"))
157
+ expect_output(
158
+ " create #{output_dir}/abc\n" +
159
+ " not dir #{output_dir}/abc\n"
160
+ )
161
+ assert_output_file_exists("abc")
162
+ end
163
+
164
+ file_test "write a message if dir to remove is not empty" do
165
+ FileRobot.create_dir(output_path("abc"))
166
+ FileRobot.create_file(output_path("abc/def.txt"), "")
167
+ assert_output_file_exists('abc/def.txt')
168
+ FileRobot.remove_dir(output_path("abc"))
169
+ expect_output(
170
+ " create #{output_dir}/abc\n" +
171
+ " create #{output_dir}/abc/def.txt\n" +
172
+ " not empty #{output_dir}/abc\n"
173
+ )
174
+ assert_output_file_exists("abc/def.txt")
175
+ end
176
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + "/../../test_helpers"
2
+
3
+ class StringTest < Test::Unit::TestCase
4
+ include Ritsu::Utility::Strings
5
+
6
+ ['abc', 'abc_def_ghi', 'abc123_1939'].each do |str|
7
+ must "is_underscore_case?(#{str}) be true" do
8
+ assert is_underscore_case?(str)
9
+ end
10
+ end
11
+
12
+ ['SomethingAweful', '9adef'].each do |str|
13
+ must "is_underscore_case?(#{str}) be false" do
14
+ assert !is_underscore_case?(str)
15
+ end
16
+ end
17
+
18
+ ['abc', '_', '_abc', 'Something_Aweful', 'test_create_empty_file'].each do |str|
19
+ must "is_c_name?(#{str}) be true" do
20
+ assert is_c_name?(str)
21
+ end
22
+ end
23
+
24
+ ['32abc', 'dog cat', 'meow?'].each do |str|
25
+ must "is_c_name?(#{str}) be false" do
26
+ assert !is_c_name?(str)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/ritsu'
3
+ require File.dirname(__FILE__) + '/../lib/ritsu/ext/test_case'
4
+ require File.dirname(__FILE__) + '/../lib/ritsu/test_helpers'
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ritsu
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - dragonmeteor
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-23 00:00:00 +07:00
18
+ default_executable: ritsu
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thor
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 13
30
+ - 4
31
+ version: 0.13.4
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: activesupport
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 3
44
+ - 5
45
+ version: 2.3.5
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 4
58
+ - 0
59
+ version: 1.4.0
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: yard
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ - 5
72
+ - 3
73
+ version: 0.5.3
74
+ type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: maruku
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ - 5
86
+ - 9
87
+ version: 0.5.9
88
+ type: :development
89
+ version_requirements: *id005
90
+ description: A code generation system that facilitates building C/C++ software with the help of CMake and Doxygen
91
+ email: dragonmeteor@gmail.com
92
+ executables:
93
+ - ritsu
94
+ extensions: []
95
+
96
+ extra_rdoc_files:
97
+ - README.md
98
+ - Thorfile
99
+ - VERSION
100
+ files:
101
+ - README.md
102
+ - Thorfile
103
+ - VERSION
104
+ - bin/ritsu
105
+ - lib/ritsu.rb
106
+ - lib/ritsu/block.rb
107
+ - lib/ritsu/ext/test_case.rb
108
+ - lib/ritsu/external_library.rb
109
+ - lib/ritsu/project.rb
110
+ - lib/ritsu/project_generator.rb
111
+ - lib/ritsu/project_generators.rb
112
+ - lib/ritsu/project_generators/default_generator.rb
113
+ - lib/ritsu/project_generators/default_generator_files/Thorfile.erb
114
+ - lib/ritsu/project_generators/default_generator_files/meta/project.rb.erb
115
+ - lib/ritsu/src_file.rb
116
+ - lib/ritsu/src_files.rb
117
+ - lib/ritsu/src_files/cpp_file.rb
118
+ - lib/ritsu/src_files/cpp_file_mixin.rb
119
+ - lib/ritsu/src_files/executable_cmake_lists.rb
120
+ - lib/ritsu/src_files/header_file.rb
121
+ - lib/ritsu/src_files/header_file_mixin.rb
122
+ - lib/ritsu/src_files/project_cmake_lists.rb
123
+ - lib/ritsu/src_files/project_config_header_file.rb
124
+ - lib/ritsu/src_files/project_config_header_template_file.rb
125
+ - lib/ritsu/src_files/shared_library_cmake_lists.rb
126
+ - lib/ritsu/src_files/static_library_cmake_lists.rb
127
+ - lib/ritsu/src_files/target_cmake_lists.rb
128
+ - lib/ritsu/src_files/templated_src_file.rb
129
+ - lib/ritsu/target.rb
130
+ - lib/ritsu/targets.rb
131
+ - lib/ritsu/targets/executable.rb
132
+ - lib/ritsu/targets/library.rb
133
+ - lib/ritsu/targets/shared_library.rb
134
+ - lib/ritsu/targets/static_library.rb
135
+ - lib/ritsu/template.rb
136
+ - lib/ritsu/template_policies.rb
137
+ - lib/ritsu/test_helpers.rb
138
+ - lib/ritsu/thors.rb
139
+ - lib/ritsu/thors/default_thor.rb
140
+ - lib/ritsu/utility.rb
141
+ - lib/ritsu/utility/accessors.rb
142
+ - lib/ritsu/utility/check_upon_add_set.rb
143
+ - lib/ritsu/utility/file_robot.rb
144
+ - lib/ritsu/utility/files.rb
145
+ - lib/ritsu/utility/instance_dependencies.rb
146
+ - lib/ritsu/utility/instance_set.rb
147
+ - lib/ritsu/utility/platform.rb
148
+ - lib/ritsu/utility/simple_io.rb
149
+ - lib/ritsu/utility/single_instance.rb
150
+ - lib/ritsu/utility/strings.rb
151
+ has_rdoc: true
152
+ homepage: http://github.com/dragonmeteor/ritsu
153
+ licenses: []
154
+
155
+ post_install_message:
156
+ rdoc_options:
157
+ - --charset=UTF-8
158
+ - --title
159
+ - Ritsu
160
+ - --main
161
+ - README.md
162
+ - --line-numbers
163
+ - --inline-source
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ segments:
171
+ - 0
172
+ version: "0"
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ segments:
178
+ - 0
179
+ version: "0"
180
+ requirements: []
181
+
182
+ rubyforge_project: ritsu
183
+ rubygems_version: 1.3.6
184
+ signing_key:
185
+ specification_version: 3
186
+ summary: A code generation system that facilitates building C/C++ software with the help of CMake and Doxygen
187
+ test_files:
188
+ - test/ritsu/block_test.rb
189
+ - test/ritsu/external_library_test.rb
190
+ - test/ritsu/project_generators/default_generator_test.rb
191
+ - test/ritsu/project_test.rb
192
+ - test/ritsu/src_file_test.rb
193
+ - test/ritsu/src_files/cpp_file_test.rb
194
+ - test/ritsu/src_files/executable_cmake_lists_test.rb
195
+ - test/ritsu/src_files/header_file_test.rb
196
+ - test/ritsu/src_files/project_cmake_lists_test.rb
197
+ - test/ritsu/src_files/shared_library_cmake_lists_test.rb
198
+ - test/ritsu/src_files/static_library_cmake_lists_test.rb
199
+ - test/ritsu/src_files/target_cmake_lists_test.rb
200
+ - test/ritsu/target_test.rb
201
+ - test/ritsu/targets/executable_test.rb
202
+ - test/ritsu/targets/shared_library_test.rb
203
+ - test/ritsu/targets/static_library_test.rb
204
+ - test/ritsu/template_policies_test.rb
205
+ - test/ritsu/utility/accessors_test.rb
206
+ - test/ritsu/utility/check_upon_add_set_test.rb
207
+ - test/ritsu/utility/file_robot_test.rb
208
+ - test/ritsu/utility/strings_test.rb
209
+ - test/test_helpers.rb