Class: LogGenerator::Apache::Page

Inherits:
Object
  • Object
show all
Includes:
RAND
Defined in:
lib/apache-loggen/base.rb

Constant Summary

Constants included from RAND

RAND::RANDOM

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RAND

#grand

Constructor Details

#initializePage

Returns a new instance of Page.



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/apache-loggen/base.rb', line 172

def initialize
  cate = PAGE_CATEGORIES[grand(PAGE_CATEGORIES.size)]
  item = grand(RECORDS)

  if grand(2) == 0
    w = [cate, PAGE_CATEGORIES[grand(PAGE_CATEGORIES.size)]]
  else
    w = [cate]
  end
  q = w.map {|k| k[0..0].upcase + k[1..-1] }.join('+')
  search_path = "/search/?c=#{q}"
  google_ref = "http://www.google.com/search?ie=UTF-8&q=google&sclient=psy-ab&q=#{q}&oq=#{q}&aq=f&aqi=g-vL1&aql=&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&biw=#{grand(5000)}&bih=#{grand(600)}"

  case grand(12)
  when 0,1,2,3,4,5
    @path = "/category/#{cate}"
    @referers = [nil, nil, nil, nil, nil, nil, nil, google_ref]
    @method = 'GET'
    @code = 200

  when 6
    @path = "/category/#{cate}?from=#{grand(3)*10}"
    @referers = [search_path, "/category/#{cate}"]
    @method = 'GET'
    @code = 200

  when 7,8,9,10
    @path = "/item/#{cate}/#{item}"
    @referers = [search_path, search_path, google_ref, "/category/#{cate}"]
    @method = 'GET'
    if grand(100) == 0
      @code = 404
    else
      @code = 200
    end

  when 11
    @path = search_path
    @referers = [nil]
    @method = 'POST'
    @code = 200
  end

  @size = grand(100) + 40
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



218
219
220
# File 'lib/apache-loggen/base.rb', line 218

def code
  @code
end

#methodObject (readonly)

Returns the value of attribute method.



218
219
220
# File 'lib/apache-loggen/base.rb', line 218

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



218
219
220
# File 'lib/apache-loggen/base.rb', line 218

def path
  @path
end

#sizeObject (readonly)

Returns the value of attribute size.



218
219
220
# File 'lib/apache-loggen/base.rb', line 218

def size
  @size
end

Instance Method Details

#refererObject



220
221
222
223
224
# File 'lib/apache-loggen/base.rb', line 220

def referer
  if grand(2) == 0
    @referers[grand(@referers.size)]
  end
end