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



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

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, *args, &block) ⇒ Object



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

def get(url, *args, &block)
  args << block if block_given?

  @pages << Page.new(:get, url, *args)
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



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

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

  @login
end

#post(url, *args, &block) ⇒ Object



26
27
28
29
30
# File 'lib/trample/configuration.rb', line 26

def post(url, *args, &block)
  args << block if block_given?

  @pages << Page.new(:post, url, *args)
end