where_chain 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -4
- data/lib/where_chain/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00b02560557c167de9ce11d97c1d0c9184579c753ca0e8b735d9b1734cc77317
|
4
|
+
data.tar.gz: 38dd58fcefd3dc9975b984b3742c558f74a59e813fb0f72a6dea6548ddeed0c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e19f7b633157d5a84a43c28b084cf2e2fc29e19d1a61fae14cf6951bf7619f751287099656ebd2b8504e79072a9a405735e1bece3d221d5622ef944a701f80f
|
7
|
+
data.tar.gz: 5e5b9cb231931d9949126eed5f365d69f6c1c9eccae6b87cc8e05d0a544d24373dd95d4630be5aef9a6a9ea3ef12d24f56dc3be5a7d05d30e1557486bd58a733
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# WhereChain
|
4
4
|
|
5
|
-
In Rails, we usually use Active Record, which allows us to escape from writing SQL code like this `SELECT * FROM posts WHERE posts.name = 'Foo'` and allows us to write `Post.where(name: 'Foo')` instead. However, this has always been limited to matching equality, so you still have to write `Post.where('comments > ?', 5)` to get Posts that have more than 5 comments.
|
5
|
+
In Rails, we usually use Active Record, which allows us to escape from writing SQL code like this `SELECT * FROM posts WHERE posts.name = 'Foo'` and allows us to write `Post.where(name: 'Foo')` instead. However, this has always been limited to matching equality, so you still have to write `Post.where('comments > ?', 5)` to get Posts that have more than 5 comments.
|
6
6
|
|
7
7
|
In the older versions, you also had to write `Post.where('name IS NOT null')` to do a negation. Rails 4.0 added a class called `WhereChain` that added some [new possibilities](https://github.com/rails/rails/commit/de75af7acc5c05c708443de40e78965925165217), one of which was a `not` method. The proper way to write became `Post.where.not(name: nil)` instead.
|
8
8
|
|
@@ -10,7 +10,7 @@ Within the same comment there were also two new methods that [didn't survive to
|
|
10
10
|
|
11
11
|
This gem brings these two methods back and extends WhereChain with additional methods: `.gt`, `.gte`, `.lt` and `.lte`, so that by using it you can replace the SQL strings like `Post.where('comments > 5')` with `Post.where.gt(comments: 5)`.
|
12
12
|
|
13
|
-
WhereChain depends on the Active Record gem in a version higher than 4.2, due to problems with Ruby versions lesser than 2.4. Rails 4.2 is already the version that's being maintained, so you probably should not use an earlier one anyway. The gem is tested on the latest Ruby and all current Rails versions - 4.2, 5.0, 5.1 and 5.2
|
13
|
+
WhereChain depends on the Active Record gem in a version higher than 4.2, due to problems with Ruby versions lesser than 2.4. Rails 4.2 is already the version that's being maintained, so you probably should not use an earlier one anyway. The gem is tested on the latest Ruby and all current Rails versions - 4.2, 5.0, 5.1 and 5.2.
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
@@ -51,7 +51,7 @@ Post.where.gt(comments: { bad: :thing })
|
|
51
51
|
ArgumentError: The value passed to this method should be a valid type.
|
52
52
|
|
53
53
|
Post.where.gt('comments > ?', 5)
|
54
|
-
Post.where.gt([{number: 5}, 'name > ?'], 'abc')
|
54
|
+
Post.where.gt([{ number: 5 }, 'name > ?'], 'abc')
|
55
55
|
|
56
56
|
ArgumentError: This method requires a Hash as an argument.
|
57
57
|
```
|
@@ -79,7 +79,24 @@ $ gem install where_chain
|
|
79
79
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
80
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
81
81
|
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
-
5.
|
82
|
+
5. Make sure all the tests pass on all versions
|
83
|
+
6. Create new Pull Request
|
84
|
+
|
85
|
+
## Testing the code
|
86
|
+
|
87
|
+
Running all the tests for all Rails version targets:
|
88
|
+
|
89
|
+
```bash
|
90
|
+
$ bundle exec appraisal rspec
|
91
|
+
```
|
92
|
+
|
93
|
+
Running tests for a specific version:
|
94
|
+
|
95
|
+
```bash
|
96
|
+
$ bundle exec appraisal 5.0 rspec
|
97
|
+
```
|
98
|
+
|
99
|
+
You can see all the targets to use instead of `5.0` in the `Appraisals` file.
|
83
100
|
|
84
101
|
## License
|
85
102
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/where_chain/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: where_chain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Ruszkiewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -139,7 +139,7 @@ files:
|
|
139
139
|
- lib/active_record/where_chain_shared_methods.rb
|
140
140
|
- lib/where_chain.rb
|
141
141
|
- lib/where_chain/version.rb
|
142
|
-
homepage: https://github.com/marcinruszkiewicz
|
142
|
+
homepage: https://github.com/marcinruszkiewicz/where_chain
|
143
143
|
licenses:
|
144
144
|
- MIT
|
145
145
|
metadata: {}
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.7.
|
162
|
+
rubygems_version: 2.7.6
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: 'WhereChain extensions - Model.where.lt(created_at: Date.today)'
|