baby_squeel 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +13 -0
- data/lib/baby_squeel/compat.rb +18 -1
- data/lib/baby_squeel/dsl.rb +1 -1
- data/lib/baby_squeel/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d31d8ac2c6564c5116b4fcfb2175c7747e1689
|
4
|
+
data.tar.gz: a1882420d085c5d2e071434ae8da6d28951ad3f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fdc066c0f04ebe17744c95cbc4499a492c993ca23d06fc6b11b41077d7d2a45591504f7a831b4fdf1e21aa16c640b6847a1bbf58e7fc3b1b232e0366209b0d9
|
7
|
+
data.tar.gz: dac5d32acfb013e580aa4e51433a6b1e2bafe17288001feb09295f1da2b26e93a61486598c8884707e687ee591c024ac7ad82091b5a1833ed239f2ee009cfb42
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
Nothing yet.
|
4
4
|
|
5
|
+
## [0.3.1] - 2016-08-02
|
6
|
+
### Added
|
7
|
+
- Ported backticks and #my from Squeel
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- DSL#sql now returns a node wrapped in a BabySqueel proxy.
|
11
|
+
|
5
12
|
## [0.3.0] - 2016-06-26
|
6
13
|
### Added
|
7
14
|
- Added Squeel compatibility mode that allows `select`, `order`, `joins`, `group`, `where`, and `having` to accept DSL blocks.
|
@@ -45,7 +52,8 @@ Nothing yet.
|
|
45
52
|
### Added
|
46
53
|
- Initial support for selects, orders, wheres, and joins.
|
47
54
|
|
48
|
-
[Unreleased]: https://github.com/rzane/baby_squeel/compare/v0.3.
|
55
|
+
[Unreleased]: https://github.com/rzane/baby_squeel/compare/v0.3.1...HEAD
|
56
|
+
[0.3.1]: https://github.com/rzane/baby_squeel/compare/v0.3.0...v0.3.1
|
49
57
|
[0.3.0]: https://github.com/rzane/baby_squeel/compare/v0.2.2...v0.3.0
|
50
58
|
[0.2.2]: https://github.com/rzane/baby_squeel/compare/v0.2.1...v0.2.2
|
51
59
|
[0.2.1]: https://github.com/rzane/baby_squeel/compare/v0.2.0...v0.2.1
|
data/README.md
CHANGED
@@ -228,6 +228,19 @@ Post.joining {
|
|
228
228
|
}
|
229
229
|
```
|
230
230
|
|
231
|
+
##### Helpers
|
232
|
+
|
233
|
+
```ruby
|
234
|
+
# SQL Literals
|
235
|
+
Post.select('1 as one').ordering { sql('one').desc }
|
236
|
+
|
237
|
+
# Quoting
|
238
|
+
Post.selecting { title.op('||', quoted('diddly')) }
|
239
|
+
|
240
|
+
# Functions
|
241
|
+
Post.select { func('coalesce', id, 1) }
|
242
|
+
```
|
243
|
+
|
231
244
|
## Sifters
|
232
245
|
|
233
246
|
Sifters are like little snippets of conditions that can take arguments.
|
data/lib/baby_squeel/compat.rb
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
module BabySqueel
|
2
2
|
module Compat
|
3
3
|
def self.enable!
|
4
|
+
BabySqueel::DSL.prepend BabySqueel::Compat::DSL
|
4
5
|
::ActiveRecord::Base.singleton_class.prepend QueryMethods
|
5
6
|
::ActiveRecord::Relation.prepend QueryMethods
|
6
7
|
end
|
7
8
|
|
9
|
+
module DSL
|
10
|
+
def `(str)
|
11
|
+
sql(str)
|
12
|
+
end
|
13
|
+
|
14
|
+
def my(&block)
|
15
|
+
@caller.instance_eval(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Remember the original binding of the block
|
19
|
+
def evaluate(&block)
|
20
|
+
@caller = block.binding.eval('self')
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
8
25
|
module QueryMethods
|
9
26
|
def joins(*args, &block)
|
10
27
|
if block_given? && args.empty?
|
@@ -56,7 +73,7 @@ module BabySqueel
|
|
56
73
|
|
57
74
|
def where(*args, &block)
|
58
75
|
if block_given? && args.empty?
|
59
|
-
|
76
|
+
where.has(&block)
|
60
77
|
else
|
61
78
|
super
|
62
79
|
end
|
data/lib/baby_squeel/dsl.rb
CHANGED
data/lib/baby_squeel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baby_squeel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.4.8
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: A tiny squeel implementation without all of the evil.
|