Permalink
Browse files

Updated searchgasm

  • Loading branch information...
1 parent f8e95aa commit b01fee22afd0657a0a75f81d509a9ee164dbcbd6 @binarylogic committed Sep 23, 2008
Showing with 492 additions and 541 deletions.
  1. +0 −1 app/models/user.rb
  2. +1 −1 config/environment.rb
  3. +1 −1 config/initializers/searchgasm.rb
  4. +0 −8 vendor/plugins/searchgasm-1.1.1/lib/searchgasm/active_record.rb
  5. +0 −9 vendor/plugins/searchgasm-1.1.1/lib/searchgasm/helpers.rb
  6. +0 −57 vendor/plugins/searchgasm-1.1.1/lib/searchgasm/helpers/control_types.rb
  7. +0 −7 vendor/plugins/searchgasm-1.1.1/lib/searchgasm/search.rb
  8. +0 −41 vendor/plugins/searchgasm-1.1.1/lib/searchgasm/shared/searching.rb
  9. +0 −216 vendor/plugins/searchgasm-1.1.1/searchgasm.gemspec
  10. +6 −0 vendor/plugins/searchgasm/.gitignore
  11. +15 −0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/CHANGELOG.rdoc
  12. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/MIT-LICENSE
  13. +2 −4 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/Manifest
  14. +3 −4 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/README.rdoc
  15. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/Rakefile
  16. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/examples/README.rdoc
  17. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/init.rb
  18. +3 −1 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm.rb
  19. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/active_record/associations.rb
  20. +23 −20 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/active_record/base.rb
  21. +13 −9 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/base.rb
  22. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/begins_with.rb
  23. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/child_of.rb
  24. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/contains.rb
  25. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/descendant_of.rb
  26. +2 −4 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/does_not_equal.rb
  27. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/ends_with.rb
  28. +2 −4 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/equals.rb
  29. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/greater_than.rb
  30. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/greater_than_or_equal_to.rb
  31. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/inclusive_descendant_of.rb
  32. +23 −0 vendor/plugins/searchgasm/lib/searchgasm/condition/is_blank.rb
  33. +23 −0 vendor/plugins/searchgasm/lib/searchgasm/condition/is_nil.rb
  34. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/keywords.rb
  35. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/less_than.rb
  36. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/less_than_or_equal_to.rb
  37. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/sibling_of.rb
  38. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/condition/tree.rb
  39. +41 −28 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/conditions/base.rb
  40. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/conditions/protection.rb
  41. +14 −14 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/config.rb
  42. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/core_ext/hash.rb
  43. +55 −0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/helpers/control_types/link.rb
  44. +4 −9 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/helpers/control_types/links.rb
  45. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/helpers/control_types/remote_link.rb
  46. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/helpers/control_types/remote_links.rb
  47. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/helpers/control_types/remote_select.rb
  48. +7 −4 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/helpers/control_types/select.rb
  49. +2 −2 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/helpers/form.rb
  50. +3 −2 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/helpers/utilities.rb
  51. +27 −3 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/search/base.rb
  52. +11 −14 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/search/conditions.rb
  53. +32 −29 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/search/ordering.rb
  54. +16 −10 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/search/pagination.rb
  55. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/search/protection.rb
  56. +43 −0 vendor/plugins/searchgasm/lib/searchgasm/shared/searching.rb
  57. +18 −0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/shared/utilities.rb
  58. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/shared/virtual_classes.rb
  59. +1 −1 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/lib/searchgasm/version.rb
  60. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/fixtures/accounts.yml
  61. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/fixtures/orders.yml
  62. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/fixtures/users.yml
  63. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/libs/acts_as_tree.rb
  64. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/libs/rexml_fix.rb
  65. +2 −2 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_active_record_associations.rb
  66. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_active_record_base.rb
  67. +2 −14 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_condition_base.rb
  68. +48 −0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_condition_types.rb
  69. +21 −10 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_conditions_base.rb
  70. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_conditions_protection.rb
  71. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_config.rb
  72. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_helper.rb
  73. +28 −12 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_search_base.rb
  74. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_search_conditions.rb
  75. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_search_ordering.rb
  76. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_search_pagination.rb
  77. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/test_search_protection.rb
  78. 0 vendor/plugins/{searchgasm-1.1.1 → searchgasm}/test/text_config.rb
View
@@ -1,5 +1,4 @@
class User < ActiveRecord::Base
belongs_to :user_group
- has_one :cool_order, :class_name => "Order", :conditions => {:total => 100}
has_many :orders
end
View
@@ -46,7 +46,7 @@
config.time_zone = 'UTC'
#if RAILS_ENV == "development" # putting this in environments/development.rb doesn't work, not sure why
- # config.plugin_paths = ["#{RAILS_ROOT}/../../Ruby Libs"]
+ # config.plugin_paths = ["#{RAILS_ROOT}/../../Libs"]
# config.plugins = [:searchgasm]
# require "ruby-debug"
#end
@@ -1,6 +1,6 @@
# Confugration
Searchgasm::Config.configure do |config|
- config.per_page = config.per_page_choices.first # 20
+ config.per_page = config.per_page_choices.first # 10
end
# Actual function for MySQL databases only
@@ -1,8 +0,0 @@
-module Searchgasm
- # == Searchgasm ActiveRecord
- #
- # Hooks into ActiveRecord to add all of the searchgasm functionality into your models. Only uses what is publically available, doesn't dig into internals, and
- # searchgasm only gets involved when needed.
- module ActiveRecord
- end
-end
@@ -1,9 +0,0 @@
-module Searchgasm
- # = Searchgasm Helpers
- #
- # Provides helpers for rails applications that make using Searchgasm extremely easy. Please see Searchgasm::Helpers::ControlTypes and Searchgasm::Helpers::Form for more information on how to use these helpers.
- #
- # Also, I am always looking to improve these. I feel confident that I made these flexible enough for just about any need, but there is always that one crazy instance. If these helpers restrict you
- # in any way please contact me and let me know. You can do some on my website: www.binarylogic.com. I will more than likely add in your functionality that week.
- module Helpers
- module UtilitiesHelper # :nodoc:
@@ -1,57 +0,0 @@
-module Searchgasm
- module Helpers
- # = Control Type Helpers
- #
- # The purpose of these helpers is to make ordering and paginating data, in your view, a breeze. Everyone has their own flavor of displaying data, so I made these helpers extra flexible, just for you.
- #
- # === Tutorial
- #
- # Check out my tutorial on how to implement searchgasm into a rails app: http://www.binarylogic.com/2008/9/7/tutorial-pagination-ordering-and-searching-with-searchgasm
- #
- # === How it's organized
- #
- # If we break it down, you can do 4 different things with your data in your view:
- #
- # 1. Order your data by a single column or an array of columns
- # 2. Descend or ascend your data
- # 3. Change how many items are on each page
- # 4. Paginate through your data
- #
- # Each one of these actions comes with 3 different types of helpers:
- #
- # 1. Link - A single link for a single value. Requires that you pass a value as the first parameter.
- # 2. Links - A group of single links.
- # 3. Select - A select with choices that perform an action once selected. Basically the same thing as a group of links, but just as a select form element
- # 4. Remote - lets you prefix any of these helpers with "remote_" and it will use the built in rails ajax helpers. I highly recommend unobstrusive javascript though, using jQuery.
- #
- # === Examples
- #
- # Sometimes the best way to explain something is with some examples. Let's pretend we are performing these actions on a User model. Check it out:
- #
- # order_by_link(:name)
- # => produces a single link that when clicked will order by the name column, and each time its clicked alternated between "ASC" and "DESC"
- #
- # order_by_links
- # => produces a group of links for all of the columns in your users table, each link is basically order_by_link(column.name)
- #
- # order_by_select
- # => produces a select form element with all of the user's columns as choices, when the value is change (onchange) it will act as if they clicked a link.
- # => This is just order_by_links as a select form element, nothing fancy
- #
- # What about paginating? I got you covered:
- #
- # page_link(2)
- # => creates a link to page 2
- #
- # page_links
- # => creates a group of links for pages, similar to a flickr style of pagination
- #
- # page_select
- # => creates a drop down instead of a group of links. The user can select the page in the drop down and it will be as if they clicked a link for that page.
- #
- # You can apply the _link, _links, or _select to any of the following: order_by, order_as, per_page, page. You have your choice on how you want to set up the interface. For more information and options on these individual
- # helpers check out their source files. Look at the sub modules under this one (Ex: Searchgasm::Helpers::ControlTypes::Select)
- module ControlTypes
- end
- end
-end
@@ -1,7 +0,0 @@
-module Searchgasm
- # = Searchgasm Shared Functionality
- #
- # Encapsulates shared functions / code that is used throughout searchgasm, so that we dont repeat ourself
- module Shared
- end
-end
@@ -1,41 +0,0 @@
-module Searchgasm
- module Shared
- # = Searchgasm Searching
- #
- # Implements searching functionality for searchgasm. Searchgasm::Search::Base and Searchgasm::Conditions::Base can both search and include
- # this module.
- module Searching
- # Use these methods just like you would in ActiveRecord
- SEARCH_METHODS = [:all, :find, :first]
- CALCULATION_METHODS = [:average, :calculate, :count, :maximum, :minimum, :sum]
-
- # Setup methods for searching
- SEARCH_METHODS.each do |method|
- class_eval <<-"end_eval", __FILE__, __LINE__
- def #{method}(*args)
- options = args.extract_options!
- klass.send(:with_scope, :find => options) do
- args << (self.class < Searchgasm::Conditions::Base ? {:conditions => sanitize} : sanitize)
- klass.#{method}(*args)
- end
- end
- end_eval
- end
-
- # Setup methods for calculating
- CALCULATION_METHODS.each do |method|
- class_eval <<-"end_eval", __FILE__, __LINE__
- def #{method}(*args)
- options = args.extract_options!
- klass.send(:with_scope, :find => options) do
- find_options = (self.class < Searchgasm::Conditions::Base ? {:conditions => sanitize} : sanitize(false))
- [:select, :limit, :offset].each { |option| find_options.delete(option) }
- args << find_options
- klass.#{method}(*args)
- end
- end
- end_eval
- end
- end
- end
-end
@@ -1,216 +0,0 @@
-
-# Gem::Specification for Searchgasm-1.1.1
-# Originally generated by Echoe
-
---- !ruby/object:Gem::Specification
-name: searchgasm
-version: !ruby/object:Gem::Version
- version: 1.1.1
-platform: ruby
-authors:
-- Ben Johnson of Binary Logic
-autorequire:
-bindir: bin
-
-date: 2008-09-19 00:00:00 -04:00
-default_executable:
-dependencies:
-- !ruby/object:Gem::Dependency
- name: activerecord
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-- !ruby/object:Gem::Dependency
- name: activesupport
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-- !ruby/object:Gem::Dependency
- name: echoe
- type: :development
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-description: Object based ActiveRecord searching, ordering, pagination, and more!
-email: bjohnson@binarylogic.com
-executables: []
-
-extensions: []
-
-extra_rdoc_files:
-- CHANGELOG.rdoc
-- lib/searchgasm/active_record/associations.rb
-- lib/searchgasm/active_record/base.rb
-- lib/searchgasm/active_record.rb
-- lib/searchgasm/condition/base.rb
-- lib/searchgasm/condition/begins_with.rb
-- lib/searchgasm/condition/child_of.rb
-- lib/searchgasm/condition/contains.rb
-- lib/searchgasm/condition/descendant_of.rb
-- lib/searchgasm/condition/does_not_equal.rb
-- lib/searchgasm/condition/ends_with.rb
-- lib/searchgasm/condition/equals.rb
-- lib/searchgasm/condition/greater_than.rb
-- lib/searchgasm/condition/greater_than_or_equal_to.rb
-- lib/searchgasm/condition/inclusive_descendant_of.rb
-- lib/searchgasm/condition/keywords.rb
-- lib/searchgasm/condition/less_than.rb
-- lib/searchgasm/condition/less_than_or_equal_to.rb
-- lib/searchgasm/condition/sibling_of.rb
-- lib/searchgasm/condition/tree.rb
-- lib/searchgasm/conditions/base.rb
-- lib/searchgasm/conditions/protection.rb
-- lib/searchgasm/config.rb
-- lib/searchgasm/core_ext/hash.rb
-- lib/searchgasm/helpers/control_types/link.rb
-- lib/searchgasm/helpers/control_types/links.rb
-- lib/searchgasm/helpers/control_types/remote_link.rb
-- lib/searchgasm/helpers/control_types/remote_links.rb
-- lib/searchgasm/helpers/control_types/remote_select.rb
-- lib/searchgasm/helpers/control_types/select.rb
-- lib/searchgasm/helpers/control_types.rb
-- lib/searchgasm/helpers/form.rb
-- lib/searchgasm/helpers/utilities.rb
-- lib/searchgasm/helpers.rb
-- lib/searchgasm/search/base.rb
-- lib/searchgasm/search/conditions.rb
-- lib/searchgasm/search/ordering.rb
-- lib/searchgasm/search/pagination.rb
-- lib/searchgasm/search/protection.rb
-- lib/searchgasm/search.rb
-- lib/searchgasm/shared/searching.rb
-- lib/searchgasm/shared/utilities.rb
-- lib/searchgasm/shared/virtual_classes.rb
-- lib/searchgasm/version.rb
-- lib/searchgasm.rb
-- README.rdoc
-files:
-- CHANGELOG.rdoc
-- examples/README.rdoc
-- init.rb
-- lib/searchgasm/active_record/associations.rb
-- lib/searchgasm/active_record/base.rb
-- lib/searchgasm/active_record.rb
-- lib/searchgasm/condition/base.rb
-- lib/searchgasm/condition/begins_with.rb
-- lib/searchgasm/condition/child_of.rb
-- lib/searchgasm/condition/contains.rb
-- lib/searchgasm/condition/descendant_of.rb
-- lib/searchgasm/condition/does_not_equal.rb
-- lib/searchgasm/condition/ends_with.rb
-- lib/searchgasm/condition/equals.rb
-- lib/searchgasm/condition/greater_than.rb
-- lib/searchgasm/condition/greater_than_or_equal_to.rb
-- lib/searchgasm/condition/inclusive_descendant_of.rb
-- lib/searchgasm/condition/keywords.rb
-- lib/searchgasm/condition/less_than.rb
-- lib/searchgasm/condition/less_than_or_equal_to.rb
-- lib/searchgasm/condition/sibling_of.rb
-- lib/searchgasm/condition/tree.rb
-- lib/searchgasm/conditions/base.rb
-- lib/searchgasm/conditions/protection.rb
-- lib/searchgasm/config.rb
-- lib/searchgasm/core_ext/hash.rb
-- lib/searchgasm/helpers/control_types/link.rb
-- lib/searchgasm/helpers/control_types/links.rb
-- lib/searchgasm/helpers/control_types/remote_link.rb
-- lib/searchgasm/helpers/control_types/remote_links.rb
-- lib/searchgasm/helpers/control_types/remote_select.rb
-- lib/searchgasm/helpers/control_types/select.rb
-- lib/searchgasm/helpers/control_types.rb
-- lib/searchgasm/helpers/form.rb
-- lib/searchgasm/helpers/utilities.rb
-- lib/searchgasm/helpers.rb
-- lib/searchgasm/search/base.rb
-- lib/searchgasm/search/conditions.rb
-- lib/searchgasm/search/ordering.rb
-- lib/searchgasm/search/pagination.rb
-- lib/searchgasm/search/protection.rb
-- lib/searchgasm/search.rb
-- lib/searchgasm/shared/searching.rb
-- lib/searchgasm/shared/utilities.rb
-- lib/searchgasm/shared/virtual_classes.rb
-- lib/searchgasm/version.rb
-- lib/searchgasm.rb
-- Manifest
-- MIT-LICENSE
-- Rakefile
-- README.rdoc
-- test/fixtures/accounts.yml
-- test/fixtures/orders.yml
-- test/fixtures/users.yml
-- test/libs/acts_as_tree.rb
-- test/libs/rexml_fix.rb
-- test/test_active_record_associations.rb
-- test/test_active_record_base.rb
-- test/test_condition_base.rb
-- test/test_condition_types.rb
-- test/test_conditions_base.rb
-- test/test_conditions_protection.rb
-- test/test_config.rb
-- test/test_helper.rb
-- test/test_search_base.rb
-- test/test_search_conditions.rb
-- test/test_search_ordering.rb
-- test/test_search_pagination.rb
-- test/test_search_protection.rb
-- test/text_config.rb
-- searchgasm.gemspec
-has_rdoc: true
-homepage: http://github.com/binarylogic/searchgasm
-post_install_message:
-rdoc_options:
-- --line-numbers
-- --inline-source
-- --title
-- Searchgasm
-- --main
-- README.rdoc
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - "="
- - !ruby/object:Gem::Version
- version: "1.2"
- version:
-requirements: []
-
-rubyforge_project: searchgasm
-rubygems_version: 1.2.0
-specification_version: 2
-summary: Object based ActiveRecord searching, ordering, pagination, and more!
-test_files:
-- test/test_active_record_associations.rb
-- test/test_active_record_base.rb
-- test/test_condition_base.rb
-- test/test_condition_types.rb
-- test/test_conditions_base.rb
-- test/test_conditions_protection.rb
-- test/test_config.rb
-- test/test_helper.rb
-- test/test_search_base.rb
-- test/test_search_conditions.rb
-- test/test_search_ordering.rb
-- test/test_search_pagination.rb
-- test/test_search_protection.rb
@@ -0,0 +1,6 @@
+.DS_Store
+*.log
+pkg/*
+coverage/*
+doc/*
+benchmarks/*
@@ -1,3 +1,18 @@
+== 1.1.3 released 2008-09-23
+
+* Setting a condition to nil removes it if the condition is set to ignore blanks
+* Setting search.conditions = "some sql" will reset ALL conditions. Alternatively search.conditions => {:first_name_contains => "Ben"} will overwrite "some sql". The same goes with search.conditions.first_name_contains = "Ben".
+* Fixed bug with inspect
+* Other small performance enhancements with memoized attributes
+
+== 1.1.2 released 2008-09-22
+
+* Fixed bug with select control types not using :search_obj to determine its select values.
+* Added is_nil and is_blank condition types.
+* "memoized" various attributes for performance enhancements
+* Removed the :order option from calculation options when :order is useless and just slows down query.
+* Switched from using :include to :joins, big performance increase
+
== 1.1.1 released 2008-09-19
* Fixed typo in "next page" button.
Oops, something went wrong.

0 comments on commit b01fee2

Please sign in to comment.