nberger-searchlogic 2.4.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +308 -0
  3. data/Rakefile +35 -0
  4. data/VERSION.yml +5 -0
  5. data/init.rb +1 -0
  6. data/lib/searchlogic.rb +56 -0
  7. data/lib/searchlogic/active_record/association_proxy.rb +19 -0
  8. data/lib/searchlogic/active_record/consistency.rb +49 -0
  9. data/lib/searchlogic/active_record/named_scope_tools.rb +101 -0
  10. data/lib/searchlogic/core_ext/object.rb +43 -0
  11. data/lib/searchlogic/core_ext/proc.rb +17 -0
  12. data/lib/searchlogic/named_scopes/alias_scope.rb +67 -0
  13. data/lib/searchlogic/named_scopes/association_conditions.rb +132 -0
  14. data/lib/searchlogic/named_scopes/association_ordering.rb +44 -0
  15. data/lib/searchlogic/named_scopes/conditions.rb +232 -0
  16. data/lib/searchlogic/named_scopes/or_conditions.rb +141 -0
  17. data/lib/searchlogic/named_scopes/ordering.rb +48 -0
  18. data/lib/searchlogic/rails_helpers.rb +79 -0
  19. data/lib/searchlogic/search.rb +26 -0
  20. data/lib/searchlogic/search/base.rb +26 -0
  21. data/lib/searchlogic/search/conditions.rb +58 -0
  22. data/lib/searchlogic/search/date_parts.rb +23 -0
  23. data/lib/searchlogic/search/implementation.rb +14 -0
  24. data/lib/searchlogic/search/method_missing.rb +123 -0
  25. data/lib/searchlogic/search/ordering.rb +10 -0
  26. data/lib/searchlogic/search/scopes.rb +19 -0
  27. data/lib/searchlogic/search/to_yaml.rb +38 -0
  28. data/lib/searchlogic/search/unknown_condition_error.rb +15 -0
  29. data/nberger-searchlogic.gemspec +96 -0
  30. data/rails/init.rb +1 -0
  31. data/spec/searchlogic/active_record/association_proxy_spec.rb +23 -0
  32. data/spec/searchlogic/active_record/consistency_spec.rb +28 -0
  33. data/spec/searchlogic/core_ext/object_spec.rb +9 -0
  34. data/spec/searchlogic/core_ext/proc_spec.rb +8 -0
  35. data/spec/searchlogic/named_scopes/alias_scope_spec.rb +23 -0
  36. data/spec/searchlogic/named_scopes/association_conditions_spec.rb +203 -0
  37. data/spec/searchlogic/named_scopes/association_ordering_spec.rb +27 -0
  38. data/spec/searchlogic/named_scopes/conditions_spec.rb +319 -0
  39. data/spec/searchlogic/named_scopes/or_conditions_spec.rb +66 -0
  40. data/spec/searchlogic/named_scopes/ordering_spec.rb +34 -0
  41. data/spec/searchlogic/search_spec.rb +509 -0
  42. data/spec/spec_helper.rb +152 -0
  43. metadata +135 -0
@@ -0,0 +1,152 @@
1
+ require 'spec'
2
+ require 'rubygems'
3
+ require 'ruby-debug'
4
+ require 'active_record'
5
+
6
+ ENV['TZ'] = 'UTC'
7
+ Time.zone = 'Eastern Time (US & Canada)'
8
+
9
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
10
+ ActiveRecord::Base.configurations = true
11
+
12
+ ActiveRecord::Schema.verbose = false
13
+ ActiveRecord::Schema.define(:version => 1) do
14
+ create_table :audits do |t|
15
+ t.string :auditable_type
16
+ t.integer :auditable_id
17
+ end
18
+
19
+ create_table :companies do |t|
20
+ t.datetime :created_at
21
+ t.datetime :updated_at
22
+ t.string :name
23
+ t.string :description
24
+ t.integer :users_count, :default => 0
25
+ end
26
+
27
+ create_table :user_groups do |t|
28
+ t.string :name
29
+ end
30
+
31
+ create_table :user_groups_users, :id => false do |t|
32
+ t.integer :user_group_id, :null => false
33
+ t.integer :user_id, :null => false
34
+ end
35
+
36
+ create_table :users do |t|
37
+ t.datetime :created_at
38
+ t.datetime :updated_at
39
+ t.integer :company_id
40
+ t.string :username
41
+ t.string :name
42
+ t.integer :age
43
+ t.boolean :male
44
+ t.string :some_type_id
45
+ t.datetime :whatever_at
46
+ end
47
+
48
+ create_table :carts do |t|
49
+ t.datetime :created_at
50
+ t.datetime :updated_at
51
+ t.integer :user_id
52
+ end
53
+
54
+ create_table :orders do |t|
55
+ t.datetime :created_at
56
+ t.datetime :updated_at
57
+ t.integer :user_id
58
+ t.date :shipped_on
59
+ t.float :taxes
60
+ t.float :total
61
+ end
62
+
63
+ create_table :fees do |t|
64
+ t.datetime :created_at
65
+ t.datetime :updated_at
66
+ t.string :owner_type
67
+ t.integer :owner_id
68
+ t.float :cost
69
+ end
70
+
71
+ create_table :line_items do |t|
72
+ t.datetime :created_at
73
+ t.datetime :updated_at
74
+ t.integer :order_id
75
+ t.float :price
76
+ end
77
+
78
+ create_table :people do |t|
79
+ t.string :full_name
80
+ t.string :type
81
+ t.integer :company_id
82
+ end
83
+ end
84
+
85
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
86
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
87
+ require 'searchlogic'
88
+
89
+ Spec::Runner.configure do |config|
90
+ config.before(:each) do
91
+ class ::Audit < ActiveRecord::Base
92
+ belongs_to :auditable, :polymorphic => true
93
+ end
94
+
95
+ class ::Company < ActiveRecord::Base
96
+ has_many :orders, :through => :users
97
+ has_many :users, :dependent => :destroy
98
+ has_many :people
99
+ has_many :managers
100
+ has_many :employees
101
+ end
102
+
103
+ class ::UserGroup < ActiveRecord::Base
104
+ has_and_belongs_to_many :users
105
+ end
106
+
107
+ class ::User < ActiveRecord::Base
108
+ belongs_to :company, :counter_cache => true
109
+ has_many :orders, :dependent => :destroy
110
+ has_many :orders_big, :class_name => 'Order', :conditions => 'total > 100'
111
+ has_and_belongs_to_many :user_groups
112
+
113
+ self.skip_time_zone_conversion_for_attributes = [:whatever_at]
114
+ end
115
+
116
+ class ::Order < ActiveRecord::Base
117
+ belongs_to :user
118
+ has_many :line_items, :dependent => :destroy
119
+ end
120
+
121
+ class ::Fee < ActiveRecord::Base
122
+ belongs_to :owner, :polymorphic => true
123
+ end
124
+
125
+ class ::LineItem < ActiveRecord::Base
126
+ belongs_to :order
127
+ end
128
+
129
+ class ::Person < ActiveRecord::Base
130
+ end
131
+ class ::Manager < ::Person
132
+ end
133
+ class ::Employee < ::Person
134
+ end
135
+
136
+ ::Company.destroy_all
137
+ ::User.destroy_all
138
+ ::Order.destroy_all
139
+ ::LineItem.destroy_all
140
+ ::Person.destroy_all
141
+ end
142
+
143
+ config.after(:each) do
144
+ Object.send(:remove_const, :Company)
145
+ Object.send(:remove_const, :User)
146
+ Object.send(:remove_const, :Order)
147
+ Object.send(:remove_const, :LineItem)
148
+ Object.send(:remove_const, :Person)
149
+ Object.send(:remove_const, :Manager)
150
+ Object.send(:remove_const, :Employee)
151
+ end
152
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nberger-searchlogic
3
+ version: !ruby/object:Gem::Version
4
+ hash: 39
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 4
9
+ - 28
10
+ version: 2.4.28
11
+ platform: ruby
12
+ authors:
13
+ - "Nicol\xC3\xA1s Berger, Yoomee Developers, Ben Johnson of Binary Logic"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-24 00:00:00 -03:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activerecord
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 2
32
+ - 0
33
+ - 0
34
+ version: 2.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Searchlogic makes using ActiveRecord named scopes easier and less repetitive.
38
+ email: nberger@yellowspot.com.ar, developers@yoomee.com, bjohnson@binarylogic.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - LICENSE
45
+ - README.rdoc
46
+ files:
47
+ - LICENSE
48
+ - README.rdoc
49
+ - Rakefile
50
+ - VERSION.yml
51
+ - init.rb
52
+ - lib/searchlogic.rb
53
+ - lib/searchlogic/active_record/association_proxy.rb
54
+ - lib/searchlogic/active_record/consistency.rb
55
+ - lib/searchlogic/active_record/named_scope_tools.rb
56
+ - lib/searchlogic/core_ext/object.rb
57
+ - lib/searchlogic/core_ext/proc.rb
58
+ - lib/searchlogic/named_scopes/alias_scope.rb
59
+ - lib/searchlogic/named_scopes/association_conditions.rb
60
+ - lib/searchlogic/named_scopes/association_ordering.rb
61
+ - lib/searchlogic/named_scopes/conditions.rb
62
+ - lib/searchlogic/named_scopes/or_conditions.rb
63
+ - lib/searchlogic/named_scopes/ordering.rb
64
+ - lib/searchlogic/rails_helpers.rb
65
+ - lib/searchlogic/search.rb
66
+ - lib/searchlogic/search/base.rb
67
+ - lib/searchlogic/search/conditions.rb
68
+ - lib/searchlogic/search/date_parts.rb
69
+ - lib/searchlogic/search/implementation.rb
70
+ - lib/searchlogic/search/method_missing.rb
71
+ - lib/searchlogic/search/ordering.rb
72
+ - lib/searchlogic/search/scopes.rb
73
+ - lib/searchlogic/search/to_yaml.rb
74
+ - lib/searchlogic/search/unknown_condition_error.rb
75
+ - nberger-searchlogic.gemspec
76
+ - rails/init.rb
77
+ - spec/searchlogic/active_record/association_proxy_spec.rb
78
+ - spec/searchlogic/active_record/consistency_spec.rb
79
+ - spec/searchlogic/core_ext/object_spec.rb
80
+ - spec/searchlogic/core_ext/proc_spec.rb
81
+ - spec/searchlogic/named_scopes/alias_scope_spec.rb
82
+ - spec/searchlogic/named_scopes/association_conditions_spec.rb
83
+ - spec/searchlogic/named_scopes/association_ordering_spec.rb
84
+ - spec/searchlogic/named_scopes/conditions_spec.rb
85
+ - spec/searchlogic/named_scopes/or_conditions_spec.rb
86
+ - spec/searchlogic/named_scopes/ordering_spec.rb
87
+ - spec/searchlogic/search_spec.rb
88
+ - spec/spec_helper.rb
89
+ has_rdoc: true
90
+ homepage: http://github.com/nberger/searchlogic
91
+ licenses: []
92
+
93
+ post_install_message:
94
+ rdoc_options: []
95
+
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ requirements: []
117
+
118
+ rubyforge_project: searchlogic
119
+ rubygems_version: 1.3.7
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Searchlogic makes using ActiveRecord named scopes easier and less repetitive.
123
+ test_files:
124
+ - spec/searchlogic/active_record/association_proxy_spec.rb
125
+ - spec/searchlogic/active_record/consistency_spec.rb
126
+ - spec/searchlogic/core_ext/object_spec.rb
127
+ - spec/searchlogic/core_ext/proc_spec.rb
128
+ - spec/searchlogic/named_scopes/alias_scope_spec.rb
129
+ - spec/searchlogic/named_scopes/association_conditions_spec.rb
130
+ - spec/searchlogic/named_scopes/association_ordering_spec.rb
131
+ - spec/searchlogic/named_scopes/conditions_spec.rb
132
+ - spec/searchlogic/named_scopes/or_conditions_spec.rb
133
+ - spec/searchlogic/named_scopes/ordering_spec.rb
134
+ - spec/searchlogic/search_spec.rb
135
+ - spec/spec_helper.rb