binarylogic-searchlogic 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,8 +1,13 @@
1
- == 2.0.2
1
+ == 2.1.1 released 2009-06-28
2
+
3
+ * Added inner_join convenience method.
4
+
5
+ == 2.1.0 released 2009-06-28
2
6
 
3
7
  * Added a delete method to the Search class to allow the deleting of conditions off of the object.
4
8
  * Add alias_scope feature, lets your create "named scopes" that represent a procedure of named scopes, while at the same time telling Searchlogic it is safe to use in the Search class.
5
9
  * Use url_for as the default with form_for since rails does some magic to determine the url to use.
10
+ * Switched to using inner joins instead of left outer joins.
6
11
 
7
12
  == 2.0.1 released 2009-06-20
8
13
 
data/README.rdoc CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  <b>Searchlogic has been <em>completely</em> rewritten for v2. It is much simpler and has taken an entirely new approach. To give you an idea, v1 had ~2300 lines of code, v2 has ~420 lines of code.</b>
4
4
 
5
- <b>Attention v1 users. To start using v2 you must use the binarylogic-searchlogic gem. I have decided to start using github to host my gems. See below for installation instructions.</b>
6
-
7
5
  Searchlogic provides common named scopes and object based searching for ActiveRecord.
8
6
 
9
7
  == Helpful links
@@ -19,19 +17,21 @@ If you find a bug or a problem please post it on lighthouse. If you need help wi
19
17
 
20
18
  == Install & use
21
19
 
22
- In your rails project:
20
+ Install the gem from rubyforge:
21
+
22
+ sudo gem install searchlogic
23
+
24
+ Or from github:
23
25
 
24
- # config/environment.rb
25
- config.gem "binarylogic-searchlogic",
26
- :lib => 'searchlogic',
27
- :source => 'http://gems.github.com',
28
- :version => '~> 2.0.0'
26
+ sudo gem install binarylogic-searchlogic
29
27
 
30
- Then install the gem:
28
+ Now just include it in your project and you are ready to go.
31
29
 
32
- rake gems:install
30
+ You can also install this as a plugin:
33
31
 
34
- That's it, you are ready to go. See below for usage examples.
32
+ script/plugin install git://github.com/binarylogic/searchlogic.git
33
+
34
+ See below for usage examples.
35
35
 
36
36
  == Search using conditions on columns
37
37
 
@@ -121,7 +121,11 @@ You can set, read, and chain conditions off of your search too:
121
121
  search.count => integer
122
122
  # .. etc
123
123
 
124
- All that the search method does is chain named scopes together for you. What's so great about that? It keeps your controllers extremely simple:
124
+ So let's start with the controller...
125
+
126
+ === Your controller
127
+
128
+ The search class just chains named scopes together for you. What's so great about that? It keeps your controllers extremely simple:
125
129
 
126
130
  class UsersController < ApplicationController
127
131
  def index
@@ -130,7 +134,11 @@ All that the search method does is chain named scopes together for you. What's s
130
134
  end
131
135
  end
132
136
 
133
- It doesn't get any simpler than that. Adding a search condition is as simple as adding a condition to your form. Remember all of those named scopes above? Just create fields with the same names:
137
+ It doesn't get any simpler than that.
138
+
139
+ === Your form
140
+
141
+ Adding a search condition is as simple as adding a condition to your form. Remember all of those named scopes above? Just create fields with the same names:
134
142
 
135
143
  - form_for @search do |f|
136
144
  = f.text_field :username_like
@@ -138,11 +146,18 @@ It doesn't get any simpler than that. Adding a search condition is as simple as
138
146
  = f.text_field :orders_total_greater_than
139
147
  = f.submit
140
148
 
141
- When a Searchlogic::Search object is passed to form_for it will add a hidden field for the "order" condition, to preserve the order of the data. If you want to order your search with a link, just specify the name of the column. Ex:
149
+ When a Searchlogic::Search object is passed to form_for it will add a hidden field for the "order" condition, to preserve the order of the data.
150
+
151
+ === Additional helpers
152
+
153
+ There really isn't a big need for helpers in searchlogic, other than helping you order data. If you want to order your search with a link, just specify the name of the column. Ex:
142
154
 
143
155
  = order @search, :by => :age
156
+ = order @search, :by => :created_at, :as => "Created date"
157
+
158
+ The first one will create a link that alternates between calling "ascend_by_age" and "descend_by_age". If you wanted to order your data by more than just a column, create your own named scopes: "ascend_by_*" and "descend_by_*". The "order" helper is a very straight forward helper, checkout the docs for some of the options.
144
159
 
145
- This will create a link that alternates between calling "ascend_by_age" and "descend_by_age". If you wanted to order your data by more than just a column, create your own named scopes: "ascend_by_*" and "descend_by_*". The "order" helper is a very straight forward helper, checkout the docs for some of the options.
160
+ <b>This helper is just a convenience method. It's extremely simple and there is nothing wrong with creating your own. If it doesn't do what you want, copy the code, modify it, and create your own. You could even fork the project, modify it there, and use your own gem.</b>
146
161
 
147
162
  == Use your existing named scopes
148
163
 
data/Rakefile CHANGED
@@ -9,9 +9,9 @@ begin
9
9
  gem.email = "bjohnson@binarylogic.com"
10
10
  gem.homepage = "http://github.com/binarylogic/searchlogic"
11
11
  gem.authors = ["Ben Johnson of Binary Logic"]
12
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
12
+ gem.rubyforge_project = "searchlogic"
13
+ gem.add_dependency "activerecord", ">= 2.0.0"
13
14
  end
14
-
15
15
  rescue LoadError
16
16
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
17
  end
@@ -31,18 +31,12 @@ end
31
31
 
32
32
  task :default => :spec
33
33
 
34
- require 'rake/rdoctask'
35
- Rake::RDocTask.new do |rdoc|
36
- if File.exist?('VERSION.yml')
37
- config = YAML.load(File.read('VERSION.yml'))
38
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
39
- else
40
- version = ""
34
+ begin
35
+ require 'rake/contrib/sshpublisher'
36
+ namespace :rubyforge do
37
+ desc "Release gem to RubyForge"
38
+ task :release => ["rubyforge:release:gem"]
41
39
  end
42
-
43
- rdoc.rdoc_dir = 'rdoc'
44
- rdoc.title = "search #{version}"
45
- rdoc.rdoc_files.include('README*')
46
- rdoc.rdoc_files.include('lib/**/*.rb')
40
+ rescue LoadError
41
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
47
42
  end
48
-
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 2
3
3
  :minor: 1
4
- :patch: 0
4
+ :patch: 1
@@ -29,6 +29,12 @@ module Searchlogic
29
29
  !association_alias_condition_details(name).nil?
30
30
  end
31
31
 
32
+ # A convenience method for creating inner join sql to that your inner joins
33
+ # are consistent with how Active Record creates them.
34
+ def inner_joins(association_name)
35
+ ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, association_name, nil).join_associations.collect { |assoc| assoc.association_join }
36
+ end
37
+
32
38
  private
33
39
  def method_missing(name, *args, &block)
34
40
  if details = association_condition_details(name)
@@ -93,7 +99,6 @@ module Searchlogic
93
99
  # named scope that is based on a hash.
94
100
  options = scope.proxy_options
95
101
  options[:joins] = options[:joins].blank? ? association.name : {association.name => options[:joins]}
96
- #add_left_outer_joins(options, association)
97
102
  options
98
103
  else
99
104
  # The underlying condition requires parameters, let's match the parameters it requires
data/searchlogic.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{searchlogic}
5
- s.version = "2.1.0"
5
+ s.version = "2.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ben Johnson of Binary Logic"]
9
- s.date = %q{2009-06-27}
9
+ s.date = %q{2009-06-28}
10
10
  s.email = %q{bjohnson@binarylogic.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  s.homepage = %q{http://github.com/binarylogic/searchlogic}
44
44
  s.rdoc_options = ["--charset=UTF-8"]
45
45
  s.require_paths = ["lib"]
46
+ s.rubyforge_project = %q{searchlogic}
46
47
  s.rubygems_version = %q{1.3.4}
47
48
  s.summary = %q{Searchlogic provides common named scopes and object based searching for ActiveRecord.}
48
49
  s.test_files = [
@@ -61,8 +62,11 @@ Gem::Specification.new do |s|
61
62
  s.specification_version = 3
62
63
 
63
64
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
65
+ s.add_runtime_dependency(%q<activerecord>, [">= 2.0.0"])
64
66
  else
67
+ s.add_dependency(%q<activerecord>, [">= 2.0.0"])
65
68
  end
66
69
  else
70
+ s.add_dependency(%q<activerecord>, [">= 2.0.0"])
67
71
  end
68
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binarylogic-searchlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-27 00:00:00 -07:00
12
+ date: 2009-06-28 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activerecord
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.0
24
+ version:
16
25
  description:
17
26
  email: bjohnson@binarylogic.com
18
27
  executables: []
@@ -70,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
79
  version:
71
80
  requirements: []
72
81
 
73
- rubyforge_project:
82
+ rubyforge_project: searchlogic
74
83
  rubygems_version: 1.2.0
75
84
  signing_key:
76
85
  specification_version: 3