britt-geminstaller 0.5.2 → 0.5.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/.loadpath +5 -0
  2. data/COPYING +1 -0
  3. data/History.txt +69 -0
  4. data/LICENSE +21 -0
  5. data/Manifest.txt +78 -0
  6. data/README.txt +64 -0
  7. data/Rakefile +184 -0
  8. data/TODO.txt +138 -0
  9. data/bin/geminstaller +30 -0
  10. data/cruise_config.rb +14 -0
  11. data/focused_spec.sh +2 -0
  12. data/focused_spec_debug.sh +2 -0
  13. data/geminstaller.yml +42 -0
  14. data/lib/geminstaller.rb +103 -0
  15. data/lib/geminstaller/application.rb +105 -0
  16. data/lib/geminstaller/arg_parser.rb +166 -0
  17. data/lib/geminstaller/autogem.rb +46 -0
  18. data/lib/geminstaller/backward_compatibility.rb +10 -0
  19. data/lib/geminstaller/config.rb +68 -0
  20. data/lib/geminstaller/config_builder.rb +65 -0
  21. data/lib/geminstaller/enhanced_stream_ui.rb +71 -0
  22. data/lib/geminstaller/exact_match_list_command.rb +16 -0
  23. data/lib/geminstaller/file_reader.rb +31 -0
  24. data/lib/geminstaller/gem_arg_processor.rb +44 -0
  25. data/lib/geminstaller/gem_command_manager.rb +74 -0
  26. data/lib/geminstaller/gem_interaction_handler.rb +41 -0
  27. data/lib/geminstaller/gem_list_checker.rb +55 -0
  28. data/lib/geminstaller/gem_runner_proxy.rb +62 -0
  29. data/lib/geminstaller/gem_source_index_proxy.rb +21 -0
  30. data/lib/geminstaller/gem_spec_manager.rb +53 -0
  31. data/lib/geminstaller/geminstaller_access_error.rb +4 -0
  32. data/lib/geminstaller/geminstaller_error.rb +13 -0
  33. data/lib/geminstaller/hoe_extensions.rb +9 -0
  34. data/lib/geminstaller/install_processor.rb +71 -0
  35. data/lib/geminstaller/missing_dependency_finder.rb +46 -0
  36. data/lib/geminstaller/missing_file_error.rb +4 -0
  37. data/lib/geminstaller/noninteractive_chooser.rb +114 -0
  38. data/lib/geminstaller/output_filter.rb +49 -0
  39. data/lib/geminstaller/output_listener.rb +33 -0
  40. data/lib/geminstaller/output_observer.rb +36 -0
  41. data/lib/geminstaller/output_proxy.rb +36 -0
  42. data/lib/geminstaller/registry.rb +127 -0
  43. data/lib/geminstaller/requires.rb +81 -0
  44. data/lib/geminstaller/rogue_gem_finder.rb +195 -0
  45. data/lib/geminstaller/ruby_gem.rb +58 -0
  46. data/lib/geminstaller/rubygems_exit.rb +5 -0
  47. data/lib/geminstaller/rubygems_extensions.rb +9 -0
  48. data/lib/geminstaller/rubygems_version_checker.rb +15 -0
  49. data/lib/geminstaller/rubygems_version_warnings.rb +38 -0
  50. data/lib/geminstaller/source_index_search_adapter.rb +41 -0
  51. data/lib/geminstaller/unauthorized_dependency_prompt_error.rb +4 -0
  52. data/lib/geminstaller/unexpected_prompt_error.rb +4 -0
  53. data/lib/geminstaller/valid_platform_selector.rb +49 -0
  54. data/lib/geminstaller/version_specifier.rb +24 -0
  55. data/lib/geminstaller/yaml_loader.rb +22 -0
  56. data/lib/geminstaller_rails_preinitializer.rb +46 -0
  57. data/start_local_gem_server.sh +1 -0
  58. data/test/test_all.rb +36 -0
  59. data/test/test_all_smoketests.rb +21 -0
  60. data/website/config.yaml +11 -0
  61. data/website/src/analytics.page +6 -0
  62. data/website/src/code/ci.virtual +5 -0
  63. data/website/src/code/coverage/index.virtual +5 -0
  64. data/website/src/code/index.page +88 -0
  65. data/website/src/code/rdoc/index.virtual +6 -0
  66. data/website/src/community/index.page +14 -0
  67. data/website/src/community/links.page +11 -0
  68. data/website/src/community/rubyforge.virtual +4 -0
  69. data/website/src/default.css +175 -0
  70. data/website/src/default.template +42 -0
  71. data/website/src/documentation/documentation.page +476 -0
  72. data/website/src/documentation/index.page +53 -0
  73. data/website/src/documentation/tutorials.page +337 -0
  74. data/website/src/download.page +12 -0
  75. data/website/src/faq.page +36 -0
  76. data/website/src/index.page +92 -0
  77. data/website/src/metainfo +54 -0
  78. data/website/src/webgen.css +112 -0
  79. metadata +80 -3
@@ -0,0 +1,6 @@
1
+ index.html:
2
+ title: Rdoc
3
+ url: index.html
4
+ in_menu: true
5
+ sort_info: 30
6
+
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: Feedback
3
+ ---
4
+ h1. Feedback, Bugs, and Source Code
5
+
6
+ h2. Rubyforge Bug/Feature Tracker and Mailing Lists
7
+
8
+ * "RubyForge Page":http://rubyforge.org/projects/geminstaller/
9
+ * "Bug/Feature Tracker":http://thewoolleyweb.lighthouseapp.com/projects/11580-geminstaller/overview
10
+ * "Mailing Lists":http://rubyforge.org/mail/?group_id=1902
11
+
12
+ h2. Source Code
13
+
14
+ * Subversion Repository: "http://geminstaller.rubyforge.org/svn/trunk":http://geminstaller.rubyforge.org/svn/trunk
@@ -0,0 +1,11 @@
1
+
2
+ h1. Links
3
+
4
+ * Chad's links:
5
+ ** "Chad's Home Page":http://www.thewoolleyweb.com
6
+ ** "Pivotal Labs":http://pivotallabs.com - where Chad works
7
+ ** "DiabeticMommy.com":http://www.diabeticmommy.com - Support site for women with diabetes, created and edited by Chad's wife
8
+ * RubyGems
9
+ ** "RubyGems Homepage":http://rubygems.org
10
+ * RSpec
11
+ ** "RSpec Homepage":http://rspec.info/
@@ -0,0 +1,4 @@
1
+ rubyforge.html:
2
+ title: Rubyforge
3
+ url: http://rubyforge.org/projects/geminstaller
4
+ in_menu: true
@@ -0,0 +1,175 @@
1
+ /* andreas09 v1.0 (Dec 10th 2005) - An open source template by Andreas Viklund - http://andreasviklund.com. Free to use for any purpose as long as the proper credits are given to the original author. */
2
+
3
+ body {
4
+ background:#FFFFFF;
5
+ color:#303030;
6
+ font:90% Verdana,Tahoma,Arial,sans-serif;
7
+ margin:0;
8
+ padding:0;
9
+ text-align:center;
10
+ }
11
+
12
+ a {
13
+ color:#3A5FCD;
14
+ font-weight:bold;
15
+ }
16
+
17
+ a:visited {
18
+ color:#551A8B;
19
+ }
20
+
21
+ a:hover {
22
+ color:#808080;
23
+ }
24
+
25
+ p {
26
+ line-height:1.5em;
27
+ margin:0 0 15px;
28
+ }
29
+
30
+ code {
31
+ font-size:1.3em;
32
+ }
33
+
34
+ /*** Main container ***/
35
+
36
+ #container {
37
+ background:#CCCCCC;
38
+ color:#303030;
39
+ margin:0;
40
+ min-width:770px;
41
+ padding:0;
42
+ text-align:left;
43
+ width:100%;
44
+ }
45
+
46
+ /*** Header section ***/
47
+
48
+ #header {
49
+ background:#000000;
50
+ padding-bottom:10px;
51
+ }
52
+
53
+ #sitename {
54
+ color:#ffffff;
55
+ margin:0 20px 10px 40px;
56
+ text-align:left;
57
+ }
58
+
59
+ #sitename h1,#sitename h2 {
60
+ letter-spacing:7px;
61
+ margin:0;
62
+ padding:0;
63
+ }
64
+
65
+ #sitename h1 {
66
+ font-size:2.6em;
67
+ padding-top:18px;
68
+ }
69
+
70
+ #sitename h2 {
71
+ font-size:1.8em;
72
+ }
73
+
74
+
75
+
76
+ #navigation {
77
+ text-align:left;
78
+ margin:0 18px 10px auto;
79
+ padding:0;
80
+ font-size:1.4em;
81
+ line-height:.3em;
82
+ }
83
+ #navigation li {
84
+ margin:0;
85
+ padding-right: 10px;
86
+ list-style:none;
87
+ display:inline;
88
+ }
89
+ #navigation li a {
90
+ margin:0 1px 0 1px;
91
+ color:#666;
92
+ text-decoration:none;
93
+ font-weight:bold;
94
+ }
95
+ #navigation li a:hover {
96
+ color:#AA2233;
97
+ }
98
+ #navigation li.webgen-menu-item-selected a, #naviation li.webgen-menu-item-selected a:hover {
99
+ color: #000;
100
+ }
101
+
102
+
103
+ /*** Content wrap ***/
104
+
105
+ #wrap {
106
+ background:#FFFFFF;
107
+ clear:both;
108
+ font-size:1.1em;
109
+ padding-top:10px;
110
+ }
111
+
112
+ /*** Content ***/
113
+ #content {
114
+ padding:0px 20px 5px;
115
+ }
116
+
117
+ #content {
118
+ margin-top: 10px;
119
+ margin-left: 20px;
120
+ margin-right: 20px;
121
+ }
122
+
123
+ #content h1,#content h2,#content h3 {
124
+ background-color:inherit;
125
+ color:#606060;
126
+ font-size:1.8em;
127
+ font-weight:bold;
128
+ letter-spacing:-1px;
129
+ margin:0 0 10px;
130
+ padding:0;
131
+ }
132
+
133
+ #content h2 {
134
+ font-size:1.6em;
135
+ margin-bottom:10px;
136
+ }
137
+
138
+ #content h3 {
139
+ font-size:1.4em;
140
+ margin-bottom:10px;
141
+ }
142
+
143
+ #content img {
144
+ border:1px solid #b0b0b0;
145
+ float:left;
146
+ margin:5px 15px 6px;
147
+ padding:5px;
148
+ }
149
+
150
+ /*** Footer ***/
151
+
152
+ #footer {
153
+ background:#FFFFFF;
154
+ clear:both;
155
+ color:#d0d0d0;
156
+ font-size:1.0em;
157
+ font-weight:bold;
158
+ margin:0;
159
+ padding:20px 0;
160
+ text-align:center;
161
+ width:100%;
162
+ }
163
+
164
+ #footer a {
165
+ color:#d0d0d0;
166
+ font-weight:bold;
167
+ }
168
+
169
+
170
+ /* START webgen horizontal menu style */
171
+ .webgen-menu-horiz ul { display: block; }
172
+ .webgen-menu-horiz li { display: inline; }
173
+ /* STOP webgen horizontal menu style */
174
+
175
+ /*** End of file ***/
@@ -0,0 +1,42 @@
1
+ --- pipeline:tags,blocks
2
+ <?xml version="1.0" encoding="UTF-8"?>
3
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang:}">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <meta name="description" content="geminstaller.rubyforge.org" />
8
+ <meta name="keywords" content="ruby,gems,rubygems" />
9
+ <meta name="author" content="Chad Woolley / Original design by Andreas Viklund - http://andreasviklund.com" />
10
+ <meta name="generator" content="webgen - http://webgen.rubyforge.org" />
11
+ <link rel="stylesheet" href="{relocatable: default.css}" type="text/css" media="screen" />
12
+ <title>{title:}</title>
13
+ </head>
14
+
15
+ <body>
16
+ <div id="container">
17
+
18
+ <div id="header">
19
+ <div id="sitename">
20
+ <h1>GemInstaller</h1>
21
+ <h2>Automated Gem installation, activation, and much more!</h2>
22
+ </div>
23
+ </div>
24
+
25
+ <div id="navigation">
26
+ {menu:}
27
+ </div>
28
+
29
+ <div id="wrap">
30
+
31
+ <div id="content">
32
+ <webgen:block name="content" />
33
+ </div>
34
+
35
+ </div>
36
+ </div>
37
+
38
+ <div id="footer">&copy; 2008 Chad Woolley | Generated by <a href="http://webgen.rubyforge.org">webgen</a></div>
39
+ {include_file: {filename: src/analytics.page, escape_html: false, process_output: false}}
40
+
41
+ </body>
42
+ </html>
@@ -0,0 +1,476 @@
1
+ h1. Detailed Documentation
2
+
3
+ h2. Table of Contents
4
+
5
+ * "Setup":#setup
6
+ ** "Requirements":#requirements
7
+ ** "Installation":#installation
8
+ * "Command Line Options":#command_line_options
9
+ ** "Command Line Options Summary":#command_line_options_summary
10
+ ** "<code>--config</code> option":#config_option
11
+ ** "<code>--exceptions</code> option":#exceptions_option
12
+ ** "<code>--redirect-stderr-to-stdout</code> option":#redirect_stderr_to_stdout_option
13
+ ** "<code>--geminstaller-output</code> option":#geminstaller_output_option
14
+ ** "<code>--rubygems-output</code> option":#rubygems_output_option
15
+ ** "<code>--print-rogue-gems</code> option":#print_rogue_gems_option
16
+ ** "<code>--sudo</code> option":#sudo_option
17
+ ** "<code>--silent</code> option":#silent_option
18
+ ** "Unsuppressible Output":#unsuppressible_output
19
+ * "Config File":#config_file
20
+ ** "Config File Syntax Summary":#config_file_syntax_summary
21
+ ** "<code>name</code> config property":#name_config_property
22
+ ** "<code>version</code> config property":#version_config_property
23
+ ** "<code>platform</code> config property":#platform_config_property
24
+ ** "<code>install_options</code> config property":#install_options_config_property
25
+ ** "<code>check_for_upgrade</code> config property":#check_for_upgrade_config_property
26
+ ** "<code>fix_dependencies</code> config property":#fix_dependencies_config_property
27
+ ** "<code>no_autogem</code> config property":#no_autogem_config_property
28
+ ** "<code>prefer_binary_platform</code> config property":#prefer_binary_platform_config_property (deprecated)
29
+ ** "<code>include_config</code> directive":#include_config
30
+ * "Using GemInstaller with Ruby on Rails or Other Ruby Apps":#using_geminstaller_with_ruby_on_rails_or_other_ruby_apps
31
+ ** "Invoking <code>GemInstaller</code> from Rails":#invoking_geminstaller_from_rails
32
+ ** "DEPRECATED Invoking <code>GemInstaller</code> from Rails 1.0":#invoking_geminstaller_from_rails_10
33
+ ** "Bootstrapping Rails with GemInstaller":#bootstrapping_rails_with_geminstaller
34
+ ** "Using GemInstaller from Other Ruby Apps":#using_geminstaller_from_other_ruby_apps
35
+ * "Using <code>erb</code> in config files":#using_erb_in_config_files
36
+ * "Automatic Platform Detection":#automatic_platform_detection
37
+ * "Dealing with sudo and root-owned RubyGem installations":#dealing_with_sudo
38
+ ** "Option 1 - Use the <code>-s</code> or <code>--sudo</code> option on the <code>geminstaller</code> executable":#option_1
39
+ ** "Option 2 - Run <code>sudo</code> or log in as root yourself":#option_2
40
+ ** "Option 3 - Make everything owned by the local user that runs geminstaller":#option_3
41
+ ** "Tips on configuring sudo":#tips_on_configuring_sudo
42
+ * "Automatically Requiring Gems with the <code>autogem</code> Method":#automatically_requiring_gems_with_the_autogem_method
43
+
44
+ h2(#setup). Setup
45
+
46
+ h3(#requirements). Requirements
47
+
48
+ Runtime Requirements:
49
+ * None. There are no dependencies required to run GemInstaller, other than an installation of RubyGems itself
50
+
51
+ Build/Test requirements:
52
+ * GemInstaller has a *geminstaller.yml* file to specify it's own dependencies. After installing the geminstaller gem (via 'gem install geminstaller'), change to the root of the geminstaller source tree, and run 'geminstaller' to auto-install the dependencies.
53
+
54
+ h3(#installation). Installation
55
+
56
+ *Installing Latest Release:* Run <code>'gem install geminstaller'</code> to install GemInstaller from RubyForge. Run it via <code>'sudo'</code> if necessary, but first read the section on "Dealing with sudo and root-owned RubyGem installations":#dealing_with_sudo.
57
+
58
+ *Installing Source Distribution:* Run <code>'rake install_gem'</code> from the root of the GemInstaller source tree. This assumes that Hoe and other required build/test dependencies are installed. Note this currently won't work on windows because Hoe always tries to run sudo. It will generate a pkg/geminstaller-version.gem file, though, which you can install with the <code>'gem install <pkgfile>'</code> command.
59
+
60
+ h2(#command_line_options). Command Line Options
61
+
62
+ h3(#command_line_options_summary). Command Line Options Summary
63
+
64
+ <pre><code>
65
+ $ geminstaller --help
66
+ Usage: geminstaller [options]
67
+
68
+ -c, --config=CONFIGPATHS Comma-delimited path(s) to GemInstaller config file(s).
69
+ -e, --exceptions Raise any exceptions, rather than just printing them and exiting
70
+ with a non-zero return code.
71
+ -d, --redirect-stderr-to-stdout Redirect all STDERR output to STDOUT. Useful to get all output when
72
+ invoking GemInstaller via system().
73
+ -g, --geminstaller-output=TYPES Comma-delimited list of output types to show from GemInstaller.
74
+ Examples:
75
+ --gall
76
+ --geminstaller-output=error,install,commandecho
77
+ Default: error,install,info
78
+ Valid types:
79
+ - none: print only fatal errors
80
+ - error: print error messages
81
+ - install: print install messages
82
+ - info: print informational messages
83
+ - commandecho: print rubygems commands as they are invoked
84
+ - debug: print debug messages
85
+ - all: print all messages
86
+ -h, --help Show this message.
87
+ -p, --print-rogue-gems Print a report of all locally installed gems which are not specified
88
+ in the geminstaller config file.
89
+ -r, --rubygems-output=TYPES Comma-delimited list of output types to show from internal:
90
+ RubyGems command invocation.
91
+ Examples:
92
+ --rall
93
+ --rubygems-output=stderr
94
+ Default: stderr
95
+ Valid types:
96
+ - none: print no output
97
+ - stdout: print standard output stream
98
+ - stderr: print standard error stream
99
+ - all: print all output
100
+ -s, --sudo Perform all gem operations under sudo (as root). Will only work on
101
+ correctly configured, supported systems. See docs for more info.
102
+ -t, --silent Suppress all output except fatal exceptions, and output from
103
+ rogue-gems option.
104
+ -v, --version Show GemInstaller version and exit.
105
+ </code></pre>
106
+
107
+ h3(#config_option). <code>--config</code> option
108
+
109
+ 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:
110
+
111
+ <pre><code>
112
+ geminstaller --config=../common-config/geminstaller-common-across-projects.yml,geminstaller-custom-for-myproject.yml
113
+ </code></pre>
114
+
115
+ h3(#exceptions_option). <code>--exceptions</code> option
116
+
117
+ By default, GemInstaller will not throw exceptions for errors when invoked via <code>GemInstaller.install</code> or <code>GemInstaller.autogem</code>. This is so that any GemInstaller errors will not abort startup of Rails or any other app other apps. However, if you do want errors to abort startup of Rails or your app, you can set this option.
118
+
119
+ h3(#redirect_stderr_to_stdout_option). <code>--redirect-stderr-to-stdout</code> option
120
+
121
+ Currently, the GemInstaller <code>--sudo</code> option works by recursively re-invoking the <code>geminstaller</code> executable via <code>system()</code>. This option is automatically added in this case to ensure that errors that would normally go to <code>stderr</code> are printed to <code>stdout</code>. There are other solutions to this problem, but as of Ruby 1.8.5, there is no _easy_ way to make a system call which will give a return code AND show both stderr and stdout _synchronously_. GemInstaller does not have and will not have any third-party runtime dependencies, so I needed to roll my own solution, and this was The Simplest Thing That Could Possibly Work.
122
+
123
+ h3(#geminstaller_output_option). <code>--geminstaller-output</code> option
124
+
125
+ The <code>--geminstaller-output</code> option controls what GemInstaller prints out about it's internal activity. It is a comma-delimited list (no spaces), which can specify any of these output types:
126
+
127
+ * none: Prints only fatal errors/exceptions which cause geminstaller to fail. The same as specifying none of the other types.
128
+ * error: Prints error messages.
129
+ * install: Prints messages indicating when gems are going to be installed. This may be gems which are directly specified in a GemInstaller config file, or dependency gems which are automatically installed to meet the requirments of a dependent gem.
130
+ * info: Prints informational messages.
131
+ * commandecho: Print rubygems commands as they are automatically invoked by GemInstaller.
132
+ * debug: Prints debug messages
133
+ * all: Prints all messages. This is the same as specifying all of the other types (except 'none')
134
+
135
+ This option works in conjuntion the <code>--rubygems-output</code>, which is used similarly, but controls output which is generated by RubyGems itself.
136
+
137
+ h3(#rubygems_output_option). <code>--rubygems-output</code> option
138
+
139
+ GemInstaller works by automatically invoking RubyGems commands. The <code>--rubygems-output</code> option controls what types of output from RubyGems is printed out. It is a comma-delimited list (no spaces), which can specify any of these output types:
140
+
141
+ * none: Prints no output from RubyGems.
142
+ * stdout: Prints standard output stream from RubyGems.
143
+ * stderr: Prints standard error stream from RubyGems.
144
+ * all: Prints all messages. This is the same as specifying all of the other types (except 'none')
145
+
146
+ h3(#print_rogue_gems_option). <code>--print-rogue-gems</code> option
147
+
148
+ The <code>--print-rogue-gems</code> option prints a report of all locally installed gems which are not specified in the active loaded GemInstaller config file(s). GemInstaller, being "Narcissistic Software" (tm), considers these "rogue gems". The output format is in YAML, so it can be cut and pasted or piped directly into a new or existing config file. This allows you to bootstrap a new system, by creating an empty config file with no gems specified, and running geminstaller with the <code>--print-rogue-gems</code> option to identify all gems which are currently installed on the system. It can also be used to identify gems which were manually installed without being entered into a GemInstaller config.
149
+
150
+ Some gems are automatically installed with RubyGems itself. The 'sources' gem always exists, and the Ruby Windows One Click Installer installs several windows-specific gems. The <code>--print-rogue-gems</code> option will include these gems, but will mark them with a comment indicating that they may have been automatically installed by RubyGems.
151
+
152
+ h3(#sudo_option). <code>--sudo</code> option
153
+
154
+ The <code>--sudo</code> option runs GemInstaller as root by using the <code>sudo</code> command. This command is neither valid nor necessary on Windows platforms. See the "Dealing with sudo and root-owned RubyGem installations":#dealing_with_sudo section for more details.
155
+
156
+ NOTE: As a security feature, the sudo command does NOT pass along the current environment. That means that if you use the <code>--sudo</code> option, environment variables that are currently set will NOT be available to GemInstaller config files. There are options to get around this - read the docs on sudoers for your unix distro.
157
+
158
+ h3(#silent_option). <code>--silent</code> option
159
+
160
+ The <code>--silent</code> option suppresses all RubyGems output except fatal errors/exceptions. It overrides the <code>--geminstaller-output</code> and <code>--rubygems-output</code> options.
161
+
162
+ h3(#unsuppressible_output). Unsuppressible Output
163
+
164
+ Sometimes, errors from RubyGems activity will still be printed even if the <code>'--geminstaller-output=none'</code> or <code>--silent</code> options are specified. This usually due to some failure when building gem docs, or on a windows platform. This is probably due to a gem directly printing to stderr or stdout. GemInstaller does not currently capture this type of output, only messages which are directly generated by RubyGems itself. This may be fixed in a later release.
165
+
166
+ h2(#config_file). Config File
167
+
168
+ The GemInstaller config file is simple YAML file. It contains a section specifying all the gems you want to install, and their associated options/properties, and another section which contains defaults to apply to all gems. By default, GemInstaller will look for a config file named *<code>geminstaller.yml</code>* in the working directory, but you can override this file name (and specify multiple config files) with the "<code>--config</code> option":#config_option.
169
+
170
+ GemInstaller offers a great deal of flexibility in configuration. By creatively using multiple config files, defaults within single config files, "<code>erb</code> in config files":#using_erb_in_config_files, and the features of YAML itself, you should be able to come up with a unified GemInstaller config approach that works for multiple applications across multiple machines, platforms, and environments, with a minimum of duplication.
171
+
172
+ NOTE: Currently, the order of gems in the config file matters. It will install them, and any dependencies, in the order listed. This means if you have a gem listed explicitly, but it is a dependency of an earlier gem, it won't use the options you set - it will use default/inherited options from it's dependent gem. Perhaps a future version of GemInstaller will be smart enough to handle this better.
173
+
174
+ h3(#config_file_syntax_summary). Config File Syntax Summary
175
+
176
+ This is an example config file template showing all the valid properties (boolean defaults capitalized):
177
+
178
+ <pre><code>---
179
+ defaults:
180
+ install_options: [ any valid option for the RubyGems 'gem install' command ]
181
+ check_for_upgrade: [ true | FALSE ]
182
+ fix_dependencies: [ true | FALSE ]
183
+ no_autogem: [ true | FALSE ]
184
+ prefer_binary_platform: [ TRUE | false ] (deprecated)
185
+ gems:
186
+ - name: [ gem name ]
187
+ version: '[ any valid version specification for this gem, e.g. >= 1.0.0 ]'
188
+ platform: [ any valid platform for this Gem and version specification ]
189
+ install_options: [ any valid option for the RubyGems 'gem' command ]
190
+ check_for_upgrade: [ true | FALSE ]
191
+ fix_dependencies: [ true | FALSE ]
192
+ no_autogem: [ true | FALSE ]
193
+ prefer_binary_platform: [ TRUE | false ]
194
+ - name: [ another gem name ]
195
+ - name: [ yet another gem name ]
196
+ (etc...)
197
+ <%= include_config("#{File.expand_path(File.dirname(__FILE__))}/path/to/included_snippet.yml") %>
198
+ </code></pre>
199
+
200
+ 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
+
202
+ h3(#name_config_property). <code>name</code> config property
203
+
204
+ Required, no default. This is the name of the gem to install. GemInstaller always does an exact match on the name, a substring will not match.
205
+
206
+ h3(#version_config_property). <code>version</code> config property
207
+
208
+ Defaults to '> 0'. This is the version specification used to select a gem. The highest version which meets the specification will be installed. GemInstaller always does an exact match on the name, a substring will not match.
209
+
210
+ You should enclose the version specification in single quotes. This is not always necessary, but sometimes YAML will have trouble parsing it if you don't, so it's best to always use quotes.
211
+
212
+ There are many different options for version specifications. For more info, see the section on "Specifying Versions":http://rubygems.org/read/chapter/16 in the RubyGems User Guide.
213
+
214
+ h3(#platform_config_property). <code>platform</code> config property
215
+
216
+ Defaults to 'ruby'. This is the platform for the gem. This must match a platform which is valid and available for the gem name and version specification. See the sections on "Automatic Platform Detection":#automatic_platform_detection and the "<code>prefer_binary_platform</code> config property":#prefer_binary_platform (deprecated) for more info on how platforms are handled.
217
+
218
+ h3(#install_options_config_property). <code>install_options</code> config property
219
+
220
+ Defaults to empty string. The <code>install_options</code> config property can contain any option which is valid to pass to the RubyGems <code>'gem install'</code> command. These options will be passed on when GemInstaller internally invokes RubyGems. Type <code>gem install --help</code> to list the options.
221
+
222
+ h3(#check_for_upgrade_config_property). <code>check_for_upgrade</code> config property
223
+
224
+ Defaults to false. By default, GemInstaller will not perform any remote operations unless they are necessary to install a required gem. In other words, if there is a local gem which meets the specs, nothing will be done. This allows GemInstaller to still run normally when you are not connected to a network.
225
+
226
+ However, if you are using a non-specific version spec (for example, '>= 1.0.0), there COULD be a higher version available on the remote gem server. If set to true, <code>check_for_upgrade</code> will force GemInstaller to check for a higher-versioned gem on the server which still matches the version specification, and install it if one is found.
227
+
228
+ h3(#fix_dependencies_config_property). <code>fix_dependencies</code> config property
229
+
230
+ Defaults to false. Ruby Gems can depend on other gems, but the other gem might still get manually uninstalled (by using the <code>gem uninstall --ignore-dependencies GEMNAME</code>) option. The <code>--fix_dependencies</code> option will detect these missing dependencies, and automatically fix them. You shouldn't need this unless you go around uninstalling gems with the <code>--ignore-dependencies</code> option. WARNING: This option can GREATLY increase the time it takes to run GemInstaller, especially if you have a lot of gems in your config, and especially on Windows. You probably always want it left as the default of false unless you suspect that some dependencies have been uninstalled.
231
+
232
+ h3(#no_autogem_config_property). <code>no_autogem</code> config property
233
+
234
+ Defaults to false. This option will prevent the <code>autogem</code> command from automatically requiring a gem. If you only want to require a few gems, you could set the default for this property to true, and only enable it (by setting a false value) for specific gems. For more details see "Automatically Requiring Gems with the <code>autogem</code> Method":#automatically_requiring_gems_with_the_autogem_method.
235
+
236
+ h3(#prefer_binary_platform_config_property). <code>prefer_binary_platform</code> config property (deprecated)
237
+
238
+ DEPRECATED: This is deprecated when using RubyGems >= 0.9.5, which handles platform detection.
239
+
240
+ Defaults to true. GemInstaller automatically guesses at the correct platform for gem which have no platform specified. Any platform which is not 'ruby' is considered a 'binary' platform.
241
+
242
+ This option determines whether the 'ruby' platform, or a 'binary' platform will be chosen first. By default, binary platforms will be chosen if there is one available which seems to match the platform of the current machine. In practice, this usually only applies to windows, since (hopefully) most gems which need to be compiled distribute a windows-specific precompiled gem version. See "Automatic Platform Detection":#automatic_platform_detection for more info.
243
+
244
+ h3(#include_config). <code>include_config</code> directive
245
+
246
+ Inside a GemInstaller yaml config file, you can use the <code>include_config</code> directive to include another config file via ERB. This also works recursively - included files can include other files.
247
+
248
+ This is an alternative to specifying multiple files in the <code>--config</code> command line option - it allows you to abstract out common portions of config files across multiple files, while still only having to specify a single top-level config file.
249
+
250
+ 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
+
252
+ <pre><code>---
253
+ # .../geminstaller.yml
254
+ gems:
255
+ <%= include_config("#{File.expand_path(File.dirname(__FILE__))}/subdir1/included_gem_config1.yml") %>
256
+ </code></pre>
257
+
258
+ <pre><code>---
259
+ # .../subdir1/included_gem_config1.yml
260
+ - name: testgem1
261
+ <%= include_config("#{File.expand_path(File.dirname(__FILE__))}/../subdir2/included_gem_config2.yml") %>
262
+ </code></pre>
263
+
264
+ <pre><code>---
265
+ # .../subdir2/included_gem_config2.yml
266
+ - name: testgem2
267
+ </code></pre>
268
+
269
+
270
+ h2(#using_geminstaller_with_ruby_on_rails_or_other_ruby_apps). Using GemInstaller with Ruby on Rails or Other Ruby Apps
271
+
272
+ GemInstaller can also be embedded in another application, such as a Rails app. This is done by invoking the GemInstaller class or the geminstaller executable directly from Ruby. Also see the tutorial on "Using GemInstaller with Ruby on Rails":index.html#using_geminstaller_with_ruby_on_rails .
273
+
274
+ IMPORTANT NOTE: You need to know whether you run on unix and need root/sudo access to install gems and/or gem executables. See "Dealing with sudo and root-owned RubyGem installations":#dealing_with_sudo section for more details.
275
+
276
+ 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:
277
+
278
+ <pre><code>---
279
+ defaults:
280
+ install_options: --no-ri --no-rdoc
281
+ gems:
282
+ - name: rails
283
+ version: '= 1.1.6'
284
+ - name: mongrel
285
+ version: '= 1.0.1'
286
+ platform: <%= RUBY_PLATFORM =~ /mswin/ ? 'mswin32' : 'ruby'%>
287
+ </code></pre>
288
+
289
+ h3(#invoking_geminstaller_from_rails). Invoking <code>GemInstaller</code> from Rails
290
+
291
+ * Install the GemInstaller gem and create your *<code>config/geminstaller.yml</code>* config file.
292
+
293
+ * 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.
294
+
295
+ * Create a <code>config/preinitializer.rb</code> file to invoke GemInstaller on your Rails app startup:
296
+
297
+ *RAILS_ROOT/config/preinitializer.rb*:
298
+ <pre><code> require 'rubygems'
299
+ require 'geminstaller'
300
+ # You can use the geminstaller_rails_preinitializer out of the GemInstaller gem:
301
+ require 'geminstaller_rails_preinitializer'
302
+ # If you require different geminstaller command options, copy the geminstaller_rails_preinitializer.rb
303
+ # file into from the GemInstaller source into your Rails app, modify it, and require your customized
304
+ # version. For example:
305
+ # require "#{File.expand_path(RAILS_ROOT)}/config/custom_geminstaller_rails_preinitializer.rb"
306
+ </code></pre>
307
+
308
+ * Start your app: <code>ruby script/server</code>. You should see (depending on verbosity level) messages indicating the gems (and dependency gems) are being installed and auto-required.
309
+ * Stop the app, and verify the gems are installed: <code>gem list [some gem in your geminstaller.yml]</code>
310
+ * For an example, check out the "Sample Rails App":http://geminstaller.rubyforge.org/svn/trunk/spec/fixture/sample_rails_app/ in the GemInstaller source.
311
+
312
+ The default <code>geminstaller_rails_preinitializer.rb</code> in the GemInstaller source 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.
313
+
314
+ h3(#invoking_geminstaller_from_rails_10). DEPRECATED - Invoking <code>GemInstaller</code> from Rails 1.0
315
+
316
+ This section describes how to use GemInstaller with Rails 1.0 (which doesn't support config/preinitializer.rb). If you are using Rails 2.0 or above, use "these instructions":#invoking_geminstaller_from_rails
317
+
318
+ Once you have your *<code>geminstaller.yml</code>* created, invoke GemInstaller on Rails 1.0 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):
319
+
320
+ *RAILS_1.0_ROOT/config/boot.rb*:
321
+ <pre><code> ...
322
+ unless defined?(RAILS_ROOT)
323
+ ...
324
+ end
325
+
326
+ ############# Begin GemInstaller config - see http://geminstaller.rubyforge.org
327
+ require "rubygems"
328
+ require "geminstaller"
329
+
330
+ # Path(s) to your GemInstaller config file(s)
331
+ config_paths = "#{File.expand_path(RAILS_ROOT)}/config/geminstaller.yml"
332
+
333
+ # Arguments which will be passed to GemInstaller (you can add any extra ones)
334
+ args = "--config #{config_paths}"
335
+
336
+ # The 'exceptions' flag determines whether errors encountered while running GemInstaller
337
+ # should raise exceptions (and abort Rails), or just return a nonzero return code
338
+ args += " --exceptions"
339
+
340
+ # This will use sudo by default on all non-windows platforms, but requires an entry in your
341
+ # sudoers file to avoid having to type a password. It can be omitted if you don't want to use sudo.
342
+ # See http://geminstaller.rubyforge.org/documentation/documentation.html#dealing_with_sudo
343
+ args += " --sudo" unless RUBY_PLATFORM =~ /mswin/
344
+
345
+ # The 'install' method will auto-install gems as specified by the args and config
346
+ GemInstaller.install(args)
347
+
348
+ # The 'autogem' method will automatically add all gems in the GemInstaller config to your load path, using the 'gem'
349
+ # or 'require_gem' command. Note that only the *first* version of any given gem will be loaded.
350
+ GemInstaller.autogem(args)
351
+ ############# End GemInstaller config
352
+
353
+ unless defined?(Rails::Initializer)
354
+ ...
355
+ </code></pre>
356
+
357
+ h3(#bootstrapping_rails_with_geminstaller). Bootstrapping Rails with GemInstaller
358
+
359
+ 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 methods 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:
360
+
361
+ <pre><code>
362
+ $ cd [RAILS_APP_ROOT]/config
363
+ $ geminstaller --sudo # only use the -sudo option if necessary
364
+ </code></pre>
365
+
366
+ h3(#using_geminstaller_from_other_ruby_apps). Using GemInstaller from Other Ruby Apps
367
+
368
+ If you want to automatically invoke GemInstaller from some other Ruby application, the approach will be very similar to the Rails approach "shown above":#invoking_geminstaller_from_rails. Instead of preinitializer.rb, put the GemInstaller invocation into the class or script which is the very first one run when your application starts up. To use it in build scripts such as <code>rake</code>, include it in a task. GemInstaller (obviously) must run before any gems are loaded or referenced.
369
+
370
+ h2(#using_erb_in_config_files). Using <code>erb</code> in config files
371
+
372
+ 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.
373
+
374
+ <pre><code>---
375
+ # geminstaller-detect-platform.yml
376
+ gems:
377
+ - name: x10-cm17a
378
+ version: '> 1.0.0'
379
+ platform: <%= RUBY_PLATFORM =~ /mswin/ ? 'i386-mswin32' : 'ruby'%>
380
+ </code></pre>
381
+
382
+ h2(#automatic_platform_detection). Automatic Platform Detection
383
+
384
+ Up through version 0.9.4, RubyGems did not provide any way to specify a platform programatically or via the command line, and prompted via stdin if a specified version of a gem has any binary or platform-specific releases. RubyGems 0.9.5 and later should correctly determine the correct platform to install, and GemInstaller will automatically use this feature.
385
+
386
+ However, if you must run older versions of RubyGems <= 0.9.4, GemInstaller still includes support for automatically selecting the platform without any stdin prompts. If a multi-platform gem version is found, GemInstaller will handle the list prompt, and automatically select the correct platform.
387
+
388
+ This means that you don't have to worry about what version of RubyGems your app will run on - GemInstaller handles automatic platform selection on all RubyGems versions.
389
+
390
+ If you do want explicit control over the platform which is used, all you need to do is specify the <code>'platform'</code> property for any multiplatform gems can be specified in the geminstaller config file. If you know what platform you want for a specific gem, and you only run GemInstaller on one platform, you can hardcode this value. Even if you run GemInstaller on multiple platforms (and therefore can't hardcode the platform string), you can use <code>erb</code> to programatically pick the correct platform. See "Using <code>erb</code> in config files":#using_erb_in_config_files for an example.
391
+
392
+ See the section on the "<code>prefer_binary_platform</code> config property":#prefer_binary_platform_config_property (deprecated) for more info.
393
+
394
+ h2(#dealing_with_sudo). Dealing with sudo and root-owned RubyGem installations
395
+
396
+ If you only run geminstaller on Windows, you don't have to worry about this section :)
397
+
398
+ <strong>UPDATE:</strong>
399
+
400
+ Probably the best way to "deal with sudo" is to never use it at all, and recent releases of RubyGems will automatically install gems to ~/.gem if you run gem install commands as a non-root user. However, the RubyGems developers (Eric Hodel) have indicated that this feature may not remain, since it causes issues under Ruby 1.9. I have a "feature":http://thewoolleyweb.lighthouseapp.com/projects/11580/tickets/1-automatically-create-use-and-manage-writeable-gem-home-if-system-gem-home-is-not-writeable to track the progress of this issue.
401
+
402
+ <strong>FOR NOW, THOUGH, HERE'S HOW TO USE SUDO WITH GEMINSTALLER:</strong>
403
+
404
+ <strong>Important Note:</strong> For security, the sudo command does NOT pass most environment variables. See the faq item on "Environment Variables and sudo":../faq.html#environment_vars_and_sudo for more info.
405
+
406
+ On many unix-like systems (Mac, Linux, etc.), the root user will own the local installation of RubyGems (often /usr/local/ruby) and/or the executable directory where gem executables are installed (often /usr/local/bin). If this is the case, then gems must be installed and uninstalled by the root user, or via the sudo command. This presents a problem for geminstaller, which must have this same permission to automatically install gems.
407
+
408
+ There are several different solutions this problem. The solutions that are available are also determined by the way you use geminstaller (whether you call it from the executable, or use the GemInstaller classes directly from Ruby).
409
+
410
+ A transparent solution to this problem is planned for a future release of GemInstaller. For now, however, you will need to pick one of the following approaches below. If you use sudo, you should also read the docs on configuring sudo.
411
+
412
+ h3(#option_1). Option 1 - Use the <code>-s</code> or <code>--sudo</code> option on the <code>geminstaller</code> executable
413
+
414
+ Examples:
415
+ <pre><code>
416
+ $ geminstaller -s
417
+ $ geminstaller --sudo
418
+ </code></pre>
419
+
420
+ h3(#option_2). Option 2 - Run <code>sudo</code> or log in as root yourself. If you are running from a deploy script (Capistrano), this is probably the best option.
421
+
422
+ Example of using sudo:
423
+ <pre><code>
424
+ $ sudo geminstaller
425
+ </code></pre>
426
+
427
+ Examples of running geminstaller as root
428
+ <pre><code>
429
+ $ su - # if you can log in as root on your system, OR
430
+ $ sudo -s # if you must use sudo to log in as root on your system
431
+ # geminstaller
432
+ </code></pre>
433
+
434
+ h3(#option_3). Option 3 - Make everything owned by the local user that runs geminstaller
435
+
436
+ (replace <code><local user></code> with your username)
437
+ <pre><code>
438
+ $ cd /usr/local/lib/ruby # or wherever you have ruby installed
439
+ $ sudo chown -R <local user> .
440
+ </code></pre>
441
+
442
+ h3(#tips_on_configuring_sudo). Tips on configuring sudo
443
+
444
+ Sudo can be configured to not ask for a password for certain commands. This will be useful if you want to run geminstaller against a root-owned gem repository without being prompted (such as a Rails app being deployed via Capistrano).
445
+
446
+ You should consult the man or info pages on sudoers and visudo for more info (<code>man sudoers</code> or <code>info sudoers</code>). _*Make sure you understand the security implications of this approach*_.
447
+
448
+ 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:
449
+
450
+ <pre><code>
451
+ $ sudo visudo
452
+ add this line:
453
+ <local user> ALL = NOPASSWD: /usr/local/bin/geminstaller, /usr/local/bin/ruby, /usr/local/bin/gem
454
+ </code></pre>
455
+
456
+ h2(#automatically_requiring_gems_with_the_autogem_method). Automatically Requiring Gems with the <code>autogem</code> Method
457
+
458
+ GemInstaller provides a <code>GemInstaller.autogem</code> class method which will automatically invoke RubyGems' 'gem' method to add all of the gems in your GemInstaller config file(s) to the load path. On RubyGems versions 0.8.x, the 'require_gem' method is used instead.
459
+
460
+ If there are some gems you don't want to auto-require, you can set the '<code>no_autogem: true</code> config config property in the GemInstaller config file. This can be set for individual gems, or as a default.
461
+
462
+ 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):
463
+
464
+ <pre><code>
465
+ ...
466
+ GemInstaller.autogem('--config=/path/to/one/geminstaller.yml,/path/to/another/geminstaller.yml')
467
+ ...
468
+ </code></pre>
469
+
470
+ 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.
471
+
472
+ You can also use the "--exceptions" argument to cause <code>autogem</code> to throw an exception if it encounters any error. This is useful if you want to abort your application startup if any gems failed to load.
473
+
474
+ *IMPORTANT NOTE*: The RubyGems <code>'gem'</code> and <code>'require_gem'</code> commands will only load a single version of any given gem onto the load path. Because of this, the GemInstaller autogem command will only process the first version that it finds of any given gem.
475
+
476
+ For more info on the RubyGems 'gem and 'require_gem' commands, see "Using Explicit Versions":http://docs.rubygems.org/read/chapter/4#page71 in the RubyGems docs.