Parent

GemInstaller::RogueGemFinder

Attributes

output_proxy[W]
gem_command_manager[W]
gem_spec_manager[W]
boilerplate_lines[W]
preinstalled_gem_names[W]
preinstalled_comment[W]

Public Instance Methods

default_boilerplate_lines(config_gems, config_file_paths) click to toggle source
    # File lib/geminstaller/rogue_gem_finder.rb, line 34
34:     def default_boilerplate_lines(config_gems, config_file_paths)
35:       boilerplate = []
36:       boilerplate <<  [
37:         "#",
38:         "# This is a GemInstaller config file (http://geminstaller.rubyforge.org)",
39:         "# It was generated using the 'geminstaller --print-rogue-gems' option on #{Time.now}",
40:         "#",
41:         "# You can bootstrap your config by piping the output to a file: ",
42:         "#   'geminstaller --print-rogue-gems > geminstaller.yml'",
43:         "#",
44:         "# You can then install these gems on another system by running geminstaller with this file.",
45:         "#"
46:       ]
47:       
48:       if config_file_paths.size == 0
49:         boilerplate << "# Since there was no config file specified, the 'gems:' section below lists all gems on your system."
50:       else
51:         boilerplate << "# The following config file(s) and gems were already specified:"
52:         boilerplate << "#   Files:"
53:         config_file_paths.each do |config_file_path|
54:           boilerplate << "#     * " + config_file_path
55:         end
56:         boilerplate << "#   Gems:"
57:         if config_gems.size > 0
58:           config_gems.each do |config_gem|
59:             boilerplate << "#     * #{config_gem.name} #{config_gem.version}"
60:           end
61:         else
62:           boilerplate << "#     No Gems"
63:         end
64:       end
65:       boilerplate << "#"
66:       boilerplate << "defaults:"
67:       boilerplate << "  install_options: --include-dependencies"
68:       return boilerplate
69:     end
default_preinstalled_comment() click to toggle source
     # File lib/geminstaller/rogue_gem_finder.rb, line 141
141:     def default_preinstalled_comment
142:       "# NOTE: This gem may have been automatially installed with Ruby, and not actually be used by your app(s)."
143:     end
default_preinstalled_gem_names() click to toggle source
     # File lib/geminstaller/rogue_gem_finder.rb, line 71
 71:     def default_preinstalled_gem_names
 72:       # This is the list of preinstalled gems from the Ruby windows 1-click installer, v186-25
 73:       # 
 74:       # fxri (0.3.6)
 75:       #     Graphical interface to the RI documentation, with search engine.
 76:       # 
 77:       # fxruby (1.6.6)
 78:       #     FXRuby is the Ruby binding to the FOX GUI toolkit.
 79:       # 
 80:       # hpricot (0.4)
 81:       #     a swift, liberal HTML parser with a fantastic library
 82:       # 
 83:       # log4r (1.0.5)
 84:       #     Log4r is a comprehensive and flexible logging library for Ruby.
 85:       # 
 86:       # rake (0.7.2)
 87:       #     Ruby based make-like utility.
 88:       # 
 89:       # sources (0.0.1)
 90:       #     This package provides download sources for remote gem installation
 91:       # 
 92:       # win32-clipboard (0.4.1)
 93:       #     A package for interacting with the Windows clipboard
 94:       # 
 95:       # win32-dir (0.3.1)
 96:       #     Extra constants and methods for the Dir class on Windows.
 97:       # 
 98:       # win32-eventlog (0.4.3)
 99:       #     Interface for the MS Windows Event Log.
100:       # 
101:       # win32-file (0.5.3)
102:       #     Extra or redefined methods for the File class on Windows.
103:       # 
104:       # win32-file-stat (1.2.3)
105:       #     A File::Stat class tailored to MS Windows
106:       # 
107:       # win32-process (0.5.1)
108:       #     Adds fork, wait, wait2, waitpid, waitpid2 and a special kill method
109:       # 
110:       # win32-sapi (0.1.3)
111:       #     An interface to the MS SAPI (Sound API) library.
112:       # 
113:       # win32-sound (0.4.0)
114:       #     A package for playing with sound on Windows.
115:       # 
116:       # windows-pr (0.6.2)
117:       #     Windows functions and constants predefined via Win32API
118: 
119:       if RUBY_PLATFORM =~ /mswin/
120:         return [
121:           'fxri',
122:           'fxruby',
123:           'hpricot',
124:           'log4r',
125:           'rake',
126:           'sources',
127:           'win32-clipboard',
128:           'win32-dir',
129:           'win32-eventlog',
130:           'win32-file',
131:           'win32-file-stat',
132:           'win32-process',
133:           'win32-sapi',
134:           'win32-sound',
135:           'windows-pr'
136:         ]
137:       end
138:       return ['sources']
139:     end
format_to_yaml(gems) click to toggle source
     # File lib/geminstaller/rogue_gem_finder.rb, line 186
186:     def format_to_yaml(gems)
187:       names_and_versions = []
188:       gems.each do |gem|
189:         names_and_versions << {'name' => gem.name, 'version' => gem.version}
190:       end
191:       hash_for_yaml = {'gems' => names_and_versions}
192:       YAML.dump(hash_for_yaml)
193:     end
handle_output(yaml) click to toggle source
     # File lib/geminstaller/rogue_gem_finder.rb, line 145
145:     def handle_output(yaml)
146:       yaml_lines = yaml.split("\n")
147:       yaml_doc_separator = yaml_lines.delete_at(0)
148:       
149:       output = []
150:       output.push(yaml_doc_separator)
151:       
152:       output << @boilerplate_lines
153:       
154:       yaml_lines.each do |yaml_line| 
155:         name_parser_regexp = /- name: (.*)/
156:         yaml_line =~  name_parser_regexp
157:         gem_name = $1
158:         preinstalled_comment = ''
159:         if @preinstalled_gem_names.include?(gem_name)
160:           preinstalled_comment = " " + @preinstalled_comment
161:         end
162:         output.push yaml_line + preinstalled_comment
163:       end
164:       
165:       output_string = output.join("\n")
166:       @output_proxy.sysout output_string
167:       output_string
168:     end
process_gem(gem) click to toggle source
     # File lib/geminstaller/rogue_gem_finder.rb, line 170
170:     def process_gem(gem)
171:       @config_gems_with_dependencies << gem
172:       process_gem_dependencies(gem)
173:     end
process_gem_dependencies(gem) click to toggle source
     # File lib/geminstaller/rogue_gem_finder.rb, line 175
175:     def process_gem_dependencies(gem)
176:       # TODO: this method is duplicated in autogem  Should abstract and take a block
177:       matching_gems = @gem_spec_manager.local_matching_gems(gem)
178:       matching_gems.each do |matching_gem|
179:         dependency_gems = @gem_command_manager.dependency(matching_gem.name, matching_gem.version.to_s)
180:         dependency_gems.each do |dependency_gem|
181:           process_gem(dependency_gem)
182:         end
183:       end
184:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.