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



37
38
39
40
41
42
# File 'lib/trample/configuration.rb', line 37

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



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

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



28
29
30
31
32
33
34
35
# File 'lib/trample/configuration.rb', line 28

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

  @login
end

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



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

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