Skip to content

Commit

Permalink
Reorganization and documentation
Browse files Browse the repository at this point in the history
* Reorganized Resource and created Model, which is the module containing the class level methods of Resource.
* Small "require" error in novel.rb resolved in the specs.
* Updated documentation.
  • Loading branch information
greglu committed Nov 26, 2009
1 parent c5bea91 commit 79f4b03
Show file tree
Hide file tree
Showing 13 changed files with 448 additions and 395 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -5,3 +5,5 @@
.loadpath
.project
pkg/
doc/
.yardoc
2 changes: 1 addition & 1 deletion README.rdoc
Expand Up @@ -48,7 +48,7 @@ Modify your Ruby class/model similarly to the following:
index :description # Defaults to type :text
end

BigIndex will then override the default Model.find() method to pass through the indexer first. Model.find() will also accept the option {:bypass_index => true}, which bypasses the indexed #find method and dispatches it to the original Model.find() method, e.g. Model.find(:all, :bypass_index => true). Alternatively, you can use Model.find_without_index(:all) for the same functionality.
BigIndex will then override the default Model.find() method to pass through the indexer first. Model.find() will also accept the option ":bypass_index => true", which bypasses the indexed #find method and dispatches it to the original Model.find() method, e.g. Model.find(:all, :bypass_index => true). Alternatively, you can use Model.find_without_index(:all) for the same functionality.

== Rebuilding your index

Expand Down
4 changes: 1 addition & 3 deletions lib/big_index.rb
Expand Up @@ -5,13 +5,11 @@
dir = File.expand_path(File.join(File.dirname(__FILE__), 'big_index')) + '/'
vendor_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor')) + '/'

# Autoload the Solr library when requested
# autoload :Solr, (vendor_dir + 'solr').to_s
require (vendor_dir + 'solr').to_s

require dir + 'support'
require dir + 'adapters'
require dir + 'repository'
require dir + 'model'
require dir + 'resource'
require dir + 'index_field'

Expand Down
12 changes: 11 additions & 1 deletion lib/big_index/adapters/abstract_adapter.rb
@@ -1,10 +1,17 @@
module BigIndex
module Adapters

# This {AbstractAdapter} defines the API needed by BigIndex to provide
# indexing functionality by different indexers. For a concrete example
# of an implemented adapter, refer to {SolrAdapter}.
#
class AbstractAdapter

attr_reader :name, :options, :connection

# BigIndex Adapter API methods ====================================


def adapter_name
'abstract'
end
Expand Down Expand Up @@ -57,14 +64,17 @@ def optimize_index
raise NotImplementedError
end


# End of BigIndex Adapter API ====================================

private

def initialize(name, options)
@name = name
@options = options
end

end # class AbstractAdapter
end

end # module Adapters
end # module BigIndex
9 changes: 8 additions & 1 deletion lib/big_index/adapters/solr_adapter.rb
@@ -1,12 +1,18 @@
module BigIndex
module Adapters

# This adapter is used to interact with the Solr search system. Implemented
# with the Apache provided solr-ruby gem and extended functionality
# in vendor/solr of Bigindex.
#
class SolrAdapter < AbstractAdapter

# Extended the solr-ruby gem to contain custom code for Bigindex
include ::Solr::AdapterMethods

# BigIndex Adapter API methods ====================================


def adapter_name
'solr'
end
Expand Down Expand Up @@ -164,6 +170,7 @@ def optimize_index
solr_optimize
end


# End of BigIndex Adapter API ====================================

private
Expand All @@ -174,7 +181,7 @@ def initialize(name, options)
super(name, options)
end

end # class SolrAdapter
end

end # module Adapters
end # module BigIndex
12 changes: 12 additions & 0 deletions lib/big_index/index_field.rb
Expand Up @@ -2,6 +2,18 @@

module BigIndex

# = Index Fields
#
# Index fields define the blocks of information that should be used when
# indexing (creation and retrieval) occurs for a class.
#
# Although these IndexField objects aren't created manually, they're
# implicitly created from calls to the {BigIndex::Model#index} macro.
#
# At a minimum, an IndexField requires a name and will default to type "text".
# In this case, the name needs to refer to a valid method (of appropriate
# type), and will just index the return of the method.
#
class IndexField
include Assertions

Expand Down

0 comments on commit 79f4b03

Please sign in to comment.