lib/picky/sources/couch.rb in picky-0.11.2 vs lib/picky/sources/couch.rb in picky-0.12.0

- old
+ new

@@ -6,13 +6,13 @@ class NoCouchDBGiven < StandardError; end class Couch < Base - def initialize *field_names, options + def initialize *category_names, options check_gem - Hash === options && options[:url] || raise_no_db_given(field_names) + Hash === options && options[:url] || raise_no_db_given(category_names) @db = RestClient::Resource.new options.delete(:url), options end def check_gem require 'rest_client' @@ -21,23 +21,24 @@ exit 1 end # Harvests the data to index. # - def harvest type, field + def harvest type, category + category_name = category.name.to_s get_data do |doc| - yield doc['_id'].to_i, doc[field.name.to_s] || next + yield doc['_id'].to_i, doc[category_name] || next end end def get_data &block resp = @db['_all_docs?include_docs=true'].get JSON.parse(resp)['rows']. map{|row| row['doc']}. each &block end - - def raise_no_db_given field_names - raise NoCouchDBGiven.new(field_names.join(', ')) + + def raise_no_db_given category_names + raise NoCouchDBGiven.new(category_names.join(', ')) end end end