Class: PseudoCleaner::RedisMonitorCleaner::RedisMessage
- Inherits:
-
Object
- Object
- PseudoCleaner::RedisMonitorCleaner::RedisMessage
- Defined in:
- lib/pseudo_cleaner/redis_monitor_cleaner.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#cur_pos ⇒ Object
readonly
Returns the value of attribute cur_pos.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#time_stamp ⇒ Object
readonly
Returns the value of attribute time_stamp.
Instance Method Summary collapse
-
#initialize(message_string) ⇒ RedisMessage
constructor
A new instance of RedisMessage.
- #keys ⇒ Object
- #next_value ⇒ Object
- #parse_message ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(message_string) ⇒ RedisMessage
Returns a new instance of RedisMessage.
176 177 178 179 180 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 176 def initialize() = end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
173 174 175 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 173 def command @command end |
#cur_pos ⇒ Object (readonly)
Returns the value of attribute cur_pos.
174 175 176 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 174 def cur_pos @cur_pos end |
#db ⇒ Object (readonly)
Returns the value of attribute db.
170 171 172 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 170 def db @db end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
171 172 173 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 171 def host @host end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
168 169 170 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 168 def end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
172 173 174 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 172 def port @port end |
#time_stamp ⇒ Object (readonly)
Returns the value of attribute time_stamp.
169 170 171 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 169 def time_stamp @time_stamp end |
Instance Method Details
#keys ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 236 def keys unless defined?() = [] if Redis::Namespace::COMMANDS.include? command handling = Redis::Namespace::COMMANDS[command.to_s.downcase] (before, after) = handling case before when :first << next_value when :all while @cur_pos < .length << next_value end when :exclude_first next_value while @cur_pos < .length << next_value end when :exclude_last while @cur_pos < .length << next_value end .delete_at(.length - 1) when :exclude_options = ["weights", "aggregate", "sum", "min", "max"] while @cur_pos < .length << next_value if .include?([-1].downcase) .delete_at(.length - 1) break end end when :alternate while @cur_pos < .length << next_value next_value end when :sort next_value while @cur_pos < .length a_value = next_value if a_value.downcase == "store" [0] = next_value end end # when :eval_style # # when :scan_style end end end end |
#next_value ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 206 def next_value in_quote = ([@cur_pos] == '"') if in_quote @cur_pos += 1 end_pos = @cur_pos while (end_pos && end_pos < .length) end_pos = .index("\"", end_pos) num_backslashes = 0 back_pos = end_pos while [back_pos - 1] == "\\" num_backslashes += 1 back_pos -= 1 end break if (num_backslashes % 2) == 0 end_pos += 1 end else end_pos = .index(" ", @cur_pos) end the_value = [@cur_pos..end_pos - 1] end_pos += 1 if in_quote @cur_pos = end_pos + 1 the_value.gsub("\\\\", "\\").gsub("\\\"", "\"") end |
#parse_message ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 182 def if =~ /[0-9]+\.[0-9]+ \[[0-9]+ [^:]+:[^\]]+\] \"[^\"]+\"/ end_pos = .index(" ") @time_stamp = [0..end_pos - 1] @cur_pos = end_pos + 2 # " [" end_pos = .index(" ", @cur_pos) @db = [@cur_pos..end_pos - 1].to_i @cur_pos = end_pos + 1 end_pos = .index(":", @cur_pos) @host = [@cur_pos..end_pos - 1] @cur_pos = end_pos + 1 end_pos = .index("]", @cur_pos) @port = [@cur_pos..end_pos - 1].to_i @cur_pos = end_pos + 2 # "] " @command = next_value.downcase else @command = end end |
#to_s ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/pseudo_cleaner/redis_monitor_cleaner.rb', line 302 def to_s { time_stamp: time_stamp, db: db, host: host, port: port, command: command, message: , cur_pos: cur_pos }.to_s end |