mongrel2 0.28.0 → 0.29.0

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.tar.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,19 @@
1
+ == v0.29.0 [2012-07-13] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Make m2sh.rb write audit log events for modifying actions
4
+ - Add a --why option to m2sh.rb to allow reasons for actions to be
5
+ logged.
6
+ - Add a convenience delegator to Mongrel2::Config for logging an
7
+ action.
8
+ - Finish Mongrel2::Config::Log method documentation
9
+ - Remove RDoc sections from Mongrel2::Config::Server, as they made
10
+ stuff more difficult to find.
11
+ - Add Mongrel2::Config::Server#to_s
12
+ - Make stringified Log events only include parens if the event has a
13
+ 'why' field.
14
+ - Remove extraneous message from m2sh.rb's quickstart subcommand
15
+
16
+
1
17
  == v0.28.0 [2012-07-12] Michael Granger <ged@FaerieMUD.org>
2
18
 
3
19
  - Add Mongrel2::Config::Server pathname methods for the path
data/bin/m2sh.rb CHANGED
@@ -185,6 +185,8 @@ class Mongrel2::M2SHCommand
185
185
  opt :sudo, "Use 'sudo' to run the mongrel2 server."
186
186
  opt :port, "Reset the server port to <i> before starting it.",
187
187
  :type => :integer
188
+ opt :why, "Specify the reason for an action for the event log.",
189
+ :type => :string
188
190
  text ''
189
191
 
190
192
  text 'Other Options:'
@@ -292,6 +294,7 @@ class Mongrel2::M2SHCommand
292
294
  source = File.read( configfile )
293
295
 
294
296
  runspace.module_eval( source, configfile, 1 )
297
+ Mongrel2::Config.log_action( "Loaded config from #{configfile}", self.options.why )
295
298
  end
296
299
  help :load, "Overwrite the config database with the values from the speciifed CONFIGFILE."
297
300
  usage :load, <<-END_USAGE
@@ -444,6 +447,8 @@ class Mongrel2::M2SHCommand
444
447
  server.bind_addr,
445
448
  server.port,
446
449
  ]
450
+
451
+ Mongrel2::Config.log_action( "Starting server: #{server}", self.options.why )
447
452
  header "Starting mongrel2 at: #{url}"
448
453
  exec( *cmd )
449
454
  end
@@ -467,6 +472,8 @@ class Mongrel2::M2SHCommand
467
472
  control.reload
468
473
  control.close
469
474
  message "done."
475
+
476
+ Mongrel2::Config.log_action( "Restarted server #{server}", self.options.why )
470
477
  end
471
478
  help :reload, "Reload the specified server's configuration"
472
479
  usage :reload, "[server]"
@@ -481,6 +488,8 @@ class Mongrel2::M2SHCommand
481
488
  control.stop
482
489
  control.close
483
490
  message "done."
491
+
492
+ Mongrel2::Config.log_action( "Stopped server #{server}", self.options.why )
484
493
  end
485
494
  help :stop, "Stop the specified server gracefully"
486
495
  usage :stop, "[server]"
@@ -539,11 +548,6 @@ class Mongrel2::M2SHCommand
539
548
  self.bootstrap_command( configfile )
540
549
  edit( configfile )
541
550
  self.load_command( configfile )
542
-
543
- message '---'
544
- header "Point a browser at: "
545
- message '---'
546
-
547
551
  self.start_command()
548
552
  end
549
553
  help :quickstart, "Set up a basic mongrel2 server and run it."
data/lib/mongrel2.rb CHANGED
@@ -20,10 +20,10 @@ module Mongrel2
20
20
  abort "\n\n>>> Mongrel2 requires Ruby 1.9.2 or later. <<<\n\n" if RUBY_VERSION < '1.9.2'
21
21
 
22
22
  # Library version constant
23
- VERSION = '0.28.0'
23
+ VERSION = '0.29.0'
24
24
 
25
25
  # Version-control revision constant
26
- REVISION = %q$Revision: 511f5e29f0a0 $
26
+ REVISION = %q$Revision: cc6fcfdf3335 $
27
27
 
28
28
 
29
29
  require 'mongrel2/constants'
@@ -194,6 +194,7 @@ module Mongrel2
194
194
 
195
195
  # Force the associations to reset
196
196
  self.db = db
197
+ self.log_action( "Initialized the config database." )
197
198
  end
198
199
 
199
200
 
@@ -210,6 +211,14 @@ module Mongrel2
210
211
  end
211
212
 
212
213
 
214
+ ### Log an entry to the commit log with the given +what+, +why+, +where+, and +how+ values
215
+ ### and return it after it's saved.
216
+ def self::log_action( what, why=nil, where=nil, how=nil )
217
+ Mongrel2::Config::Log.log_action( what, why, where, how )
218
+ end
219
+
220
+
221
+
213
222
  #########
214
223
  protected
215
224
  #########
@@ -38,11 +38,44 @@ class Mongrel2::Config::Log < Mongrel2::Config( :log )
38
38
 
39
39
  # :todo: Correct the happened_at, which is set in UTC, but fetched in localtime.
40
40
 
41
+ ##
42
+ # :method: id
43
+ # Get the ID of the log entry
44
+
45
+ ##
46
+ # :method: who
47
+ # Get "who" was reponsible for the event.
48
+
49
+ ##
50
+ # :method: what
51
+ # Get a description of "what" happened
52
+
53
+ ##
54
+ # :method: location
55
+ # Get the "where" of the event.
56
+
57
+ ##
58
+ # :method: happened_at
59
+ # Get the timestamp of the event.
60
+
61
+ ##
62
+ # :method: how
63
+ # Get a description of "how" the event happened.
64
+
65
+ ##
66
+ # :method: why
67
+ # Get a description of "why" the event happened.
68
+
69
+
41
70
 
42
71
  ### Stringify the log entry and return it.
43
72
  def to_s
44
73
  # 2011-09-09 19:35:40 [who] @where how: what (why)
45
- return "%{happened_at} [%{who}] @%{location} %{how}: %{what} (%{why})" % self.values
74
+ msg = "%{happened_at} [%{who}] @%{location} %{how}: %{what}" % self.values
75
+ msg += " (#{self.why})" if self.why
76
+ return msg
46
77
  end
47
78
 
48
79
  end # class Mongrel2::Config::Log
80
+
81
+
@@ -25,6 +25,23 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
25
25
  # port INTEGER,
26
26
  # use_ssl INTEGER default 0);
27
27
 
28
+ ##
29
+ # Return the dataset for looking up a server by its UUID.
30
+ # :singleton-method: by_uuid
31
+ # :call-seq:
32
+ # by_uuid( uuid )
33
+ def_dataset_method( :by_uuid ) {|uuid| filter(:uuid => uuid).limit(1) }
34
+
35
+
36
+ ##
37
+ # The hosts[rdoc-ref:Mongrel2::Config::Host] that belong to this server.
38
+ one_to_many :hosts
39
+
40
+ ##
41
+ # The filters[rdoc-ref:Mongrel2::Config::Filter] that will be loaded by this server.
42
+ one_to_many :filters
43
+
44
+
28
45
  ##
29
46
  # :method: uuid
30
47
  # Get the server identifier, which is typically a UUID, but can
@@ -114,35 +131,6 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
114
131
  end
115
132
 
116
133
 
117
- #
118
- # :section: Associations
119
- #
120
-
121
- ##
122
- # The hosts[rdoc-ref:Mongrel2::Config::Host] that belong to this server.
123
- one_to_many :hosts
124
-
125
- ##
126
- # The filters[rdoc-ref:Mongrel2::Config::Filter] that will be loaded by this server.
127
- one_to_many :filters
128
-
129
-
130
- #
131
- # :section: Dataset Methods
132
- #
133
-
134
- ##
135
- # Return the dataset for looking up a server by its UUID.
136
- # :singleton-method: by_uuid
137
- # :call-seq:
138
- # by_uuid( uuid )
139
- def_dataset_method( :by_uuid ) {|uuid| filter(:uuid => uuid).limit(1) }
140
-
141
-
142
- #
143
- # :section: Socket/Pathname Convenience Methods
144
- #
145
-
146
134
  ### Return the URI for its control socket.
147
135
  def control_socket_uri
148
136
  # Find the control socket relative to the server's chroot
@@ -167,10 +155,6 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
167
155
  end
168
156
 
169
157
 
170
- #
171
- # :section: Validation Callbacks
172
- #
173
-
174
158
  ### Sequel validation callback: add errors if the record is invalid.
175
159
  def validate
176
160
  self.validates_presence [ :access_log, :error_log, :pid_file, :default_host, :port ],
@@ -178,6 +162,13 @@ class Mongrel2::Config::Server < Mongrel2::Config( :server )
178
162
  end
179
163
 
180
164
 
165
+ ### Stringification method -- return a human-readable description of the server.
166
+ def to_s
167
+ return "%s {%s} %s:%d" % [ self.name, self.uuid, self.bind_addr, self.port ]
168
+ end
169
+
170
+
171
+
181
172
  ### DSL methods for the Server context besides those automatically-generated from its
182
173
  ### columns.
183
174
  module DSLMethods
@@ -68,14 +68,28 @@ describe Mongrel2::Config::Log do
68
68
  what: 'what',
69
69
  location: 'location',
70
70
  happened_at: Time.at( 1315598592 ),
71
- how: 'how',
72
- why: 'why'
71
+ how: 'how'
73
72
  )
74
73
  end
75
74
 
76
75
 
77
76
  it "stringifies as a readable log file line" do
78
77
 
78
+ # 2011-09-09 20:29:47 -0700 [mgranger] @localhost m2sh: load etc/mongrel2.conf (updating)
79
+ @log.to_s.should =~ %r{
80
+ ^
81
+ (?-x:\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [\+\-]\d{4} )
82
+ \[who\] \s
83
+ @location \s
84
+ how: \s
85
+ what
86
+ $
87
+ }x
88
+ end
89
+
90
+ it "stringifies with a reason if it has one" do
91
+ @log.why = 'Because'
92
+
79
93
  # 2011-09-09 20:29:47 -0700 [mgranger] @localhost m2sh: load etc/mongrel2.conf (updating)
80
94
  @log.to_s.should =~ %r{
81
95
  ^
@@ -84,7 +98,7 @@ describe Mongrel2::Config::Log do
84
98
  @location \s
85
99
  how: \s
86
100
  what \s
87
- \(why\)
101
+ \(Because\)
88
102
  $
89
103
  }x
90
104
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongrel2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.29.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
37
37
  Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
38
38
  cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2012-07-12 00:00:00.000000000 Z
39
+ date: 2012-07-13 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
metadata.gz.sig CHANGED
Binary file