inochi 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/CREDITS +17 -1
  2. data/bin/inochi +19 -539
  3. data/lib/inochi.rb +1 -41
  4. data/lib/inochi/engine.rb +101 -0
  5. data/lib/inochi/generate.rb +52 -0
  6. data/lib/inochi/inochi.rb +109 -0
  7. data/lib/inochi/tasks/ann.rake +230 -0
  8. data/lib/inochi/tasks/api.rake +28 -0
  9. data/lib/inochi/tasks/gem.rake +46 -0
  10. data/lib/inochi/tasks/init.rake +38 -0
  11. data/lib/inochi/tasks/man.rake +78 -0
  12. data/lib/inochi/tasks/project.rake +25 -0
  13. data/lib/inochi/tasks/pub.rake +130 -0
  14. data/lib/inochi/templates/CREDITS.rbs +18 -0
  15. data/lib/inochi/templates/EXAMPLES.rbs +24 -0
  16. data/lib/inochi/templates/FURTHER.rbs +17 -0
  17. data/lib/inochi/templates/HACKING.rbs +92 -0
  18. data/lib/inochi/templates/HISTORY.rbs +55 -0
  19. data/lib/inochi/templates/LICENSE.rbs +15 -0
  20. data/lib/inochi/templates/MANUAL.rbs +27 -0
  21. data/lib/inochi/templates/README.rbs +60 -0
  22. data/lib/inochi/templates/USAGE.rbs +23 -0
  23. data/lib/inochi/templates/command.rbs +23 -0
  24. data/lib/inochi/templates/inochi.opts.rbs +43 -0
  25. data/lib/inochi/templates/inochi.rb.rbs +102 -0
  26. data/lib/inochi/templates/library.rbs +7 -0
  27. data/lib/inochi/templates/library_test.rb.rbs +3 -0
  28. data/lib/inochi/templates/test_helper.rb.rbs +3 -0
  29. data/lib/inochi/templates/test_runner.rbs +25 -0
  30. data/{doc → logo}/inochi.png +0 -0
  31. data/man.html +959 -0
  32. data/man/man1/inochi.1.gz +0 -0
  33. metadata +129 -198
  34. data/doc/README +0 -6
  35. data/doc/api/apple-touch-icon.png +0 -0
  36. data/doc/api/classes/Array.html +0 -370
  37. data/doc/api/classes/File.html +0 -110
  38. data/doc/api/classes/Inochi.html +0 -1477
  39. data/doc/api/classes/Inochi/Manual.html +0 -157
  40. data/doc/api/classes/Inochi/Phrases.html +0 -331
  41. data/doc/api/classes/Inochi/Version.html +0 -190
  42. data/doc/api/classes/TempDir.html +0 -164
  43. data/doc/api/created.rid +0 -1
  44. data/doc/api/css/main.css +0 -263
  45. data/doc/api/css/panel.css +0 -383
  46. data/doc/api/css/reset.css +0 -53
  47. data/doc/api/favicon.ico +0 -0
  48. data/doc/api/files/CREDITS.html +0 -61
  49. data/doc/api/files/LICENSE.html +0 -76
  50. data/doc/api/files/lib/inochi/book_rb.html +0 -106
  51. data/doc/api/files/lib/inochi/init_rb.html +0 -66
  52. data/doc/api/files/lib/inochi/main_rb.html +0 -52
  53. data/doc/api/files/lib/inochi/rake_rb.html +0 -52
  54. data/doc/api/files/lib/inochi/test/bacon_rb.html +0 -67
  55. data/doc/api/files/lib/inochi/test/context_rb.html +0 -69
  56. data/doc/api/files/lib/inochi/test/dfect_rb.html +0 -67
  57. data/doc/api/files/lib/inochi/test/matchy_rb.html +0 -69
  58. data/doc/api/files/lib/inochi/test/minitest_rb.html +0 -71
  59. data/doc/api/files/lib/inochi/test/mocha_rb.html +0 -67
  60. data/doc/api/files/lib/inochi/test/rspec_rb.html +0 -67
  61. data/doc/api/files/lib/inochi/test/shoulda_rb.html +0 -67
  62. data/doc/api/files/lib/inochi/test/test_spec_rb.html +0 -67
  63. data/doc/api/files/lib/inochi/test/test_unit_rb.html +0 -67
  64. data/doc/api/files/lib/inochi/util/combo_rb.html +0 -59
  65. data/doc/api/files/lib/inochi/util/tempdir_rb.html +0 -68
  66. data/doc/api/files/lib/inochi/util_rb.html +0 -59
  67. data/doc/api/files/lib/inochi_rb.html +0 -76
  68. data/doc/api/i/arrows.png +0 -0
  69. data/doc/api/i/results_bg.png +0 -0
  70. data/doc/api/i/tree_bg.png +0 -0
  71. data/doc/api/index.html +0 -14
  72. data/doc/api/js/jquery-1.3.2.min.js +0 -19
  73. data/doc/api/js/jquery-effect.js +0 -593
  74. data/doc/api/js/main.js +0 -22
  75. data/doc/api/js/searchdoc.js +0 -628
  76. data/doc/api/panel/index.html +0 -71
  77. data/doc/api/panel/search_index.js +0 -1
  78. data/doc/api/panel/tree.js +0 -1
  79. data/doc/history.erb +0 -268
  80. data/doc/index.erb +0 -11
  81. data/doc/index.html +0 -3179
  82. data/doc/inochi.svg +0 -405
  83. data/doc/intro.erb +0 -87
  84. data/doc/setup.erb +0 -105
  85. data/doc/usage.erb +0 -641
  86. data/lib/inochi/book.rb +0 -91
  87. data/lib/inochi/init.rb +0 -256
  88. data/lib/inochi/main.rb +0 -85
  89. data/lib/inochi/rake.rb +0 -902
  90. data/lib/inochi/test/bacon.rb +0 -3
  91. data/lib/inochi/test/context.rb +0 -4
  92. data/lib/inochi/test/dfect.rb +0 -3
  93. data/lib/inochi/test/matchy.rb +0 -4
  94. data/lib/inochi/test/minitest.rb +0 -7
  95. data/lib/inochi/test/mocha.rb +0 -3
  96. data/lib/inochi/test/rspec.rb +0 -3
  97. data/lib/inochi/test/shoulda.rb +0 -3
  98. data/lib/inochi/test/test_spec.rb +0 -3
  99. data/lib/inochi/test/test_unit.rb +0 -3
  100. data/lib/inochi/util.rb +0 -99
  101. data/lib/inochi/util/combo.rb +0 -191
  102. data/lib/inochi/util/tempdir.rb +0 -29
  103. data/rakefile +0 -12
  104. data/test/inochi.rb +0 -111
@@ -1,105 +0,0 @@
1
- %#--
2
- %# Copyright protects this work.
3
- %# See LICENSE file for details.
4
- %#++
5
-
6
-
7
- %|chapter "Setup"
8
-
9
-
10
- %|section "Requirements"
11
-
12
- Your system needs the following software to run <%= $project %>.
13
-
14
- | Software | Description | Notes |
15
- | -------- | ----------- | ----- |
16
- | [Ruby](http://ruby-lang.org) | Ruby language interpreter | Version 1.8.6 or 1.8.7 is required. |
17
- | [RubyGems](http://rubygems.org) | Ruby packaging system | Version 1.3.1 or newer is required. |
18
- | [Lynx](http://lynx.isc.org) | Text-mode web browser | Version 2.8.6 or newer is required to convert HTML into plain text. |
19
-
20
-
21
- %|section "Installation"
22
-
23
- You can install <%= $project %> by running this command:
24
-
25
- gem install <%= $program %> --development
26
-
27
- To check whether the installation was sucessful, run this command:
28
-
29
- <%= $program %> --version
30
-
31
- If the installation was successful, you will see output like this:
32
-
33
- <pre><%= `ruby bin/#{$program} --version` %></pre>
34
-
35
- If you do not see such output, you may
36
- <%= xref "License", "ask the author(s)" %> for help.
37
-
38
-
39
- %|section "Manifest"
40
-
41
- You will see the following items inside <%= $project %>'s installation
42
- directory, whose path you can determine by running this command:
43
-
44
- <%= $program %> --version
45
-
46
- * <tt>bin/</tt>
47
-
48
- * <tt><%= $program %></tt> --- the main <%= $project %> executable.
49
-
50
- * <tt>lib/</tt>
51
-
52
- * <tt><%= $program %>.rb</tt> --- the main <%= $project %> library.
53
-
54
- * <tt>doc/</tt>
55
-
56
- * <tt>api/</tt> --- API reference documentation.
57
-
58
- * <tt>index.erb</tt> --- source of this user manual.
59
-
60
- * <tt>lang/</tt> --- translations of language phrases.
61
-
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,641 +0,0 @@
1
- %#--
2
- %# Copyright protects this work.
3
- %# See LICENSE file for details.
4
- %#++
5
-
6
- % require 'inochi/util/tempdir'
7
- % yaml_addr = "http://yaml.kwiki.org/?YamlInFiveMinutes"
8
-
9
-
10
- %|part "Usage"
11
-
12
-
13
- %|section "Command-line interface"
14
-
15
- When you run this command:
16
-
17
- <%= $program %> --help
18
-
19
- You will see this output:
20
-
21
- <pre><%= verbatim `ruby bin/#{$program} --help` %></pre>
22
-
23
-
24
- %|tip "Merging files with **kdiff3**"
25
-
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:
27
-
28
- 1. Create a file named <tt>merge2</tt> with the following content:
29
-
30
- #!/bin/sh
31
-
32
- old_file=$1
33
- shift
34
-
35
- new_file=$1
36
- shift
37
-
38
- output_file=$1
39
- shift
40
-
41
- kdiff3 --merge "$old_file" "$new_file" --output "$output_file"
42
-
43
- 2. Make the file executable:
44
-
45
- chmod +x merge2
46
-
47
- 3. Place the file in a directory that is listed in your `PATH` environment variable.
48
-
49
- 4. Run <%= $project %> like this:
50
-
51
- <%= $program %> -m merge2
52
-
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.
54
-
55
-
56
- %|section "Ruby library interface"
57
-
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:
59
- * Your project's main library invokes the `Inochi.init()` method.
60
- * Your project's main executable invokes the `Inochi.main()` method.
61
- * Your project's <tt>rakefile</tt> invokes the `Inochi.rake()` method.
62
- * Your project's user manual invokes the `Inochi.book()` method.
63
-
64
-
65
- %|section "General walkthrough", "Tutorial"
66
-
67
- This tutorial shows how <%= $project %> is used to manage a hypothetical `WordCount` project throughout the various stages of its life.
68
-
69
-
70
- %|section "Have a brilliant idea"
71
-
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.
73
-
74
- > Push on! Keep on!
75
-
76
- Until at last, pushed far beyond its limit, your body overpowers your will and drags you into black unconsciousness.
77
-
78
- *BEEP* *BEEP* *B*---
79
-
80
- Half-asleep and violent from the sudden disturbance, you silence the bleeting alarm clock with vengeance. It is 2pm on Sunday afternoon.
81
-
82
- Red beams of sunlight slip through the gaps in your curtains. It is a beautiful day, outside. *Outside*--- you think,
83
-
84
- > What am I doing to myself?
85
- >
86
- > I've got to get *outside*.
87
- >
88
- > I've got to get *away*...
89
- >
90
- > Away from this computer... this... mental prison in which I toil night after night, like a souless machine.
91
-
92
- Venturing into the courtyard outside your quarters, you find peace. A warm breeze graces you, sweeping your hair gently as a mother would. The bright sunlight penetrates your mind's eye as your thoughts fade...
93
-
94
- Thoughts of tests to write, units to refactor, bugs to fix, options to document. They melt and mix and flow into nothingness.
95
-
96
- All is clear. No thoughts. No more.
97
-
98
- > No!
99
-
100
- You collapse heavily onto the grassy earth beneath you. Breathing deeply, you sink into yourself and whisper
101
-
102
- > It's okay.
103
- >
104
- > Just, let go.
105
-
106
- and fall asleep.
107
-
108
- You awaken that evening relaxed and refreshed. A brilliant idea for a new project enters your mind: the project will be a tool that counts the number of words in text file. And, the project can be accessed from Ruby via the `WordCount` module.
109
-
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.
111
-
112
-
113
- %|cd TempDir.new.path
114
-
115
- % main_executable = 'bin/word_count'
116
-
117
-
118
- %|section "Generate your project"
119
-
120
- Give life to your new project:
121
-
122
- <pre>
123
- # inochi WordCount
124
- %= verbatim `ruby #{$install}/bin/inochi WordCount`
125
- </pre>
126
-
127
- Enter the <tt>word_count</tt> directory:
128
-
129
- <pre>
130
- # cd word_count
131
- % cd "word_count"
132
- </pre>
133
-
134
-
135
- %|paragraph "View Rake tasks"
136
-
137
- <pre>
138
- # rake -T
139
- %= verbatim `rake -T`
140
- </pre>
141
-
142
-
143
- %|paragraph "Run unit tests"
144
-
145
- <pre>
146
- # rake test
147
- %= verbatim `rake test`
148
- </pre>
149
-
150
-
151
- %|paragraph "Run project executable"
152
-
153
- <pre>
154
- % command = main_executable
155
- # ruby <%= command %>
156
- %= verbatim `ruby #{command}`
157
- </pre>
158
-
159
- See usage information:
160
-
161
- <pre>
162
- % command = "#{main_executable} --help"
163
- # ruby <%= command %>
164
- %= verbatim `ruby #{command}`
165
- </pre>
166
-
167
- See project & version information:
168
-
169
- <pre>
170
- % command = "#{main_executable} --version"
171
- # ruby <%= command %>
172
- %= verbatim `ruby #{command}`
173
- </pre>
174
-
175
-
176
- %|paragraph "Show user manual"
177
-
178
- Build the user manual (please disregard any "unclosed span" warnings):
179
-
180
- <pre>
181
- # rake doc:man
182
- </pre>
183
-
184
- Launch the user manual:
185
-
186
- <pre>
187
- % command = "#{main_executable} --manual"
188
- # ruby <%= command %>
189
- </pre>
190
-
191
- The manual will now appear in your default web browser.
192
-
193
-
194
- %|section "Configure your project"
195
-
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.
197
-
198
-
199
- %|section "Project information"
200
-
201
- % license_file = 'LICENSE'
202
-
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:
204
-
205
- <pre>
206
- %= verbatim File.read(license_file)
207
- </pre>
208
-
209
- % main_library = 'lib/word_count.rb'
210
-
211
- Open the main project library file <tt><%= main_library %></tt> and fill in the blanks:
212
-
213
- <code>
214
- %= verbatim File.read(main_library)
215
- </code>
216
-
217
-
218
- %|section "Project executable"
219
-
220
- Open the <tt><%= main_executable %></tt> file and fill in the blanks:
221
-
222
- <code>
223
- %= verbatim File.read(main_executable)
224
- </code>
225
-
226
-
227
- %|section "Rake tasks"
228
-
229
- % rake_file = 'rakefile'
230
-
231
- Open the <tt><%= rake_file %></tt> and fill in the blanks:
232
-
233
- <code>
234
- %= verbatim File.read(rake_file)
235
- </code>
236
-
237
-
238
- %|section "User manual"
239
-
240
- <%
241
- whole = 'doc/index.erb'
242
- parts = File.read(whole).
243
- scan(/^[[:blank:]]*%\+[[:blank:]]*(.*)\s*/).
244
- flatten.map {|s| "doc/" + eval(s) }
245
-
246
- files = [whole, *parts]
247
- %>
248
-
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.
250
-
251
- Open these source files and fill in the blanks:
252
-
253
-
254
- %|files.each |f|
255
- %|paragraph "<tt>#{f}</tt>"
256
- <code lang="rhtml"><%= verbatim File.read(f) %></code>
257
-
258
-
259
- %|section "Implement your project"
260
-
261
- Add the following code to the bottom of <tt>lib/word_count.rb</tt>, the main project library:
262
-
263
- <code>
264
- module WordCount
265
- # Returns the number of words in the given input.
266
- def WordCount.count input
267
- input.to_s.split(/\W+/).length
268
- end
269
- end
270
- </code>
271
-
272
- Add the following code to the bottom of <tt>bin/word_count</tt>, the main project executable:
273
-
274
- <code>
275
- input = ARGF.read
276
- total = WordCount.count(input)
277
- puts "There are #{total} words in the input."
278
- </code>
279
-
280
- Add the following code to the bottom of <tt>test/word_count.rb</tt>, a unit test for the main project library:
281
-
282
- <code>
283
- describe WordCount do
284
- it 'handles empty input' do
285
- WordCount.count(nil).must_equal(0)
286
- WordCount.count('').must_equal(0)
287
- WordCount.count(' ').must_equal(0)
288
- end
289
-
290
- it 'handles single words' do
291
- WordCount.count('a').must_equal(1)
292
- WordCount.count('foo').must_equal(1)
293
- WordCount.count('bar').must_equal(1)
294
- end
295
-
296
- it 'handles multiple words' do
297
- WordCount.count('a b').must_equal(2)
298
- WordCount.count('a-b').must_equal(2)
299
- WordCount.count('a/b').must_equal(2)
300
- end
301
-
302
- it 'ignores punctuation and space' do
303
- WordCount.count('!').must_equal(0)
304
- WordCount.count('! @ # % #!@#').must_equal(0)
305
- WordCount.count(' !').must_equal(0)
306
- WordCount.count('! ').must_equal(0)
307
- WordCount.count(' ! ').must_equal(0)
308
- WordCount.count(' ! ').must_equal(0)
309
- end
310
- end
311
- </code>
312
-
313
-
314
- %|paragraph "Goodbye `$LOAD_PATH`, hello `require()`"
315
-
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.
317
-
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.
319
-
320
- % sub_library = 'word_count/odf/text'
321
-
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:
323
-
324
- <code>
325
- require '<%= sub_library %>'
326
- </code>
327
-
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.
329
-
330
-
331
- %|section "Test your project"
332
-
333
- To reduce the amount of code you have to write, <%= $project %> defines the following convention for unit tests.
334
-
335
-
336
- %|paragraph "Units and tests"
337
-
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**.
339
-
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.
341
-
342
-
343
- %|paragraph "Test execution"
344
-
345
- <pre>rake test</pre>
346
-
347
- The above command begins the testing process, during which:
348
-
349
- * Tests which lack corresponding units are *skipped* and not executed. A message specifying which test file was skipped is printed to the standard error stream whenever this occurs.
350
-
351
- * Before a test is executed, its corresponding unit is automatically loaded into the Ruby environment using `require()`.
352
-
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:
354
-
355
- % test_libs.sort.each do |f|
356
- * <tt><%= File.basename(f, '.rb') %></tt> ---
357
- %= File.read(f).scan(/^#(.*)/).join
358
-
359
-
360
- %|paragraph "Helper libraries"
361
-
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.
363
-
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:
365
-
366
- <code>
367
- require 'test/foo/qux'
368
- </code>
369
-
370
-
371
- %|section "Translate your project"
372
-
373
- % phrases_file = "<tt>lang/phrases.yaml</tt>"
374
-
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.
376
-
377
-
378
- %|section "Language phrases"
379
-
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.
381
-
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" %>:
383
-
384
- <code>
385
- your_project::PHRASES['Have a nice day!']
386
- </code>
387
-
388
- If there is no <%= xref "Translation files", "translation file" %> for the user's preferred language, or it does not define a translation for a particular language phrase, then the language phrase will be used untranslated:
389
-
390
- <code>
391
- your_project::PHRASES['No translation for this']
392
- #=> 'No translation for this'
393
- </code>
394
-
395
-
396
- %|paragraph "Parameterizing language phrases"
397
-
398
- Language phrases can be parameterized using [`printf` format placeholders](http://en.wikipedia.org/wiki/Printf#printf_format_placeholders) to ease translation:
399
-
400
- <code>
401
- your_project::PHRASES['Good afternoon, %s.', user_name]
402
- your_project::PHRASES['You are %d years old.', user_age]
403
- </code>
404
-
405
-
406
- %|paragraph "Explicit translation into a language"
407
-
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:
409
-
410
- <code>
411
- # explictly translate into Japanese (ja)
412
- your_project::PHRASES.ja('Goodbye %s!', user_name)
413
-
414
- # explictly translate into French (fr)
415
- your_project::PHRASES.fr('Farewell %s!', user_name)
416
- </code>
417
-
418
-
419
- %|section "Translation files"
420
-
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.
422
-
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:
424
-
425
- <pre>
426
- #
427
- # (this is a comment)
428
- #
429
- # language phrase : translation
430
- #
431
- Hello %s! : ¡Hola %s!
432
- Money : Dinero
433
- Ticket : Tarjeta
434
- See you later %s! : ¡Hasta la vista %s!
435
- "%s: Quickly, please!" : "%s: ¡Rápidamente, por favor!"
436
- </pre>
437
-
438
- On each line, the original language phrase (as used in your project) appears first, then a single semicolon (:), followed by the translation.
439
-
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.
441
-
442
-
443
- %|section "Extracting language phrases"
444
-
445
- <pre>
446
- # rake lang:dump
447
- %= verbatim `rake lang:dump`
448
- </pre>
449
-
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.
451
-
452
-
453
- %|paragraph "Dynamic analysis"
454
-
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.
456
-
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.
458
-
459
- However, note that if your unit tests *do not* exercise a part of your project that defines language phrases, then those phrases *will not* be extracted by <%= $project %>.
460
-
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.
462
-
463
-
464
- %|paragraph "Static analysis"
465
-
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.
467
-
468
- Patches are welcome! :-)
469
-
470
-
471
- %|section "Translating language phrases"
472
-
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):
474
-
475
- <pre>
476
- # rake lang:conv from=LANGUAGE_CODE
477
- %= verbatim `rake lang:conv from=LANGUAGE_CODE 2>&1`
478
- </pre>
479
-
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.
481
-
482
-
483
- %|section "Publish your project"
484
-
485
- <pre>
486
- # rake pub
487
- </pre>
488
-
489
- The above command performs all automated steps described in the following sections.
490
-
491
-
492
- %|section "Build a RubyGem"
493
-
494
- Build a RubyGem by running:
495
-
496
- <pre>
497
- # 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
- %>
534
- </pre>
535
-
536
- See the RubyGem contents:
537
-
538
- <code lang="yaml">
539
- # gem spec pkg/*.gem
540
- %= `gem spec pkg/*.gem`.rstrip
541
- </code>
542
-
543
-
544
- %|section "Publish a RubyGem"
545
-
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.
547
-
548
- Publish a RubyGem by running:
549
-
550
- <pre>
551
- # rake pub:gem
552
- </pre>
553
-
554
-
555
- %|section "Announce a release"
556
-
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" %>.
558
-
559
- Announce a release by running:
560
-
561
- <pre>
562
- # rake pub:ann
563
- </pre>
564
-
565
-
566
- %|paragraph "Login information"
567
-
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/).
569
-
570
- % logins_file = "~/.config/inochi/logins.yaml"
571
-
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:
573
-
574
- <code lang="yaml">
575
- www.ruby-forum.com:
576
- user: YOUR_USERNAME_HERE
577
- pass: YOUR_PASSWORD_HERE
578
-
579
- raa.ruby-lang.org:
580
- pass: YOUR_PASSWORD_HERE
581
- </code>
582
-
583
- For better security, you should ensure that this file is only readable and writable by you and is not accessible by anyone else. In a UNIX environment, this can be accomplished by running the following command:
584
-
585
- # chmod 0600 <%= logins_file %>
586
-
587
-
588
- %|section "Manual release announcement"
589
-
590
- Build release announcements by running:
591
-
592
- <pre>
593
- # rake ann
594
- %= `rake ann`
595
- </pre>
596
-
597
- This produces the following files in your project directory:
598
-
599
- %|Dir['ANN*'].each |f|
600
- * <tt><%= f %></tt>
601
-
602
- Now you can manually announce your release using these files.
603
-
604
-
605
- %|section "Publish the documentation"
606
-
607
- Publish the user manual and API documentation by running:
608
-
609
- <pre>
610
- # rake pub:doc
611
- </pre>
612
-
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
-