mirror of
https://github.com/moparisthebest/mailcatcher
synced 2025-03-11 06:50:12 -04:00
Expose whole options hash instead of using define_method
This commit is contained in:
parent
6ce4dda354
commit
8913812b92
@ -46,7 +46,7 @@ module MailCatcher extend self
|
||||
end
|
||||
end
|
||||
|
||||
@defaults = {
|
||||
@@defaults = {
|
||||
:smtp_ip => '127.0.0.1',
|
||||
:smtp_port => '1025',
|
||||
:http_ip => '127.0.0.1',
|
||||
@ -58,8 +58,12 @@ module MailCatcher extend self
|
||||
:no_exit => false,
|
||||
}
|
||||
|
||||
def options
|
||||
@@options
|
||||
end
|
||||
|
||||
def parse! arguments=ARGV, defaults=@defaults
|
||||
@defaults.dup.tap do |options|
|
||||
@@defaults.dup.tap do |options|
|
||||
OptionParser.new do |parser|
|
||||
parser.banner = "Usage: mailcatcher [options]"
|
||||
parser.version = VERSION
|
||||
@ -127,15 +131,14 @@ module MailCatcher extend self
|
||||
|
||||
def run! options=nil
|
||||
# If we are passed options, fill in the blanks
|
||||
options &&= @defaults.merge options
|
||||
options &&= options.reverse_merge @@defaults
|
||||
# Otherwise, parse them from ARGV
|
||||
options ||= parse!
|
||||
|
||||
puts "Starting MailCatcher"
|
||||
# Stash them away for later
|
||||
@@options = options
|
||||
|
||||
define_method :no_exit do
|
||||
options[:no_exit]
|
||||
end
|
||||
puts "Starting MailCatcher"
|
||||
|
||||
Thin::Logging.silent = true
|
||||
|
||||
|
@ -18,7 +18,7 @@ class MailCatcher::Web < Sinatra::Base
|
||||
end
|
||||
|
||||
delete '/' do
|
||||
unless MailCatcher.no_exit
|
||||
unless MailCatcher.options[:no_exit]
|
||||
MailCatcher.quit!
|
||||
status 204
|
||||
end
|
||||
|
@ -21,7 +21,7 @@
|
||||
%input{:type => 'search', :name => 'search', :placeholder => 'Search messages...', :incremental => true}
|
||||
%li.clear
|
||||
%a{:href => '#', :title => 'Clear all messages'} Clear
|
||||
- unless MailCatcher.no_exit
|
||||
- unless MailCatcher.options[:no_exit]
|
||||
%li.quit
|
||||
%a{:href => '#', :title => 'Quit MailCatcher'} Quit
|
||||
%nav#messages
|
||||
|
Loading…
x
Reference in New Issue
Block a user