wharel 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f1a415500f1ace6b7dd7ef92e229fd7d4586bb540c205cc70bddf0658b76484
4
- data.tar.gz: 9f0368d29226dc719e46a9e6ec33e2499f2d9b1926c76b16654d2003a8270b78
3
+ metadata.gz: b6ddbdc7852c67834cd3bfcd0a5fd12e46fdf6679a81c10c33f016d0ad46e902
4
+ data.tar.gz: f2365f7188bc6ed17e3938027efe39e5c7daf16bc00847de9dbdd8c62502f9ed
5
5
  SHA512:
6
- metadata.gz: '04528bf9b9fd6d710c779c477e180f496738b8a390ceea7ce9f5c315a9ace364bad3177dfe3120e36df2fdeb0d384d5e01e95a2706b3b985ab48d3a9eed9c393'
7
- data.tar.gz: 922b8917d0c62596b2c693efcda21c77cb84d9fa599c5cc75a232dce82f11beda1939199abafdacbdddbacfd8d7f874d18a0928d6e906aa4db49097d0e22e98d
6
+ metadata.gz: 29093610ff9d675b74417951434e24105e83d89bfdf9c2a2394d6069b905b0b4aefc0614357f9c8cc6b235dcbae5968244f38ac1c16438df6e497c8e3e0e344e
7
+ data.tar.gz: 517eabee061ded8ab3bd39b258402e87cc1ea61c6bc51f18d87dd64aa3090d52f4a18ccb762d704c1d9f1ad6cd3ff90185bf3c37321b54365afdc182fc4ee527
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wharel (0.0.1)
4
+ wharel (0.1.0)
5
5
  activerecord (~> 5.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Wharel
2
2
 
3
+ [![Build Status](https://travis-ci.org/shioyama/wharel.svg?branch=master)][travis]
4
+
5
+ [travis]: https://travis-ci.org/shioyama/wharel
6
+
3
7
  Wharel helps you write concise Arel queries with ActiveRecord using Virtual
4
8
  Rows inspired by
5
9
  [Sequel](http://sequel.jeremyevans.net/rdoc/files/doc/virtual_rows_rdoc.html).
@@ -8,7 +12,7 @@ Although similar in spirit to gems like
8
12
  [Squeel](https://github.com/activerecord-hackery/squeel) and
9
13
  [BabySqueel](https://github.com/rzane/baby_squeel), which provide sophisticated
10
14
  block-based interfaces for querying with Arel, Wharel is much much smaller. In
11
- fact, the core of the gem is only [25 lines
15
+ fact, the core of the gem is only [30 lines
12
16
  long](https://github.com/shioyama/wharel/blob/master/lib/wharel.rb)! It uses a
13
17
  single `BasicObject` as a [clean
14
18
  room](https://www.sethvargo.com/the-cleanroom-pattern/) to evaluate
@@ -19,7 +23,7 @@ the query block. That's really all there is to it.
19
23
  Add this line to your application's Gemfile:
20
24
 
21
25
  ```ruby
22
- gem 'wharel'
26
+ gem 'wharel', '~> 0.2.0'
23
27
  ```
24
28
 
25
29
  And then execute:
@@ -61,6 +65,12 @@ Post.where { title.matches("foo").and(content.matches("bar")) }
61
65
  Wharel will map `title` and `content` in the block to the appropriate Arel
62
66
  attribute for the column.
63
67
 
68
+ Works with `where.not` too:
69
+
70
+ ```ruby
71
+ Post.where.not { title.eq("foo") }
72
+ ```
73
+
64
74
  Now suppose we have another model `Comment` with a column `content`, and a
65
75
  `Post` `has_many :comments`:
66
76
 
data/lib/wharel.rb CHANGED
@@ -6,6 +6,12 @@ module Wharel
6
6
  def where(opts = :chain, *rest, &block)
7
7
  block_given? ? super(VirtualRow.build_query(self, &block)) : super
8
8
  end
9
+
10
+ module WhereChain
11
+ def not(*args, &block)
12
+ block_given? ? super(VirtualRow.build_query(@scope, &block)) : super
13
+ end
14
+ end
9
15
  end
10
16
 
11
17
  class VirtualRow < BasicObject
@@ -30,3 +36,4 @@ end
30
36
  # Monkey-patch ActiveRecord. Should make this optional.
31
37
  ::ActiveRecord::Base.singleton_class.prepend ::Wharel::QueryMethods
32
38
  ::ActiveRecord::Relation.prepend ::Wharel::QueryMethods
39
+ ::ActiveRecord::QueryMethods::WhereChain.prepend ::Wharel::QueryMethods::WhereChain
@@ -1,3 +1,3 @@
1
1
  module Wharel
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wharel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- 0G���9���u�����R�Y�?O5����ti����X�L����((d�>��XX3����@�?;�jX�Ĭ�}#���2�����,;�����vB���囘�;G���+�
1
+ �����w�-'��=aNA h閲������p�spYӬT�I��>4y9t�����̊<�t(Y��Ǐ�؜o8XEA���f��8N���W���ڙ�� �#c�<Ks���eU��{3N�,�jg�m�g�^$:��}�0�ϋ���Ȳ܇PL =V˯�v0jU�!`6?֗�ͽ��6;�?6����)�t0ٵ<�8TE��+��h~1:�\�L+� h�|�Tb�$;��6��seP�Lkz�