minidusen 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ mysql:
2
+ database: minidusen_test
3
+ host: localhost
4
+ username: root
5
+ password: secret
6
+
7
+ postgresql:
8
+ database: minidusen_test
9
+ user:
10
+ password:
@@ -0,0 +1,9 @@
1
+ mysql:
2
+ database: minidusen_test
3
+ username: travis
4
+ password:
5
+
6
+ postgresql:
7
+ database: minidusen_test
8
+ user: postgres
9
+ password:
@@ -0,0 +1,81 @@
1
+ class User < ActiveRecord::Base
2
+
3
+ end
4
+
5
+
6
+ class UserFilter
7
+ include Minidusen::Filter
8
+
9
+ filter :text do |scope, phrases|
10
+ scope.where_like([:name, :email, :city] => phrases)
11
+ end
12
+
13
+ filter :city do |scope, city|
14
+ # scope.scoped(:conditions => { :city => city })
15
+ # scope.scoped(:conditions => ['city = ?', city]) #:conditions => { :city => city })
16
+ scope.scoped(:conditions => { :city => city })
17
+ end
18
+
19
+ filter :email do |scope, email|
20
+ scope.scoped(:conditions => { :email => email })
21
+ end
22
+
23
+ filter :role do |scope, role|
24
+ scope.scoped(:conditions => { :role => role })
25
+ end
26
+
27
+ filter :name_and_city_regex do |scope, regex|
28
+ # Example for regexes that need to be and'ed together by syntax#build_exclude_scope
29
+ regexp_operator = Minidusen::Util.regexp_operator(scope)
30
+ first = scope.where("users.name #{regexp_operator} ?", regex)
31
+ second = scope.where("users.city #{regexp_operator} ?", regex)
32
+ first.merge(second)
33
+ end
34
+
35
+ end
36
+
37
+
38
+ class Recipe < ActiveRecord::Base
39
+
40
+ validates_presence_of :name
41
+
42
+ has_many :ingredients, :class_name => 'Recipe::Ingredient', :inverse_of => :recipe
43
+ belongs_to :category, :class_name => 'Recipe::Category', :inverse_of => :recipes
44
+
45
+ end
46
+
47
+
48
+ class RecipeFilter
49
+ include Minidusen::Filter
50
+
51
+ filter :text do |scope, text|
52
+ scope.where_like(:name => text)
53
+ end
54
+
55
+ filter :category do |scope, category_name|
56
+ scope.joins(:category).where('recipe_categories.name = ?', category_name)
57
+ end
58
+
59
+ end
60
+
61
+
62
+ class Recipe::Category < ActiveRecord::Base
63
+
64
+ self.table_name = 'recipe_categories'
65
+
66
+ validates_presence_of :name
67
+
68
+ has_many :recipes, :inverse_of => :category
69
+
70
+ end
71
+
72
+
73
+ class Recipe::Ingredient < ActiveRecord::Base
74
+
75
+ self.table_name = 'recipe_ingredients'
76
+
77
+ validates_presence_of :name
78
+
79
+ belongs_to :recipe, :inverse_of => :ingredients
80
+
81
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minidusen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ platform: ruby
6
+ authors:
7
+ - Henning Koch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: edge_rider
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.5
55
+ description: Low-tech search for ActiveRecord with MySQL or PostgreSQL
56
+ email: henning.koch@makandra.de
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".gitignore"
62
+ - ".rspec"
63
+ - ".ruby-version"
64
+ - ".travis.yml"
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - doc/filtered_index_view.cropped.png
69
+ - gemfiles/Gemfile.3.2.mysql2
70
+ - gemfiles/Gemfile.3.2.mysql2.lock
71
+ - gemfiles/Gemfile.4.2.mysql2
72
+ - gemfiles/Gemfile.4.2.mysql2.lock
73
+ - gemfiles/Gemfile.4.2.pg
74
+ - gemfiles/Gemfile.4.2.pg.lock
75
+ - gemfiles/Gemfile.5.0.mysql2
76
+ - gemfiles/Gemfile.5.0.mysql2.lock
77
+ - gemfiles/Gemfile.5.0.pg
78
+ - gemfiles/Gemfile.5.0.pg.lock
79
+ - lib/minidusen.rb
80
+ - lib/minidusen/active_record_ext.rb
81
+ - lib/minidusen/filter.rb
82
+ - lib/minidusen/parser.rb
83
+ - lib/minidusen/query.rb
84
+ - lib/minidusen/syntax.rb
85
+ - lib/minidusen/token.rb
86
+ - lib/minidusen/util.rb
87
+ - lib/minidusen/version.rb
88
+ - minidusen.gemspec
89
+ - spec/minidusen/active_record_ext_spec.rb
90
+ - spec/minidusen/filter_spec.rb
91
+ - spec/minidusen/parser_spec.rb
92
+ - spec/minidusen/query_spec.rb
93
+ - spec/minidusen/util_spec.rb
94
+ - spec/spec_helper.rb
95
+ - spec/support/database.rb
96
+ - spec/support/database.sample.yml
97
+ - spec/support/database.travis.yml
98
+ - spec/support/models.rb
99
+ homepage: https://github.com/makandra/minidusen
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.4.5.1
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Low-tech search for ActiveRecord with MySQL or PostgreSQL
123
+ test_files: []