Sha256: 3318ee231ac1939f4dcf69fdc4b7b1ee044d0e01880f9fc87416d5de166b1b6f
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
module Thin # Run a command though the +thin+ command-line script. class Command include Logging class << self # Path to the +thin+ script used to control the servers. # Leave this to default to use the one in the path. attr_accessor :script end def initialize(name, options={}) @name = name @options = options end def self.run(*args) new(*args).run end # Send the command to the +thin+ script def run shell_cmd = shellify trace shell_cmd ouput = `#{shell_cmd}`.chomp log " " + ouput.gsub("\n", " \n") unless ouput.empty? end # Turn into a runnable shell command def shellify shellified_options = @options.inject([]) do |args, (name, value)| args << case value when NilClass when TrueClass then "--#{name}" else "--#{name.to_s.tr('_', '-')}=#{value.inspect}" end end raise ArgumentError, "Path to thin script can't be found, set Command.script" unless self.class.script "#{self.class.script} #{@name} #{shellified_options.compact.join(' ')}" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
thin-0.6.3 | lib/thin/command.rb |
thin-0.6.3-x86-mswin32-60 | lib/thin/command.rb |
thin-0.6.4-x86-mswin32-60 | lib/thin/command.rb |
thin-0.6.4 | lib/thin/command.rb |