Class: CrawlKit::SimpleDB

Inherits:
Object
  • Object
show all
Defined in:
lib/crawl_kit/simple_db.rb

Class Method Summary collapse

Class Method Details

.connectionObject



4
5
6
# File 'lib/crawl_kit/simple_db.rb', line 4

def connection
  AWS::SimpleDB.new
end

.count(params) ⇒ Object



31
32
33
# File 'lib/crawl_kit/simple_db.rb', line 31

def count(params)
  items.where(params).count
end

.crawl_domain(domain_name = nil) ⇒ Object



8
9
10
11
12
# File 'lib/crawl_kit/simple_db.rb', line 8

def crawl_domain(domain_name=nil)
  domain_name ||= CrawlKit.config.crawl_domain
  raise "A crawl domain is required" unless domain_name
  connection.domains[domain_name]
end

.delete_item(hashed_uri) ⇒ Object

replaced delete_attributes



23
24
25
# File 'lib/crawl_kit/simple_db.rb', line 23

def delete_item(hashed_uri) #replaced delete_attributes
  crawl_domain.items[hashed_uri].try(:delete)
end

.each_item(params) ⇒ Object



41
42
43
# File 'lib/crawl_kit/simple_db.rb', line 41

def each_item(params)
  select(params).each {|item| yield(item) }
end

.get_item(hashed_uri) ⇒ Object Also known as: find



18
19
20
# File 'lib/crawl_kit/simple_db.rb', line 18

def get_item(hashed_uri)
  crawl_domain.items[hashed_uri]
end

.itemsObject



14
15
16
# File 'lib/crawl_kit/simple_db.rb', line 14

def items
  crawl_domain.items
end

.select(params) ⇒ Object



27
28
29
# File 'lib/crawl_kit/simple_db.rb', line 27

def select(params)
  items.where(params)
end

.select_each(params) ⇒ Object



35
36
37
38
39
# File 'lib/crawl_kit/simple_db.rb', line 35

def select_each(params)
  select(params).each do |item|
    yield(item)
  end
end