Class: Broadway::Sinatra::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/broadway/sinatra/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, url = nil) ⇒ Processor

Returns a new instance of Processor.



9
10
11
12
# File 'lib/broadway/sinatra/processor.rb', line 9

def initialize(site, url = nil)
  self.site = site
  self.url  = URI.parse(url || site.url)
end

Instance Attribute Details

#pathsObject

Returns the value of attribute paths.



7
8
9
# File 'lib/broadway/sinatra/processor.rb', line 7

def paths
  @paths
end

#siteObject

Returns the value of attribute site.



7
8
9
# File 'lib/broadway/sinatra/processor.rb', line 7

def site
  @site
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/broadway/sinatra/processor.rb', line 7

def url
  @url
end

Instance Method Details

#error?(response, path, whiny = true) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'lib/broadway/sinatra/processor.rb', line 18

def error?(response, path, whiny = true)
  if !response.is_a?(Net::HTTPSuccess)
    raise message if whiny
    puts "Error at '#{path}': #{response.to_s}"
    return true
  end
  false
end

#path(path) ⇒ Object



27
28
29
# File 'lib/broadway/sinatra/processor.rb', line 27

def path(path)
  self.paths << path
end

#run(&block) ⇒ Object



31
32
33
34
35
36
# File 'lib/broadway/sinatra/processor.rb', line 31

def run(&block)
  self.paths = [] if block_given?
  self.instance_eval(&block)
  self.paths.reverse!
  requests
end

#setting(name) ⇒ Object



14
15
16
# File 'lib/broadway/sinatra/processor.rb', line 14

def setting(name)
  Sinatra::Application.send(name).to_s
end