inochi 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,103 +1,67 @@
1
1
  %#--
2
- %# Copyright 2009 Suraj N. Kurapati
3
- %# See the LICENSE file for details.
2
+ %# Copyright protects this work.
3
+ %# See LICENSE file for details.
4
4
  %#++
5
5
 
6
6
  % api_url = './api/index.html'
7
- % repo_url = 'http://github.com/sunaku/' + $program
8
- % repo_scm = '[Git](http://git-scm.com)'
7
+ % src_url = 'http://github.com/sunaku/' + $program
8
+ % src_scm = '[Git](http://git-scm.com)'
9
+ % test_libs = Dir[Inochi::INSTALL + '/lib/inochi/test/*.rb']
10
+
9
11
 
10
12
  %|chapter "Introduction"
13
+
14
+
11
15
  %|project
12
- <%= $project %> is an infrastructure for [RubyGems](http://www.rubygems.org)-based software projects that encourages good documentation and reduces programming effort by automating common tasks.
13
16
 
14
- <%= $project %> is exciting because:
17
+ <%= $project %> is an infrastructure for [RubyGems](http://www.rubygems.org)-based software that encourages good documentation, reduces programming effort, and automates common tasks.
18
+
19
+
20
+ * <%= xref "History", "What's new?" %> --- history of project releases.
21
+ * [Source code](<%= src_url %>) --- obtain via <%= src_scm %> or browse online.
22
+ * [API reference](<%= api_url %>) --- documentation for source code.
23
+ * [Project home](<%= $website %>) --- the <%= $project %> project home page.
24
+
25
+ To get help or provide feedback, simply
26
+ <%= xref "License", "contact the author(s)" %>.
27
+
28
+
29
+ %|section "Features"
15
30
 
16
- * It encourages good documentation:
31
+ <%= $project %> is exciting because:
17
32
 
18
- * Provides a comprehensive user manual that integrates release notes, setup and usage instructions, and more.
33
+ * It encourages good documentation:
34
+ * Provides a comprehensive user manual that integrates release notes, setup and usage instructions, and more.
35
+ * Automates the display of help, version, and usage information for your project's main executable.
19
36
 
20
- * Automates the display of help, version, and usage information for your project's main executable.
37
+ * It reduces programming effort:
38
+ * Makes it easy to <%= xref "Translate your project", "translate your project" %> into many languages.
39
+ * Provides a single point of entry to your project's libraries.
40
+ * Keeps your project's configuration in one place.
41
+ * Parses command-line options using [the Trollop library](http://trollop.rubyforge.org).
21
42
 
22
- * It reduces programming effort:
23
- * Makes it easy to <%= xref "Translate your project", "translate your project" %> into many languages.
24
- * Provides a single point of entry to your project's libraries.
25
- * Keeps your project's configuration in one place.
26
- * Parses command-line options using [the Trollop library](http://trollop.rubyforge.org).
43
+ * It automates common tasks:
44
+ * Generates project scaffolds while merging changes from previous ones.
45
+ * Provides Rake tasks for packaging, publishing, and announcing your project.
46
+ * Integrates with <%= xref "Test execution", "#{test_libs.length} different unit testing libraries" %> for your convenience.
27
47
 
28
- * It automates common tasks:
29
- * Generates project scaffolds while merging changes from previous ones.
30
- * Provides Rake tasks for packaging, publishing, and announcing your project.
31
48
 
32
- These features distinguish <%= $project %> from the competition:
33
- * [hoe](http://seattlerb.rubyforge.org/hoe/)
34
- * [newgem](http://newgem.rubyforge.org)
35
- * [Mr Bones](http://codeforpeople.rubyforge.org/bones/)
36
- * [Gemify](http://gitorious.org/projects/gemify/)
37
- * [Jeweler](http://technicalpickles.github.com/jeweler/)
38
- * [GemMake](https://simonmenke.github.com/gm/)
39
- * [SimpleGem](http://github.com/reagent/simple-gem/tree/master)
49
+ %|section "Etymology"
40
50
 
41
- %|paragraph "Etymology"
42
51
  In the past, software development was thought to be like mathematical modeling or building construction: the assembly of inanimate objects. Nowadays, it is thought to be more like gardening: the cultivation of life!
43
52
 
44
53
  In this manner, I consider this project not as a generator of skeletons or as a builder of scaffolds, but as a *giver of life*. That is why I named this project "inochi", the Japanese word for *life*.
45
54
 
46
55
  Happy cultivation!
47
56
 
48
- %|section "Logistics"
49
- * <%= xref "History", "Release notes" %> --- history of project releases.
50
- * [Source code](<%= repo_url %>) --- obtain via <%= repo_scm %> or browse online.
51
- * [API reference](<%= api_url %>) --- documentation for source code.
52
- * [Project home](<%= $website %>) --- the <%= $project %> project home page.
53
-
54
- To get help or provide feedback, simply
55
- <%= xref "License", "contact the author(s)" %>.
56
-
57
- %|paragraph "Version numbers"
58
- <%= $project %> releases are numbered in *major.minor.patch*
59
- form according to the [RubyGems rational versioning
60
- policy](http://www.rubygems.org/read/chapter/7), which
61
- can be summarized thus:
62
-
63
- <table markdown="1">
64
- <thead>
65
- <tr>
66
- <td rowspan="2">What increased in the version number?</td>
67
- <td colspan="3">The increase indicates that the release:</td>
68
- </tr>
69
- <tr>
70
- <th>Is backward compatible?</th>
71
- <th>Has new features?</th>
72
- <th>Has bug fixes?</th>
73
- </tr>
74
- </thead>
75
- <tbody>
76
- <tr>
77
- <th>major</th>
78
- <td style="background-color: #FFE4E1;">No</td>
79
- <td>Yes</td>
80
- <td>Yes</td>
81
- </tr>
82
- <tr>
83
- <th>minor</th>
84
- <td>Yes</td>
85
- <td>Yes</td>
86
- <td>Yes</td>
87
- </tr>
88
- <tr>
89
- <th>patch</th>
90
- <td>Yes</td>
91
- <td style="background-color: #FFE4E1;">No</td>
92
- <td>Yes</td>
93
- </tr>
94
- </tbody>
95
- </table>
96
57
 
97
58
  %|section "License"
59
+
98
60
  %< "../LICENSE"
99
61
 
100
- %|section "Credits" |n|
62
+
63
+ %|section "Credits" |n|
64
+
101
65
  %= $logo = n.xref_link("![#{$project} logo](#{$program}.png)".to_inline_xhtml)
102
66
 
103
67
  %< "README"
@@ -107,3 +71,17 @@
107
71
  from users like you:
108
72
 
109
73
  %< "../CREDITS"
74
+
75
+
76
+ %|section "Related works"
77
+
78
+ * [GemMake](https://simonmenke.github.com/gm/)
79
+ * [Gemify](http://gitorious.org/projects/gemify/)
80
+ * [Jeweler](http://technicalpickles.github.com/jeweler/)
81
+ * [Mr Bones](http://codeforpeople.rubyforge.org/bones/)
82
+ * [Reap](http://reap.rubyforge.org)
83
+ * [echoe](http://blog.evanweaver.com/files/doc/fauna/echoe/)
84
+ * [hoe](http://seattlerb.rubyforge.org/hoe/)
85
+ * [newgem](http://newgem.rubyforge.org)
86
+ * [simple-gem](http://sneaq.net/gems-simple)
87
+
@@ -1,10 +1,14 @@
1
1
  %#--
2
- %# Copyright 2009 Suraj N. Kurapati
3
- %# See the LICENSE file for details.
2
+ %# Copyright protects this work.
3
+ %# See LICENSE file for details.
4
4
  %#++
5
5
 
6
+
6
7
  %|chapter "Setup"
8
+
9
+
7
10
  %|section "Requirements"
11
+
8
12
  Your system needs the following software to run <%= $project %>.
9
13
 
10
14
  | Software | Description | Notes |
@@ -13,7 +17,9 @@
13
17
  | [RubyGems](http://rubygems.org) | Ruby packaging system | Version 1.3.1 or newer is required. |
14
18
  | [Lynx](http://lynx.isc.org) | Text-mode web browser | Version 2.8.6 or newer is required to convert HTML into plain text. |
15
19
 
20
+
16
21
  %|section "Installation"
22
+
17
23
  You can install <%= $project %> by running this command:
18
24
 
19
25
  gem install <%= $program %> --development
@@ -29,7 +35,9 @@
29
35
  If you do not see such output, you may
30
36
  <%= xref "License", "ask the author(s)" %> for help.
31
37
 
38
+
32
39
  %|section "Manifest"
40
+
33
41
  You will see the following items inside <%= $project %>'s installation
34
42
  directory, whose path you can determine by running this command:
35
43
 
@@ -52,3 +60,46 @@
52
60
  * <tt>lang/</tt> --- translations of language phrases.
53
61
 
54
62
  * <tt>LICENSE</tt> --- copyright notice and legal conditions.
63
+
64
+
65
+ %|paragraph "Version numbers"
66
+
67
+ <%= $project %> releases are numbered in *major.minor.patch*
68
+ form according to the [RubyGems rational versioning
69
+ policy](http://www.rubygems.org/read/chapter/7), which
70
+ can be summarized thus:
71
+
72
+ <table markdown="1">
73
+ <thead>
74
+ <tr>
75
+ <td rowspan="2">What increased in the version number?</td>
76
+ <td colspan="3">The increase indicates that the release:</td>
77
+ </tr>
78
+ <tr>
79
+ <th>Is backward compatible?</th>
80
+ <th>Has new features?</th>
81
+ <th>Has bug fixes?</th>
82
+ </tr>
83
+ </thead>
84
+ <tbody>
85
+ <tr>
86
+ <th>major</th>
87
+ <td style="background-color: #FFE4E1;">No</td>
88
+ <td>Yes</td>
89
+ <td>Yes</td>
90
+ </tr>
91
+ <tr>
92
+ <th>minor</th>
93
+ <td>Yes</td>
94
+ <td>Yes</td>
95
+ <td>Yes</td>
96
+ </tr>
97
+ <tr>
98
+ <th>patch</th>
99
+ <td>Yes</td>
100
+ <td style="background-color: #FFE4E1;">No</td>
101
+ <td>Yes</td>
102
+ </tr>
103
+ </tbody>
104
+ </table>
105
+
@@ -1,13 +1,17 @@
1
1
  %#--
2
- %# Copyright 2009 Suraj N. Kurapati
3
- %# See the LICENSE file for details.
2
+ %# Copyright protects this work.
3
+ %# See LICENSE file for details.
4
4
  %#++
5
5
 
6
6
  % require 'inochi/util/tempdir'
7
7
  % yaml_addr = "http://yaml.kwiki.org/?YamlInFiveMinutes"
8
8
 
9
+
9
10
  %|part "Usage"
11
+
12
+
10
13
  %|section "Command-line interface"
14
+
11
15
  When you run this command:
12
16
 
13
17
  <%= $program %> --help
@@ -16,7 +20,9 @@
16
20
 
17
21
  <pre><%= verbatim `ruby bin/#{$program} --help` %></pre>
18
22
 
23
+
19
24
  %|tip "Merging files with **kdiff3**"
25
+
20
26
  Instead of merging files by hand, you can transfer wanted changes between files semi-automatically using [kdiff3](http://kdiff3.sourceforge.net). Simply follow these instructions:
21
27
 
22
28
  1. Create a file named <tt>merge2</tt> with the following content:
@@ -46,17 +52,23 @@
46
52
 
47
53
  Now **kdiff3** will be invoked to help you transfer your changes. When you are finished transferring changes, save the file and quit **kdiff3**. If you do not want to transfer any changes, simply quit **kdiff3** _without_ saving the file.
48
54
 
55
+
49
56
  %|section "Ruby library interface"
57
+
50
58
  The `Inochi` module has several class methods which provide a common configuration for various aspects of your project. These aspects, and their interactions with the `Inochi` module, are as follows:
51
59
  * Your project's main library invokes the `Inochi.init()` method.
52
60
  * Your project's main executable invokes the `Inochi.main()` method.
53
61
  * Your project's <tt>rakefile</tt> invokes the `Inochi.rake()` method.
54
62
  * Your project's user manual invokes the `Inochi.book()` method.
55
63
 
56
- %|section "Tutorial"
64
+
65
+ %|section "General walkthrough", "Tutorial"
66
+
57
67
  This tutorial shows how <%= $project %> is used to manage a hypothetical `WordCount` project throughout the various stages of its life.
58
68
 
69
+
59
70
  %|section "Have a brilliant idea"
71
+
60
72
  It is 4am on Sunday morning. Unwilling to sleep, you have spent the past few hours programming obsessively.. Though your eyes grow heavy and your stomach churns from hunger, your mind charges forth with haste.
61
73
 
62
74
  > Push on! Keep on!
@@ -97,60 +109,72 @@
97
109
 
98
110
  *However*, you must go to work the next morning, so there isn't much time. What can you do? Let's see how <%= $project %> can help us meet this challenge.
99
111
 
112
+
100
113
  %|cd TempDir.new.path
114
+
101
115
  % main_executable = 'bin/word_count'
102
116
 
117
+
103
118
  %|section "Generate your project"
119
+
104
120
  Give life to your new project:
105
121
 
106
122
  <pre>
107
123
  # inochi WordCount
108
- <%= verbatim `ruby #{$install}/bin/inochi WordCount` %>
124
+ %= verbatim `ruby #{$install}/bin/inochi WordCount`
109
125
  </pre>
110
126
 
111
127
  Enter the <tt>word_count</tt> directory:
112
128
 
113
129
  <pre>
114
130
  # cd word_count
115
- <% cd "word_count" %>
131
+ % cd "word_count"
116
132
  </pre>
117
133
 
134
+
118
135
  %|paragraph "View Rake tasks"
136
+
119
137
  <pre>
120
138
  # rake -T
121
- <%= verbatim `rake -T` %>
139
+ %= verbatim `rake -T`
122
140
  </pre>
123
141
 
142
+
124
143
  %|paragraph "Run unit tests"
144
+
125
145
  <pre>
126
146
  # rake test
127
- <%= verbatim `rake test` %>
147
+ %= verbatim `rake test`
128
148
  </pre>
129
149
 
150
+
130
151
  %|paragraph "Run project executable"
152
+
131
153
  <pre>
132
- <% command = main_executable %>
154
+ % command = main_executable
133
155
  # ruby <%= command %>
134
- <%= verbatim `ruby #{command}` %>
156
+ %= verbatim `ruby #{command}`
135
157
  </pre>
136
158
 
137
159
  See usage information:
138
160
 
139
161
  <pre>
140
- <% command = "#{main_executable} --help" %>
162
+ % command = "#{main_executable} --help"
141
163
  # ruby <%= command %>
142
- <%= verbatim `ruby #{command}` %>
164
+ %= verbatim `ruby #{command}`
143
165
  </pre>
144
166
 
145
167
  See project & version information:
146
168
 
147
169
  <pre>
148
- <% command = "#{main_executable} --version" %>
170
+ % command = "#{main_executable} --version"
149
171
  # ruby <%= command %>
150
- <%= verbatim `ruby #{command}` %>
172
+ %= verbatim `ruby #{command}`
151
173
  </pre>
152
174
 
175
+
153
176
  %|paragraph "Show user manual"
177
+
154
178
  Build the user manual (please disregard any "unclosed span" warnings):
155
179
 
156
180
  <pre>
@@ -160,49 +184,59 @@
160
184
  Launch the user manual:
161
185
 
162
186
  <pre>
163
- <% command = "#{main_executable} --manual" %>
187
+ % command = "#{main_executable} --manual"
164
188
  # ruby <%= command %>
165
189
  </pre>
166
190
 
167
191
  The manual will now appear in your default web browser.
168
192
 
193
+
169
194
  %|section "Configure your project"
195
+
170
196
  <%= xref "Ruby library interface" %> lists and documents the interactions between your project and <%= $project %>. These points of interaction are illustrated in the following sections.
171
197
 
198
+
172
199
  %|section "Project information"
173
- <% license_file = 'LICENSE' %>
200
+
201
+ % license_file = 'LICENSE'
174
202
 
175
203
  Open the <tt><%= license_file %></tt> file, which contains the open source [ISC license](http://www.opensource.org/licenses/isc-license.txt) by default, and add a copyright notice with your name and (optional) email address:
176
204
 
177
205
  <pre>
178
- <%= verbatim File.read(license_file) %>
206
+ %= verbatim File.read(license_file)
179
207
  </pre>
180
208
 
181
- <% main_library = 'lib/word_count.rb' %>
209
+ % main_library = 'lib/word_count.rb'
182
210
 
183
211
  Open the main project library file <tt><%= main_library %></tt> and fill in the blanks:
184
212
 
185
213
  <code>
186
- <%= verbatim File.read(main_library) %>
214
+ %= verbatim File.read(main_library)
187
215
  </code>
188
216
 
217
+
189
218
  %|section "Project executable"
219
+
190
220
  Open the <tt><%= main_executable %></tt> file and fill in the blanks:
191
221
 
192
222
  <code>
193
- <%= verbatim File.read(main_executable) %>
223
+ %= verbatim File.read(main_executable)
194
224
  </code>
195
225
 
226
+
196
227
  %|section "Rake tasks"
197
- <% rake_file = 'rakefile' %>
228
+
229
+ % rake_file = 'rakefile'
198
230
 
199
231
  Open the <tt><%= rake_file %></tt> and fill in the blanks:
200
232
 
201
233
  <code>
202
- <%= verbatim File.read(rake_file) %>
234
+ %= verbatim File.read(rake_file)
203
235
  </code>
204
236
 
237
+
205
238
  %|section "User manual"
239
+
206
240
  <%
207
241
  whole = 'doc/index.erb'
208
242
  parts = File.read(whole).
@@ -212,15 +246,18 @@
212
246
  files = [whole, *parts]
213
247
  %>
214
248
 
215
- The user manual's source file <tt><%= whole %></tt> subdivides its content into several smaller files, according to topic, for easier editing and maintenance. These files are processed by the [<%= ERBook::PROJECT %>](<%= ERBook::WEBSITE %>) program's [XHTML format](<%= ERBook::DOCSITE %>#xhtml) to produce the <tt>doc/index.xhtml</tt> file.
249
+ The user manual's source file <tt><%= whole %></tt> subdivides its content into several smaller files, according to topic, for easier editing and maintenance. These files are processed by the [<%= ERBook::PROJECT %>](<%= ERBook::WEBSITE %>) program's [XHTML format](<%= ERBook::DOCSITE %>#xhtml) to produce the <tt>doc/index.html</tt> file.
216
250
 
217
251
  Open these source files and fill in the blanks:
218
252
 
253
+
219
254
  %|files.each |f|
220
255
  %|paragraph "<tt>#{f}</tt>"
221
256
  <code lang="rhtml"><%= verbatim File.read(f) %></code>
222
257
 
258
+
223
259
  %|section "Implement your project"
260
+
224
261
  Add the following code to the bottom of <tt>lib/word_count.rb</tt>, the main project library:
225
262
 
226
263
  <code>
@@ -273,12 +310,14 @@
273
310
  end
274
311
  </code>
275
312
 
313
+
276
314
  %|paragraph "Goodbye `$LOAD_PATH`, hello `require()`"
315
+
277
316
  Notice that, in the Ruby files that you modified so far, there were no `$LOAD_PATH` manipulations and no explicit `require()` statements to pull in the various parts of your project. That is because <%= $project %> does this for you automatically.
278
317
 
279
318
  Furthermore, you can always `require()` a sub-library anywhere in your project using its canonical path because <%= $project %> puts your main project libraries on the Ruby load path.
280
319
 
281
- <% sub_library = 'word_count/odf/text' %>
320
+ % sub_library = 'word_count/odf/text'
282
321
 
283
322
  For example, if your project has a sub-library, say, <tt>lib/<%= sub_library %>.rb</tt> that counts the number of words in an [OpenDocument Text](http://en.wikipedia.org/wiki/OpenDocument) document, then it would be loaded into the main project executable like this:
284
323
 
@@ -288,15 +327,21 @@
288
327
 
289
328
  Regardless of whether a sub-library is used within your project itself or from within an external application, we always `require()` the sub-library using the same canonical path.
290
329
 
330
+
291
331
  %|section "Test your project"
332
+
292
333
  To reduce the amount of code you have to write, <%= $project %> defines the following convention for unit tests.
293
334
 
335
+
294
336
  %|paragraph "Units and tests"
337
+
295
338
  Every Ruby source file in your project's <tt>lib/</tt> directory is considered to be a **unit**. Likewise, every Ruby source file in your project's <tt>test/</tt> is considered to be a **test**.
296
339
 
297
340
  As a result, your project's <tt>test/</tt> directory structure *mirrors* the structure of your project's <tt>lib/</tt> directory. For example, if your project has a <tt>lib/foo/bar.rb</tt> unit, then <tt>test/foo/bar.rb</tt> would be its corresponding test.
298
341
 
342
+
299
343
  %|paragraph "Test execution"
344
+
300
345
  <pre>rake test</pre>
301
346
 
302
347
  The above command begins the testing process, during which:
@@ -307,11 +352,13 @@
307
352
 
308
353
  The details of test execution are left to the integration libraries specified by the `:test_with` parameter of the `Inochi.rake()` method. Possible values for this parameter are:
309
354
 
310
- % Dir[Inochi::INSTALL + '/lib/inochi/test/*.rb'].sort.each do |f|
355
+ % test_libs.sort.each do |f|
311
356
  * <tt><%= File.basename(f, '.rb') %></tt> ---
312
- <%= File.read(f).scan(/^#(.*)/).join %>
357
+ %= File.read(f).scan(/^#(.*)/).join
358
+
313
359
 
314
360
  %|paragraph "Helper libraries"
361
+
315
362
  Your project's main directory is added to Ruby's load path. So if your tests have helper libraries stored in your project's <tt>test/</tt> directory, you can load them into your tests by adding a "test/" prefix.
316
363
 
317
364
  For example, if your <tt>test/foo/bar.rb</tt> test has a <tt>test/foo/qux.rb</tt> helper library, then you would write the following code inside the test to load the helper library:
@@ -320,12 +367,16 @@
320
367
  require 'test/foo/qux'
321
368
  </code>
322
369
 
370
+
323
371
  %|section "Translate your project"
324
- <% phrases_file = "<tt>lang/phrases.yaml</tt>" %>
372
+
373
+ % phrases_file = "<tt>lang/phrases.yaml</tt>"
325
374
 
326
375
  Although English is the *lingua franca* of today, your project's users may prefer to interact with it in their native language. <%= $project %> makes it easy to translate your project and also makes it easy for users to correct and contribute translations to your project.
327
376
 
377
+
328
378
  %|section "Language phrases"
379
+
329
380
  <%= $project %> equips your project module with a `PHRASES` constant (see the `Inochi::Phrases` class) which provides access to translations of language phrases used in your project.
330
381
 
331
382
  The `Inochi::Phrases#[]` method translates a given language phrase into the user's preferred language, which is automatically inferred from their environment, but may be explictly overridden by the user via the <tt>--locale</tt> option of <%= xref "Run project executable", "your project's main executable" %>:
@@ -341,7 +392,9 @@
341
392
  #=> 'No translation for this'
342
393
  </code>
343
394
 
395
+
344
396
  %|paragraph "Parameterizing language phrases"
397
+
345
398
  Language phrases can be parameterized using [`printf` format placeholders](http://en.wikipedia.org/wiki/Printf#printf_format_placeholders) to ease translation:
346
399
 
347
400
  <code>
@@ -349,7 +402,9 @@
349
402
  your_project::PHRASES['You are %d years old.', user_age]
350
403
  </code>
351
404
 
405
+
352
406
  %|paragraph "Explicit translation into a language"
407
+
353
408
  If a language phrase must be translated into a specific language, regardless of the user's preference, you can invoke the respective method (whose name is the same as the [ISO-639 language code](http://en.wikipedia.org/wiki/ISO_639) of the language into which you wish to translate) on your `PHRASES` object:
354
409
 
355
410
  <code>
@@ -360,7 +415,9 @@
360
415
  your_project::PHRASES.fr('Farewell %s!', user_name)
361
416
  </code>
362
417
 
418
+
363
419
  %|section "Translation files"
420
+
364
421
  Translation files are [YAML documents](<%= yaml_addr %>) that reside in your project's <tt>lang/</tt> directory. They provide translations for <%= xref "Language phrases", "language phrases" %> used in your project.
365
422
 
366
423
  For example, suppose that your language phrases are written in English, the <tt>lang/es.yaml</tt> (Spanish) translation file would appear like this:
@@ -382,15 +439,19 @@
382
439
 
383
440
  Also, notice that if a language phrase contains a semicolon, then the entire phrase must be enclosed in quotation marks. The same rule applies to its corresponding translation.
384
441
 
442
+
385
443
  %|section "Extracting language phrases"
444
+
386
445
  <pre>
387
446
  # rake lang:dump
388
- <%= verbatim `rake lang:dump` %>
447
+ %= verbatim `rake lang:dump`
389
448
  </pre>
390
449
 
391
450
  The above command exercises your project's code and extracts all *utilized* language phrases into the <%= phrases_file %> file. Continue reading to learn how this is accomplished.
392
451
 
452
+
393
453
  %|paragraph "Dynamic analysis"
454
+
394
455
  Because Ruby is a dynamically interpreted language, the easiest way to extract language phrases is to evaluate the code that defines them and keep track of which phrases are defined.
395
456
 
396
457
  But how can <%= $project %> exercise all Ruby code in your project? The answer is through *unit tests*. Because unit tests already exercise your project's code, <%= $project %> can use them to reach and extract all language phrases from your project.
@@ -399,44 +460,89 @@
399
460
 
400
461
  This gives you extra motivation to improve the coverage of your test suite---at least to the point where all code that defines language phrases is covered.
401
462
 
463
+
402
464
  %|paragraph "Static analysis"
465
+
403
466
  In a future release, I plan to extract language phrases through static analysis of Ruby code. This approach will supplement the current practice of reaching language phrases through unit tests.
404
467
 
405
468
  Patches are welcome! :-)
406
469
 
470
+
407
471
  %|section "Translating language phrases"
472
+
408
473
  After you have extracted all language phrases from your project (either manually or via <%= xref "Extracting language phrases" %>) into the <%= phrases_file %> file, <%= $project %> can automatically translate them into various languages using the [Yahoo! BabelFish translation service](http://babelfish.yahoo.com):
409
474
 
410
475
  <pre>
411
476
  # rake lang:conv from=LANGUAGE_CODE
412
- <%= verbatim `rake lang:conv from=LANGUAGE_CODE 2>&1` %>
477
+ %= verbatim `rake lang:conv from=LANGUAGE_CODE 2>&1`
413
478
  </pre>
414
479
 
415
480
  Notice that you must specify the language in which your phrases are written, via the <tt>from=</tt> parameter. <%= $project %> cannot determine this automatically.
416
481
 
482
+
417
483
  %|section "Publish your project"
484
+
418
485
  <pre>
419
486
  # rake pub
420
487
  </pre>
421
488
 
422
489
  The above command performs all automated steps described in the following sections.
423
490
 
491
+
424
492
  %|section "Build a RubyGem"
493
+
425
494
  Build a RubyGem by running:
426
495
 
427
496
  <pre>
428
497
  # rake gem
429
- <%= `rake gem` %>
498
+ <%=
499
+ # prevent Maruku errors about blanks (__________) in the
500
+ # scaffold-generated documentation for this dummy project
501
+ Dir['doc/*.erb'].each do |doc|
502
+ File.open(doc, 'r+') do |f|
503
+ old = f.read
504
+ new = old.gsub('__________', '')
505
+
506
+ f.rewind
507
+ f.write new
508
+ end
509
+ end
510
+
511
+ # remove TODO and FIXME words (which come
512
+ # from the scaffold-generated output for
513
+ # this dummy project)from the gem spec
514
+ # that RubyGems does not reject it
515
+ File.open('rakefile', 'r+') do |f|
516
+ old = f.read
517
+ new = old.sub(/^Inochi.rake.*$/) do |header|
518
+ header + %q{
519
+ [:summary, :description].each do |field|
520
+ old = gem.send(field)
521
+ new = old.gsub(/\b(TODO|FIXME)\b/o, '')
522
+
523
+ gem.send("#{field}=", new)
524
+ end
525
+ }
526
+ end
527
+
528
+ f.rewind
529
+ f.write new
530
+ end
531
+
532
+ `rake gem`
533
+ %>
430
534
  </pre>
431
535
 
432
536
  See the RubyGem contents:
433
537
 
434
- <pre>
538
+ <code lang="yaml">
435
539
  # gem spec pkg/*.gem
436
- <code lang="yaml"><%= `gem spec pkg/*.gem`.rstrip %></code>
437
- </pre>
540
+ %= `gem spec pkg/*.gem`.rstrip
541
+ </code>
542
+
438
543
 
439
544
  %|section "Publish a RubyGem"
545
+
440
546
  You must first register your project on [RubyForge](http://rubyforge.org) before you can publish a RubyGem. If your RubyForge project name is different from your actual project name, then you should pass the `:rubyforge_project` and `:rubyforge_section` options to the `Inochi.rake()` method.
441
547
 
442
548
  Publish a RubyGem by running:
@@ -445,7 +551,9 @@
445
551
  # rake pub:gem
446
552
  </pre>
447
553
 
554
+
448
555
  %|section "Announce a release"
556
+
449
557
  You must first provide your <%= xref "Login information" %> to <%= $project %>. If you do not want to do this, then see <%= xref "Manual release announcement" %>.
450
558
 
451
559
  Announce a release by running:
@@ -454,10 +562,12 @@
454
562
  # rake pub:ann
455
563
  </pre>
456
564
 
565
+
457
566
  %|paragraph "Login information"
567
+
458
568
  In order to automate the announcement of releases, <%= $project %> needs to know your login information for the [RAA (Ruby Application Archive)](http://raa.ruby-lang.org) and [RubyForum](http://www.ruby-forum.com/forum/4), which serves as a gateway to the [ruby-talk mailing list](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/).
459
569
 
460
- <% logins_file = "~/.config/inochi/logins.yaml" %>
570
+ % logins_file = "~/.config/inochi/logins.yaml"
461
571
 
462
572
  This information is expected to be stored in a <tt><%= logins_file %></tt> file (this location can be overridden by passing the `:logins_file` option to the `Inochi.rake()` method), where <tt>~</tt> denotes the path to your home directory. This file is a [YAML document](<%= yaml_addr %>) containing the following parameters:
463
573
 
@@ -474,12 +584,14 @@
474
584
 
475
585
  # chmod 0600 <%= logins_file %>
476
586
 
587
+
477
588
  %|section "Manual release announcement"
589
+
478
590
  Build release announcements by running:
479
591
 
480
592
  <pre>
481
593
  # rake ann
482
- <%= `rake ann` %>
594
+ %= `rake ann`
483
595
  </pre>
484
596
 
485
597
  This produces the following files in your project directory:
@@ -489,7 +601,9 @@
489
601
 
490
602
  Now you can manually announce your release using these files.
491
603
 
604
+
492
605
  %|section "Publish the documentation"
606
+
493
607
  Publish the user manual and API documentation by running:
494
608
 
495
609
  <pre>
@@ -497,3 +611,31 @@
497
611
  </pre>
498
612
 
499
613
  If your documentation website (see the `:docsite` option for the `Inochi.init()` method) is hosted on RubyForge, then the above command will automatically upload your project's documentation to the correct place.
614
+
615
+
616
+ %|section "Specific topics"
617
+
618
+
619
+ %|section "Build a RubyGem without #{$project} as runtime dependency"
620
+
621
+ <%= $project %> adds itself as a runtime dependency to your project's gem, by default, because it assumes that you want to use its runtime convenience facilities in your project.
622
+
623
+ However, if you only wish to use <%= $project %>'s gem building facilities and your project has no use for its runtime convenience facilities, then you can build your project's gem without <%= $project %> as a runtime dependency as follows.
624
+
625
+ 1. Create your project's <tt>rakefile</tt> with the following structure and fill in the blanks:
626
+
627
+ <code>
628
+ require 'rubygems'
629
+ require 'inochi'
630
+
631
+ Inochi.init __________
632
+
633
+ Inochi.rake __________, :inochi_consumer => false
634
+ </code>
635
+
636
+ Notice the `:inochi_consumer => false` parameter being passed to `Inochi.rake()`. This is what tells <%= $project %> not to add itself as a runtime dependency to your project's gem.
637
+
638
+ 2. Build your project's gem <%= xref "Build a RubyGem", "as you normally would" %>.
639
+
640
+ Now your project uses <%= $project %> *only* when building its gem and contains <%= $project %>-related code *only* in its <tt>rakefile</tt>. The remainder of your project is isolated from, and has no knowledge of, <%= $project %>.
641
+