Class: Trample::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/trample/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Configuration

Returns a new instance of Configuration.



5
6
7
8
# File 'lib/trample/configuration.rb', line 5

def initialize(&block)
  @pages = []
  instance_eval(&block)
end

Instance Attribute Details

#pagesObject (readonly)

Returns the value of attribute pages.



3
4
5
# File 'lib/trample/configuration.rb', line 3

def pages
  @pages
end

Instance Method Details

#==(other) ⇒ Object



42
43
44
45
46
47
# File 'lib/trample/configuration.rb', line 42

def ==(other)
  other.is_a?(Configuration) &&
    other.pages == pages &&
    other.concurrency == concurrency &&
    other.iterations  == iterations
end

#concurrency(*value) ⇒ Object



10
11
12
13
# File 'lib/trample/configuration.rb', line 10

def concurrency(*value)
  @concurrency = value.first unless value.empty?
  @concurrency
end

#get(url, &block) ⇒ Object



25
26
27
# File 'lib/trample/configuration.rb', line 25

def get(url, &block)
  @pages << Page.new(:get, url, block || {})
end

#iterations(*value) ⇒ Object



15
16
17
18
# File 'lib/trample/configuration.rb', line 15

def iterations(*value)
  @iterations = value.first unless value.empty?
  @iterations
end

#loginObject



33
34
35
36
37
38
39
40
# File 'lib/trample/configuration.rb', line 33

def 
  if block_given?
    yield
    @login = pages.pop
  end

  @login
end

#post(url, params = nil, &block) ⇒ Object



29
30
31
# File 'lib/trample/configuration.rb', line 29

def post(url, params = nil, &block)
  @pages << Page.new(:post, url, params || block)
end

#sleep(*value) ⇒ Object



20
21
22
23
# File 'lib/trample/configuration.rb', line 20

def sleep(*value)
  @sleep = value.first unless value.empty?
  @sleep
end