inochi 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CREDITS +1 -0
- data/bin/inochi +112 -104
- data/doc/api/classes/Array.html +370 -0
- data/doc/api/classes/File.html +110 -0
- data/doc/api/classes/Inochi.html +1493 -0
- data/doc/api/classes/Inochi/Manual.html +157 -0
- data/doc/api/classes/Inochi/Phrases.html +331 -0
- data/doc/api/classes/Inochi/Version.html +190 -0
- data/doc/api/classes/TempDir.html +164 -0
- data/doc/api/created.rid +1 -0
- data/doc/api/css/main.css +263 -0
- data/doc/api/css/panel.css +383 -0
- data/doc/api/css/reset.css +53 -0
- data/doc/api/files/CREDITS.html +61 -0
- data/doc/api/files/LICENSE.html +76 -0
- data/doc/api/files/lib/inochi/book_rb.html +96 -0
- data/doc/api/files/lib/inochi/init_rb.html +78 -0
- data/doc/api/files/lib/inochi/main_rb.html +52 -0
- data/doc/api/files/lib/inochi/rake_rb.html +52 -0
- data/doc/api/files/lib/inochi/test/bacon_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/context_rb.html +69 -0
- data/doc/api/files/lib/inochi/test/dfect_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/matchy_rb.html +69 -0
- data/doc/api/files/lib/inochi/test/minitest_rb.html +71 -0
- data/doc/api/files/lib/inochi/test/mocha_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/rspec_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/shoulda_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/test_spec_rb.html +67 -0
- data/doc/api/files/lib/inochi/test/test_unit_rb.html +67 -0
- data/doc/api/files/lib/inochi/util/combo_rb.html +59 -0
- data/doc/api/files/lib/inochi/util/tempdir_rb.html +68 -0
- data/doc/api/files/lib/inochi/util_rb.html +59 -0
- data/doc/api/files/lib/inochi_rb.html +78 -0
- data/doc/api/i/arrows.png +0 -0
- data/doc/api/i/results_bg.png +0 -0
- data/doc/api/i/tree_bg.png +0 -0
- data/doc/api/index.html +14 -18
- data/doc/api/js/jquery-1.3.2.min.js +19 -0
- data/doc/api/js/jquery-effect.js +593 -0
- data/doc/api/js/main.js +22 -0
- data/doc/api/js/searchdoc.js +605 -0
- data/doc/api/panel/index.html +63 -0
- data/doc/api/panel/search_index.js +1 -0
- data/doc/api/panel/tree.js +1 -0
- data/doc/history.erb +75 -34
- data/doc/index.erb +10 -5
- data/doc/index.xhtml +806 -1145
- data/doc/intro.erb +33 -27
- data/doc/setup.erb +16 -15
- data/doc/usage.erb +86 -137
- data/lib/inochi.rb +25 -13
- data/lib/inochi/book.rb +13 -6
- data/lib/inochi/init.rb +41 -24
- data/lib/inochi/main.rb +17 -7
- data/lib/inochi/rake.rb +200 -59
- data/lib/inochi/test/bacon.rb +3 -0
- data/lib/inochi/test/context.rb +4 -0
- data/lib/inochi/test/dfect.rb +3 -0
- data/lib/inochi/test/matchy.rb +4 -0
- data/lib/inochi/test/minitest.rb +7 -0
- data/lib/inochi/test/mocha.rb +3 -0
- data/lib/inochi/test/rspec.rb +3 -0
- data/lib/inochi/test/shoulda.rb +3 -0
- data/lib/inochi/test/test_spec.rb +3 -0
- data/lib/inochi/test/test_unit.rb +3 -0
- data/lib/inochi/util.rb +23 -1
- data/lib/inochi/util/combo.rb +191 -0
- data/lib/inochi/util/tempdir.rb +29 -0
- data/rakefile +12 -0
- data/test/inochi.rb +5 -0
- metadata +119 -45
- data/Rakefile +0 -6
- data/doc/api/Inochi.html +0 -2574
- data/doc/api/Inochi/Manual.html +0 -230
- data/doc/api/Inochi/Phrases.html +0 -409
- data/doc/api/Inochi/Version.html +0 -222
- data/doc/api/all-methods.html +0 -180
- data/doc/api/all-namespaces.html +0 -28
- data/doc/api/app.js +0 -18
- data/doc/api/jquery.js +0 -11
- data/doc/api/readme.html +0 -38
- data/doc/api/style.css +0 -68
- data/doc/api/syntax_highlight.css +0 -21
- data/doc/theory.erb +0 -3
data/doc/intro.erb
CHANGED
@@ -1,15 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
%#--
|
2
|
+
%# Copyright 2009 Suraj N. Kurapati
|
3
|
+
%# See the LICENSE file for details.
|
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)'
|
9
|
+
|
10
|
+
%|chapter "Introduction"
|
11
|
+
%|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
|
+
|
14
|
+
<%= $project %> is exciting because:
|
7
15
|
|
8
16
|
* It encourages good documentation:
|
17
|
+
|
9
18
|
* Provides a comprehensive user manual that integrates release notes, setup and usage instructions, and more.
|
19
|
+
|
10
20
|
* Automates the display of help, version, and usage information for your project's main executable.
|
11
21
|
|
12
22
|
* It reduces programming effort:
|
23
|
+
* Makes it easy to <%= xref "Translate your project", "translate your project" %> into many languages.
|
13
24
|
* Provides a single point of entry to your project's libraries.
|
14
25
|
* Keeps your project's configuration in one place.
|
15
26
|
* Parses command-line options using [the Trollop library](http://trollop.rubyforge.org).
|
@@ -18,7 +29,7 @@
|
|
18
29
|
* Generates project scaffolds while merging changes from previous ones.
|
19
30
|
* Provides Rake tasks for packaging, publishing, and announcing your project.
|
20
31
|
|
21
|
-
These features distinguish
|
32
|
+
These features distinguish <%= $project %> from the competition:
|
22
33
|
* [hoe](http://seattlerb.rubyforge.org/hoe/)
|
23
34
|
* [newgem](http://newgem.rubyforge.org)
|
24
35
|
* [Mr Bones](http://codeforpeople.rubyforge.org/bones/)
|
@@ -27,25 +38,24 @@
|
|
27
38
|
* [GemMake](https://simonmenke.github.com/gm/)
|
28
39
|
* [SimpleGem](http://github.com/reagent/simple-gem/tree/master)
|
29
40
|
|
30
|
-
|
41
|
+
%|paragraph "Etymology"
|
31
42
|
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!
|
32
43
|
|
33
44
|
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*.
|
34
45
|
|
35
46
|
Happy cultivation!
|
36
|
-
<% end %>
|
37
47
|
|
38
|
-
|
48
|
+
%|section "Logistics"
|
39
49
|
* <%= xref "History", "Release notes" %> --- history of project releases.
|
40
|
-
* [Source code](
|
41
|
-
* [API reference](
|
42
|
-
* [Project home](<%= $website %>) --- the
|
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.
|
43
53
|
|
44
54
|
To get help or provide feedback, simply
|
45
55
|
<%= xref "License", "contact the author(s)" %>.
|
46
56
|
|
47
|
-
|
48
|
-
|
57
|
+
%|paragraph "Version numbers"
|
58
|
+
<%= $project %> releases are numbered in *major.minor.patch*
|
49
59
|
form according to the [RubyGems rational versioning
|
50
60
|
policy](http://www.rubygems.org/read/chapter/7), which
|
51
61
|
can be summarized thus:
|
@@ -83,21 +93,17 @@
|
|
83
93
|
</tr>
|
84
94
|
</tbody>
|
85
95
|
</table>
|
86
|
-
<% end %>
|
87
|
-
<% end %>
|
88
96
|
|
89
|
-
|
90
|
-
|
91
|
-
|
97
|
+
%|section "License"
|
98
|
+
%< "../LICENSE"
|
99
|
+
|
100
|
+
%|section "Credits" |n|
|
101
|
+
%= $logo = n.xref_link("![#{$project} logo](#{$program}.png)".to_inline_xhtml)
|
92
102
|
|
93
|
-
|
94
|
-
<%= $logo = "![project logo](#{$program}.png)".to_inline_xhtml %>
|
95
|
-
<%# include README #%>
|
103
|
+
%< "README"
|
96
104
|
|
97
|
-
|
98
|
-
|
105
|
+
<%= $project %> is made possible by
|
106
|
+
%= xref "History", "contributions"
|
99
107
|
from users like you:
|
100
108
|
|
101
|
-
|
102
|
-
<% end %>
|
103
|
-
<% end %>
|
109
|
+
%< "../CREDITS"
|
data/doc/setup.erb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
%#--
|
2
|
+
%# Copyright 2009 Suraj N. Kurapati
|
3
|
+
%# See the LICENSE file for details.
|
4
|
+
%#++
|
5
|
+
|
6
|
+
%|chapter "Setup"
|
7
|
+
%|section "Requirements"
|
8
|
+
Your system needs the following software to run <%= $project %>.
|
4
9
|
|
5
10
|
| Software | Description | Notes |
|
6
11
|
| -------- | ----------- | ----- |
|
7
12
|
| [Ruby](http://ruby-lang.org) | Ruby language interpreter | Version 1.8.6 or 1.8.7 is required. |
|
8
|
-
| [RubyGems](http://rubygems.org) | Ruby packaging system | Version 1.
|
13
|
+
| [RubyGems](http://rubygems.org) | Ruby packaging system | Version 1.3.1 or newer is required. |
|
9
14
|
| [Lynx](http://lynx.isc.org) | Text-mode web browser | Version 2.8.6 or newer is required to convert HTML into plain text. |
|
10
|
-
<% end %>
|
11
15
|
|
12
|
-
|
13
|
-
You can install
|
16
|
+
%|section "Installation"
|
17
|
+
You can install <%= $project %> by running this command:
|
14
18
|
|
15
|
-
gem install
|
19
|
+
gem install <%= $program %> --development
|
16
20
|
|
17
21
|
To check whether the installation was sucessful, run this command:
|
18
22
|
|
@@ -24,21 +28,20 @@
|
|
24
28
|
|
25
29
|
If you do not see such output, you may
|
26
30
|
<%= xref "License", "ask the author(s)" %> for help.
|
27
|
-
<% end %>
|
28
31
|
|
29
|
-
|
30
|
-
You will see the following items inside
|
32
|
+
%|section "Manifest"
|
33
|
+
You will see the following items inside <%= $project %>'s installation
|
31
34
|
directory, whose path you can determine by running this command:
|
32
35
|
|
33
36
|
<%= $program %> --version
|
34
37
|
|
35
38
|
* <tt>bin/</tt>
|
36
39
|
|
37
|
-
* <tt><%= $program %></tt> --- the main
|
40
|
+
* <tt><%= $program %></tt> --- the main <%= $project %> executable.
|
38
41
|
|
39
42
|
* <tt>lib/</tt>
|
40
43
|
|
41
|
-
* <tt><%= $program %>.rb</tt> --- the main
|
44
|
+
* <tt><%= $program %>.rb</tt> --- the main <%= $project %> library.
|
42
45
|
|
43
46
|
* <tt>doc/</tt>
|
44
47
|
|
@@ -49,5 +52,3 @@
|
|
49
52
|
* <tt>lang/</tt> --- translations of language phrases.
|
50
53
|
|
51
54
|
* <tt>LICENSE</tt> --- copyright notice and legal conditions.
|
52
|
-
<% end %>
|
53
|
-
<% end %>
|
data/doc/usage.erb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
|
1
|
+
%#--
|
2
|
+
%# Copyright 2009 Suraj N. Kurapati
|
3
|
+
%# See the LICENSE file for details.
|
4
|
+
%#++
|
2
5
|
|
3
|
-
|
4
|
-
|
6
|
+
% require 'inochi/util/tempdir'
|
7
|
+
% yaml_addr = "http://yaml.kwiki.org/?YamlInFiveMinutes"
|
8
|
+
|
9
|
+
%|part "Usage"
|
10
|
+
%|section "Command-line interface"
|
5
11
|
When you run this command:
|
6
12
|
|
7
13
|
<%= $program %> --help
|
@@ -10,7 +16,7 @@
|
|
10
16
|
|
11
17
|
<pre><%= verbatim `ruby bin/#{$program} --help` %></pre>
|
12
18
|
|
13
|
-
|
19
|
+
%|tip "Merging files with **kdiff3**"
|
14
20
|
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:
|
15
21
|
|
16
22
|
1. Create a file named <tt>merge2</tt> with the following content:
|
@@ -34,26 +40,23 @@
|
|
34
40
|
|
35
41
|
3. Place the file in a directory that is listed in your `PATH` environment variable.
|
36
42
|
|
37
|
-
4. Run
|
43
|
+
4. Run <%= $project %> like this:
|
38
44
|
|
39
45
|
<%= $program %> -m merge2
|
40
46
|
|
41
47
|
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.
|
42
|
-
<% end %>
|
43
|
-
<% end %>
|
44
48
|
|
45
|
-
|
46
|
-
The
|
47
|
-
* Your project's main library invokes the
|
48
|
-
* Your project's main executable invokes the
|
49
|
-
* Your project's <tt>
|
50
|
-
* Your project's user manual invokes the
|
51
|
-
<% end %>
|
49
|
+
%|section "Ruby library interface"
|
50
|
+
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
|
+
* Your project's main library invokes the `Inochi.init()` method.
|
52
|
+
* Your project's main executable invokes the `Inochi.main()` method.
|
53
|
+
* Your project's <tt>rakefile</tt> invokes the `Inochi.rake()` method.
|
54
|
+
* Your project's user manual invokes the `Inochi.book()` method.
|
52
55
|
|
53
|
-
|
54
|
-
This tutorial shows how
|
56
|
+
%|section "Tutorial"
|
57
|
+
This tutorial shows how <%= $project %> is used to manage a hypothetical `WordCount` project throughout the various stages of its life.
|
55
58
|
|
56
|
-
|
59
|
+
%|section "Have a brilliant idea"
|
57
60
|
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.
|
58
61
|
|
59
62
|
> Push on! Keep on!
|
@@ -92,22 +95,12 @@
|
|
92
95
|
|
93
96
|
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.
|
94
97
|
|
95
|
-
*However*, you must go to work the next morning, so there isn't much time. What can you do? Let's see how
|
96
|
-
<% end %>
|
97
|
-
|
98
|
-
<%
|
99
|
-
require 'tempfile'
|
100
|
-
tmp = Tempfile.new($project).path
|
101
|
-
File.delete tmp
|
102
|
-
mkdir_p tmp
|
98
|
+
*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.
|
103
99
|
|
104
|
-
|
105
|
-
|
106
|
-
cd tmp
|
100
|
+
%|cd TempDir.new.path
|
101
|
+
% main_executable = 'bin/word_count'
|
107
102
|
|
108
|
-
|
109
|
-
%>
|
110
|
-
<% section "Generate your project" do %>
|
103
|
+
%|section "Generate your project"
|
111
104
|
Give life to your new project:
|
112
105
|
|
113
106
|
<pre>
|
@@ -122,21 +115,19 @@
|
|
122
115
|
<% cd "word_count" %>
|
123
116
|
</pre>
|
124
117
|
|
125
|
-
|
118
|
+
%|paragraph "View Rake tasks"
|
126
119
|
<pre>
|
127
120
|
# rake -T
|
128
121
|
<%= verbatim `rake -T` %>
|
129
122
|
</pre>
|
130
|
-
<% end %>
|
131
123
|
|
132
|
-
|
124
|
+
%|paragraph "Run unit tests"
|
133
125
|
<pre>
|
134
126
|
# rake test
|
135
127
|
<%= verbatim `rake test` %>
|
136
128
|
</pre>
|
137
|
-
<% end %>
|
138
129
|
|
139
|
-
|
130
|
+
%|paragraph "Run project executable"
|
140
131
|
<pre>
|
141
132
|
<% command = main_executable %>
|
142
133
|
# ruby <%= command %>
|
@@ -158,9 +149,8 @@
|
|
158
149
|
# ruby <%= command %>
|
159
150
|
<%= verbatim `ruby #{command}` %>
|
160
151
|
</pre>
|
161
|
-
<% end %>
|
162
152
|
|
163
|
-
|
153
|
+
%|paragraph "Show user manual"
|
164
154
|
Build the user manual (please disregard any "unclosed span" warnings):
|
165
155
|
|
166
156
|
<pre>
|
@@ -175,13 +165,11 @@
|
|
175
165
|
</pre>
|
176
166
|
|
177
167
|
The manual will now appear in your default web browser.
|
178
|
-
<% end %>
|
179
|
-
<% end %>
|
180
168
|
|
181
|
-
|
182
|
-
<%= xref "Ruby library interface" %> lists and documents the interactions between your project and
|
169
|
+
%|section "Configure your project"
|
170
|
+
<%= xref "Ruby library interface" %> lists and documents the interactions between your project and <%= $project %>. These points of interaction are illustrated in the following sections.
|
183
171
|
|
184
|
-
|
172
|
+
%|section "Project information"
|
185
173
|
<% license_file = 'LICENSE' %>
|
186
174
|
|
187
175
|
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:
|
@@ -197,31 +185,29 @@
|
|
197
185
|
<code>
|
198
186
|
<%= verbatim File.read(main_library) %>
|
199
187
|
</code>
|
200
|
-
<% end %>
|
201
188
|
|
202
|
-
|
189
|
+
%|section "Project executable"
|
203
190
|
Open the <tt><%= main_executable %></tt> file and fill in the blanks:
|
204
191
|
|
205
192
|
<code>
|
206
193
|
<%= verbatim File.read(main_executable) %>
|
207
194
|
</code>
|
208
|
-
<% end %>
|
209
195
|
|
210
|
-
|
211
|
-
<% rake_file = '
|
196
|
+
%|section "Rake tasks"
|
197
|
+
<% rake_file = 'rakefile' %>
|
212
198
|
|
213
199
|
Open the <tt><%= rake_file %></tt> and fill in the blanks:
|
214
200
|
|
215
201
|
<code>
|
216
202
|
<%= verbatim File.read(rake_file) %>
|
217
203
|
</code>
|
218
|
-
<% end %>
|
219
204
|
|
220
|
-
|
205
|
+
%|section "User manual"
|
221
206
|
<%
|
222
207
|
whole = 'doc/index.erb'
|
223
208
|
parts = File.read(whole).
|
224
|
-
scan(
|
209
|
+
scan(/^[[:blank:]]*%\+[[:blank:]]*(.*)\s*/).
|
210
|
+
flatten.map {|s| "doc/" + eval(s) }
|
225
211
|
|
226
212
|
files = [whole, *parts]
|
227
213
|
%>
|
@@ -230,15 +216,11 @@
|
|
230
216
|
|
231
217
|
Open these source files and fill in the blanks:
|
232
218
|
|
233
|
-
|
234
|
-
|
219
|
+
%|files.each |f|
|
220
|
+
%|paragraph "<tt>#{f}</tt>"
|
235
221
|
<code lang="rhtml"><%= verbatim File.read(f) %></code>
|
236
|
-
<% end %>
|
237
|
-
<% end %>
|
238
|
-
<% end %>
|
239
|
-
<% end %>
|
240
222
|
|
241
|
-
|
223
|
+
%|section "Implement your project"
|
242
224
|
Add the following code to the bottom of <tt>lib/word_count.rb</tt>, the main project library:
|
243
225
|
|
244
226
|
<code>
|
@@ -291,10 +273,10 @@
|
|
291
273
|
end
|
292
274
|
</code>
|
293
275
|
|
294
|
-
|
295
|
-
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
|
276
|
+
%|paragraph "Goodbye `$LOAD_PATH`, hello `require()`"
|
277
|
+
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.
|
296
278
|
|
297
|
-
Furthermore, you can always `require()` a sub-library anywhere in your project using its canonical path because
|
279
|
+
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.
|
298
280
|
|
299
281
|
<% sub_library = 'word_count/odf/text' %>
|
300
282
|
|
@@ -305,19 +287,16 @@
|
|
305
287
|
</code>
|
306
288
|
|
307
289
|
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.
|
308
|
-
<% end %>
|
309
|
-
<% end %>
|
310
290
|
|
311
|
-
|
312
|
-
To reduce the amount of code you have to write,
|
291
|
+
%|section "Test your project"
|
292
|
+
To reduce the amount of code you have to write, <%= $project %> defines the following convention for unit tests.
|
313
293
|
|
314
|
-
|
294
|
+
%|paragraph "Units and tests"
|
315
295
|
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**.
|
316
296
|
|
317
297
|
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.
|
318
|
-
<% end %>
|
319
298
|
|
320
|
-
|
299
|
+
%|paragraph "Test execution"
|
321
300
|
<pre>rake test</pre>
|
322
301
|
|
323
302
|
The above command begins the testing process, during which:
|
@@ -326,16 +305,13 @@
|
|
326
305
|
|
327
306
|
* Before a test is executed, its corresponding unit is automatically loaded into the Ruby environment using `require()`.
|
328
307
|
|
329
|
-
|
330
|
-
|
331
|
-
* Tests are executed by the [minitest] library, which allows you to write unit tests in a combination of styles: traditional xUnit TDD, alternative rSpec BDD, and mock-based validation styles.
|
308
|
+
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:
|
332
309
|
|
333
|
-
|
310
|
+
% Dir[Inochi::INSTALL + '/lib/inochi/test/*.rb'].sort.each do |f|
|
311
|
+
* <tt><%= File.basename(f, '.rb') %></tt> ---
|
312
|
+
<%= File.read(f).scan(/^#(.*)/).join %>
|
334
313
|
|
335
|
-
|
336
|
-
<% end %>
|
337
|
-
|
338
|
-
<% paragraph "Helper libraries" do %>
|
314
|
+
%|paragraph "Helper libraries"
|
339
315
|
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.
|
340
316
|
|
341
317
|
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:
|
@@ -343,18 +319,16 @@
|
|
343
319
|
<code>
|
344
320
|
require 'test/foo/qux'
|
345
321
|
</code>
|
346
|
-
<% end %>
|
347
|
-
<% end %>
|
348
322
|
|
349
|
-
|
323
|
+
%|section "Translate your project"
|
350
324
|
<% phrases_file = "<tt>lang/phrases.yaml</tt>" %>
|
351
325
|
|
352
|
-
Although English is the *lingua franca* of today, your project's users may prefer to interact with it in their native language.
|
326
|
+
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.
|
353
327
|
|
354
|
-
|
355
|
-
|
328
|
+
%|section "Language phrases"
|
329
|
+
<%= $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.
|
356
330
|
|
357
|
-
The
|
331
|
+
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" %>:
|
358
332
|
|
359
333
|
<code>
|
360
334
|
your_project::PHRASES['Have a nice day!']
|
@@ -367,16 +341,15 @@
|
|
367
341
|
#=> 'No translation for this'
|
368
342
|
</code>
|
369
343
|
|
370
|
-
|
344
|
+
%|paragraph "Parameterizing language phrases"
|
371
345
|
Language phrases can be parameterized using [`printf` format placeholders](http://en.wikipedia.org/wiki/Printf#printf_format_placeholders) to ease translation:
|
372
346
|
|
373
347
|
<code>
|
374
348
|
your_project::PHRASES['Good afternoon, %s.', user_name]
|
375
349
|
your_project::PHRASES['You are %d years old.', user_age]
|
376
350
|
</code>
|
377
|
-
<% end %>
|
378
351
|
|
379
|
-
|
352
|
+
%|paragraph "Explicit translation into a language"
|
380
353
|
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:
|
381
354
|
|
382
355
|
<code>
|
@@ -386,10 +359,8 @@
|
|
386
359
|
# explictly translate into French (fr)
|
387
360
|
your_project::PHRASES.fr('Farewell %s!', user_name)
|
388
361
|
</code>
|
389
|
-
<% end %>
|
390
|
-
<% end %>
|
391
362
|
|
392
|
-
|
363
|
+
%|section "Translation files"
|
393
364
|
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.
|
394
365
|
|
395
366
|
For example, suppose that your language phrases are written in English, the <tt>lang/es.yaml</tt> (Spanish) translation file would appear like this:
|
@@ -410,9 +381,8 @@
|
|
410
381
|
On each line, the original language phrase (as used in your project) appears first, then a single semicolon (:), followed by the translation.
|
411
382
|
|
412
383
|
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.
|
413
|
-
<% end %>
|
414
384
|
|
415
|
-
|
385
|
+
%|section "Extracting language phrases"
|
416
386
|
<pre>
|
417
387
|
# rake lang:dump
|
418
388
|
<%= verbatim `rake lang:dump` %>
|
@@ -420,48 +390,43 @@
|
|
420
390
|
|
421
391
|
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.
|
422
392
|
|
423
|
-
|
393
|
+
%|paragraph "Dynamic analysis"
|
424
394
|
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.
|
425
395
|
|
426
|
-
But how can
|
396
|
+
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.
|
427
397
|
|
428
|
-
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
|
398
|
+
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 %>.
|
429
399
|
|
430
400
|
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.
|
431
|
-
<% end %>
|
432
401
|
|
433
|
-
|
402
|
+
%|paragraph "Static analysis"
|
434
403
|
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.
|
435
404
|
|
436
405
|
Patches are welcome! :-)
|
437
|
-
<% end %>
|
438
|
-
<% end %>
|
439
406
|
|
440
|
-
|
441
|
-
After you have extracted all language phrases from your project (either manually or via <%= xref "Extracting language phrases" %>) into the <%= phrases_file %> file,
|
407
|
+
%|section "Translating language phrases"
|
408
|
+
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):
|
442
409
|
|
443
410
|
<pre>
|
444
411
|
# rake lang:conv from=LANGUAGE_CODE
|
445
412
|
<%= verbatim `rake lang:conv from=LANGUAGE_CODE 2>&1` %>
|
446
413
|
</pre>
|
447
414
|
|
448
|
-
Notice that you must specify the language in which your phrases are written, via the <tt>from=</tt> parameter.
|
449
|
-
<% end %>
|
450
|
-
<% end %>
|
415
|
+
Notice that you must specify the language in which your phrases are written, via the <tt>from=</tt> parameter. <%= $project %> cannot determine this automatically.
|
451
416
|
|
452
|
-
|
417
|
+
%|section "Publish your project"
|
453
418
|
<pre>
|
454
419
|
# rake pub
|
455
420
|
</pre>
|
456
421
|
|
457
422
|
The above command performs all automated steps described in the following sections.
|
458
423
|
|
459
|
-
|
424
|
+
%|section "Build a RubyGem"
|
460
425
|
Build a RubyGem by running:
|
461
426
|
|
462
427
|
<pre>
|
463
|
-
# rake
|
464
|
-
<%= `rake
|
428
|
+
# rake gem
|
429
|
+
<%= `rake gem` %>
|
465
430
|
</pre>
|
466
431
|
|
467
432
|
See the RubyGem contents:
|
@@ -470,20 +435,18 @@
|
|
470
435
|
# gem spec pkg/*.gem
|
471
436
|
<code lang="yaml"><%= `gem spec pkg/*.gem`.rstrip %></code>
|
472
437
|
</pre>
|
473
|
-
<% end %>
|
474
438
|
|
475
|
-
|
476
|
-
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
|
439
|
+
%|section "Publish a RubyGem"
|
440
|
+
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.
|
477
441
|
|
478
442
|
Publish a RubyGem by running:
|
479
443
|
|
480
444
|
<pre>
|
481
|
-
# rake pub:
|
445
|
+
# rake pub:gem
|
482
446
|
</pre>
|
483
|
-
<% end %>
|
484
447
|
|
485
|
-
|
486
|
-
You must first provide your <%= xref "Login information" %> to
|
448
|
+
%|section "Announce a release"
|
449
|
+
You must first provide your <%= xref "Login information" %> to <%= $project %>. If you do not want to do this, then see <%= xref "Manual release announcement" %>.
|
487
450
|
|
488
451
|
Announce a release by running:
|
489
452
|
|
@@ -491,12 +454,12 @@
|
|
491
454
|
# rake pub:ann
|
492
455
|
</pre>
|
493
456
|
|
494
|
-
|
495
|
-
In order to automate the announcement of releases,
|
457
|
+
%|paragraph "Login information"
|
458
|
+
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/).
|
496
459
|
|
497
460
|
<% logins_file = "~/.config/inochi/logins.yaml" %>
|
498
461
|
|
499
|
-
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
|
462
|
+
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:
|
500
463
|
|
501
464
|
<code lang="yaml">
|
502
465
|
www.ruby-forum.com:
|
@@ -511,9 +474,7 @@
|
|
511
474
|
|
512
475
|
# chmod 0600 <%= logins_file %>
|
513
476
|
|
514
|
-
|
515
|
-
|
516
|
-
<% section "Manual release announcement" do %>
|
477
|
+
%|section "Manual release announcement"
|
517
478
|
Build release announcements by running:
|
518
479
|
|
519
480
|
<pre>
|
@@ -522,29 +483,17 @@
|
|
522
483
|
</pre>
|
523
484
|
|
524
485
|
This produces the following files in your project directory:
|
525
|
-
|
526
|
-
*
|
527
|
-
|
486
|
+
|
487
|
+
%|Dir['ANN*'].each |f|
|
488
|
+
* <tt><%= f %></tt>
|
528
489
|
|
529
490
|
Now you can manually announce your release using these files.
|
530
|
-
<% end %>
|
531
|
-
<% end %>
|
532
491
|
|
533
|
-
|
492
|
+
%|section "Publish the documentation"
|
534
493
|
Publish the user manual and API documentation by running:
|
535
494
|
|
536
495
|
<pre>
|
537
496
|
# rake pub:doc
|
538
497
|
</pre>
|
539
498
|
|
540
|
-
If your documentation website (see the `:docsite` option for the
|
541
|
-
<% end %>
|
542
|
-
<% end %>
|
543
|
-
<%
|
544
|
-
ensure
|
545
|
-
cd old
|
546
|
-
rm_rf tmp
|
547
|
-
end
|
548
|
-
%>
|
549
|
-
<% end %>
|
550
|
-
<% end %>
|
499
|
+
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.
|