geminstaller 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/COPYING +1 -0
  2. data/History.txt +4 -0
  3. data/LICENSE +21 -0
  4. data/Manifest.txt +62 -0
  5. data/README.txt +60 -0
  6. data/Rakefile +92 -0
  7. data/TODO.txt +88 -0
  8. data/bin/geminstaller +30 -0
  9. data/geminstaller.yml +34 -0
  10. data/lib/geminstaller/application.rb +105 -0
  11. data/lib/geminstaller/arg_parser.rb +162 -0
  12. data/lib/geminstaller/autogem.rb +43 -0
  13. data/lib/geminstaller/config.rb +69 -0
  14. data/lib/geminstaller/config_builder.rb +40 -0
  15. data/lib/geminstaller/dependency_injector.rb +129 -0
  16. data/lib/geminstaller/enhanced_stream_ui.rb +57 -0
  17. data/lib/geminstaller/exact_match_list_command.rb +16 -0
  18. data/lib/geminstaller/file_reader.rb +31 -0
  19. data/lib/geminstaller/gem_arg_processor.rb +44 -0
  20. data/lib/geminstaller/gem_command_line_proxy.rb +32 -0
  21. data/lib/geminstaller/gem_command_manager.rb +62 -0
  22. data/lib/geminstaller/gem_interaction_handler.rb +30 -0
  23. data/lib/geminstaller/gem_list_checker.rb +55 -0
  24. data/lib/geminstaller/gem_runner_proxy.rb +43 -0
  25. data/lib/geminstaller/gem_source_index_proxy.rb +21 -0
  26. data/lib/geminstaller/gem_spec_manager.rb +42 -0
  27. data/lib/geminstaller/geminstaller_error.rb +13 -0
  28. data/lib/geminstaller/hoe_extensions.rb +5 -0
  29. data/lib/geminstaller/install_processor.rb +56 -0
  30. data/lib/geminstaller/missing_dependency_finder.rb +41 -0
  31. data/lib/geminstaller/missing_file_error.rb +4 -0
  32. data/lib/geminstaller/noninteractive_chooser.rb +107 -0
  33. data/lib/geminstaller/output_filter.rb +49 -0
  34. data/lib/geminstaller/output_listener.rb +33 -0
  35. data/lib/geminstaller/output_observer.rb +32 -0
  36. data/lib/geminstaller/output_proxy.rb +36 -0
  37. data/lib/geminstaller/requires.rb +59 -0
  38. data/lib/geminstaller/rogue_gem_finder.rb +195 -0
  39. data/lib/geminstaller/ruby_gem.rb +44 -0
  40. data/lib/geminstaller/rubygems_exit.rb +5 -0
  41. data/lib/geminstaller/rubygems_extensions.rb +5 -0
  42. data/lib/geminstaller/unauthorized_dependency_prompt_error.rb +4 -0
  43. data/lib/geminstaller/unexpected_prompt_error.rb +4 -0
  44. data/lib/geminstaller/valid_platform_selector.rb +44 -0
  45. data/lib/geminstaller/version_specifier.rb +24 -0
  46. data/lib/geminstaller/yaml_loader.rb +22 -0
  47. data/lib/geminstaller.rb +102 -0
  48. data/start_local_gem_server.sh +1 -0
  49. data/test/test_all.rb +31 -0
  50. data/website/config.yaml +2 -0
  51. data/website/metainfo.yaml +72 -0
  52. data/website/src/code/index.page +25 -0
  53. data/website/src/community/index.page +14 -0
  54. data/website/src/community/links.page +9 -0
  55. data/website/src/default.css +168 -0
  56. data/website/src/default.template +41 -0
  57. data/website/src/documentation/documentation.page +417 -0
  58. data/website/src/documentation/index.page +88 -0
  59. data/website/src/documentation/tutorials.page +94 -0
  60. data/website/src/download.page +12 -0
  61. data/website/src/faq.page +7 -0
  62. data/website/src/index.page +38 -0
  63. metadata +107 -0
data/COPYING ADDED
@@ -0,0 +1 @@
1
+ Placeholder...
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 / 2006-07-29
2
+
3
+ * 1 major enhancement
4
+ * Initial Creation
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2006 Chad Woolley
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/Manifest.txt ADDED
@@ -0,0 +1,62 @@
1
+ COPYING
2
+ History.txt
3
+ LICENSE
4
+ Manifest.txt
5
+ README.txt
6
+ Rakefile
7
+ TODO.txt
8
+ bin/geminstaller
9
+ geminstaller.yml
10
+ lib/geminstaller.rb
11
+ lib/geminstaller/application.rb
12
+ lib/geminstaller/arg_parser.rb
13
+ lib/geminstaller/autogem.rb
14
+ lib/geminstaller/config.rb
15
+ lib/geminstaller/config_builder.rb
16
+ lib/geminstaller/dependency_injector.rb
17
+ lib/geminstaller/enhanced_stream_ui.rb
18
+ lib/geminstaller/exact_match_list_command.rb
19
+ lib/geminstaller/file_reader.rb
20
+ lib/geminstaller/gem_arg_processor.rb
21
+ lib/geminstaller/gem_command_line_proxy.rb
22
+ lib/geminstaller/gem_command_manager.rb
23
+ lib/geminstaller/gem_interaction_handler.rb
24
+ lib/geminstaller/gem_list_checker.rb
25
+ lib/geminstaller/gem_runner_proxy.rb
26
+ lib/geminstaller/gem_source_index_proxy.rb
27
+ lib/geminstaller/gem_spec_manager.rb
28
+ lib/geminstaller/geminstaller_error.rb
29
+ lib/geminstaller/hoe_extensions.rb
30
+ lib/geminstaller/install_processor.rb
31
+ lib/geminstaller/missing_dependency_finder.rb
32
+ lib/geminstaller/missing_file_error.rb
33
+ lib/geminstaller/noninteractive_chooser.rb
34
+ lib/geminstaller/output_filter.rb
35
+ lib/geminstaller/output_listener.rb
36
+ lib/geminstaller/output_observer.rb
37
+ lib/geminstaller/output_proxy.rb
38
+ lib/geminstaller/requires.rb
39
+ lib/geminstaller/rogue_gem_finder.rb
40
+ lib/geminstaller/ruby_gem.rb
41
+ lib/geminstaller/rubygems_exit.rb
42
+ lib/geminstaller/rubygems_extensions.rb
43
+ lib/geminstaller/unauthorized_dependency_prompt_error.rb
44
+ lib/geminstaller/unexpected_prompt_error.rb
45
+ lib/geminstaller/valid_platform_selector.rb
46
+ lib/geminstaller/version_specifier.rb
47
+ lib/geminstaller/yaml_loader.rb
48
+ start_local_gem_server.sh
49
+ test/test_all.rb
50
+ website/config.yaml
51
+ website/metainfo.yaml
52
+ website/src/code/index.page
53
+ website/src/community/index.page
54
+ website/src/community/links.page
55
+ website/src/default.css
56
+ website/src/default.template
57
+ website/src/documentation/documentation.page
58
+ website/src/documentation/index.page
59
+ website/src/documentation/tutorials.page
60
+ website/src/download.page
61
+ website/src/faq.page
62
+ website/src/index.page
data/README.txt ADDED
@@ -0,0 +1,60 @@
1
+ GemInstaller
2
+ by Chad Woolley
3
+ http://geminstaller.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
7
+ GemInstaller provides automated management of RubyGems.
8
+
9
+ == FEATURES:
10
+
11
+ GemInstaller provides automated management of RubyGems. It uses a simple YAML config file to:
12
+
13
+ * Automatically install the correct versions of all required gems wherever your app runs.
14
+ * Automatically ensure installed gems and versions are consistent across multiple applications, machines, platforms, and environments
15
+ * Automatically add correct versions of gems to the ruby load path when your app runs ('require_gem'/'gem')
16
+ * Automatically reinstall missing dependency gems
17
+ * Automatically guess at correct platform to install for multi-platform gems
18
+ * Print YAML for "rogue gems" which are not specified in the current config, to easily bootstrap your config file, or find gems that were manually installed without GemInstaller.
19
+ * Avoid the "works on demo, broken on production" syndrome
20
+
21
+ == SYNOPSYS:
22
+
23
+ GemInstaller provides automated management of RubyGems.
24
+
25
+ === Download:
26
+
27
+ Downloads are available at http://rubyforge.org/frs/?group_id=1902
28
+
29
+ === Quick Start:
30
+
31
+ See http://geminstaller.rubyforge.org/documentation/index.html
32
+
33
+ == INSTALL:
34
+
35
+ * [sudo] gem install geminstaller
36
+
37
+ == LICENSE:
38
+
39
+ (The MIT License)
40
+
41
+ Copyright (c) 2006 Chad Woolley
42
+
43
+ Permission is hereby granted, free of charge, to any person obtaining
44
+ a copy of this software and associated documentation files (the
45
+ 'Software'), to deal in the Software without restriction, including
46
+ without limitation the rights to use, copy, modify, merge, publish,
47
+ distribute, sublicense, and/or sell copies of the Software, and to
48
+ permit persons to whom the Software is furnished to do so, subject to
49
+ the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be
52
+ included in all copies or substantial portions of the Software.
53
+
54
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
55
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
56
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
57
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
58
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
59
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
60
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,92 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'hoe'
6
+ rescue LoadError
7
+ abort "ERROR: GemInstaller has build- and test-time dependencies
8
+ on Hoe and other libraries. Run the 'geminstaller'
9
+ executable from the root of the geminstaller source
10
+ tree, and GemInstaller will automatically install
11
+ these dependencies."
12
+ end
13
+
14
+ require './lib/geminstaller.rb'
15
+ require './lib/geminstaller/hoe_extensions.rb'
16
+
17
+ IndependentHoe.new('geminstaller', GemInstaller.version) do |p|
18
+ p.author = 'Chad Woolley'
19
+ p.rubyforge_name = 'geminstaller'
20
+ p.summary = p.paragraphs_of('README.txt', 1).first.split(/\n/)[2]
21
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
22
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
23
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
24
+ p.clean_globs << 'coverage'
25
+ p.clean_globs << 'website/output'
26
+ p.extra_deps = []
27
+ end
28
+
29
+ desc "Run all metrics"
30
+ task :metrics do
31
+ Rake::Task[:coverage].invoke
32
+ Rake::Task[:audit].invoke
33
+ end
34
+
35
+ task :coverage do
36
+ rm_rf "coverage"
37
+ rm_rf "website/output/code/coverage"
38
+ sh "mkdir -p website/output/code"
39
+ sh "rcov -o website/output/code/coverage test/test_all.rb"
40
+ end
41
+
42
+ desc "Diff the manifest"
43
+ task :diff_manifest => :clean do
44
+ f = "Manifest.tmp"
45
+ require 'find'
46
+ files = []
47
+ Find.find '.' do |path|
48
+ next unless File.file? path
49
+ next if path =~ /\.svn|tmp$|CVS/
50
+ next if path =~ /\.iml|\.ipr|\.iws|\.kpf|\.tmproj|\.project/
51
+ next if path =~ /\.\/spec/
52
+ next if path =~ /\.\/pkg/
53
+ next if path =~ /\.\/output/
54
+ next if path =~ /\.\/website\/output/
55
+ files << path[2..-1]
56
+ end
57
+ files = files.sort.join "\n"
58
+ File.open f, 'w' do |fp| fp.puts files end
59
+ system "diff -du Manifest.txt #{f}"
60
+ rm f
61
+ end
62
+
63
+ desc "Update the manifest"
64
+ task :update_manifest do
65
+ system('rake diff_manifest | patch -p0 Manifest.txt')
66
+ end
67
+
68
+ desc "Run Webgen to generate website"
69
+ task :webgen do
70
+ # rm_rf "website/output"
71
+ sh "webgen -d website"
72
+ end
73
+
74
+ desc "Move ri docs to website"
75
+ task :website_rdocs => :docs do
76
+ rm_rf "website/output/code/rdoc"
77
+ sh "mkdir -p website/output/code/"
78
+ mv "doc", "website/output/code/rdoc"
79
+ end
80
+
81
+ desc "Generate ri locally for testing"
82
+ task :website => [:webgen, :website_rdocs, :coverage] do
83
+ end
84
+
85
+ desc 'Publish website to RubyForge'
86
+ task :publish_website => [:clean, :website] do
87
+ host = "thewoolleyman@rubyforge.org"
88
+ remote_dir = "/var/www/gforge-projects/geminstaller"
89
+ local_dir = 'website/output'
90
+ sh %{rsync -av --delete --exclude=statsvn #{local_dir}/ #{host}:#{remote_dir}}
91
+ end
92
+ # vim: syntax=Ruby
data/TODO.txt ADDED
@@ -0,0 +1,88 @@
1
+ * upload gem
2
+ ================ 0.2.0 release ===================
3
+ * docs should indicate that I eat my own dog food
4
+ * update docs with details on how to handle unmet dependencies when -y is not specified
5
+ * tutorial: rails
6
+ * tutorial: using common or shared config files, with different configs for different environments - test (rspec) vs. dev (capistrano) vs. demo/staging/prod
7
+ * tutorial: running via capistrano
8
+ * crossreference front page, tutorials, and docs
9
+ * put mongrel/rails startup bug in tracker, add link in "known bugs" section on home page.
10
+ * links - rspec, rubygems
11
+ ================ 0.2.0 finishing website ===================
12
+ * make valid_platform_selector use data from tattle
13
+ * autogem and run args can be passed as string or array
14
+ * tell rspec not to alphabetize my specs, or figure out how to not run testgemhome in the middle and have it set up test gem home twice
15
+ * better test coverage for --sudo and --exception options
16
+ * Verify compatibility with RubyGems trunk - especially Gem::ListCommand vs. Gem::Commands::ListCommand
17
+ * use rspec context_setup
18
+ * split out geminstaller_spec into application_spec and geminstaller_spec. Fix reference in docs / design
19
+ * newlines printed between dots when "updating" message is included in error message
20
+ * Error on activerecord for brand-new rubygems installation - couldn't find gem. Did a gem list --remote activerecord, then it went away (got sudo error), then happened again, then worked when I passed -gall -rall options.
21
+ * Fastthread = only shows version 0.6.2 on windows, rubygems 0.9 ???
22
+ * geminstaller_spec autogem spec must have the GemRunner "initialized" or else the stub gem in test_gem_home won't be found by autogem.
23
+ * fix_dependencies=true takes FOREVER on windows
24
+ * echo stdin, lists presented for debug output levels
25
+ * Just ignore sudo option on windows, rather than throwing an error
26
+ * why does windows try to reinstall fxruby 1.6.6 when it is already installed???
27
+ * Figure out how to avoid checking dependency gems multiple times if multiple dependent gems depend on them.
28
+ * write coverage_no_platform_specific rake task (to get 100% coverage on a mac)
29
+ * On rogue gems, allow configuration of gems which are auto-installed and/or should be ignored.
30
+ * add option to print rogue gems with no extra output, for concatenation to existing gem list
31
+ * Research what all existing gem platforms are. See if they can all be covered in valid_platform_selector
32
+ * Can GemInstaller handle multiple gem server sources via multiple config files?
33
+ * Handle default gems that come with ruby/rubygems windows distro.
34
+ * refactor enhanced_stream_ui.ask_yes_no - does it need to catch the exception? Also review context name (no OutputProxy) and use of StringIO, and exception tests.
35
+ * rename enhanced_stream_ui to noninteractive_stream_ug
36
+ * add multilevel dependency smoketests for autogem (old rails version)
37
+ * refactor duplication in autogem/rogue_gem_finder using blocks
38
+ * rubygems stdout - don't print prefix for single dot
39
+ * clean up regexps - no leading or trailing .*
40
+ * Return meaningful message instructing to use the --sudo option if Errno::EACCES is caught on a sudo-able platform - should throw GemInstaller::AccessException, which can be caught
41
+ * Rails integration doesn't work under mongrel when invoked via executable (e.g, actionmailer gem not recognized after install, only after mongrel restart). Does't occur under webrick, or if geminstaller is invoked programatically via class.
42
+ * rails example doesn't print any warning if geminstaller is not installed
43
+ * "Installing gem" messages are duplicated if info message is specified, one from rubygems, one from geminstaller. See todo in install_processor.rb
44
+ * boot.rb parsed twice under webrick?
45
+ * commandecho doesn't print regexps correctly
46
+ * code coverage for logic paths supporting old rubygems versions
47
+ * spec_utils - use extend+include ClassAndInstanceMethods approach
48
+ * clean up registry - third-party first, no dependency next, alphabetized
49
+ * review/clean up ri/rdoc
50
+ * Better errors for invalid yaml (unsupported keys)
51
+ ========= 0.3.0 release ==============
52
+ * patch hoe to install_gem without sudo on windows
53
+ * understand why '> 1' must be quoted to be a valid yaml value - see yaml_loader_spec.rb
54
+ * tests failed when "partially" connected to network? (wireless at office)
55
+ * tests fail with timeouts intermittently on windows
56
+ * add more tests for dependencies to geminstaller_spec
57
+ * reconcile methods for testing error messages - manually vs proc_should_raise_with_message. Probably should patch rspec.
58
+ * remove test_gem_home.reset from geminstaller_spec.rb WITHOUT breaking the test suite.
59
+ * tests fail on windows - seems to be related to test_gem_home running twice. smoketest still passes.
60
+ * Use rubygems executables from test_gem_home. In order to do this, we must run test_gem_home and ensure it is on the load path BEFORE the system installation of rubygems ever gets initialized. We will also have to manually include all geminstaller test dependency gems in test_gem_home or on the path. Tried this once and failed, patch on linux box...
61
+ * clean up spec_utils - remove duplication of class and instance methods
62
+ * spec_utils global teardown method which uninstalls all gems
63
+ * can't run binary out of source dir unless running it via ruby
64
+ * running binary via ruby out of bin dir will pick up gem first on load path if it is installed
65
+ * verify that >= version spec works with a specific platform, if that platform is not available for the highest version
66
+ * Check for write access, and exit with warning to use sudo if there is no write access.
67
+ * store rubygems dist as a tar, and untar it on demand
68
+ * Add spec file name to all contexts (or see if rspec can do it automatically)
69
+ * Make GemInstaller.run take a parameter to not fail if there is any error
70
+ * Embedded gem_server process doesn't get killed on windows during tests - need to use ruby services, see comment in embedded_gem_server.rb
71
+ * Embedded gem_server ports aren't handled correctly on linux during tests - port conflict on startup, open ports die off slowly after tests finish
72
+ * Do a port check before starting embedded gem server, give option to kill process or at least exit with a descriptive warning.
73
+ * Clean up spec_helper, find out simplest way to invoke rspec via test_unit, and still provide proper return codes/output
74
+ * remove cruft from test output - intercept output streams from gem_server and rubygems setup
75
+ * enhance DependencyInjector - allow items to be substituted prior to initialization - then geminstaller_spec could simply set a mock output_proxy on the registry instead of explicitly setting it every place it is used.
76
+ * ensure --debug install option works as expected
77
+ * fix all Zentest warnings
78
+ * Rename RubyGem class to RubyGemAction, add install vs. uninstall actions in config (install is default)
79
+ * Automate process for creating a stubgem
80
+ * Give nice error message if gem server is unavailable (check socket)
81
+ * Make tests run under RadRails debugger
82
+ * handle unsupported gem install options - for example, -t gives uninitialized constant Gem::Validator
83
+ * update info in stubgem (not sow defaults)
84
+ * Fix errors when using relative or ~/ dir in --config path
85
+ * make verbose option specify --backtrace on all gem commands
86
+ * Add support, syntax, and options for uninstalling gems - completely, or down to highest specified version.
87
+ * add feature to automatically warn if there is a more recent version of the gem available and check_for_upgrade == false. Use "gem outdated" command
88
+ * auto-generate geminstaller.yml files (possibly by parsing source, or based on all gems installed locally)
data/bin/geminstaller ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ dir = File.dirname(__FILE__)
4
+
5
+ begin
6
+ require 'geminstaller'
7
+ rescue LoadError
8
+ require 'rubygems'
9
+ begin
10
+ # try load path
11
+ require 'geminstaller'
12
+ rescue LoadError
13
+ begin
14
+ # try lib subdir (TODO: is this necessary?)
15
+ require 'lib/geminstaller'
16
+ rescue LoadError
17
+ # try lib dir as peer of current dir
18
+ require "#{dir}/../lib/geminstaller"
19
+ end
20
+ end
21
+ end
22
+
23
+ geminstaller_executable ||= File.join(File.expand_path(dir), 'geminstaller')
24
+
25
+ if ARGV.include?('--geminstaller-exec-path')
26
+ print "geminstaller_exec_path=#{geminstaller_executable}"
27
+ exit 0
28
+ end
29
+
30
+ exit GemInstaller.run(ARGV, geminstaller_executable)
data/geminstaller.yml ADDED
@@ -0,0 +1,34 @@
1
+ ---
2
+ # GemInstaller config file which specifies the actual build, test, and doc dependencies for GemInstaller itself.
3
+ defaults:
4
+ install_options: --include-dependencies
5
+ gems:
6
+ - name: diff-lcs
7
+ version: '>= 1.1.2'
8
+ - name: hoe
9
+ version: '>= 1.1.6'
10
+ - name: rake
11
+ version: '>= 0.7.1'
12
+ - name: rcov
13
+ version: '>= 0.7.0.1'
14
+ platform: <%= RUBY_PLATFORM =~ /mswin/ ? 'mswin32' : 'ruby'%>
15
+ - name: RedCloth
16
+ version: '>= 3.0.4'
17
+ - name: rspec
18
+ version: '= 0.9.3'
19
+ - name: cmdparse
20
+ version: '>= 2.0.2'
21
+ - name: webgen
22
+ version: '>= 0.4.2'
23
+ <% if RUBY_PLATFORM =~ /mswin/ %>
24
+ - name: win32-process
25
+ version: '>= 0.5.0'
26
+ platform: 'mswin32'
27
+ - name: win32console
28
+ version: '>= 1.0.8'
29
+ platform: 'mswin32'
30
+ - name: win32-open3
31
+ version: '>= 0.2.5'
32
+ platform: 'mswin32'
33
+ <% end %>
34
+
@@ -0,0 +1,105 @@
1
+ module GemInstaller
2
+ class Application
3
+ # we have accessors instead of just writers so that we can ensure it is assembled correctly in the dependency injector test
4
+ attr_accessor :config_builder, :install_processor, :output_filter, :arg_parser, :args, :options, :rogue_gem_finder
5
+ attr_writer :autogem
6
+
7
+ def initialize
8
+ @args = nil
9
+ end
10
+
11
+ def run
12
+ begin
13
+ exit_flag_and_return_code = handle_args
14
+ if exit_flag_and_return_code[0]
15
+ return exit_flag_and_return_code[1]
16
+ end
17
+ gems = create_gems_from_config
18
+ if @options[:print_rogue_gems]
19
+ @rogue_gem_finder.print_rogue_gems(gems, @config_builder.config_file_paths_array)
20
+ return 0
21
+ end
22
+ if gems.size == 0
23
+ message = "No gems found in config file. Try the --print-rogue-gems option to help populate your config file."
24
+ @output_filter.geminstaller_output(:info,message + "\n")
25
+ else
26
+ process_gems(gems)
27
+ end
28
+ rescue Exception => e
29
+ handle_exception(e)
30
+ return 1
31
+ end
32
+ return 0
33
+ end
34
+
35
+ def autogem
36
+ begin
37
+ # TODO: do some validation that args only contains --config option, especially not print_rogue_gems since this would mask a missing file error
38
+ exit_flag_and_return_code = handle_args
39
+ if exit_flag_and_return_code[0]
40
+ return exit_flag_and_return_code[1]
41
+ end
42
+ gems = create_gems_from_config
43
+ message = "GemInstaller is automatically requiring gems: "
44
+ print_startup_message(gems, message)
45
+ return @autogem.autogem(gems)
46
+ rescue Exception => e
47
+ handle_exception(e)
48
+ return 1
49
+ end
50
+ end
51
+
52
+ def handle_exception(e)
53
+ message = e.message
54
+ message += "\n"
55
+ @output_filter.geminstaller_output(:error,message)
56
+ backtrace_as_string = e.backtrace.join("\n")
57
+ @output_filter.geminstaller_output(:debug,"#{backtrace_as_string}\n")
58
+ raise e if @options[:exceptions]
59
+ end
60
+
61
+ def create_gems_from_config
62
+ begin
63
+ config = @config_builder.build_config
64
+ rescue GemInstaller::MissingFileError => e
65
+ # if user wants to print rogue gems and they have no config at all, don't show an error
66
+ return [] if @options[:print_rogue_gems] && (@config_builder.config_file_paths_array.size == 1)
67
+ missing_path = e.message
68
+ error_message = "Error: A GemInstaller config file is missing at #{missing_path}. You can generate one with the --print-rogue-gems option. See the GemInstaller docs at http://geminstaller.rubyforge.org for more info."
69
+ raise GemInstaller::MissingFileError.new(error_message)
70
+ end
71
+ config.gems
72
+ end
73
+
74
+ def process_gems(gems)
75
+ message = "GemInstaller is verifying gem installation: "
76
+ print_startup_message(gems, message)
77
+ @install_processor.process(gems)
78
+ end
79
+
80
+ def handle_args
81
+ return_code = @arg_parser.parse(@args)
82
+ arg_parser_output = @arg_parser.output
83
+ if (arg_parser_output && arg_parser_output != '')
84
+ if return_code == 0
85
+ @output_filter.geminstaller_output(:info,arg_parser_output)
86
+ else
87
+ @output_filter.geminstaller_output(:error,arg_parser_output)
88
+ end
89
+ return [true, return_code]
90
+ end
91
+ config_file_paths = @options[:config_paths]
92
+ @config_builder.config_file_paths = config_file_paths if config_file_paths
93
+ return [false, 0]
94
+ end
95
+
96
+ def print_startup_message(gems, message)
97
+ gems.each_with_index do |gem, index|
98
+ gem_info = "#{gem.name} #{gem.version}"
99
+ message += gem_info
100
+ message += ", " if index + 1 < gems.size
101
+ end
102
+ @output_filter.geminstaller_output(:info,message + "\n")
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,162 @@
1
+ module GemInstaller
2
+ class ArgParser
3
+ attr_reader :output
4
+ attr_writer :options
5
+
6
+ VALID_GEMINSTALLER_OUTPUT_FLAGS = [:none,:error,:install,:info,:commandecho,:debug,:all]
7
+ VALID_RUBYGEMS_OUTPUT_FLAGS = [:none,:stdout,:stderr,:all]
8
+
9
+ def parse(args = [])
10
+ raise GemInstaller::GemInstallerError.new("Args must be passed as an array.") unless args.nil? or args.respond_to? :shift
11
+ args = ARGV if args.nil? || args == []
12
+
13
+ @options[:exceptions] = false
14
+ @options[:redirect_stderr_to_stdout] = false
15
+ @options[:silent] = false
16
+ @options[:sudo] = false
17
+ @options[:geminstaller_output] = [:error,:install,:info]
18
+ @options[:rubygems_output] = [:stderr]
19
+ @output = ""
20
+ opts = OptionParser.new do |opts|
21
+ opts.banner = "Usage: geminstaller [options]"
22
+
23
+ opts.separator ""
24
+
25
+ config_msg = "Comma-delimited path(s) to GemInstaller config file(s)."
26
+ exceptions_msg = "Raise any exceptions, rather than just printing them and exiting\n" +
27
+ " with a non-zero return code."
28
+ redirect_stderr_to_stdout_msg = "Redirect all STDERR output to STDOUT. Useful to get all output when\n" +
29
+ " invoking GemInstaller via system()."
30
+ geminstaller_output_msg = "Comma-delimited list of output types to show from GemInstaller.\n" +
31
+ " Examples:\n" +
32
+ " --gall\n" +
33
+ " --geminstaller-output=error,install,commandecho\n" +
34
+ " Default: error,install,info\n" +
35
+ " Valid types:\n" +
36
+ " - none: print only fatal errors\n" +
37
+ " - error: print error messages\n" +
38
+ " - install: print install messages\n" +
39
+ " - info: print informational messages\n" +
40
+ " - commandecho: print rubygems commands as they are invoked\n" +
41
+ " - debug: print debug messages\n" +
42
+ " - all: print all messages"
43
+ help_msg = "Show this message."
44
+ print_rogue_gems_msg = "Print a report of all locally installed gems which are not specified\n" +
45
+ " in the geminstaller config file."
46
+ rubygems_output_msg = "Comma-delimited list of output types to show from internal:\n" +
47
+ " RubyGems command invocation.\n" +
48
+ " Examples:\n" +
49
+ " --rall\n" +
50
+ " --rubygems-output=stderr\n" +
51
+ " Default: stderr\n" +
52
+ " Valid types:\n" +
53
+ " - none: print no output\n" +
54
+ " - stdout: print standard output stream\n" +
55
+ " - stderr: print standard error stream\n" +
56
+ " - all: print all output"
57
+ sudo_msg = "Perform all gem operations under sudo (as root). Will only work on\n" +
58
+ " correctly configured, supported systems. See docs for more info."
59
+ silent_msg = "Suppress all output except fatal exceptions, and output from\n" +
60
+ " rogue-gems option."
61
+ version_msg = "Show GemInstaller version and exit."
62
+
63
+ opts.on("-cCONFIGPATHS", "--config=CONFIGPATHS", String, config_msg) do |config_paths|
64
+ @options[:config_paths] = config_paths
65
+ end
66
+
67
+ opts.on("-e", "--exceptions", exceptions_msg) do
68
+ @options[:exceptions] = true
69
+ end
70
+
71
+ opts.on("-d", "--redirect-stderr-to-stdout", redirect_stderr_to_stdout_msg) do
72
+ @options[:redirect_stderr_to_stdout] = true
73
+ end
74
+
75
+ opts.on("-gTYPES", "--geminstaller-output=TYPES", String, geminstaller_output_msg) do |geminstaller_output_flags|
76
+ @unparsed_geminstaller_output_flags = geminstaller_output_flags
77
+ end
78
+
79
+ opts.on("-h", "--help", help_msg) do
80
+ @output = opts.to_s
81
+ end
82
+
83
+ opts.on("-p", "--print-rogue-gems", print_rogue_gems_msg) do
84
+ @options[:print_rogue_gems] = true
85
+ end
86
+
87
+ opts.on("-rTYPES", "--rubygems-output=TYPES", String, rubygems_output_msg) do |rubygems_output_flags|
88
+ @unparsed_rubygems_output_flags = rubygems_output_flags
89
+ end
90
+
91
+ opts.on("-s", "--sudo", sudo_msg) do
92
+ @options[:sudo] = true
93
+ end
94
+
95
+ opts.on("-t", "--silent", silent_msg) do
96
+ @options[:silent] = true
97
+ end
98
+
99
+ opts.on("-v", "--version", version_msg) do
100
+ @output = "#{GemInstaller::version}\n"
101
+ end
102
+ end
103
+
104
+ begin
105
+ opts.parse!(args)
106
+ rescue(OptionParser::InvalidOption)
107
+ @output << opts.to_s
108
+ return 1
109
+ end
110
+
111
+ if @options[:silent] and (@unparsed_geminstaller_output_flags or @unparsed_rubygems_output_flags)
112
+ @output = "The rubygems-output or geminstaller-output option cannot be specified if the silent option is true."
113
+ return 1
114
+ end
115
+
116
+ if (@options[:sudo])
117
+ @output = "The sudo option is not (yet) supported when invoking GemInstaller programatically. It is only supported when using the command line 'geminstaller' executable. See the docs for more info."
118
+ return 1
119
+ end
120
+
121
+ # TODO: remove duplication
122
+ if @unparsed_geminstaller_output_flags
123
+ flags = @unparsed_geminstaller_output_flags.split(',')
124
+ flags.delete_if {|flag| flag == nil or flag == ''}
125
+ flags.map! {|flag| flag.downcase}
126
+ flags.sort!
127
+ flags.uniq!
128
+ flags.map! {|flag| flag.to_sym}
129
+ geminstaller_output_valid = true
130
+ flags.each do |flag|
131
+ unless VALID_GEMINSTALLER_OUTPUT_FLAGS.include?(flag)
132
+ @output = "Invalid geminstaller-output flag: #{flag}\n"
133
+ geminstaller_output_valid = false
134
+ end
135
+ end
136
+ @options[:geminstaller_output] = flags if geminstaller_output_valid
137
+ end
138
+
139
+ if @unparsed_rubygems_output_flags
140
+ flags = @unparsed_rubygems_output_flags.split(',')
141
+ flags.delete_if {|flag| flag == nil or flag == ''}
142
+ flags.map! {|flag| flag.downcase}
143
+ flags.sort!
144
+ flags.uniq!
145
+ flags.map! {|flag| flag.to_sym}
146
+ rubygems_output_valid = true
147
+ flags.each do |flag|
148
+ unless VALID_RUBYGEMS_OUTPUT_FLAGS.include?(flag)
149
+ @output = "Invalid rubygems-output flag: #{flag}\n"
150
+ rubygems_output_valid = false
151
+ end
152
+ end
153
+ @options[:rubygems_output] = flags if rubygems_output_valid
154
+ end
155
+
156
+ # nil out @output if there was no output
157
+ @output = nil if @output == ""
158
+ return 0
159
+
160
+ end
161
+ end
162
+ end