dynamic_query 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -0
- data/Rakefile +2 -11
- data/lib/dynamic_query/version.rb +2 -2
- data/lib/dynamic_query.rb +12 -4
- metadata +43 -27
data/README.md
CHANGED
@@ -21,6 +21,9 @@ rails g dynamic_query:helper
|
|
21
21
|
``` ruby
|
22
22
|
## controller of Rails 3
|
23
23
|
dq = dynamic_query(:list, :entry) # list models you wish to be queried. e.g. List => :list, AbcDef => :abc_def
|
24
|
+
# Since version 0.4.0, you can use model's names directly.
|
25
|
+
dq = dynamic_query(List, Entry)
|
26
|
+
|
24
27
|
@panel = dq.panel(params[:query])
|
25
28
|
@lists = List.includes(:entries).where(dq.statement(params[:query])).all
|
26
29
|
|
@@ -34,10 +37,14 @@ dq = dynamic_query(:list, :entry) # list models you wish to be queried. e.g. Lis
|
|
34
37
|
# columns with name 'id' or name ended with '_id' are hided by default
|
35
38
|
# :reveal_keys => true reveals those columns in the query panel
|
36
39
|
dq = dynamic_query(:list, :entry, :reveal_keys => true)
|
40
|
+
# Works for version >= 0.4.0
|
41
|
+
dq = dynamic_query(List, Entry, :reveal_keys => true)
|
37
42
|
|
38
43
|
# a white list or a black list can be defined by following options
|
39
44
|
dq = dynamic_query(:list, :entry, :accept => { :list => [:name], :entry => [:title, :priority] }, :reject => { :entry => [:title] })
|
40
45
|
# only lists.name and entries.priority can be seen on the query panel because the white list gets higher precedence than the black list
|
46
|
+
# Works for version >= 0.4.0
|
47
|
+
dq = dynamic_query(List, Entry, :accept => { List => [:name], Entry => [:title, :priority] }, :reject => { Entry => [:title] })
|
41
48
|
|
42
49
|
# column display names can be defined by following options
|
43
50
|
dq = dynamic_query(:list, :entry, :alias => { 'lists.name' => 'Full Name' })
|
data/Rakefile
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'bundler'
|
5
|
-
require './lib/dynamic_query/version.rb'
|
6
|
-
|
7
5
|
begin
|
8
6
|
Bundler.setup(:default, :development)
|
9
7
|
rescue Bundler::BundlerError => e
|
@@ -14,12 +12,13 @@ end
|
|
14
12
|
require 'rake'
|
15
13
|
|
16
14
|
require 'jeweler'
|
15
|
+
require './lib/dynamic_query/version.rb'
|
17
16
|
Jeweler::Tasks.new do |gem|
|
18
17
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
19
|
-
gem.version = DynamicQuery::Version::STRING
|
20
18
|
gem.name = "dynamic_query"
|
21
19
|
gem.homepage = "http://github.com/wnameless/dynamic_query"
|
22
20
|
gem.license = "Apache License, Version 2.0"
|
21
|
+
gem.version = DynamicQuery::Version::STRING
|
23
22
|
gem.summary = "dynamic_query-#{gem.version}"
|
24
23
|
gem.description = %Q{A dynamic query gui for ActiveRecord}
|
25
24
|
gem.email = "wnameless@gmail.com"
|
@@ -36,14 +35,6 @@ Rake::TestTask.new(:test) do |test|
|
|
36
35
|
test.verbose = true
|
37
36
|
end
|
38
37
|
|
39
|
-
require 'rcov/rcovtask'
|
40
|
-
Rcov::RcovTask.new do |test|
|
41
|
-
test.libs << 'test'
|
42
|
-
test.pattern = 'test/**/test_*.rb'
|
43
|
-
test.verbose = true
|
44
|
-
test.rcov_opts << '--exclude "gems/*"'
|
45
|
-
end
|
46
|
-
|
47
38
|
task :default => :test
|
48
39
|
|
49
40
|
require 'rdoc/task'
|
data/lib/dynamic_query.rb
CHANGED
@@ -27,13 +27,21 @@ module DynamicQuery
|
|
27
27
|
opt = {}
|
28
28
|
end
|
29
29
|
|
30
|
+
models.map! do |m|
|
31
|
+
if [String, Symbol].include? m.class
|
32
|
+
m.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
33
|
+
else
|
34
|
+
m
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
30
38
|
opt.each do |key, val|
|
31
39
|
@reveal_keys = true if key == :reveal_keys && val
|
32
40
|
|
33
41
|
if key == :accept
|
34
42
|
val.each do |model, columns|
|
35
43
|
if models.include? model
|
36
|
-
model = model.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
44
|
+
# model = model.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
37
45
|
columns.each { |col| @white_list << "#{model.table_name}.#{col}" }
|
38
46
|
end
|
39
47
|
end
|
@@ -42,7 +50,7 @@ module DynamicQuery
|
|
42
50
|
if key == :reject
|
43
51
|
val.each do |model, columns|
|
44
52
|
if models.include? model
|
45
|
-
model = model.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
53
|
+
# model = model.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
46
54
|
columns.each { |col| @black_list << "#{model.table_name}.#{col}" }
|
47
55
|
end
|
48
56
|
end
|
@@ -55,14 +63,14 @@ module DynamicQuery
|
|
55
63
|
|
56
64
|
@columns = {}
|
57
65
|
models.each do |model|
|
58
|
-
model = model.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
66
|
+
# model = model.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
59
67
|
model = Hash[model.columns.map { |col| ["#{model.table_name}.#{col.name}"] * 2 }]
|
60
68
|
@columns.merge! model
|
61
69
|
end
|
62
70
|
|
63
71
|
@column_types = {}
|
64
72
|
models.each do |model|
|
65
|
-
model = model.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
73
|
+
# model = model.to_s.split(/_/).map { |word| word.capitalize }.join.constantize
|
66
74
|
model = Hash[model.columns.map { |col| ["#{model.table_name}.#{col.name}", col.type] }]
|
67
75
|
@column_types.merge! model
|
68
76
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,46 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jquery-rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.2.0
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: rails
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
19
|
-
- -
|
35
|
+
- - "~>"
|
20
36
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
37
|
+
version: 3.2.0
|
22
38
|
type: :runtime
|
23
39
|
prerelease: false
|
24
40
|
version_requirements: !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
26
42
|
requirements:
|
27
|
-
- -
|
43
|
+
- - "~>"
|
28
44
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
45
|
+
version: 3.2.0
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: shoulda
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
33
49
|
none: false
|
34
50
|
requirements:
|
35
|
-
- -
|
51
|
+
- - "~>"
|
36
52
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
53
|
+
version: 3.3.2
|
38
54
|
type: :development
|
39
55
|
prerelease: false
|
40
56
|
version_requirements: !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
58
|
requirements:
|
43
|
-
- -
|
59
|
+
- - "~>"
|
44
60
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
61
|
+
version: 3.3.2
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: rdoc
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
49
65
|
none: false
|
50
66
|
requirements:
|
51
|
-
- - ~>
|
67
|
+
- - "~>"
|
52
68
|
- !ruby/object:Gem::Version
|
53
69
|
version: '3.12'
|
54
70
|
type: :development
|
@@ -56,7 +72,7 @@ dependencies:
|
|
56
72
|
version_requirements: !ruby/object:Gem::Requirement
|
57
73
|
none: false
|
58
74
|
requirements:
|
59
|
-
- - ~>
|
75
|
+
- - "~>"
|
60
76
|
- !ruby/object:Gem::Version
|
61
77
|
version: '3.12'
|
62
78
|
- !ruby/object:Gem::Dependency
|
@@ -64,23 +80,23 @@ dependencies:
|
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
65
81
|
none: false
|
66
82
|
requirements:
|
67
|
-
- -
|
83
|
+
- - "~>"
|
68
84
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.
|
85
|
+
version: 1.2.3
|
70
86
|
type: :development
|
71
87
|
prerelease: false
|
72
88
|
version_requirements: !ruby/object:Gem::Requirement
|
73
89
|
none: false
|
74
90
|
requirements:
|
75
|
-
- -
|
91
|
+
- - "~>"
|
76
92
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.
|
93
|
+
version: 1.2.3
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: jeweler
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
81
97
|
none: false
|
82
98
|
requirements:
|
83
|
-
- - ~>
|
99
|
+
- - "~>"
|
84
100
|
- !ruby/object:Gem::Version
|
85
101
|
version: 1.8.4
|
86
102
|
type: :development
|
@@ -88,25 +104,25 @@ dependencies:
|
|
88
104
|
version_requirements: !ruby/object:Gem::Requirement
|
89
105
|
none: false
|
90
106
|
requirements:
|
91
|
-
- - ~>
|
107
|
+
- - "~>"
|
92
108
|
- !ruby/object:Gem::Version
|
93
109
|
version: 1.8.4
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
111
|
+
name: sqlite3
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
97
113
|
none: false
|
98
114
|
requirements:
|
99
|
-
- - ~>
|
115
|
+
- - "~>"
|
100
116
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
117
|
+
version: 1.3.7
|
102
118
|
type: :development
|
103
119
|
prerelease: false
|
104
120
|
version_requirements: !ruby/object:Gem::Requirement
|
105
121
|
none: false
|
106
122
|
requirements:
|
107
|
-
- - ~>
|
123
|
+
- - "~>"
|
108
124
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
125
|
+
version: 1.3.7
|
110
126
|
description: A dynamic query gui for ActiveRecord
|
111
127
|
email: wnameless@gmail.com
|
112
128
|
executables: []
|
@@ -137,16 +153,16 @@ require_paths:
|
|
137
153
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
154
|
none: false
|
139
155
|
requirements:
|
140
|
-
- -
|
156
|
+
- - ">="
|
141
157
|
- !ruby/object:Gem::Version
|
142
158
|
version: '0'
|
143
159
|
segments:
|
144
160
|
- 0
|
145
|
-
hash:
|
161
|
+
hash: 974901957563084135
|
146
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
163
|
none: false
|
148
164
|
requirements:
|
149
|
-
- -
|
165
|
+
- - ">="
|
150
166
|
- !ruby/object:Gem::Version
|
151
167
|
version: '0'
|
152
168
|
requirements: []
|
@@ -154,5 +170,5 @@ rubyforge_project:
|
|
154
170
|
rubygems_version: 1.8.24
|
155
171
|
signing_key:
|
156
172
|
specification_version: 3
|
157
|
-
summary: dynamic_query-0.
|
173
|
+
summary: dynamic_query-0.4.0
|
158
174
|
test_files: []
|