wharel 0.2.0 → 0.3.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: b6ddbdc7852c67834cd3bfcd0a5fd12e46fdf6679a81c10c33f016d0ad46e902
4
- data.tar.gz: f2365f7188bc6ed17e3938027efe39e5c7daf16bc00847de9dbdd8c62502f9ed
3
+ metadata.gz: cc8166e429d2ef5b94da9090fc6e37c8c98cb8008d930af8229732d6c0410383
4
+ data.tar.gz: b81996c6e91ceb04b0275fc808db76eeec0fa9c412129bc9766431debb5850dd
5
5
  SHA512:
6
- metadata.gz: 29093610ff9d675b74417951434e24105e83d89bfdf9c2a2394d6069b905b0b4aefc0614357f9c8cc6b235dcbae5968244f38ac1c16438df6e497c8e3e0e344e
7
- data.tar.gz: 517eabee061ded8ab3bd39b258402e87cc1ea61c6bc51f18d87dd64aa3090d52f4a18ccb762d704c1d9f1ad6cd3ff90185bf3c37321b54365afdc182fc4ee527
6
+ metadata.gz: 84952c21346ffd4a9fa7feef44e4c9ed1ff2e497de79380aa19438c4f373c9a404708b6d21e1f29fda6a52b2debf58e73bb015c4de11ec43513bab0d925423d1
7
+ data.tar.gz: 948c2aa3dc4cd7c18e70119c7f55f34d5159181eb97e9cb3e826927e1bebd83fdd34cc09f08005896414679ee6499c1e988ec45f9e6dafa88482391fe62d3681
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Wharel Changelog
2
+
3
+ ## 0.3
4
+
5
+ ### 0.3.0
6
+
7
+ - Add support for `order` ([#2](https://github.com/shioyama/wharel/pull/7))
8
+
9
+ ## 0.2
10
+
11
+ ### 0.2.0
12
+
13
+ - Add support for `where.not` ([#1](https://github.com/shioyama/wharel/pull/1))
14
+
15
+ ## 0.1
16
+
17
+ ### 0.1.0
18
+
19
+ - Basic support for `where` with blocks.
data/Gemfile CHANGED
@@ -6,3 +6,13 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
6
  gemspec
7
7
 
8
8
  gem 'pry-byebug'
9
+
10
+ case (ENV['RAILS_VERSION'] || '6.0')
11
+ when '5.2'
12
+ gem 'activerecord', '~> 5.2'
13
+ gem 'sqlite3', '~> 1.3.13'
14
+ when '6.0'
15
+ gem 'activerecord', '~> 6.0'
16
+ else
17
+ raise ArgumentError, 'invalid Rails version'
18
+ end
data/Gemfile.lock CHANGED
@@ -1,69 +1,69 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wharel (0.1.0)
5
- activerecord (~> 5.0)
4
+ wharel (0.3.0)
5
+ activerecord (>= 5, <= 6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (5.2.0)
11
- activesupport (= 5.2.0)
12
- activerecord (5.2.0)
13
- activemodel (= 5.2.0)
14
- activesupport (= 5.2.0)
15
- arel (>= 9.0)
16
- activesupport (5.2.0)
10
+ activemodel (6.0.0)
11
+ activesupport (= 6.0.0)
12
+ activerecord (6.0.0)
13
+ activemodel (= 6.0.0)
14
+ activesupport (= 6.0.0)
15
+ activesupport (6.0.0)
17
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
17
  i18n (>= 0.7, < 2)
19
18
  minitest (~> 5.1)
20
19
  tzinfo (~> 1.1)
21
- arel (9.0.0)
22
- byebug (10.0.2)
20
+ zeitwerk (~> 2.1, >= 2.1.8)
21
+ byebug (11.0.1)
23
22
  coderay (1.1.2)
24
- concurrent-ruby (1.0.5)
23
+ concurrent-ruby (1.1.5)
25
24
  database_cleaner (1.7.0)
26
25
  diff-lcs (1.3)
27
- i18n (1.0.1)
26
+ i18n (1.7.0)
28
27
  concurrent-ruby (~> 1.0)
29
- method_source (0.9.0)
30
- minitest (5.11.3)
31
- pry (0.11.3)
28
+ method_source (0.9.2)
29
+ minitest (5.13.0)
30
+ pry (0.12.2)
32
31
  coderay (~> 1.1.0)
33
32
  method_source (~> 0.9.0)
34
- pry-byebug (3.6.0)
35
- byebug (~> 10.0)
33
+ pry-byebug (3.7.0)
34
+ byebug (~> 11.0)
36
35
  pry (~> 0.10)
37
36
  rake (10.5.0)
38
- rspec (3.7.0)
39
- rspec-core (~> 3.7.0)
40
- rspec-expectations (~> 3.7.0)
41
- rspec-mocks (~> 3.7.0)
42
- rspec-core (3.7.1)
43
- rspec-support (~> 3.7.0)
44
- rspec-expectations (3.7.0)
37
+ rspec (3.9.0)
38
+ rspec-core (~> 3.9.0)
39
+ rspec-expectations (~> 3.9.0)
40
+ rspec-mocks (~> 3.9.0)
41
+ rspec-core (3.9.0)
42
+ rspec-support (~> 3.9.0)
43
+ rspec-expectations (3.9.0)
45
44
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.7.0)
47
- rspec-mocks (3.7.0)
45
+ rspec-support (~> 3.9.0)
46
+ rspec-mocks (3.9.0)
48
47
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.7.0)
50
- rspec-support (3.7.1)
51
- sqlite3 (1.3.13)
48
+ rspec-support (~> 3.9.0)
49
+ rspec-support (3.9.0)
50
+ sqlite3 (1.4.1)
52
51
  thread_safe (0.3.6)
53
52
  tzinfo (1.2.5)
54
53
  thread_safe (~> 0.1)
54
+ zeitwerk (2.2.0)
55
55
 
56
56
  PLATFORMS
57
57
  ruby
58
58
 
59
59
  DEPENDENCIES
60
- bundler (~> 1.16)
61
- database_cleaner
60
+ activerecord (~> 6.0)
61
+ database_cleaner (~> 1.5, >= 1.5.3)
62
62
  pry-byebug
63
63
  rake (~> 10.0)
64
64
  rspec (~> 3.0)
65
- sqlite3
65
+ sqlite3 (>= 1.3, < 1.5)
66
66
  wharel!
67
67
 
68
68
  BUNDLED WITH
69
- 1.16.1
69
+ 2.0.2
data/README.md CHANGED
@@ -18,12 +18,15 @@ single `BasicObject` as a [clean
18
18
  room](https://www.sethvargo.com/the-cleanroom-pattern/) to evaluate
19
19
  the query block. That's really all there is to it.
20
20
 
21
+ For a more detailed explanation of the implementation, see [this blog
22
+ post](https://dejimata.com/2018/5/30/arel-with-wharel).
23
+
21
24
  ## Installation
22
25
 
23
26
  Add this line to your application's Gemfile:
24
27
 
25
28
  ```ruby
26
- gem 'wharel', '~> 0.2.0'
29
+ gem 'wharel', '~> 0.3.0'
27
30
  ```
28
31
 
29
32
  And then execute:
@@ -71,6 +74,12 @@ Works with `where.not` too:
71
74
  Post.where.not { title.eq("foo") }
72
75
  ```
73
76
 
77
+ ... and also with `order`:
78
+
79
+ ```ruby
80
+ Post.order { title.lower }
81
+ ```
82
+
74
83
  Now suppose we have another model `Comment` with a column `content`, and a
75
84
  `Post` `has_many :comments`:
76
85
 
@@ -103,12 +112,10 @@ Much better!
103
112
 
104
113
  ## Contributing
105
114
 
106
- Bug reports and pull requests are welcome on GitHub at https://github.com/shioyama/wharel. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
115
+ Notice something wrong or a feature missing? Post an
116
+ [issue](https://github.com/shioyama/wharel/issues) or create a [pull
117
+ request](https://github.com/shioyama/wharel/pulls).
107
118
 
108
119
  ## License
109
120
 
110
121
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
111
-
112
- ## Code of Conduct
113
-
114
- Everyone interacting in the Wharel project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/shioyama/wharel/blob/master/CODE_OF_CONDUCT.md).
@@ -1,3 +1,3 @@
1
1
  module Wharel
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/wharel.rb CHANGED
@@ -7,6 +7,10 @@ module Wharel
7
7
  block_given? ? super(VirtualRow.build_query(self, &block)) : super
8
8
  end
9
9
 
10
+ def order(*args, &block)
11
+ block_given? ? super(VirtualRow.build_query(self, &block)) : super
12
+ end
13
+
10
14
  module WhereChain
11
15
  def not(*args, &block)
12
16
  block_given? ? super(VirtualRow.build_query(@scope, &block)) : super
@@ -26,7 +30,7 @@ module Wharel
26
30
  class << self
27
31
  def build_query(klass, &block)
28
32
  row = new(klass)
29
- query = (block.arity == 0) ? row.instance_eval(&block) : block.call(row)
33
+ query = block.arity.zero? ? row.instance_eval(&block) : block.call(row)
30
34
  ::ActiveRecord::Relation === query ? query.arel.constraints.inject(&:and) : query
31
35
  end
32
36
  end
metadata CHANGED
@@ -1,65 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wharel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
8
8
  autorequire:
9
9
  bindir: exe
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQ4wDAYDVQQDDAVjaHJp
14
- czEYMBYGCgmSJomT8ixkARkWCGRlamltYXRhMRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTE3MDgxMTE0NDU0N1oXDTE4MDgxMTE0NDU0N1owPzEOMAwGA1UEAwwFY2hy
16
- aXMxGDAWBgoJkiaJk/IsZAEZFghkZWppbWF0YTETMBEGCgmSJomT8ixkARkWA2Nv
17
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK4/1rb97IE2+aDbwqO0
18
- BdbiS9QONr9mZRyTCSVkKh4XY+Ex3XzoJSK/qj0E6eRb2K8Lsc8JNZra+1h6do8H
19
- dkl+GfFcHnWVuDkt17YcZuK/uAaxFOlWGVbFIdGxYz94rBddWGh3bOxqQGr3YtdD
20
- Ajj1foUnsPmxQ0j8p8vAJhHM0h0MTyphFxMT5xTDJkprVQOiktfWQBL+76jx/UQ4
21
- UXczbSgaObaUzvNM7ggi7+PPNG4S39SafjQ0MM/QvBZ31B6tN1KuzluKFhAMC+sH
22
- NofRUmYbrjZiCId6WCepJz48/fel6BtQ8CQGcQShx+eYOKEWRBiDkhpIil5JVaxi
23
- NucCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFAzG
24
- 77899+wndUmwUTLUD8z+YnnwMB0GA1UdEQQWMBSBEmNocmlzQGRlamltYXRhLmNv
25
- bTAdBgNVHRIEFjAUgRJjaHJpc0BkZWppbWF0YS5jb20wDQYJKoZIhvcNAQEFBQAD
26
- ggEBAGP58/sXe/VX8dZ74Ih5VscaWOHZqfT5VzsremZS2899Mf+MaSDhMmdYx8b7
27
- e8Muzpi0V7EIbP0+QeocepYHugyodeoKerqaLEPQ0yCbUbfNAZd9HwkpFbd8hA/J
28
- Nt2Az+BsBS0COBZKnruEqXA2AbrDua/ifSAjQMPBKCJ8nPQqRQf5A1hcP71yO3du
29
- 8t13MBd1vS8/4nYUoCQnOCTA8A1Lj6RSbQWyS1zZHq7hDm9hmgvvcIMGOkBCcFhy
30
- eGDROPZoL5RXwiOnRbexxa7dcAxMrDfGB/hpiunIPWPsi4n5P7K/6OO/sGVMl9xv
31
- SZBPXjzrHdyOFLBYXB+PG7s3F/4=
32
- -----END CERTIFICATE-----
33
- date: 2018-05-25 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2019-11-01 00:00:00.000000000 Z
34
12
  dependencies:
35
13
  - !ruby/object:Gem::Dependency
36
14
  name: activerecord
37
15
  requirement: !ruby/object:Gem::Requirement
38
16
  requirements:
39
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ - - "<="
40
21
  - !ruby/object:Gem::Version
41
- version: '5.0'
22
+ version: '6'
42
23
  type: :runtime
43
24
  prerelease: false
44
25
  version_requirements: !ruby/object:Gem::Requirement
45
26
  requirements:
46
- - - "~>"
27
+ - - ">="
47
28
  - !ruby/object:Gem::Version
48
- version: '5.0'
49
- - !ruby/object:Gem::Dependency
50
- name: bundler
51
- requirement: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
29
+ version: '5'
30
+ - - "<="
54
31
  - !ruby/object:Gem::Version
55
- version: '1.16'
56
- type: :development
57
- prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '1.16'
32
+ version: '6'
63
33
  - !ruby/object:Gem::Dependency
64
34
  name: rake
65
35
  requirement: !ruby/object:Gem::Requirement
@@ -94,28 +64,40 @@ dependencies:
94
64
  requirements:
95
65
  - - ">="
96
66
  - !ruby/object:Gem::Version
97
- version: '0'
67
+ version: '1.3'
68
+ - - "<"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.5'
98
71
  type: :development
99
72
  prerelease: false
100
73
  version_requirements: !ruby/object:Gem::Requirement
101
74
  requirements:
102
75
  - - ">="
103
76
  - !ruby/object:Gem::Version
104
- version: '0'
77
+ version: '1.3'
78
+ - - "<"
79
+ - !ruby/object:Gem::Version
80
+ version: '1.5'
105
81
  - !ruby/object:Gem::Dependency
106
82
  name: database_cleaner
107
83
  requirement: !ruby/object:Gem::Requirement
108
84
  requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.5'
109
88
  - - ">="
110
89
  - !ruby/object:Gem::Version
111
- version: '0'
90
+ version: 1.5.3
112
91
  type: :development
113
92
  prerelease: false
114
93
  version_requirements: !ruby/object:Gem::Requirement
115
94
  requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.5'
116
98
  - - ">="
117
99
  - !ruby/object:Gem::Version
118
- version: '0'
100
+ version: 1.5.3
119
101
  description: Use arel predicates directly from where.
120
102
  email:
121
103
  - chris@dejimata.com
@@ -123,7 +105,7 @@ executables: []
123
105
  extensions: []
124
106
  extra_rdoc_files: []
125
107
  files:
126
- - CODE_OF_CONDUCT.md
108
+ - CHANGELOG.md
127
109
  - Gemfile
128
110
  - Gemfile.lock
129
111
  - LICENSE.txt
@@ -134,7 +116,10 @@ files:
134
116
  homepage: https://github.com/shioyama/wharel
135
117
  licenses:
136
118
  - MIT
137
- metadata: {}
119
+ metadata:
120
+ homepage_uri: https://github.com/shioyama/wharel
121
+ source_code_uri: https://github.com/shioyama/wharel
122
+ changelog_uri: https://github.com/shioyama/wharel/blob/master/CHANGELOG.md
138
123
  post_install_message:
139
124
  rdoc_options: []
140
125
  require_paths:
@@ -150,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
135
  - !ruby/object:Gem::Version
151
136
  version: '0'
152
137
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.7.6
138
+ rubygems_version: 3.0.6
155
139
  signing_key:
156
140
  specification_version: 4
157
141
  summary: Arel + Where = Wharel
checksums.yaml.gz.sig DELETED
@@ -1 +0,0 @@
1
- �Ez���咇����y�o�Z�Sj�$z����Fta���'���aj�طmt��);5Mݴ�1F,�3D|�u��Og%��n��9 ����Db�����$�R*A(��{Ua�0��h2�Ӵ�ł������Վ�?Ay�11��W�o����7��B8���j�x�yY]�bm����\�)="��Q_��@nS�FH��
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at chris@dejimata.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data.tar.gz.sig DELETED
@@ -1 +0,0 @@
1
- jN�Ǟ_�M),�*��b�c_������l�F�&B�T>M����7�����b�i�����zn��i��T��.:�>�ɱ�l�S�%��lg�B����Q�v�`�M�>L��h�(��>�r�%���U�D#{�S�d?�Y�# �
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- �����w�-'��=aNA h閲������p�s�pYӬT�I��>4y9t�����̊<�t(Y��Ǐ�؜o8XEA���f��8N���W���ڙ�� �#c�<Ks���e�U��{3N�,�jg�m�g�^$:��}�0�ϋ���Ȳ܇PL =V˯�v0jU�!`6?֗�ͽ��6;�?6����)�t0ٵ<�8TE��+��h~1:�\�L+� h�|�Tb�$;��6��s�eP�Lkz�