Class: CouchRest::Streamer

Inherits:
Object
  • Object
show all
Defined in:
lib/couchrest/helper/streamer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ Streamer

Returns a new instance of Streamer.



4
5
6
# File 'lib/couchrest/helper/streamer.rb', line 4

def initialize db
  @db = db
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



3
4
5
# File 'lib/couchrest/helper/streamer.rb', line 3

def db
  @db
end

Instance Method Details

#view(name, params = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/couchrest/helper/streamer.rb', line 8

def view name, params = nil
  urlst = /^_/.match(name) ? "#{@db.root}/#{name}" : "#{@db.root}/_view/#{name}"
  url = CouchRest.paramify_url urlst, params
  IO.popen("curl --silent #{url}") do |view|
    view.gets # discard header
    while row = parse_line(view.gets)
      yield row
    end
  end
end