esql 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -1
- data/Gemfile +4 -0
- data/README.md +35 -9
- data/esql.gemspec +0 -1
- data/lib/esql/parser.rb +0 -7
- data/lib/esql/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d9c585a99213519841d4d931eece38fdafdfd5630c97061720faa2bd8bcbeee
|
4
|
+
data.tar.gz: 31cd360fa758a6a2892319cc5ffdb2f7dcf34c83665350a646af9b706dcaa768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a4182cfb152f5ecebbddc622317458bcf15561e9d2bf68ed705cb7907f8073c1e6e125f86aec65877dcf90a9ce4e9726d3beba91a6be3314fa09cff3a08423
|
7
|
+
data.tar.gz: 9b6afb34fbfd9559ac06ed1f59c98245a48e6dfb15decd5c745701a465261e1840ad7f1ae989cf8e29728a4eb594f1a79ff9d812b4a5122146e9c94655d03306
|
data/.travis.yml
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
---
|
2
2
|
language: ruby
|
3
|
-
cache: bundler
|
4
3
|
rvm:
|
5
4
|
- 2.6.0
|
5
|
+
before_script:
|
6
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
7
|
+
- chmod +x ./cc-test-reporter
|
8
|
+
- ./cc-test-reporter before-build
|
9
|
+
script:
|
10
|
+
- bundle exec rspec
|
11
|
+
after_script:
|
12
|
+
- ./cc-test-reporter after-build -t simplecov --exit-code $TRAVIS_TEST_RESULT
|
6
13
|
before_install: gem install bundler -v 2.1.4
|
14
|
+
install:
|
15
|
+
- bundle
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# esql
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/esql.svg)](https://badge.fury.io/rb/esql) [![Build Status](https://travis-ci.org/paulholden2/esql.svg?branch=master)](https://travis-ci.org/paulholden2/esql) [![Inline docs](http://inch-ci.org/github/paulholden2/esql.svg?branch=master)](http://inch-ci.org/github/paulholden2/esql)
|
4
|
+
|
3
5
|
Esql is a library for ActiveRecord scoping using simple expressions.
|
4
6
|
|
5
7
|
## Installation
|
@@ -90,17 +92,41 @@ Errors that get past this simple check layer (like type mismatches or even
|
|
90
92
|
query runtime errors) will bubble up as ActiveRecord exceptions that you'll
|
91
93
|
have to handle yourself.
|
92
94
|
|
93
|
-
|
95
|
+
### Operators
|
96
|
+
|
97
|
+
* Arithmetic
|
98
|
+
* Multiplication: *
|
99
|
+
* Division: /
|
100
|
+
* Addition: +
|
101
|
+
* Subtraction: -
|
102
|
+
* Logical
|
103
|
+
* Less than: <
|
104
|
+
* Less than or equal: <=
|
105
|
+
* Greater than: >
|
106
|
+
* Greater than or equal: >=
|
107
|
+
|
108
|
+
### Attributes
|
109
|
+
|
110
|
+
Attributes are referenced using the column name, e.g. `first_name`. Note that
|
111
|
+
the attribute must exist on the model in your scope, otherwise an error will
|
112
|
+
be raised.
|
113
|
+
|
114
|
+
### Related attributes
|
115
|
+
|
116
|
+
You can use values on related records using the dot operator, e.g.
|
117
|
+
`employee.first_name`. This essentially calls `joins` on your scope with the
|
118
|
+
given relationship, as long as it is valid. The attribute must exist on the
|
119
|
+
related model, otherwise an error will be raised.
|
120
|
+
|
121
|
+
### Related aggregates
|
122
|
+
|
123
|
+
You can retrieve aggregates on related records, also using the dot operator,
|
124
|
+
e.g. `employees.count`. This `joins` a subquery, so keep that in mind.
|
94
125
|
|
95
|
-
|
96
|
-
run `rake spec` to run the tests. You can also run `bin/console` for an
|
97
|
-
interactive prompt that will allow you to experiment.
|
126
|
+
### Functions
|
98
127
|
|
99
|
-
|
100
|
-
|
101
|
-
run `bundle exec rake release`, which will create a git tag for the version,
|
102
|
-
push git commits and tags, and push the `.gem` file to
|
103
|
-
[rubygems.org](https://rubygems.org).
|
128
|
+
* String functions:
|
129
|
+
* concat(arg1, arg2, ...)
|
104
130
|
|
105
131
|
## Contributing
|
106
132
|
|
data/esql.gemspec
CHANGED
data/lib/esql/parser.rb
CHANGED
@@ -35,7 +35,6 @@ module Esql
|
|
35
35
|
:function,
|
36
36
|
:string,
|
37
37
|
:number,
|
38
|
-
:boolean,
|
39
38
|
:related_count,
|
40
39
|
:related_attribute,
|
41
40
|
:attribute
|
@@ -133,11 +132,5 @@ module Esql
|
|
133
132
|
return scope, self.text
|
134
133
|
end
|
135
134
|
end
|
136
|
-
|
137
|
-
rule :boolean, /(true|false)/ do
|
138
|
-
def evaluate(scope)
|
139
|
-
return scope, self.text
|
140
|
-
end
|
141
|
-
end
|
142
135
|
end
|
143
136
|
end
|
data/lib/esql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Holden
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: simplecov
|
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
97
|
description: A library for ActiveRecord scoping using simple expressions.
|
112
98
|
email:
|
113
99
|
- paul@codelunker.com
|