directiverecord 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -0
  3. data/CHANGELOG.rdoc +5 -0
  4. data/Gemfile +3 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +49 -0
  7. data/Rakefile +10 -0
  8. data/VERSION +1 -0
  9. data/directiverecord.gemspec +27 -0
  10. data/lib/directive_record.rb +6 -0
  11. data/lib/directive_record/gem_ext.rb +1 -0
  12. data/lib/directive_record/gem_ext/active_record.rb +2 -0
  13. data/lib/directive_record/gem_ext/active_record/base.rb +13 -0
  14. data/lib/directive_record/gem_ext/active_record/relation.rb +17 -0
  15. data/lib/directive_record/query.rb +25 -0
  16. data/lib/directive_record/query/monetdb.rb +54 -0
  17. data/lib/directive_record/query/mysql.rb +36 -0
  18. data/lib/directive_record/query/sql.rb +291 -0
  19. data/lib/directive_record/relation.rb +70 -0
  20. data/lib/directive_record/version.rb +7 -0
  21. data/lib/directiverecord.rb +1 -0
  22. data/test/application/app/models/customer.rb +6 -0
  23. data/test/application/app/models/employee.rb +5 -0
  24. data/test/application/app/models/office.rb +14 -0
  25. data/test/application/app/models/order.rb +4 -0
  26. data/test/application/app/models/order_detail.rb +4 -0
  27. data/test/application/app/models/payment.rb +3 -0
  28. data/test/application/app/models/product.rb +3 -0
  29. data/test/application/app/models/product_line.rb +3 -0
  30. data/test/application/app/models/tag.rb +3 -0
  31. data/test/application/boot.rb +27 -0
  32. data/test/application/config/database.yml +8 -0
  33. data/test/application/db/database.sql +327 -0
  34. data/test/test_helper.rb +17 -0
  35. data/test/test_helper/coverage.rb +13 -0
  36. data/test/unit/gem_ext/active_record/test_base.rb +30 -0
  37. data/test/unit/gem_ext/active_record/test_relation.rb +42 -0
  38. data/test/unit/query/test_monetdb.rb +27 -0
  39. data/test/unit/query/test_mysql.rb +238 -0
  40. data/test/unit/query/test_sql.rb +46 -0
  41. data/test/unit/test_directive_record.rb +15 -0
  42. data/test/unit/test_query.rb +40 -0
  43. data/test/unit/test_relation.rb +42 -0
  44. metadata +221 -0
@@ -0,0 +1,42 @@
1
+ require_relative "../test_helper"
2
+
3
+ module Unit
4
+ class TestQuery < MiniTest::Test
5
+
6
+ describe DirectiveRecord::Relation do
7
+ describe "#initialize" do
8
+ it "stores the passed active relation as an instance variable" do
9
+ directive_relation = DirectiveRecord::Relation.new(active_relation = mock)
10
+ assert_equal active_relation, directive_relation.instance_variable_get(:@active_relation)
11
+ end
12
+ end
13
+
14
+ describe "#qry_options" do
15
+ it "returns the expected options" do
16
+ assert_equal({
17
+ :select => ["city"],
18
+ :where => ["id = 1"]
19
+ }, Office.where(:id => 1).qry_options("city"))
20
+
21
+ assert_equal({
22
+ :select => ".*",
23
+ :where => ["employees.first_name LIKE '%y'"]
24
+ }, Office.where("employees.first_name LIKE ?", "%y").qry_options)
25
+
26
+ assert_equal({
27
+ :select => ["id, city"],
28
+ :where => ["employees.first_name LIKE '%y'"],
29
+ :group_by => ["id"],
30
+ :order_by => ["city"]
31
+ }, Office.select("id, city").where("employees.first_name LIKE ?", "%y").group("id").order("city").qry_options)
32
+
33
+ assert_equal({
34
+ :select => ".*",
35
+ :where => ["sales_rep_employee.office.city LIKE '%on'"]
36
+ }, Customer.where("sales_rep_employee.office.city LIKE ?", "%on").qry_options)
37
+ end
38
+ end
39
+ end
40
+
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,221 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: directiverecord
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Engel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mysql2
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mocha
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A layer on top of ActiveRecord for using paths within queries without
126
+ thinking about association joins
127
+ email: pm_engel@icloud.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - CHANGELOG.rdoc
134
+ - Gemfile
135
+ - MIT-LICENSE
136
+ - README.md
137
+ - Rakefile
138
+ - VERSION
139
+ - directiverecord.gemspec
140
+ - lib/directive_record.rb
141
+ - lib/directive_record/gem_ext.rb
142
+ - lib/directive_record/gem_ext/active_record.rb
143
+ - lib/directive_record/gem_ext/active_record/base.rb
144
+ - lib/directive_record/gem_ext/active_record/relation.rb
145
+ - lib/directive_record/query.rb
146
+ - lib/directive_record/query/monetdb.rb
147
+ - lib/directive_record/query/mysql.rb
148
+ - lib/directive_record/query/sql.rb
149
+ - lib/directive_record/relation.rb
150
+ - lib/directive_record/version.rb
151
+ - lib/directiverecord.rb
152
+ - test/application/app/models/customer.rb
153
+ - test/application/app/models/employee.rb
154
+ - test/application/app/models/office.rb
155
+ - test/application/app/models/order.rb
156
+ - test/application/app/models/order_detail.rb
157
+ - test/application/app/models/payment.rb
158
+ - test/application/app/models/product.rb
159
+ - test/application/app/models/product_line.rb
160
+ - test/application/app/models/tag.rb
161
+ - test/application/boot.rb
162
+ - test/application/config/database.yml
163
+ - test/application/db/database.sql
164
+ - test/test_helper.rb
165
+ - test/test_helper/coverage.rb
166
+ - test/unit/gem_ext/active_record/test_base.rb
167
+ - test/unit/gem_ext/active_record/test_relation.rb
168
+ - test/unit/query/test_monetdb.rb
169
+ - test/unit/query/test_mysql.rb
170
+ - test/unit/query/test_sql.rb
171
+ - test/unit/test_directive_record.rb
172
+ - test/unit/test_query.rb
173
+ - test/unit/test_relation.rb
174
+ homepage: https://github.com/archan937/directiverecord
175
+ licenses: []
176
+ metadata: {}
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ! '>='
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ! '>='
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ requirements: []
192
+ rubyforge_project:
193
+ rubygems_version: 2.1.11
194
+ signing_key:
195
+ specification_version: 4
196
+ summary: A layer on top of ActiveRecord for using paths within queries without thinking
197
+ about association joins
198
+ test_files:
199
+ - test/application/app/models/customer.rb
200
+ - test/application/app/models/employee.rb
201
+ - test/application/app/models/office.rb
202
+ - test/application/app/models/order.rb
203
+ - test/application/app/models/order_detail.rb
204
+ - test/application/app/models/payment.rb
205
+ - test/application/app/models/product.rb
206
+ - test/application/app/models/product_line.rb
207
+ - test/application/app/models/tag.rb
208
+ - test/application/boot.rb
209
+ - test/application/config/database.yml
210
+ - test/application/db/database.sql
211
+ - test/test_helper.rb
212
+ - test/test_helper/coverage.rb
213
+ - test/unit/gem_ext/active_record/test_base.rb
214
+ - test/unit/gem_ext/active_record/test_relation.rb
215
+ - test/unit/query/test_monetdb.rb
216
+ - test/unit/query/test_mysql.rb
217
+ - test/unit/query/test_sql.rb
218
+ - test/unit/test_directive_record.rb
219
+ - test/unit/test_query.rb
220
+ - test/unit/test_relation.rb
221
+ has_rdoc: