-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.html
314 lines (170 loc) · 11 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
New Gem Generator
</title>
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
<style>
</style>
<script type="text/javascript">
window.onload = function() {
settings = {
tl: { radius: 10 },
tr: { radius: 10 },
bl: { radius: 10 },
br: { radius: 10 },
antiAlias: true,
autoPad: true,
validTags: ["div"]
}
var versionBox = new curvyCorners(settings, document.getElementById("version"));
versionBox.applyCornersToAll();
}
</script>
</head>
<body>
<div id="main">
<h1>New Gem Generator</h1>
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return false'>
Get Version
<a href="http://rubyforge.org/projects/newgem" class="numbers">0.10.3</a>
</div>
<h1>→ ‘newgem’</h1>
<h2>What</h2>
<p>Quickly bundle any Ruby libraries into a RubyGem and share it with the world, your colleagues, or perhaps just with yourself amongst your projects.</p>
<p>RubyGems are centrally stored, versioned, and support dependencies between other gems, so they are the ultimate way to bundle libraries, executables, associated tests, examples, and more.</p>
<p>Within this gem, you get one thing – <code>newgem</code> – an executable to create your own gems. Your new gems will include designated folders for Ruby code, test files, executables, and even a default website page for you to explain your project, and which instantly uploads to RubyForge website (which looks just like this one by default)</p>
<h2>Installing</h2>
<p>The <code>newgem</code> application is distributed itself as a RubyGem and is available immediately after installation.</p>
<p><pre class="syntax"><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">newgem</span></pre></p>
<p>Alternately, download the gem and install manually.</p>
<h2>The basics</h2>
<p>Go to the folder where you want to create your new gem folder structure, and run the <code>newgem</code> command to generate your gem scaffolding.</p>
<pre>$ cd ~/ruby_projects
$ newgem wizzo
creating: wizzo
creating: wizzo/CHANGELOG.txt
creating: wizzo/README.txt
creating: wizzo/lib
creating: wizzo/scripts
creating: wizzo/website
creating: wizzo/website/javascripts
creating: wizzo/website/stylesheets
creating: wizzo/lib/wizzo
creating: wizzo/lib/wizzo.rb
creating: wizzo/lib/wizzo/version.rb
creating: wizzo/bin
creating: wizzo/test
creating: wizzo/test/test_helper.rb
creating: wizzo/test/test_wizzo.rb
creating: wizzo/examples
creating: wizzo/setup.rb
creating: wizzo/Rakefile
creating: wizzo/Manifest.txt
creating: wizzo/History.txt
creating: wizzo/scripts/txt2html
creating: wizzo/website/index.txt
creating: wizzo/website/template.rhtml
copying: wizzo/website/javascripts/rounded_corners_lite.inc.js
copying: wizzo/website/stylesheets/screen.css
NOW - update wizzo/Rakefile with gem description, etc
</pre>
<p>As of 0.10.0 – you can generate test::unit or rspec test stubs via the -t,—test-with options</p>
<h3>Setup</h3>
<p>Now modify the constants at the top of <strong>Rakefile</strong>, with your name, email and the location where you’ll host your website for the gem. The defaults are tied to RubyForge for uploading the gems and the website (see below).</p>
<h3>Create code and tests</h3>
<p>Then create your libraries (files in <code>lib</code>) and your tests (files in <code>test</code> that look like <code>test_TESTNAME.rb</code>). John Grey <span class="caps">III</span> did a nice video on test-driven design, that’s worth watching if <span class="caps">TDD</span> is new to you.</p>
<p>If you create any new files, you need to manually add them to the Manifest.txt. Alphabetical order is optional, but it will make the results of <code>rake check_manifest</code> look clean if you keep them ordered. If a file is not in the Manifest.txt it will not be included in the gem when you package and release it.</p>
<h3>Executables</h3>
<p>You can include executable Ruby applications in your gem, which will be accessible on Windows and Unix/Linux/MacOS, by creating scripts in the <code>bin</code> folder. When the gem is deployed by users, these executables will be automatically placed within their path.</p>
<h3>Website</h3>
<p>The final step before releasing your gem to the world is the all-important website. Edit the file <code>website/index.txt</code> using Textile/Redcloth syntax. Syntax highlighting is also supported (see below). If you need more website pages, create more <strong>txt</strong> files in the website folder.</p>
<p>Run the rake task <code>rake website_generate</code> to convert all your website txt files into html files.</p>
<p><span class="caps">NOTE</span>: Currently, the initial <code>index.txt</code> file includes my details not yours. Currently you need to change this manually.</p>
<p>If you don’t want a website, remove the <code>website</code> related files from the Manifest.txt.</p>
<h3>Change the gems version number</h3>
<p>The version number is set in the file <code>lib/#gem name#/version.rb</code>. Update it as appropriate with major, minor and bug fix numbers. This value will be used when generating your website, for example.</p>
<h3>Check the manifest</h3>
<blockquote>Manifest: a customs document listing the contents put on a ship or plane.</blockquote>
<cite><a href="http://www.google.com/search?q=define%3Amanifest">Google – define:manifest</a></cite>
<p>Similarly here, a manifest is the log of the files to be packaged into a gem. If its not in the <code>Manifest.txt</code> file, the users won’t get it.</p>
<p>Before you package your gem, you can compared the list of files in your gem folder, with the Manifest.txt:</p>
<pre>rake check_manifest</pre>
<p>The results show a <em>diff</em> of the two.</p>
<h2>Package and test locally</h2>
<p>Before releasing a new version of a gem, it is a great idea to install the gem locally and do some sanity checks. You know, to limit the chance of you looking like a noob.</p>
<pre>rake local_deploy</pre>
<p>This generates the website html files into your website folder, and locally installs the gem, ready for testing and local use.</p>
<p>Now pretend to be a user, and do some tests – especially of new functionality – so you are comfortable all the files have been packaged up, and you haven’t missed anything in the <code>Manifest.txt</code>.</p>
<p>One set of tests you should do is to repeat any tutorials you include in your website. If your gem is dependent on other gems that are rapidly changing, its possible your tutorial might be invalid even if your unit tests are successful. Best you find any errors before the users start emailing you!</p>
<h2>Releasing your gem to the world</h2>
<p>Once you’re ready for release there are some final steps.</p>
<p><a name="setup_rubyforge"></a></p>
<h3>Setup your environment to upload to RubyForge.</h3>
<p>There are several steps you need to perform initially to <a href="rubyforge.html">setup your environment for uploading gems to RubyForge</a>.</p>
<h3>Document changes in History.txt</h3>
<p>Between each version of your gem, you probably changed something. You should document this in the <code>History.txt</code> file. For each new release, you need to add two paragraphs that look like this:</p>
<pre>== 0.5.4 14/4/2007
* 1 major improvement
* 150% more Wizzos
* 2 bug fixes
* Wizzos are the proper colour
* You only get Wizzos when you ask for them
</pre>
<p>The two paragraphs will be automatically picked up by the following release process and documented against the release on RubyForge site. To see an example of the end result, look at the <a href="http://rubyforge.org/frs/shownotes.php?release_id=9695"><strong>Changes</strong> section for hoe 1.2</a>.</p>
<p>The History.txt notes for your first release have already been started for you.</p>
<h3>Release the gem and upload the website and rdocs</h3>
<p>Run <code>rake deploy VERSION=X.Y.Z</code> after you’ve done all these steps. It does the following:</p>
<ol>
<li>Uploads your website to rubyforge</li>
<li>Uploads your rdocs to rubyforge</li>
<li>Packages and uploads your gem to RubyForge</li>
</ol>
<p>It can take an hour or two before new gem releases are available via the gem installer. But when they are ready, everyone will be able to download and install your gem using:</p>
<pre>sudo gem install #gem_name#</pre>
<p>If your <span class="caps">GEM</span>_NAME and <span class="caps">RUBYFORGE</span>_PROJECT name are the same, then:</p>
<ul>
<li>http://RUBYFORGE_PROJECT.rubyforge.org is your website, and</li>
<li>http://RUBYFORGE_PROJECT.rubyforge.org/rdoc is your rdocs</li>
</ul>
<p>If they are different, then:</p>
<ul>
<li>http://RUBYFORGE_PROJECT.rubyforge.org/GEM_NAME is your website, and</li>
<li>http://RUBYFORGE_PROJECT.rubyforge.org/GEM_NAME/rdoc is your rdocs</li>
</ul>
<h2>Bonus tasks thanks to Hoe</h2>
<p>Your gem uses the Hoe gem to provide a dozen or so useful rake tasks for managing your gem, such as <code>release</code>, <code>check_manifest</code> and <code>publish_docs</code>.</p>
<p>See them all with:</p>
<pre>rake -T</pre>
<p>Remember, the Rakefile is yours to extend as you please with more rake tasks, such as the <code>website</code> tasks which are already added.</p>
<p>For more information about each task, see the <a href="http://seattlerb.rubyforge.org/hoe/">Hoe <span class="caps">README</span></a></p>
<h2>Related articles</h2>
<ul>
<li><a href="http://drnicwilliams.com/2006/10/11/generating-new-gems/">Original blog article and tutorial</a></li>
</ul>
<h2>Dr Nic’s Blog</h2>
<p><a href="http://www.drnicwilliams.com">http://www.drnicwilliams.com</a> – for future announcements and
other stories and things.</p>
<h2>Forum</h2>
<p><a href="http://groups.google.com/group/new-gem-generator">http://groups.google.com/group/new-gem-generator</a></p>
<h2>License</h2>
<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
<h2>Contact</h2>
<p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a>.</p>
<p class="coda">
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 24th May 2007<br>
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
</p>
</div>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-567811-2";
urchinTracker();
</script>
</body>
</html>