geminstaller 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,7 +60,7 @@ h2(#command_line_options). Command Line Options
60
60
 
61
61
  h3(#command_line_options_summary). Command Line Options Summary
62
62
 
63
- <pre>
63
+ <pre><code>
64
64
  $ geminstaller --help
65
65
  Usage: geminstaller [options]
66
66
 
@@ -101,15 +101,15 @@ Usage: geminstaller [options]
101
101
  -t, --silent Suppress all output except fatal exceptions, and output from
102
102
  rogue-gems option.
103
103
  -v, --version Show GemInstaller version and exit.
104
- </pre>
104
+ </code></pre>
105
105
 
106
106
  h3(#config_option). <code>--config</code> option
107
107
 
108
108
  By default, GemInstaller will look for a config file named <code>geminstaller.yml</code> in the working directory. The <code>'--config'</code> option allows you to override this with a different file name or path. You can also have multiple comma-delimited paths to custom-named config files. This is useful if you have multiple projects, and want them to share a common config file, but still have project-specific overrides. You could also have a standard set of gems across multiple systems, with additional custom gems specified by individual projects. The last entries in the list will override the first ones. For example:
109
109
 
110
- <pre>
110
+ <pre><code>
111
111
  geminstaller --config=../common-config/geminstaller-common-across-projects.yml,geminstaller-custom-for-myproject.yml
112
- </pre>
112
+ </code></pre>
113
113
 
114
114
  h3(#exceptions_option). <code>--exceptions</code> option
115
115
 
@@ -174,8 +174,7 @@ h3(#config_file_syntax_summary). Config File Syntax Summary
174
174
 
175
175
  This is an example config file template showing all the valid properties (boolean defaults capitalized):
176
176
 
177
- <pre>
178
- \---
177
+ <pre><code>---
179
178
  defaults:
180
179
  install_options: [ any valid option for the RubyGems 'gem install' command ]
181
180
  check_for_upgrade: [ true | FALSE ]
@@ -195,7 +194,7 @@ gems:
195
194
  - name: [ yet another gem name ]
196
195
  (etc...)
197
196
  <%= include_config("#{File.expand_path(File.dirname(__FILE__))}/path/to/included_snippet.yml") %>
198
- </pre>
197
+ </code></pre>
199
198
 
200
199
  All properties are optional, except for the gem name. If a default is specified, it will be used unless the gem specifically overrides it.
201
200
 
@@ -249,25 +248,22 @@ This is an alternative to specifying multiple files in the <code>--config</code>
249
248
 
250
249
  GemInstaller also ensures that the working directory is set to the directory containing the current yaml file - NOT the directory that <code>geminstaller</code> was invoked from. This allows you to use <code>include_config</code> to reference yaml files relative to each other. Here's an example:
251
250
 
252
- <pre>
253
- \---
251
+ <pre><code>---
254
252
  # .../geminstaller.yml
255
253
  gems:
256
254
  <%= include_config("#{File.expand_path(File.dirname(__FILE__))}/subdir1/included_gem_config1.yml") %>
257
- </pre>
255
+ </code></pre>
258
256
 
259
- <pre>
260
- \---
257
+ <pre><code>---
261
258
  # .../subdir1/included_gem_config1.yml
262
259
  - name: testgem1
263
260
  <%= include_config("#{File.expand_path(File.dirname(__FILE__))}/../subdir2/included_gem_config2.yml") %>
264
- </pre>
261
+ </code></pre>
265
262
 
266
- <pre>
267
- \---
263
+ <pre><code>---
268
264
  # .../subdir2/included_gem_config2.yml
269
265
  - name: testgem2
270
- </pre>
266
+ </code></pre>
271
267
 
272
268
 
273
269
  h2(#using_geminstaller_with_ruby_on_rails_or_other_ruby_apps). Using GemInstaller with Ruby on Rails or Other Ruby Apps
@@ -278,8 +274,7 @@ IMPORTANT NOTE: You need to know whether you run on unix and need root/sudo acce
278
274
 
279
275
  First, you need to create <code>geminstaller.yml</code> in the <code>RAILS_ROOT/config</code> directory (See also "Bootstrapping your GemInstaller Config with the <code>--print-rogue-gems</code> option":#bootstrapping_your_geminstaller_config). Here's an example config file which will install (an old version of) Rails and Mongrel:
280
276
 
281
- <pre>
282
- \---
277
+ <pre><code>---
283
278
  defaults:
284
279
  install_options: --include-dependencies
285
280
  gems:
@@ -288,50 +283,48 @@ gems:
288
283
  - name: mongrel
289
284
  version: '= 1.0.1'
290
285
  platform: <%= RUBY_PLATFORM =~ /mswin/ ? 'mswin32' : 'ruby'%>
291
- </pre>
286
+ </code></pre>
292
287
 
293
288
  h3(#invoking_geminstaller_from_rails). Invoking <code>GemInstaller</code> from Rails
294
289
 
295
290
  Once you have your *<code>geminstaller.yml</code>* created, invoke the GemInstaller on app startup in your boot.rb. It should be placed right after the block which defines the RAILS_ROOT constant, as shown below ("..." indicates omitted lines):
296
291
 
297
-
298
292
  *RAILS_ROOT/config/boot.rb*:
299
- <pre>
300
- ...
301
- unless defined?(RAILS_ROOT)
302
- ...
303
- end
304
-
305
- ############# Begin GemInstaller config - see http://geminstaller.rubyforge.org
306
- require "rubygems"
307
- require "geminstaller"
308
-
309
- # Path(s) to your GemInstaller config file(s)
310
- config_paths = "#{File.expand_path(RAILS_ROOT)}/config/geminstaller.yml"
311
-
312
- # Arguments which will be passed to GemInstaller (you can add any extra ones)
313
- args = "--config #{config_paths}"
314
-
315
- # The 'exceptions' flag determines whether errors encountered while running GemInstaller
316
- # should raise exceptions (and abort Rails), or just return a nonzero return code
317
- args += " --exceptions"
318
-
319
- # This will use sudo by default on all non-windows platforms, but requires an entry in your
320
- # sudoers file to avoid having to type a password. It can be omitted if you don't want to use sudo.
321
- # See http://geminstaller.rubyforge.org/documentation/documentation.html#dealing_with_sudo
322
- args += " --sudo" unless RUBY_PLATFORM =~ /mswin/
323
-
324
- # The 'install' method will auto-install gems as specified by the args and config
325
- GemInstaller.install(args)
326
-
327
- # The 'autogem' method will automatically add all gems in the GemInstaller config to your load path, using the 'gem'
328
- # or 'require_gem' command. Note that only the *first* version of any given gem will be loaded.
329
- GemInstaller.autogem(args)
330
- ############# End GemInstaller config
331
-
332
- unless defined?(Rails::Initializer)
333
- ...
334
- </pre>
293
+ <pre><code> ...
294
+ unless defined?(RAILS_ROOT)
295
+ ...
296
+ end
297
+
298
+ ############# Begin GemInstaller config - see http://geminstaller.rubyforge.org
299
+ require "rubygems"
300
+ require "geminstaller"
301
+
302
+ # Path(s) to your GemInstaller config file(s)
303
+ config_paths = "#{File.expand_path(RAILS_ROOT)}/config/geminstaller.yml"
304
+
305
+ # Arguments which will be passed to GemInstaller (you can add any extra ones)
306
+ args = "--config #{config_paths}"
307
+
308
+ # The 'exceptions' flag determines whether errors encountered while running GemInstaller
309
+ # should raise exceptions (and abort Rails), or just return a nonzero return code
310
+ args += " --exceptions"
311
+
312
+ # This will use sudo by default on all non-windows platforms, but requires an entry in your
313
+ # sudoers file to avoid having to type a password. It can be omitted if you don't want to use sudo.
314
+ # See http://geminstaller.rubyforge.org/documentation/documentation.html#dealing_with_sudo
315
+ args += " --sudo" unless RUBY_PLATFORM =~ /mswin/
316
+
317
+ # The 'install' method will auto-install gems as specified by the args and config
318
+ GemInstaller.install(args)
319
+
320
+ # The 'autogem' method will automatically add all gems in the GemInstaller config to your load path, using the 'gem'
321
+ # or 'require_gem' command. Note that only the *first* version of any given gem will be loaded.
322
+ GemInstaller.autogem(args)
323
+ ############# End GemInstaller config
324
+
325
+ unless defined?(Rails::Initializer)
326
+ ...
327
+ </code></pre>
335
328
 
336
329
  As you can see, this example contains several comments which are hopefully self-explanatory. See the "Command Line Options Summary":#command_line_options_summary, especially the "<code>--config</code>":#config_option, "<code>--exceptions</code>":#exceptions_option, and "<code>--sudo</code>":#sudo_option options for more details, as well as the "Integrating GemInstaller into Ruby on Rails":#integrating_geminstaller_into_ruby_on_rails tutorial.
337
330
 
@@ -339,10 +332,10 @@ h3(#bootstrapping_rails_with_geminstaller). Bootstrapping Rails with GemInstalle
339
332
 
340
333
  If you don't already have Rails or Mongrel installed (you've just checked your app out or deployed onto a new machine), you obviously can't use the above boot.rb method to run GemInstaller. In this case, you just need to run GemInstaller from the command line once to "bootstrap" and install the Rails/Mongrel gems. This assumes you already have your <code>geminstaller.yml</code> config file in the Rails <code>config</code> dir:
341
334
 
342
- <pre>
335
+ <pre><code>
343
336
  $ cd [RAILS_APP_ROOT]/config
344
337
  $ geminstaller --sudo # only use the -sudo option if necessary
345
- </pre>
338
+ </code></pre>
346
339
 
347
340
  h3(#using_geminstaller_from_other_ruby_apps). Using GemInstaller from Other Ruby Apps
348
341
 
@@ -352,14 +345,13 @@ h2(#using_erb_in_config_files). Using <code>erb</code> in config files
352
345
 
353
346
  The GemInstaller config file(s) are also run through erb, so you can embed any custom ruby code to dynamically generate portions of your config. This can be used to have the same config file select gems differently on different platforms or environments. Below is an example of using erb to detect and choose the platform. This is necessary with some gems, even though GemInstaller attempts to guess at the platform. See "Automatic Platform Detection":#automatic_platform_detection for more info.
354
347
 
355
- <pre>
356
- \---
348
+ <pre><code>---
357
349
  # geminstaller-detect-platform.yml
358
350
  gems:
359
351
  - name: x10-cm17a
360
352
  version: '> 1.0.0'
361
353
  platform: <%= RUBY_PLATFORM =~ /mswin/ ? 'i386-mswin32' : 'ruby'%>
362
- </pre>
354
+ </code></pre>
363
355
 
364
356
  h2(#automatic_platform_detection). Automatic Platform Detection
365
357
 
@@ -394,32 +386,32 @@ A transparent solution to this problem is planned for a future release of GemIns
394
386
  h3(#option_1). Option 1 - Use the <code>-s</code> or <code>--sudo</code> option on the <code>geminstaller</code> executable
395
387
 
396
388
  Examples:
397
- <pre>
389
+ <pre><code>
398
390
  $ geminstaller -s
399
391
  $ geminstaller --sudo
400
- </pre>
392
+ </code></pre>
401
393
 
402
394
  h3(#option_2). Option 2 - Run <code>sudo</code> or log in as root yourself
403
395
 
404
396
  Example of using sudo:
405
- <pre>
406
- $ sudo geminstaller
407
- </pre>
397
+ <pre><code>
398
+ $ sudo geminstaller
399
+ </code></pre>
408
400
 
409
401
  Examples of running geminstaller as root
410
- <pre>
411
- $ su - # if you can log in as root on your system, OR
412
- $ sudo -s # if you must use sudo to log in as root on your system
413
- # geminstaller
414
- </pre>
402
+ <pre><code>
403
+ $ su - # if you can log in as root on your system, OR
404
+ $ sudo -s # if you must use sudo to log in as root on your system
405
+ # geminstaller
406
+ </code></pre>
415
407
 
416
408
  h3(#option_3). Option 3 - Make everything owned by the local user that runs geminstaller
417
409
 
418
410
  (replace <code><local user></code> with your username)
419
- <pre>
420
- $ cd /usr/local/lib/ruby # or wherever you have ruby installed
421
- $ sudo chown -R <local user> .
422
- </pre>
411
+ <pre><code>
412
+ $ cd /usr/local/lib/ruby # or wherever you have ruby installed
413
+ $ sudo chown -R <local user> .
414
+ </code></pre>
423
415
 
424
416
  h3(#tips_on_configuring_sudo). Tips on configuring sudo
425
417
 
@@ -429,11 +421,11 @@ You should consult the man or info pages on sudoers and visudo for more info (<c
429
421
 
430
422
  Here's an example of how <code>sudoers</code> might be configured to allow the local user to run the <code>'gem'</code>, <code>'ruby'</code>, and <code>'geminstaller'</code> commands via <code>sudo</code> without being prompted for a password. Replace <code><local user></code> with your username, and replace '/usr/local/bin/' with the appropriate path if it is different on your system:
431
423
 
432
- <pre>
433
- $ sudo visudo
434
- add this line:
435
- <local user> ALL = NOPASSWD: /usr/local/bin/geminstaller, /usr/local/bin/ruby, /usr/local/bin/gem
436
- </pre>
424
+ <pre><code>
425
+ $ sudo visudo
426
+ add this line:
427
+ <local user> ALL = NOPASSWD: /usr/local/bin/geminstaller, /usr/local/bin/ruby, /usr/local/bin/gem
428
+ </code></pre>
437
429
 
438
430
  h2(#automatically_requiring_gems_with_the_autogem_method). Automatically Requiring Gems with the <code>autogem</code> Method
439
431
 
@@ -443,11 +435,11 @@ If there are some gems you don't want to auto-require, you can set the '<code>no
443
435
 
444
436
  To use it, invoke the <code>autogem</code> method, and pass a string of arguments, just like the GemInstaller command line, but it ignores arguments which are not applicable (such as -r or -s):
445
437
 
446
- <pre>
447
- ...
448
- GemInstaller.autogem('--config=/path/to/one/geminstaller.yml,/path/to/another/geminstaller.yml')
449
- ...
450
- </pre>
438
+ <pre><code>
439
+ ...
440
+ GemInstaller.autogem('--config=/path/to/one/geminstaller.yml,/path/to/another/geminstaller.yml')
441
+ ...
442
+ </code></pre>
451
443
 
452
444
  Alternately, you are not required to pass any args if you invoke the command from a ruby file which is in the same directory as a default-named <code>'geminstaller.yml'</code> file.
453
445
 
@@ -7,14 +7,12 @@ h2. Basic Usage - "Hello Doom"
7
7
 
8
8
  * Install GemInstaller: <code>[sudo] gem install geminstaller</code>
9
9
  * Create a <code>geminstaller.yml</code> file:
10
-
11
- <pre>
12
- \---
13
- # geminstaller.yml sample config
14
- gems:
15
- - name: ruby-doom
16
- version: '>= 0.8'
17
- </pre>
10
+ <pre><code> ---
11
+ # geminstaller.yml sample config
12
+ gems:
13
+ - name: ruby-doom
14
+ version: '>= 0.8'
15
+ </code></pre>
18
16
 
19
17
  * Run GemInstaller from the directory containing geminstaller.yml: <code>geminstaller</code>. You should see a message indicating that the gem is being installed.
20
18
  * Verify that the ruby-doom gem was installed: <code>gem list ruby-doom</code>
@@ -28,61 +26,57 @@ I've created a "Sample Rails App":http://geminstaller.rubyforge.org/svn/trunk/sp
28
26
  <strong>OLD RAILS 1.0 INSTRUCTIONS:</strong>
29
27
 
30
28
  * Create geminstaller.yml in the RAILS_ROOT/config directory. Include entries for your Rails version, and any other gems your app needs (Note: If you are too lazy to make your config file manually, or don't know what gems you need, see the tutorial on "Bootstrapping your GemInstaller Config with the <code>--print-rogue-gems</code> option":tutorials.html#bootstrapping_your_geminstaller_config):
31
-
32
- <pre>
33
- \---
34
- # geminstaller.yml rails app config
35
- defaults:
36
- install_options: --include-dependencies
37
- gems:
38
- - name: rails
39
- version: '= 1.1.6'
40
- </pre>
29
+ <pre><code> ---
30
+ # geminstaller.yml rails app config
31
+ defaults:
32
+ install_options: --include-dependencies
33
+ gems:
34
+ - name: rails
35
+ version: '= 1.1.6'
36
+ </code></pre>
41
37
 
42
38
 
43
39
 
44
40
  * Determine whether you run on unix and need root/sudo access to install gems. If you do, edit your <code>sudoers</code> file to allow the current user to run the <code>'gem'</code> command via sudo without a password. See the documentation on the GemInstaller "<code>--sudo</code> option":documentation.html#dealing_with_sudo for more details.
45
41
 
46
42
  * Edit your Rails <code>config/boot.rb</code> to invoke GemInstaller on startup to install gems and auto-require them. The following lines should be placed right after the block which defines the RAILS_ROOT constant ("..." indicates omitted lines). If you want to know what the heck this does before sticking it in your app, there are more details in the tutorial "Integrating GemInstaller into Ruby on Rails":#integrating_geminstaller_into_ruby_on_rails
47
-
48
- <pre>
49
- \---
50
- RAILS_ROOT/config/boot.rb:
51
- ...
52
- unless defined?(RAILS_ROOT)
53
- ...
54
- end
55
-
56
- ############# Begin GemInstaller config - see http://geminstaller.rubyforge.org
57
- require "rubygems"
58
- require "geminstaller"
59
-
60
- # Path(s) to your GemInstaller config file(s)
61
- config_paths = "#{File.expand_path(RAILS_ROOT)}/config/geminstaller.yml"
62
-
63
- # Arguments which will be passed to GemInstaller
64
- args = "--config #{config_paths}"
65
-
66
- # The 'exceptions' flag determines whether errors encountered while running GemInstaller
67
- # should raise exceptions (and abort Rails), or just return a nonzero return code
68
- args += " --exceptions"
69
-
70
- # This will use sudo by default on all non-windows platforms, but requires an entry in your
71
- # sudoers file to avoid having to type a password. It can be omitted if you don't want to use sudo.
72
- # See http://geminstaller.rubyforge.org/documentation/documentation.html#dealing_with_sudo
73
- args += " --sudo" unless RUBY_PLATFORM =~ /mswin/
74
-
75
- # The 'install' method will auto-install gems as specified by the args and config
76
- GemInstaller.install(args)
77
-
78
- # The 'autogem' method will automatically add all gems in the GemInstaller config to your load path, using the 'gem'
79
- # or 'require_gem' command. Note that only the *first* version of any given gem will be loaded.
80
- GemInstaller.autogem(args)
81
- ############# End GemInstaller config
82
-
83
- unless defined?(Rails::Initializer)
84
- ...
85
- </pre>
43
+ <pre><code> ---
44
+ RAILS_ROOT/config/boot.rb:
45
+ ...
46
+ unless defined?(RAILS_ROOT)
47
+ ...
48
+ end
49
+
50
+ ############# Begin GemInstaller config - see http://geminstaller.rubyforge.org
51
+ require "rubygems"
52
+ require "geminstaller"
53
+
54
+ # Path(s) to your GemInstaller config file(s)
55
+ config_paths = "#{File.expand_path(RAILS_ROOT)}/config/geminstaller.yml"
56
+
57
+ # Arguments which will be passed to GemInstaller
58
+ args = "--config #{config_paths}"
59
+
60
+ # The 'exceptions' flag determines whether errors encountered while running GemInstaller
61
+ # should raise exceptions (and abort Rails), or just return a nonzero return code
62
+ args += " --exceptions"
63
+
64
+ # This will use sudo by default on all non-windows platforms, but requires an entry in your
65
+ # sudoers file to avoid having to type a password. It can be omitted if you don't want to use sudo.
66
+ # See http://geminstaller.rubyforge.org/documentation/documentation.html#dealing_with_sudo
67
+ args += " --sudo" unless RUBY_PLATFORM =~ /mswin/
68
+
69
+ # The 'install' method will auto-install gems as specified by the args and config
70
+ GemInstaller.install(args)
71
+
72
+ # The 'autogem' method will automatically add all gems in the GemInstaller config to your load path, using the 'gem'
73
+ # or 'require_gem' command. Note that only the *first* version of any given gem will be loaded.
74
+ GemInstaller.autogem(args)
75
+ ############# End GemInstaller config
76
+
77
+ unless defined?(Rails::Initializer)
78
+ ...
79
+ </code></pre>
86
80
 
87
81
  * Start your app: <code>ruby script/server</code>. You should see messages indicating the gems (and dependency gems) are being installed and auto-required.
88
82
  * Stop the app, and verify the gems are installed: <code>gem list rails</code>