Permalink
Browse files

+ moving to 1.5.3

  • Loading branch information...
1 parent 747155e commit 64dab00d2d4890edac2ae9ab786d9c32e829ea0f @floere committed Mar 13, 2011
Showing with 1,193 additions and 862 deletions.
  1. +53 −33 server/lib/picky/application.rb
  2. +10 −6 server/lib/picky/character_substituters/west_european.rb
  3. +18 −18 server/lib/picky/cli.rb
  4. +44 −13 server/lib/picky/index/base.rb
  5. +13 −4 server/lib/picky/index_bundle.rb
  6. +26 −10 server/lib/picky/indexed/indexes.rb
  7. +26 −24 server/lib/picky/indexing/indexes.rb
  8. +23 −16 server/lib/picky/interfaces/live_parameters.rb
  9. +13 −6 server/lib/picky/internals/extensions/object.rb
  10. +30 −34 server/lib/picky/internals/frontend_adapters/rack.rb
  11. +1 −2 server/lib/picky/internals/index/backend.rb
  12. +18 −14 server/lib/picky/internals/index/file/basic.rb
  13. +16 −6 server/lib/picky/internals/index/files.rb
  14. +2 −2 server/lib/picky/internals/index/redis.rb
  15. +12 −5 server/lib/picky/internals/index/redis/basic.rb
  16. +58 −14 server/lib/picky/internals/indexed/bundle/base.rb
  17. +40 −14 server/lib/picky/internals/indexed/bundle/memory.rb
  18. +9 −30 server/lib/picky/internals/indexed/bundle/redis.rb
  19. +19 −14 server/lib/picky/internals/indexed/categories.rb
  20. +44 −20 server/lib/picky/internals/indexed/category.rb
  21. +23 −13 server/lib/picky/internals/indexed/index.rb
  22. +27 −9 server/lib/picky/internals/indexed/wrappers/bundle/wrapper.rb
  23. +1 −1 server/lib/picky/internals/indexers/serial.rb
  24. +28 −28 server/lib/picky/internals/indexing/bundle/base.rb
  25. +14 −7 server/lib/picky/internals/indexing/bundle/memory.rb
  26. +15 −11 server/lib/picky/internals/indexing/categories.rb
  27. +30 −20 server/lib/picky/internals/indexing/category.rb
  28. +22 −14 server/lib/picky/internals/indexing/index.rb
  29. +0 −15 server/lib/picky/internals/query/allocations.rb
  30. +0 −4 server/lib/picky/internals/query/combinations/base.rb
  31. +19 −8 server/lib/picky/internals/query/combinations/redis.rb
  32. +3 −6 server/lib/picky/internals/query/indexes.rb
  33. +0 −4 server/lib/picky/internals/query/token.rb
  34. +2 −11 server/lib/picky/internals/query/weights.rb
  35. +3 −10 server/lib/picky/internals/results/base.rb
  36. +64 −28 server/lib/picky/internals/tokenizers/base.rb
  37. +8 −8 server/lib/picky/internals/tokenizers/index.rb
  38. +59 −53 server/lib/picky/loader.rb
  39. +23 −29 server/lib/picky/query/base.rb
  40. +10 −10 server/lib/picky/sources/base.rb
  41. +14 −10 server/lib/picky/sources/couch.rb
  42. +21 −14 server/lib/picky/sources/csv.rb
  43. +37 −31 server/lib/picky/sources/db.rb
  44. +11 −8 server/lib/picky/sources/delicious.rb
  45. +3 −1 server/lib/picky/sources/wrappers/base.rb
  46. +3 −0 server/lib/tasks/application.rake
  47. +3 −0 server/lib/tasks/framework.rake
  48. +9 −11 server/lib/tasks/index.rake
  49. +3 −2 server/lib/tasks/routes.rake
  50. +16 −4 server/lib/tasks/shortcuts.rake
  51. +20 −12 server/lib/tasks/statistics.rake
  52. +14 −14 server/lib/tasks/try.rake
  53. +3 −3 server/spec/lib/application_spec.rb
  54. +25 −3 server/spec/lib/index/base_spec.rb
  55. +46 −20 server/spec/lib/internals/extensions/object_spec.rb
  56. +3 −3 server/spec/lib/internals/frontend_adapters/rack_spec.rb
  57. +1 −1 server/spec/lib/internals/indexers/serial_spec.rb
  58. +0 −12 server/spec/lib/internals/results/base_spec.rb
  59. +49 −1 server/spec/lib/internals/tokenizers/base_spec.rb
  60. +0 −56 server/spec/lib/query/allocations_spec.rb
  61. +25 −21 server/spec/lib/query/base_spec.rb
  62. +6 −1 server/spec/lib/query/combinations/redis_spec.rb
  63. +2 −2 server/spec/lib/sources/delicious_spec.rb
  64. +40 −52 server/test_project/app/application.rb
  65. +1 −1 server/test_project/app/logging.rb
  66. +3 −2 server/test_project/spec/app/application_spec.rb
  67. +8 −2 server/test_project/spec/integration_spec.rb
  68. +1 −1 version.rb
@@ -19,12 +19,12 @@
# my_index = Index::Memory.new :some_index_name, some_source
# You give the index a name (or identifier), and a source (see Sources), where its data comes from. Let's do that:
# class MyGreatSearch < Application
-#
+#
# books = Index::Memory.new :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv')
-#
+#
# end
# Now we have an index <tt>books</tt>.
-#
+#
# That on itself won't do much good.
#
# Note that a Redis index is also available: Index::Redis.new.
@@ -38,7 +38,7 @@
#
# Let's go ahead and define a category:
# class MyGreatSearch < Application
-#
+#
# books = Index::Memory.new :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv')
# books.define_category :title
#
@@ -56,16 +56,16 @@
# full_books_query = Query::Full.new books
# Full just means that the ids are returned with the results.
# Picky also offers a Query that returns live results, Query::Live. But that's not important right now.
-#
+#
# Now we have somebody we can ask about the index. But no external interface.
-#
+#
# == route(/regexp1/ => query1, /regexp2/ => query2, ...)
#
# Let's add a URL path (a Route, see http://github.com/floere/picky/wiki/Routing-configuration) to which we can send our queries. We do that with the route method:
# route %r{^/books/full$} => full_books_query
# In full glory:
# class MyGreatSearch < Application
-#
+#
# books = index :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv')
# books.define_category :title
#
@@ -110,7 +110,7 @@
#
# Our example, fully fleshed out with indexing, querying, and weights:
# class MyGreatSearch < Application
-#
+#
# default_indexing removes_characters: /[^a-zA-Z0-9\.]/,
# stopwords: /\b(and|or|in|on|is|has)\b/,
# splits_text_on: /\s/,
@@ -127,7 +127,7 @@
# removes_characters_after_splitting: /\./,
# substitutes_characters_with: CharacterSubstituters::WestEuropean.new,
# maximum_tokens: 4
-#
+#
# books = Index::Memory.new :books, Sources::CSV.new(:title, :author, :isbn, file:'app/library.csv')
# books.define_category :title,
# qualifiers: [:t, :title, :titre],
@@ -136,36 +136,36 @@
# books.define_category :author,
# partial: Partial::Substring.new(:from => -2)
# books.define_category :isbn
-#
+#
# query_options = { :weights => { [:title, :author] => +3, [:author, :title] => -1 } }
-#
+#
# route %r{^/books/full$} => Query::Full.new(books, query_options)
# route %r{^/books/live$} => Query::Live.new(books, query_options)
-#
+#
# end
# That's actually already a full-blown Picky App!
#
class Application
-
+
class << self
-
+
# API
#
-
+
# Returns a configured tokenizer that
# is used for indexing by default.
- #
+ #
def default_indexing options = {}
Internals::Tokenizers::Index.default = Internals::Tokenizers::Index.new(options)
end
-
+
# Returns a configured tokenizer that
# is used for querying by default.
- #
+ #
def default_querying options = {}
Internals::Tokenizers::Query.default = Internals::Tokenizers::Query.new(options)
end
-
+
# Create a new index for indexing and for querying.
#
# Parameters:
@@ -176,22 +176,23 @@ def default_querying options = {}
# * source: The source the data comes from. See Sources::Base.
#
# Options:
- # * result_identifier: Use if you'd like a different identifier/name in the results JSON than the name of the index.
+ # * result_identifier: Use if you'd like a different identifier/name in the results JSON than the name of the index.
#
- # TODO Obsolete. Phase out.
+ # TODO Remove in 1.6.
#
def index name, source, options = {}
+ raise "the Picky application method #index is deprecated, please use Index::Memory.new instead."
Index::Memory.new name, source, options
end
-
+
# Routes.
#
delegate :route, :root, :to => :rack_adapter
-
+
#
# API
-
-
+
+
# A Picky application implements the Rack interface.
#
# Delegates to its routing to handle a request.
@@ -202,7 +203,7 @@ def call env
def rack_adapter # :nodoc:
@rack_adapter ||= Internals::FrontendAdapters::Rack.new
end
-
+
# Finalize the subclass as soon as it
# has finished loading.
#
@@ -233,18 +234,37 @@ def finalize # :nodoc:
def check # :nodoc:
warnings = []
warnings << check_external_interface
- puts "\n#{warnings.join(?\n)}\n\n" unless warnings.all? &:nil?
+ warn "\n#{warnings.join(?\n)}\n\n" unless warnings.all? &:nil?
end
def check_external_interface
"WARNING: No routes defined for application configuration in #{self.class}." if rack_adapter.empty?
end
-
- # TODO Add more info if possible.
- #
+
def to_s # :nodoc:
- "#{self.name}:\n#{rack_adapter}"
+ <<-APPLICATION
+\033[1m#{name}\033[m
+#{to_stats.indented_to_s}
+APPLICATION
+ end
+ def to_stats
+ <<-APP
+\033[1mIndexing (default)\033[m:
+#{Internals::Tokenizers::Index.default.indented_to_s}
+
+\033[1mQuerying (default)\033[m:
+#{Internals::Tokenizers::Query.default.indented_to_s}
+
+\033[1mIndexes\033[m:
+#{Indexes.to_s.indented_to_s}
+
+\033[1mRoutes\033[m:
+#{to_routes.indented_to_s}
+APP
+ end
+ def to_routes
+ rack_adapter.to_s
end
-
+
end
-
+
end
@@ -6,28 +6,32 @@ module CharacterSubstituters # :nodoc:all
# (and more, see specs)
#
class WestEuropean
-
+
def initialize
@chars = ActiveSupport::Multibyte.proxy_class
end
-
+
+ def to_s
+ self.class.name
+ end
+
def substitute text
trans = @chars.new(text).normalize(:kd)
-
+
# substitute special cases
#
trans.gsub!('ß', 'ss')
-
+
# substitute umlauts (of A,O,U,a,o,u)
#
trans.gsub!(/([AOUaou])\314\210/u, '\1e')
-
+
# get rid of ecutes, graves and …
#
trans.unpack('U*').select { |cp|
cp < 0x0300 || cp > 0x035F
}.pack('U*')
end
-
+
end
end
View
@@ -1,9 +1,9 @@
module Picky
-
+
# A very simple CLI selector.
#
class CLI # :nodoc:all
-
+
# Execute a command.
#
# Note: By default, help is displayed. I.e. when no command is given.
@@ -16,7 +16,7 @@ def execute selector = nil, *args
def executor_class_for selector = nil
selector && @@mapping[selector.to_sym] || [Help]
end
-
+
class Base
def usage name, params
puts "Usage\n picky #{name} #{params_to_s(params)}"
@@ -31,41 +31,41 @@ class Statistics < Base
def execute name, args, params
relative_log_file = args.shift
port = args.shift
-
+
usage(name, params) || exit(1) unless relative_log_file
-
- ENV['PICKY_LOG_FILE'] = File.expand_path relative_log_file
+
+ ENV['PICKY_LOG_FILE'] = File.expand_path relative_log_file
ENV['PICKY_STATISTICS_PORT'] = port
-
+
begin
require 'picky-statistics'
rescue LoadError => e
require 'picky/extensions/object'
- puts_gem_missing 'picky-statistics', 'the Picky statistics'
+ warn_gem_missing 'picky-statistics', 'the Picky statistics'
exit 1
end
-
+
require 'picky-statistics/application/app'
end
end
class Live < Base
def execute name, args, params
url = args.shift
port = args.shift
-
+
usage(name, params) || exit(1) unless args.empty?
-
+
ENV['PICKY_LIVE_URL'] = url
ENV['PICKY_LIVE_PORT'] = port
-
+
begin
require 'picky-live'
rescue LoadError => e
require 'picky/extensions/object'
- puts_gem_missing 'picky-live', 'the Picky Live Interface'
+ warn_gem_missing 'picky-live', 'the Picky Live Interface'
exit 1
end
-
+
require 'picky-live/application/app'
end
end
@@ -82,11 +82,11 @@ def execute name, args, params
_, *params = object_and_params
" picky #{command} #{params_to_s(params)}"
end.join(?\n)
-
+
puts "Possible commands:\n" + commands
end
end
-
+
# Maps commands to the other gem's command.
#
@@mapping = {
@@ -98,7 +98,7 @@ def execute name, args, params
def self.mapping
@@mapping
end
-
+
end
-
+
end
Oops, something went wrong.

0 comments on commit 64dab00

Please sign in to comment.