royw-drbman 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *~
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Roy Wright
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.
data/README.rdoc ADDED
@@ -0,0 +1,14 @@
1
+ = drbman
2
+
3
+ Support for running ruby tasks via drb (druby) on multiple cores and/or systems.
4
+
5
+ Drbman provides:
6
+ * the infrastructure for pushing ruby code to remote systems,
7
+ * installing remote gems
8
+ * starting and stopping the remote drb server(s)
9
+ * cleaning up the remote system by removing any artifacts used
10
+
11
+
12
+ == Copyright
13
+
14
+ Copyright (c) 2009 Roy Wright. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "drbman"
8
+ gem.summary = 'Support for running ruby tasks via drb (druby) on multiple cores and/or systems.'
9
+ gem.email = "roy@wright.org"
10
+ gem.homepage = "http://github.com/royw/drbman"
11
+ gem.authors = ["Roy Wright"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ gem.add_dependency('log4r', '>=1.0.5')
14
+ gem.add_dependency('user-choices', '>=1.1.6')
15
+ gem.add_dependency('extlib', '>=0.9.12')
16
+ gem.add_dependency('versionomy', '>=0.0.4')
17
+ gem.add_dependency('net-ssh', '>=2.0.11')
18
+ gem.add_dependency('net-scp', '>=1.0.2')
19
+ end
20
+
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ require 'spec/rake/spectask'
26
+ Spec::Rake::SpecTask.new(:spec) do |spec|
27
+ spec.libs << 'lib' << 'spec'
28
+ spec.spec_files = FileList['spec/**/*_spec.rb']
29
+ end
30
+
31
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
32
+ spec.libs << 'lib' << 'spec'
33
+ spec.pattern = 'spec/**/*_spec.rb'
34
+ spec.rcov = true
35
+ end
36
+
37
+
38
+ task :default => :spec
39
+
40
+ require 'rake/rdoctask'
41
+ Rake::RDocTask.new do |rdoc|
42
+ if File.exist?('VERSION.yml')
43
+ config = YAML.load(File.read('VERSION.yml'))
44
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
45
+ else
46
+ version = ""
47
+ end
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "drbman #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
54
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/drbman ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/drbman")
4
+
5
+ require "drbman"
6
+
7
+ CLI.execute
data/drbman.gemspec ADDED
@@ -0,0 +1,91 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{drbman}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Roy Wright"]
9
+ s.date = %q{2009-07-14}
10
+ s.default_executable = %q{drbman}
11
+ s.email = %q{roy@wright.org}
12
+ s.executables = ["drbman"]
13
+ s.extra_rdoc_files = [
14
+ "LICENSE",
15
+ "README.rdoc"
16
+ ]
17
+ s.files = [
18
+ ".document",
19
+ ".gitignore",
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "bin/drbman",
25
+ "drbman.gemspec",
26
+ "examples/primes/VERSION",
27
+ "examples/primes/bin/primes",
28
+ "examples/primes/lib/drb_server/prime_helper.rb",
29
+ "examples/primes/lib/primes.rb",
30
+ "examples/primes/lib/primes/cli.rb",
31
+ "examples/primes/lib/primes/kernel_extensions.rb",
32
+ "examples/primes/lib/primes/primes.rb",
33
+ "examples/primes/lib/primes/sieve_of_eratosthenes.rb",
34
+ "examples/primes/spec/primes_spec.rb",
35
+ "examples/primes/spec/spec_helper.rb",
36
+ "lib/drbman.rb",
37
+ "lib/drbman/cli.rb",
38
+ "lib/drbman/drb_pool.rb",
39
+ "lib/drbman/drbman.rb",
40
+ "lib/drbman/host_machine.rb",
41
+ "spec/drbman_spec.rb",
42
+ "spec/host_machine_spec.rb",
43
+ "spec/spec_helper.rb"
44
+ ]
45
+ s.homepage = %q{http://github.com/royw/drbman}
46
+ s.rdoc_options = ["--charset=UTF-8"]
47
+ s.require_paths = ["lib"]
48
+ s.rubygems_version = %q{1.3.4}
49
+ s.summary = %q{Support for running ruby tasks via drb (druby) on multiple cores and/or systems.}
50
+ s.test_files = [
51
+ "spec/drbman_spec.rb",
52
+ "spec/host_machine_spec.rb",
53
+ "spec/spec_helper.rb",
54
+ "examples/primes/lib/drb_server/prime_helper.rb",
55
+ "examples/primes/lib/primes/cli.rb",
56
+ "examples/primes/lib/primes/kernel_extensions.rb",
57
+ "examples/primes/lib/primes/primes.rb",
58
+ "examples/primes/lib/primes/sieve_of_eratosthenes.rb",
59
+ "examples/primes/lib/primes.rb",
60
+ "examples/primes/spec/primes_spec.rb",
61
+ "examples/primes/spec/spec_helper.rb"
62
+ ]
63
+
64
+ if s.respond_to? :specification_version then
65
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
66
+ s.specification_version = 3
67
+
68
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
69
+ s.add_runtime_dependency(%q<log4r>, [">= 1.0.5"])
70
+ s.add_runtime_dependency(%q<user-choices>, [">= 1.1.6"])
71
+ s.add_runtime_dependency(%q<extlib>, [">= 0.9.12"])
72
+ s.add_runtime_dependency(%q<versionomy>, [">= 0.0.4"])
73
+ s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.11"])
74
+ s.add_runtime_dependency(%q<net-scp>, [">= 1.0.2"])
75
+ else
76
+ s.add_dependency(%q<log4r>, [">= 1.0.5"])
77
+ s.add_dependency(%q<user-choices>, [">= 1.1.6"])
78
+ s.add_dependency(%q<extlib>, [">= 0.9.12"])
79
+ s.add_dependency(%q<versionomy>, [">= 0.0.4"])
80
+ s.add_dependency(%q<net-ssh>, [">= 2.0.11"])
81
+ s.add_dependency(%q<net-scp>, [">= 1.0.2"])
82
+ end
83
+ else
84
+ s.add_dependency(%q<log4r>, [">= 1.0.5"])
85
+ s.add_dependency(%q<user-choices>, [">= 1.1.6"])
86
+ s.add_dependency(%q<extlib>, [">= 0.9.12"])
87
+ s.add_dependency(%q<versionomy>, [">= 0.0.4"])
88
+ s.add_dependency(%q<net-ssh>, [">= 2.0.11"])
89
+ s.add_dependency(%q<net-scp>, [">= 1.0.2"])
90
+ end
91
+ end
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/primes")
4
+
5
+ require "primes"
6
+
7
+ CLI.execute
@@ -0,0 +1,34 @@
1
+ require 'drb'
2
+ require 'log4r'
3
+
4
+ class PrimeHelper
5
+ attr_accessor :name
6
+ def non_primes(ip, n)
7
+ a = []
8
+ 2.upto((n - 1) / ip) { |i| a << (i * ip) }
9
+ a
10
+ end
11
+ def stop_service
12
+ DRb.stop_service
13
+ end
14
+ end
15
+
16
+ logger = Log4r::Logger.new('prime_helper')
17
+ logger.outputters = Log4r::FileOutputter.new(:console, :filename => File.join(File.dirname(__FILE__), '../prime_helper.log'))
18
+ Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
19
+ logger.level = Log4r::INFO
20
+
21
+ machine = 'localhost'
22
+ machine = ARGV[0] unless ARGV.length < 1
23
+ port = 9000
24
+ port = ARGV[1] unless ARGV.length < 2
25
+ service = "druby://#{machine}:#{port}"
26
+ logger.info { "ARGV => #{ARGV.inspect}" }
27
+ logger.info { "machine => #{machine}" }
28
+ logger.info { "port => #{port}" }
29
+ logger.info { "drb service => #{service}" }
30
+ server = PrimeHelper.new
31
+ server.name = service
32
+ DRb.start_service(service, server)
33
+ DRb.thread.join
34
+ logger.info { "finished" }
@@ -0,0 +1,81 @@
1
+ class CLI < UserChoices::Command
2
+ include UserChoices
3
+ include Singleton
4
+
5
+ # The CLI class uses the command design pattern.
6
+ # This is a class accessor helper
7
+ # @example
8
+ # CLI.execute
9
+ def self.execute
10
+ instance.execute
11
+ end
12
+
13
+ # The CLI class uses the command design pattern
14
+ # This is the main entry point
15
+ def execute
16
+ if @user_choices[:version]
17
+ puts IO.read(File.join(File.dirname(__FILE__), '../../VERSION')).strip
18
+ else
19
+ logger = setup_logger
20
+ begin
21
+ # @user_choices[:hosts] << @user_choices[:host] unless @user_choices[:host].blank?
22
+ raise Exception.new('Missing maximum integer argument') if @user_choices[:max_integer].nil?
23
+ elapse_time = elapse do
24
+ app = Primes.new(logger, @user_choices)
25
+ primes = app.execute
26
+ logger.info { "#{primes.length} primes found" }
27
+ logger.info { "calculation elapsed time: #{app.primes_elapse_time}" }
28
+ end
29
+ logger.info { "total elapsed time: #{elapse_time}" }
30
+ rescue Exception => e
31
+ logger.error { e.to_s }
32
+ logger.debug { e.backtrace.join("\n") }
33
+ end
34
+ end
35
+ end
36
+
37
+ protected
38
+
39
+ # @param builder (see UserChoices::Command#add_sources)
40
+ def add_sources(builder)
41
+ builder.add_source(CommandLineSource, :usage, "Usage #{$0} [options] INTEGER\nwhere INTEGER is the number to find all of the primes below.")
42
+ builder.add_source(EnvironmentSource, :with_prefix, "primes_")
43
+ builder.add_source(YamlConfigFileSource, :from_file, ".primes-config.yaml")
44
+ end
45
+
46
+ # @param builder (see UserChoices::Command#add_choices)
47
+ def add_choices(builder)
48
+ # don't need to explicitly declare help argument
49
+ builder.add_choice(:version, :type => :boolean, :default => false) do |command_line|
50
+ command_line.uses_switch('-V', '--version', 'The version of primes')
51
+ end
52
+ builder.add_choice(:quiet, :type => :boolean, :default => false) do |command_line|
53
+ command_line.uses_switch('-q', '--quiet', 'Display error messages only')
54
+ end
55
+ builder.add_choice(:debug, :type => :boolean, :default => false) do |command_line|
56
+ command_line.uses_switch('-v', '--verbose', 'Display debug messages')
57
+ end
58
+ builder.add_choice(:hosts, :type => [:string], :default => []) do |command_line|
59
+ command_line.uses_option('-H', '--hosts "HOST,HOST"', 'Comma separated host machines, ex: "machine1{,machine2{,...}}"')
60
+ end
61
+ builder.add_choice(:port, :type => :integer, :default => 9000) do |command_line|
62
+ command_line.uses_option('-p', '--port PORT', "The starting port number to assign to the hosts.")
63
+ end
64
+ builder.add_choice(:max_integer) do |command_line|
65
+ command_line.uses_optional_arg
66
+ end
67
+ end
68
+
69
+ # Initial setup of logger
70
+ # @return [Logger] the logger to use
71
+ def setup_logger
72
+ logger = Log4r::Logger.new('primes')
73
+ logger.outputters = Log4r::StdoutOutputter.new(:console)
74
+ Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
75
+ logger.level = Log4r::INFO
76
+ logger.level = Log4r::WARN if @user_choices[:quiet]
77
+ logger.level = Log4r::DEBUG if @user_choices[:debug]
78
+ # logger.trace = true
79
+ logger
80
+ end
81
+ end
@@ -0,0 +1,12 @@
1
+ module Kernel
2
+ def elapse(&block)
3
+ seconds = 0
4
+ unless block.nil?
5
+ start_time = Time.now
6
+ block.call
7
+ seconds = Time.now - start_time
8
+ end
9
+ seconds
10
+ end
11
+ end
12
+
@@ -0,0 +1,19 @@
1
+
2
+ class Primes
3
+ attr_reader :primes_elapse_time
4
+
5
+ def initialize(logger, choices)
6
+ @logger = logger
7
+ @user_choices = choices
8
+ end
9
+
10
+ def execute
11
+ @logger.debug { @user_choices.pretty_inspect }
12
+ sieve = SieveOfEratosthenes.new(@user_choices[:max_integer], @user_choices, @logger)
13
+ result = sieve.execute
14
+ @primes_elapse_time = sieve.primes_elapse_time
15
+ result
16
+ end
17
+
18
+
19
+ end
@@ -0,0 +1,80 @@
1
+ # Command design pattern
2
+ class SieveOfEratosthenes
3
+ attr_reader :primes_elapse_time
4
+ def initialize(n, choices, logger)
5
+ @n = n.to_i
6
+ @choices = choices
7
+ @logger = logger
8
+
9
+ # we need at least one host that has a drb server running
10
+ @choices[:hosts] = ['localhost'] if @choices[:hosts].blank?
11
+
12
+ # set the file to be ran that contains the drb server
13
+ @choices[:run] = 'drb_server/prime_helper.rb' if @choices[:run].blank?
14
+ @choices[:gems] = ['log4r']
15
+
16
+ # specify the directories to copy to the host machine
17
+ @choices[:dirs] = [File.join(File.dirname(__FILE__), '../drb_server')]
18
+ end
19
+
20
+ def execute
21
+ result = []
22
+ @logger.debug { @choices.pretty_inspect }
23
+
24
+ Drbman.new(@logger, @choices) do |drbman|
25
+ @primes_elapse_time = elapse do
26
+ result = primes(@n, drbman)
27
+ end
28
+ end
29
+ result
30
+ end
31
+
32
+ private
33
+
34
+ def primes(n, drbman)
35
+ indices = []
36
+ if n > 2
37
+ composites = calc_composites(n, drbman)
38
+ flat_comps = composites.flatten.uniq
39
+ indices = calc_indices(flat_comps, n)
40
+ end
41
+ indices
42
+ end
43
+
44
+ # when n = 20
45
+ # sqr_primes = [2,3]
46
+ # composites = [[2*2, 2*3, 2*4,...,2*9], [3*2, 3*3, 3*4,...,3*6]]
47
+ # returns Array
48
+ def calc_composites(n, drbman)
49
+ sqr_primes = primes(Math.sqrt(n).to_i, drbman)
50
+ composites = []
51
+ threads = []
52
+ mutex = Mutex.new
53
+ sqr_primes.each do |ip|
54
+ # parallelize via threads
55
+ # then use the drb object within the thread
56
+ threads << Thread.new(ip, n) do |value, max|
57
+ # @logger.debug { "thread(#{ip}, #{n})" }
58
+ drbman.get_object do |prime_helper|
59
+ # @logger.debug { "prime_helper.name => #{prime_helper.name}" }
60
+ non_primes = prime_helper.non_primes(value, max)
61
+ mutex.synchronize do
62
+ composites << non_primes
63
+ end
64
+ end
65
+ end
66
+ end
67
+ threads.each {|thrd| thrd.join}
68
+ composites
69
+ end
70
+
71
+ def calc_indices(flat_comps, n)
72
+ indices = []
73
+ flags = Array.new(n, true)
74
+ flat_comps.each {|i| flags[i] = false}
75
+ flags.each_index {|i| indices << i if flags[i] }
76
+ indices.shift(2)
77
+ indices
78
+ end
79
+
80
+ end
@@ -0,0 +1,29 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) ||
3
+ $:.include?(File.expand_path(File.dirname(__FILE__)))
4
+
5
+ require 'rubygems'
6
+
7
+ # gem 'ruby-debug', '>=0.10.3'
8
+ gem 'log4r', '>=1.0.5'
9
+ gem 'user-choices', '>=1.1.6'
10
+ gem 'fizx-thread_pool', '>=0.3.1'
11
+ gem 'extlib', '>=0.9.12'
12
+ gem 'daemons', '>=1.0.10'
13
+
14
+ require 'drb'
15
+ require 'log4r'
16
+ require 'user-choices'
17
+ require 'thread_pool'
18
+ require 'extlib'
19
+ require 'daemons'
20
+
21
+ require 'drbman'
22
+
23
+ # require 'ruby-debug'
24
+
25
+ include FileUtils::Verbose
26
+
27
+ Dir.glob(File.join(File.dirname(__FILE__), 'primes/**/*.rb')).each do |name|
28
+ require name
29
+ end
@@ -0,0 +1,24 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'primes'
3
+
4
+
5
+ describe('SieveOfEratosthenes') do
6
+ before(:each) do
7
+ @choices = {}
8
+ @logger = Log4r::Logger.new('primes_spec')
9
+ @logger.level = Log4r::DEBUG
10
+ end
11
+
12
+ it 'should find [2,3,5,7,11,13,17,19] for n=20' do
13
+ @choices[:max_integer] = 20
14
+ sieve = Primes.new(@logger, @choices)
15
+ sieve.execute.should == [2,3,5,7,11,13,17,19]
16
+ end
17
+ it 'should take a while' do
18
+ sieve = SieveOfEratosthenes.new(10000000, @choices, @logger)
19
+ primes = sieve.execute
20
+ puts "#{primes.length} primes found"
21
+ primes.length.should == 664579
22
+ end
23
+ end
24
+
@@ -0,0 +1,8 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+
6
+ Spec::Runner.configure do |config|
7
+
8
+ end
data/lib/drbman/cli.rb ADDED
@@ -0,0 +1,85 @@
1
+ # require 'commandline/optionparser'
2
+
3
+ # == Synopsis
4
+ # The Command Line Interface
5
+ class CLI < UserChoices::Command
6
+ include UserChoices
7
+ include Singleton
8
+
9
+ # The CLI class uses the command design pattern.
10
+ # This is a class accessor helper
11
+ # @example
12
+ # CLI.execute
13
+ def self.execute
14
+ instance.execute
15
+ end
16
+
17
+ # The CLI class uses the command design pattern
18
+ # This is the main entry point
19
+ def execute
20
+ if @user_choices[:version]
21
+ puts IO.read(File.join(File.dirname(__FILE__), '../../VERSION')).strip
22
+ else
23
+ logger = setup_logger
24
+ begin
25
+ app = Drbman.new(logger, @user_choices)
26
+ app.execute
27
+ rescue Exception => e
28
+ logger.error { e.to_s }
29
+ logger.debug { e.backtrace.join("\n") }
30
+ end
31
+ end
32
+ end
33
+
34
+ protected
35
+
36
+ # @param builder (see UserChoices::Command#add_sources)
37
+ def add_sources(builder)
38
+ builder.add_source(CommandLineSource, :usage, "Usage #{$0} [options]")
39
+ builder.add_source(EnvironmentSource, :with_prefix, "drbman_")
40
+ builder.add_source(YamlConfigFileSource, :from_file, ".drbman-config.yaml")
41
+ end
42
+
43
+ # @param builder (see UserChoices::Command#add_choices)
44
+ def add_choices(builder)
45
+ # don't need to explicitly declare help argument
46
+ builder.add_choice(:version, :type => :boolean, :default => false) do |command_line|
47
+ command_line.uses_switch('-V', '--version', 'The version of drbman')
48
+ end
49
+ builder.add_choice(:quiet, :type => :boolean, :default => false) do |command_line|
50
+ command_line.uses_switch('-q', '--quiet', 'Display error messages only')
51
+ end
52
+ builder.add_choice(:debug, :type => :boolean, :default => false) do |command_line|
53
+ command_line.uses_switch('-v', '--verbose', 'Display debug messages')
54
+ end
55
+ builder.add_choice(:run, :type => :string, :default => nil) do |command_line|
56
+ command_line.uses_option('-r', '--run "COMMAND"', "The ruby file that starts the drb server")
57
+ end
58
+ builder.add_choice(:hosts, :type => [:string], :default => []) do |command_line|
59
+ command_line.uses_option('-H', '--hosts "HOST,HOST"', 'Comma separated account URLs, ex: "{user{:pass}@}machine1{,{user{:pass}@}machine2}"')
60
+ end
61
+ builder.add_choice(:dirs, :type => [:string], :default => []) do |command_line|
62
+ command_line.uses_option('-d', '--dirs "PATH,PATH"', "Comma separated paths to directories to copy to the host machine(s)")
63
+ end
64
+ builder.add_choice(:gems, :type => [:string], :default => []) do |command_line|
65
+ command_line.uses_option('-g', '--gems "GEM,GEM"', "Comma separated list of gems that have to be installed on the host machine")
66
+ end
67
+ end
68
+
69
+ # Initial setup of logger
70
+ # @return [Logger] the logger to use
71
+ def setup_logger
72
+ logger = Log4r::Logger.new('drbman')
73
+ logger.outputters = Log4r::StdoutOutputter.new(:console)
74
+ Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
75
+ logger.level = Log4r::DEBUG
76
+ logger.level = Log4r::INFO
77
+ logger.level = Log4r::WARN if @user_choices[:quiet]
78
+ logger.level = Log4r::DEBUG if @user_choices[:debug]
79
+ # logger.trace = true
80
+ logger
81
+ end
82
+
83
+ end
84
+
85
+