Class: ProjectTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/almirah/project_template.rb

Overview

rubocop:disable Style/Documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_name) ⇒ ProjectTemplate

Returns a new instance of ProjectTemplate.



8
9
10
11
12
13
14
15
16
17
# File 'lib/almirah/project_template.rb', line 8

def initialize(project_name)
  path = File.join(Dir.pwd, project_name)
  Kernel.abort 'Suggested project folder already exists' if Dir.exist? path
  FileUtils.mkdir_p path
  @project_root = path
  create_requirements
  create_architecture
  create_tests
  create_test_runs
end

Instance Attribute Details

#project_rootObject

Returns the value of attribute project_root.



6
7
8
# File 'lib/almirah/project_template.rb', line 6

def project_root
  @project_root
end

Instance Method Details

#create_architectureObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/almirah/project_template.rb', line 55

def create_architecture
  path = File.join(@project_root, 'specifications/arch')
  FileUtils.mkdir_p path

  file_content = <<~EOS
    ---
    title: Architecture Specification
    author: put your name here
    ---

    # Overview

    This is an example of software architecture document.

    # System Overview

    This is a regular paragraph in the document.

    [ARCH-004] This is an architecture item that is related to requirement "REQ-001". >[REQ-001]

    [ARCH-002] This is a regular architecture item.

    # System Decomposition

    [ARCH-005] This is an architecture irem that is related to requirement "REQ-002". >[REQ-002]

    # Document Histrory

    | Revision | Description of changes | Date |
    |---|---|---|
    | A | Initial version | #{Time.now.strftime('%Y-%d-%m')} |

  EOS

  path = File.join(path, 'arch.md')
  file = File.open(path, 'w')
  file.puts file_content
  file.close
end

#create_requirementsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/almirah/project_template.rb', line 19

def create_requirements
  path = File.join(@project_root, 'specifications/req')
  FileUtils.mkdir_p path

  file_content = <<~EOS
    ---
    title: Requirements Specification
    author: put your name here
    ---

    # Overview

    This is an example of software requirements specification.

    # Requirements

    This is a regular paragraph in the document.

    [REQ-001] This is a first requirement (controlled paragraph with ID equal to "REQ-001").

    [REQ-002] This is a second requirement.

    # Document Histrory

    | Revision | Description of changes | Date |
    |---|---|---|
    | A | Initial version | #{Time.now.strftime('%Y-%d-%m')} |

  EOS

  path = File.join(path, 'req.md')
  file = File.open(path, 'w')
  file.puts file_content
  file.close
end

#create_test_001Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/almirah/project_template.rb', line 101

def create_test_001
  path = File.join(@project_root, 'tests/protocols/tp-001')
  FileUtils.mkdir_p path

  file_content = <<~EOS
    # Test Case TP-001

    This is an example of test case for software requirement "REQ-001".

    # Test Summary

    | Param | Value |
    |---|---|
    | Software Version |  |
    | Tester Name | |
    | Date |  |

    # Test Procedure

    | Test Step # | Test Step Description | Result | Req. Id |
    |---|---|---|---|
    | 1 | Some preparation step |  |  |
    | 2 | Some verification step for requirement "REQ-001" | | >[REQ-001] |

  EOS

  path = File.join(path, 'tp-001.md')
  file = File.open(path, 'w')
  file.puts file_content
  file.close
end

#create_test_002Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/almirah/project_template.rb', line 133

def create_test_002
  path = File.join(@project_root, 'tests/protocols/tp-002')
  FileUtils.mkdir_p path

  file_content = <<~EOS
    # Test Case TP-002

    This is an example of test case for software requirement "REQ-002".

    # Test Summary

    | Param | Value |
    |---|---|
    | Software Version |  |
    | Tester Name | |
    | Date |  |

    # Test Procedure

    | Test Step # | Test Step Description | Result | Req. Id |
    |---|---|---|---|
    | 1 | Some preparation step |  |  |
    | 2 | Some verification step for requirement "REQ-002" | | >[REQ-002] |

  EOS

  path = File.join(path, 'tp-002.md')
  file = File.open(path, 'w')
  file.puts file_content
  file.close
end

#create_test_003Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/almirah/project_template.rb', line 165

def create_test_003
  path = File.join(@project_root, 'tests/protocols/tq-001')
  FileUtils.mkdir_p path

  file_content = <<~EOS
    # Test Case TQ-001

    This is an example of test case for software architecture item "ARCH-002".

    # Test Summary

    | Param | Value |
    |---|---|
    | Software Version |  |
    | Tester Name | |
    | Date |  |

    # Test Procedure

    | Test Step # | Test Step Description | Result | Req. Id |
    |---|---|---|---|
    | 1 | Some preparation step |  |  |
    | 2 | Some verification step for architecture item "ARCH-002" | | >[ARCH-002] |

  EOS

  path = File.join(path, 'tq-001.md')
  file = File.open(path, 'w')
  file.puts file_content
  file.close
end

#create_test_runsObject



197
198
199
200
201
# File 'lib/almirah/project_template.rb', line 197

def create_test_runs
  run_test_001
  run_test_002
  run_test_003
end

#create_testsObject



95
96
97
98
99
# File 'lib/almirah/project_template.rb', line 95

def create_tests
  create_test_001
  create_test_002
  create_test_003
end

#run_test_001Object



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/almirah/project_template.rb', line 203

def run_test_001
  path = File.join(@project_root, 'tests/runs/001/tp-001')
  FileUtils.mkdir_p path

  file_content = <<~EOS
    # Test Case TP-001

    This is an example of test case for software requirement "REQ-001".

    # Test Summary

    | Param | Value |
    |---|---|
    | Software Version |  |
    | Tester Name | |
    | Date |  |

    # Test Procedure

    | Test Step # | Test Step Description | Result | Req. Id |
    |---|---|---|---|
    | 1 | Some preparation step | n/a |  |
    | 2 | Some verification step for requirement "REQ-001" | pass | >[REQ-001] |

  EOS

  path = File.join(path, 'tp-001.md')
  file = File.open(path, 'w')
  file.puts file_content
  file.close
end

#run_test_002Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/almirah/project_template.rb', line 235

def run_test_002
  path = File.join(@project_root, 'tests/runs/001/tp-002')
  FileUtils.mkdir_p path

  file_content = <<~EOS
    # Test Case TP-002

    This is an example of test case for software requirement "REQ-002".

    # Test Summary

    | Param | Value |
    |---|---|
    | Software Version |  |
    | Tester Name | |
    | Date |  |

    # Test Procedure

    | Test Step # | Test Step Description | Result | Req. Id |
    |---|---|---|---|
    | 1 | Some preparation step | n/a |  |
    | 2 | Some verification step for requirement "REQ-002" | fail | >[REQ-002] |

  EOS

  path = File.join(path, 'tp-002.md')
  file = File.open(path, 'w')
  file.puts file_content
  file.close
end

#run_test_003Object



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/almirah/project_template.rb', line 267

def run_test_003
  path = File.join(@project_root, 'tests/runs/010/tq-002')
  FileUtils.mkdir_p path

  file_content = <<~EOS
    # Test Case TQ-001

    This is an example of test case for software architecture item "ARCH-002".

    # Test Summary

    | Param | Value |
    |---|---|
    | Software Version |  |
    | Tester Name | |
    | Date |  |

    # Test Procedure

    | Test Step # | Test Step Description | Result | Req. Id |
    |---|---|---|---|
    | 1 | Some preparation step | n/a |  |
    | 2 | Some verification step for architecture item "ARCH-002" | pass | >[ARCH-002] |

  EOS

  path = File.join(path, 'tq-001.md')
  file = File.open(path, 'w')
  file.puts file_content
  file.close
end