Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ complete index/backend rewrite, - configuration cludge

  • Loading branch information...
commit 9fe8c8646454bdf97a9ad830685785f1d71d507c 1 parent 50883fe
@floere authored
Showing with 267 additions and 311 deletions.
  1. +0 −67 server/lib/picky/internals/configuration/index.rb
  2. +21 −21 server/lib/picky/internals/index/backend.rb
  3. +6 −6 server/lib/picky/internals/index/files.rb
  4. +14 −14 server/lib/picky/internals/index/redis.rb
  5. +2 −2 server/lib/picky/internals/indexed/bundle/base.rb
  6. +3 −3 server/lib/picky/internals/indexed/bundle/redis.rb
  7. +8 −9 server/lib/picky/internals/indexed/category.rb
  8. +2 −2 server/lib/picky/internals/indexing/bundle/base.rb
  9. +3 −3 server/lib/picky/internals/indexing/bundle/super_base.rb
  10. +7 −25 server/lib/picky/internals/indexing/category.rb
  11. +52 −0 server/lib/picky/internals/shared/category.rb
  12. +5 −1 server/lib/picky/loader.rb
  13. +1 −1  server/lib/tasks/todo.rake
  14. +0 −80 server/spec/lib/internals/configuration/index_spec.rb
  15. +2 −3 server/spec/lib/internals/index/files_spec.rb
  16. +122 −49 server/spec/lib/internals/index/redis_spec.rb
  17. +4 −6 server/spec/lib/internals/indexed/bundle/memory_spec.rb
  18. +2 −3 server/spec/lib/internals/indexed/bundle/redis_spec.rb
  19. +2 −3 server/spec/lib/internals/indexing/bundle/memory_partial_generation_speed_spec.rb
  20. +5 −6 server/spec/lib/internals/indexing/bundle/memory_spec.rb
  21. +5 −6 server/spec/lib/internals/indexing/bundle/redis_spec.rb
  22. +1 −1  server/test_project/config.ru
View
67 server/lib/picky/internals/configuration/index.rb
@@ -1,67 +0,0 @@
-module Configuration # :nodoc:all
-
- # Holds the configuration for a
- # index/category combination.
- #
- class Index
-
- attr_reader :index, :category
-
- def initialize index, category
- @index = index
- @category = category
- end
-
- def index_name
- @index_name ||= index.name
- end
- def category_name
- @category_name ||= category.name
- end
-
- #
- #
- def index_path bundle_name, name
- "#{index_directory}/#{category_name}_#{bundle_name}_#{name}"
- end
-
- # Was: search_index_file_name
- #
- def prepared_index_path
- @prepared_index_path ||= "#{index_directory}/prepared_#{category_name}_index"
- end
- def prepared_index_file &block
- @prepared_index_file ||= Internals::Index::File::Text.new prepared_index_path
- @prepared_index_file.open_for_indexing &block
- end
-
- # Identifier for internal use.
- #
- def identifier
- @identifier ||= "#{index_name}:#{category_name}"
- end
-
- def to_s
- "#{index_name} #{category_name}"
- end
-
- def self.index_root
- @index_root ||= "#{PICKY_ROOT}/index"
- end
- def index_root
- self.class.index_root
- end
- # Was: cache_directory
- #
- def index_directory
- @index_directory ||= "#{index_root}/#{PICKY_ENVIRONMENT}/#{index_name}"
- end
- # Was: prepare_cache_directory
- #
- def prepare_index_directory
- FileUtils.mkdir_p index_directory
- end
-
- end
-
-end
View
42 server/lib/picky/internals/index/backend.rb
@@ -1,29 +1,29 @@
module Internals
-
+
module Index
-
+
class Backend
-
+
attr_reader :bundle_name
attr_reader :prepared, :index, :weights, :similarity, :configuration
-
- delegate :index_name, :category_name, :to => :@config
-
- def initialize bundle_name, config
+
+ delegate :index_name, :category_name, :to => :@category
+
+ def initialize bundle_name, category
@bundle_name = bundle_name
- @config = config
- @prepared = File::Text.new config.prepared_index_path
+ @category = category
+ @prepared = File::Text.new category.prepared_index_path
end
-
+
# Delegators.
#
-
+
# Retrieving data.
#
def retrieve &block
prepared.retrieve &block
end
-
+
# Dumping.
#
def dump_index index_hash
@@ -38,7 +38,7 @@ def dump_similarity similarity_hash
def dump_configuration configuration_hash
configuration.dump configuration_hash
end
-
+
# Loading.
#
def load_index
@@ -53,7 +53,7 @@ def load_weights
def load_configuration
configuration.load
end
-
+
# Cache ok?
#
def index_cache_ok?
@@ -65,7 +65,7 @@ def similarity_cache_ok?
def weights_cache_ok?
weights.cache_ok?
end
-
+
# Cache small?
#
def index_cache_small?
@@ -77,7 +77,7 @@ def similarity_cache_small?
def weights_cache_small?
weights.cache_small?
end
-
+
# Copies the indexes to the "backup" directory.
#
def backup
@@ -86,7 +86,7 @@ def backup
similarity.backup
configuration.backup
end
-
+
# Restores the indexes from the "backup" directory.
#
def restore
@@ -95,7 +95,7 @@ def restore
similarity.restore
configuration.restore
end
-
+
# Delete all index files.
#
def delete
@@ -104,9 +104,9 @@ def delete
similarity.delete
configuration.delete
end
-
+
end
-
+
end
-
+
end
View
12 server/lib/picky/internals/index/files.rb
@@ -4,17 +4,17 @@ module Index
class Files < Backend
- def initialize bundle_name, config
- super bundle_name, config
+ def initialize bundle_name, category
+ super bundle_name, category
# Note: We marshal the similarity, as the
# Yajl json lib cannot load symbolized
# values, just keys.
#
- @index = File::JSON.new config.index_path(bundle_name, :index)
- @weights = File::JSON.new config.index_path(bundle_name, :weights)
- @similarity = File::Marshal.new config.index_path(bundle_name, :similarity)
- @configuration = File::JSON.new config.index_path(bundle_name, :configuration)
+ @index = File::JSON.new category.index_path(bundle_name, :index)
+ @weights = File::JSON.new category.index_path(bundle_name, :weights)
+ @similarity = File::Marshal.new category.index_path(bundle_name, :similarity)
+ @configuration = File::JSON.new category.index_path(bundle_name, :configuration)
end
def to_s
View
28 server/lib/picky/internals/index/redis.rb
@@ -1,28 +1,28 @@
module Internals
module Index
-
+
# TODO Needs a reconnect to be run after forking.
#
class Redis < Backend
-
- def initialize bundle_name, config
- super bundle_name, config
+
+ def initialize bundle_name, category
+ super bundle_name, category
# Refine a few Redis "types".
#
- @index = Redis::ListHash.new "#{config.identifier}:#{bundle_name}:index"
- @weights = Redis::StringHash.new "#{config.identifier}:#{bundle_name}:weights"
- @similarity = Redis::ListHash.new "#{config.identifier}:#{bundle_name}:similarity"
- @configuration = Redis::StringHash.new "#{config.identifier}:#{bundle_name}:configuration"
+ @index = Redis::ListHash.new "#{category.identifier}:#{bundle_name}:index"
+ @weights = Redis::StringHash.new "#{category.identifier}:#{bundle_name}:weights"
+ @similarity = Redis::ListHash.new "#{category.identifier}:#{bundle_name}:similarity"
+ @configuration = Redis::StringHash.new "#{category.identifier}:#{bundle_name}:configuration"
end
-
+
# Delegate to the right collection.
#
def ids sym
index.collection sym
end
-
+
# Delegate to the right member value.
#
# Note: Converts to float.
@@ -30,15 +30,15 @@ def ids sym
def weight sym
weights.member(sym).to_f
end
-
+
# Delegate to a member value.
#
def setting sym
configuration.member sym
end
-
+
end
-
+
end
-
+
end
View
4 server/lib/picky/internals/indexed/bundle/base.rb
@@ -35,8 +35,8 @@ class Base
delegate :[], :to => :configuration
delegate :size, :to => :index
- def initialize name, configuration, similarity_strategy
- @identifier = "#{configuration.identifier}:#{name}"
+ def initialize name, category, similarity_strategy
+ @identifier = "#{category.identifier}:#{name}"
@index = {}
@weights = {}
View
6 server/lib/picky/internals/indexed/bundle/redis.rb
@@ -14,10 +14,10 @@ module Bundle
#
class Redis < Base
- def initialize name, configuration, *args
- super name, configuration, *args
+ def initialize name, category, *args
+ super name, category, *args
- @backend = Internals::Index::Redis.new name, configuration
+ @backend = Internals::Index::Redis.new name, category
end
# Get the ids for the given symbol.
View
17 server/lib/picky/internals/indexed/category.rb
@@ -9,18 +9,17 @@ module Indexed
#
class Category
+ include Internals::Shared::Category
+
attr_accessor :exact
- attr_reader :identifier, :name
+ attr_reader :name, :index
attr_writer :partial
#
#
def initialize name, index, options = {}
- @name = name
-
- configuration = Configuration::Index.new index, self
-
- @identifier = configuration.identifier
+ @name = name
+ @index = index
# TODO Push the defaults out into the index.
#
@@ -28,15 +27,15 @@ def initialize name, index, options = {}
similarity = options[:similarity] || Internals::Generators::Similarity::Default
bundle_class = options[:indexed_bundle_class] || Bundle::Memory
- @exact = bundle_class.new :exact, configuration, similarity
- @partial = bundle_class.new :partial, configuration, similarity
+ @exact = bundle_class.new :exact, self, similarity
+ @partial = bundle_class.new :partial, self, similarity
# @exact = exact_lambda.call(@exact, @partial) if exact_lambda = options[:exact_lambda]
# @partial = partial_lambda.call(@exact, @partial) if partial_lambda = options[:partial_lambda]
# TODO Extract?
#
- Query::Qualifiers.add(configuration.category_name, generate_qualifiers_from(options) || [name])
+ Query::Qualifiers.add(name, generate_qualifiers_from(options) || [name])
end
def to_s
View
4 server/lib/picky/internals/indexing/bundle/base.rb
@@ -16,8 +16,8 @@ class Base < SuperBase
# Path is in which directory the cache is located.
#
- def initialize name, configuration, similarity_strategy, partial_strategy, weights_strategy
- super name, configuration, similarity_strategy
+ def initialize name, category, similarity_strategy, partial_strategy, weights_strategy
+ super name, category, similarity_strategy
@partial_strategy = partial_strategy
@weights_strategy = weights_strategy
View
6 server/lib/picky/internals/indexing/bundle/super_base.rb
@@ -33,9 +33,9 @@ class SuperBase
delegate :clear, :to => :index
delegate :[], :[]=, :to => :configuration
- def initialize name, configuration, similarity_strategy
- @identifier = "#{configuration.identifier}:#{name}"
- @files = Internals::Index::Files.new name, configuration
+ def initialize name, category, similarity_strategy
+ @identifier = "#{category.identifier}:#{name}"
+ @files = Internals::Index::Files.new name, category
@index = {}
@weights = {}
View
32 server/lib/picky/internals/indexing/category.rb
@@ -4,11 +4,9 @@ module Indexing
class Category
- attr_reader :exact, :partial, :name, :index, :configuration
+ include Internals::Shared::Category
- # TODO Delegate to the index.
- #
- delegate :identifier, :prepare_index_directory, :prepared_index_file, :to => :configuration
+ attr_reader :name, :index, :exact, :partial
# Mandatory params:
# * name: Category name to use as identifier and file names.
@@ -25,18 +23,12 @@ class Category
# * tokenizer: Use a subclass of Tokenizers::Base that implements #tokens_for and #empty_tokens.
#
def initialize name, index, options = {}
- @name = name
- @from = options[:from]
-
- # Now we have enough info to combine the index and the category.
- #
- # TODO Remove.
- #
- @configuration = Configuration::Index.new index, self
+ @name = name
@index = index
- @tokenizer = options[:tokenizer]
@source = options[:source]
+ @from = options[:from]
+ @tokenizer = options[:tokenizer]
# TODO Push into Bundle. At least the weights.
#
@@ -45,18 +37,8 @@ def initialize name, index, options = {}
similarity = options[:similarity] || Generators::Similarity::Default
bundle_class = options[:indexing_bundle_class] || Bundle::Memory
- @exact = bundle_class.new(:exact, configuration, similarity, Generators::Partial::None.new, weights)
- @partial = bundle_class.new(:partial, configuration, Generators::Similarity::None.new, partial, weights)
- end
-
- def to_s
- <<-CATEGORY
-Category(#{name} from #{from}):
- Exact:
-#{exact.indented_to_s(4)}
- Partial:
-#{partial.indented_to_s(4)}
- CATEGORY
+ @exact = bundle_class.new(:exact, self, similarity, Generators::Partial::None.new, weights)
+ @partial = bundle_class.new(:partial, self, Generators::Similarity::None.new, partial, weights)
end
def source
View
52 server/lib/picky/internals/shared/category.rb
@@ -0,0 +1,52 @@
+module Internals
+ module Shared
+
+ module Category
+
+ def index_name
+ index.name
+ end
+ def category_name
+ name
+ end
+
+ # Path and partial filename of a specific index on this category.
+ #
+ def index_path bundle_name, type
+ "#{index_directory}/#{name}_#{bundle_name}_#{type}"
+ end
+
+ #
+ #
+ def prepared_index_path
+ @prepared_index_path ||= "#{index_directory}/prepared_#{name}_index"
+ end
+ def prepared_index_file &block
+ @prepared_index_file ||= Internals::Index::File::Text.new prepared_index_path
+ @prepared_index_file.open_for_indexing &block
+ end
+
+ # Identifier for internal use.
+ #
+ def identifier
+ @identifier ||= "#{index.name}:#{name}"
+ end
+ def to_s
+ "#{index.name} #{name}"
+ end
+
+ # The index directory for this category.
+ #
+ def index_directory
+ @index_directory ||= "#{PICKY_ROOT}/index/#{PICKY_ENVIRONMENT}/#{index.name}"
+ end
+ # Creates the index directory including all necessary paths above it.
+ #
+ def prepare_index_directory
+ FileUtils.mkdir_p index_directory
+ end
+
+ end
+
+ end
+end
View
6 server/lib/picky/loader.rb
@@ -147,6 +147,10 @@ def self.load_framework_internals
load_internals 'generators/weights_generator'
load_internals 'generators/similarity_generator'
+ # Shared index elements.
+ #
+ load_internals 'shared/category'
+
# Index store handling.
#
load_internals 'index/backend'
@@ -221,7 +225,7 @@ def self.load_framework_internals
# Configuration.
#
- load_internals 'configuration/index'
+ # load_internals 'configuration/index'
# Adapters.
#
View
2  server/lib/tasks/todo.rake
@@ -1,5 +1,5 @@
desc "Finds where Picky still needs input from you."
-task :'to#{}do' do
+task :"to#{}do" do
if system "grep -e 'TODO.*' -n --color=always -R *"
puts "Picky needs a bit of input from you there. Thanks."
else
View
80 server/spec/lib/internals/configuration/index_spec.rb
@@ -1,80 +0,0 @@
-require 'spec_helper'
-
-describe 'Configuration::Index' do
-
- before(:each) do
- @index = stub :index, :name => :some_index
- @category = stub :category, :name => :some_category
- @config = Configuration::Index.new @index, @category
- end
-
- describe "index_name" do
- it "returns the right thing" do
- @config.index_name.should == :some_index
- end
- end
- describe "category_name" do
- it "returns the right thing" do
- @config.category_name.should == :some_category
- end
- end
-
- describe "index_path" do
- it "caches" do
- @config.index_path(:some_bundle, :some_name).should_not equal(@config.index_path(:some_bundle, :some_name))
- end
- it "returns the right thing" do
- @config.index_path(:some_bundle, :some_name).should == 'spec/test_directory/index/test/some_index/some_category_some_bundle_some_name'
- end
- end
-
- # describe "file_name" do
- # it "caches" do
- # @config.file_name.should equal(@config.file_name)
- # end
- # it "returns the right thing" do
- # @config.file_name.should == 'some_index_some_category'
- # end
- # end
-
- describe "identifier" do
- it "caches" do
- @config.identifier.should equal(@config.identifier)
- end
- it "returns the right thing" do
- @config.identifier.should == 'some_index:some_category'
- end
- end
- describe "index_root" do
- it "caches" do
- @config.index_root.should equal(@config.index_root)
- end
- it "returns the right thing" do
- @config.index_root.should == 'spec/test_directory/index'
- end
- end
- describe "index_directory" do
- it "caches" do
- @config.index_directory.should equal(@config.index_directory)
- end
- it "returns the right thing" do
- @config.index_directory.should == 'spec/test_directory/index/test/some_index'
- end
- end
- describe "prepared_index_path" do
- it "caches" do
- @config.prepared_index_path.should equal(@config.prepared_index_path)
- end
- it "returns the right thing" do
- @config.prepared_index_path.should == 'spec/test_directory/index/test/some_index/prepared_some_category_index'
- end
- end
- describe "prepare_index_directory" do
- it "calls the right thing" do
- FileUtils.should_receive(:mkdir_p).once.with 'spec/test_directory/index/test/some_index'
-
- @config.prepare_index_directory
- end
- end
-
-end
View
5 server/spec/lib/internals/index/files_spec.rb
@@ -4,10 +4,9 @@
before(:each) do
index = stub :index, :name => :some_index
- category = stub :category, :name => :some_category
- configuration = Configuration::Index.new index, category
+ category = Internals::Indexing::Category.new :some_category, index
- @files = described_class.new :some_name, configuration
+ @files = described_class.new :some_name, category
@prepared = @files.prepared
View
171 server/spec/lib/internals/index/redis_spec.rb
@@ -1,74 +1,147 @@
require 'spec_helper'
describe Internals::Index::Redis do
-
- let(:config) do
- index = stub :index, :name => :some_index
- category = stub :category, :name => :some_category
- Configuration::Index.new index, category
- end
- let(:redis) { described_class.new :some_name, config }
-
- describe 'setting' do
- it 'delegates to the configuration' do
- configuration = stub :configuration
- redis.stub! :configuration => configuration
-
- configuration.should_receive(:member).once.with :some_sym
- redis.setting :some_sym
+ context 'indexing' do
+ let(:category) do
+ index = stub :index, :name => :some_index
+ category = Internals::Indexing::Category.new :some_category, index
end
- it 'returns the value' do
- configuration = stub :configuration
- redis.stub! :configuration => configuration
+ let(:redis) { described_class.new :some_name, category }
- configuration.should_receive(:member).any_number_of_times.and_return "some config"
+ describe 'setting' do
+ it 'delegates to the configuration' do
+ configuration = stub :configuration
+ redis.stub! :configuration => configuration
- redis.setting(:any).should == "some config"
- end
- end
- describe 'weight' do
- it 'delegates to the weights' do
- weights = stub :weights
- redis.stub! :weights => weights
+ configuration.should_receive(:member).once.with :some_sym
+
+ redis.setting :some_sym
+ end
+ it 'returns the value' do
+ configuration = stub :configuration
+ redis.stub! :configuration => configuration
- weights.should_receive(:member).once.with :some_sym
+ configuration.should_receive(:member).any_number_of_times.and_return "some config"
- redis.weight :some_sym
+ redis.setting(:any).should == "some config"
+ end
end
- it 'returns a floated value' do
- weights = stub :weights
- redis.stub! :weights => weights
+ describe 'weight' do
+ it 'delegates to the weights' do
+ weights = stub :weights
+ redis.stub! :weights => weights
- weights.should_receive(:member).any_number_of_times.and_return "1.0"
+ weights.should_receive(:member).once.with :some_sym
- redis.weight(:any).should == 1.0
+ redis.weight :some_sym
+ end
+ it 'returns a floated value' do
+ weights = stub :weights
+ redis.stub! :weights => weights
+
+ weights.should_receive(:member).any_number_of_times.and_return "1.0"
+
+ redis.weight(:any).should == 1.0
+ end
+ it 'returns a floated value' do
+ weights = stub :weights
+ redis.stub! :weights => weights
+
+ weights.should_receive(:member).any_number_of_times.and_return 1
+
+ redis.weight(:any).should == 1.0
+ end
end
- it 'returns a floated value' do
- weights = stub :weights
- redis.stub! :weights => weights
+ describe 'ids' do
+ it 'delegates to the index' do
+ index = stub :index
+ redis.stub! :index => index
- weights.should_receive(:member).any_number_of_times.and_return 1
+ index.should_receive(:collection).once.with :some_sym
- redis.weight(:any).should == 1.0
+ redis.ids :some_sym
+ end
+ it 'returns the value' do
+ index = stub :index
+ redis.stub! :index => index
+
+ index.should_receive(:collection).any_number_of_times.and_return [1,2,3]
+
+ redis.ids(:any).should == [1,2,3]
+ end
end
end
- describe 'ids' do
- it 'delegates to the index' do
- index = stub :index
- redis.stub! :index => index
+
+ context 'indexed' do
+ let(:category) do
+ index = stub :index, :name => :some_index
+ category = Internals::Indexed::Category.new :some_category, index
+ end
+ let(:redis) { described_class.new :some_name, category }
+
+ describe 'setting' do
+ it 'delegates to the configuration' do
+ configuration = stub :configuration
+ redis.stub! :configuration => configuration
+
+ configuration.should_receive(:member).once.with :some_sym
+
+ redis.setting :some_sym
+ end
+ it 'returns the value' do
+ configuration = stub :configuration
+ redis.stub! :configuration => configuration
+
+ configuration.should_receive(:member).any_number_of_times.and_return "some config"
+
+ redis.setting(:any).should == "some config"
+ end
+ end
+ describe 'weight' do
+ it 'delegates to the weights' do
+ weights = stub :weights
+ redis.stub! :weights => weights
- index.should_receive(:collection).once.with :some_sym
+ weights.should_receive(:member).once.with :some_sym
- redis.ids :some_sym
+ redis.weight :some_sym
+ end
+ it 'returns a floated value' do
+ weights = stub :weights
+ redis.stub! :weights => weights
+
+ weights.should_receive(:member).any_number_of_times.and_return "1.0"
+
+ redis.weight(:any).should == 1.0
+ end
+ it 'returns a floated value' do
+ weights = stub :weights
+ redis.stub! :weights => weights
+
+ weights.should_receive(:member).any_number_of_times.and_return 1
+
+ redis.weight(:any).should == 1.0
+ end
end
- it 'returns the value' do
- index = stub :index
- redis.stub! :index => index
+ describe 'ids' do
+ it 'delegates to the index' do
+ index = stub :index
+ redis.stub! :index => index
- index.should_receive(:collection).any_number_of_times.and_return [1,2,3]
+ index.should_receive(:collection).once.with :some_sym
- redis.ids(:any).should == [1,2,3]
+ redis.ids :some_sym
+ end
+ it 'returns the value' do
+ index = stub :index
+ redis.stub! :index => index
+
+ index.should_receive(:collection).any_number_of_times.and_return [1,2,3]
+
+ redis.ids(:any).should == [1,2,3]
+ end
end
end
+
end
View
10 server/spec/lib/internals/indexed/bundle/memory_spec.rb
@@ -3,12 +3,11 @@
describe Internals::Indexed::Bundle::Memory do
before(:each) do
- @category = stub :category, :name => :some_category
@index = stub :index, :name => :some_index
- @configuration = Configuration::Index.new @index, @category
+ @category = Internals::Indexed::Category.new :some_category, @index
@similarity = stub :similarity
- @bundle = described_class.new :some_name, @configuration, @similarity
+ @bundle = described_class.new :some_name, @category, @similarity
end
describe 'to_s' do
@@ -161,11 +160,10 @@
describe 'initialization' do
before(:each) do
- @category = stub :category, :name => :some_category
@index = stub :index, :name => :some_index
- @configuration = Configuration::Index.new @index, @category
+ @category = Internals::Indexed::Category.new :some_category, @index
- @bundle = described_class.new :some_name, @configuration, :similarity
+ @bundle = described_class.new :some_name, @category, :similarity
end
it 'should initialize the index correctly' do
@bundle.index.should == {}
View
5 server/spec/lib/internals/indexed/bundle/redis_spec.rb
@@ -7,12 +7,11 @@
Internals::Index::Redis.stub! :new => @backend
- @category = stub :category, :name => :some_category
@index = stub :index, :name => :some_index
- @configuration = Configuration::Index.new @index, @category
+ @category = Internals::Indexed::Category.new :some_category, @index
@similarity = stub :similarity
- @bundle = described_class.new :some_name, @configuration, @similarity
+ @bundle = described_class.new :some_name, @category, @similarity
end
describe 'ids' do
View
5 server/spec/lib/internals/indexing/bundle/memory_partial_generation_speed_spec.rb
@@ -3,12 +3,11 @@
describe Internals::Indexing::Bundle::Memory do
before(:each) do
- @category = stub :category, :name => :some_category
@index = stub :index, :name => :some_index
- @configuration = Configuration::Index.new @index, @category
+ @category = Internals::Indexing::Category.new :some_category, @index
@partial_strategy = Internals::Generators::Partial::Substring.new :from => 1
- @exact = described_class.new :some_name, @configuration, nil, @partial_strategy, nil
+ @exact = described_class.new :some_name, @category, nil, @partial_strategy, nil
end
def generate_random_keys amount
View
11 server/spec/lib/internals/indexing/bundle/memory_spec.rb
@@ -3,15 +3,14 @@
describe Internals::Indexing::Bundle::Memory do
before(:each) do
- @internal_index = stub :index, :name => :some_index
- @category = stub :category, :name => :some_category
- @configuration = Configuration::Index.new @internal_index, @category
+ @index = stub :index, :name => :some_index
+ @category = Internals::Indexing::Category.new :some_category, @index
@partial = stub :partial
@weights = stub :weights
@similarity = stub :similarity
end
- let(:index) { described_class.new :some_name, @configuration, @similarity, @partial, @weights }
+ let(:index) { described_class.new :some_name, @category, @similarity, @partial, @weights }
describe 'raise_cache_missing' do
it 'does something' do
@@ -65,8 +64,8 @@
index.stub! :files => files
@ary = stub :ary
- @internal_index.should_receive(:[]).any_number_of_times.and_return @ary
- index.stub! :index => @internal_index
+ @index.should_receive(:[]).any_number_of_times.and_return @ary
+ index.stub! :index => @index
end
context 'id key format' do
before(:each) do
View
11 server/spec/lib/internals/indexing/bundle/redis_spec.rb
@@ -3,15 +3,14 @@
describe Internals::Indexing::Bundle::Redis do
before(:each) do
- @internal_index = stub :index, :name => :some_index
- @category = stub :category, :name => :some_category
- @configuration = Configuration::Index.new @internal_index, @category
+ @index = stub :index, :name => :some_index
+ @category = Internals::Indexing::Category.new :some_category, @index
@partial = stub :partial
@weights = stub :weights
@similarity = stub :similarity
end
- let(:index) { described_class.new :some_name, @configuration, @similarity, @partial, @weights }
+ let(:index) { described_class.new :some_name, @category, @similarity, @partial, @weights }
describe 'raise_cache_missing' do
it 'does something' do
@@ -65,8 +64,8 @@
index.stub! :files => files
@ary = stub :ary
- @internal_index.should_receive(:[]).any_number_of_times.and_return @ary
- index.stub! :index => @internal_index
+ @index.should_receive(:[]).any_number_of_times.and_return @ary
+ index.stub! :index => @index
end
context 'id key format' do
before(:each) do
View
2  server/test_project/config.ru
@@ -5,7 +5,7 @@
#
require File.expand_path '../../lib/picky', __FILE__
-# Load your application. This requires the files in lib TODO
+# Load your application.
#
Loader.load_application
Please sign in to comment.
Something went wrong with that request. Please try again.