dredd 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +58 -14
- data/lib/dredd/version.rb +1 -1
- data/spec/dredd/query_spec.rb +10 -0
- metadata +27 -13
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -1,29 +1,73 @@
|
|
1
1
|
# Dredd
|
2
2
|
|
3
|
-
|
3
|
+
```
|
4
|
+
.-----.
|
5
|
+
/__ # __\
|
6
|
+
|| \ / ||
|
7
|
+
|`. X .'|
|
8
|
+
| |_____| |
|
9
|
+
`---------'
|
10
|
+
d r e d d
|
4
11
|
|
12
|
+
Rules over collections
|
13
|
+
```
|
5
14
|
|
6
15
|
## Installation
|
7
16
|
|
8
|
-
|
17
|
+
```
|
18
|
+
$ gem install dredd
|
19
|
+
```
|
9
20
|
|
10
|
-
|
21
|
+
## Usage
|
11
22
|
|
12
|
-
|
23
|
+
Dredd is a sort of DSL, sort of rule runner, combined.
|
13
24
|
|
14
|
-
|
25
|
+
Use it if you want to detect various outliers/exceptions within collections, detection is expressed with Dredd rules.
|
15
26
|
|
16
|
-
Or install it yourself as:
|
17
27
|
|
18
|
-
|
28
|
+
To start, you should have
|
19
29
|
|
20
|
-
|
30
|
+
1. A collection of hashes (if you have objects, `#to_h` them).
|
31
|
+
2. A Dredd rule.
|
32
|
+
|
33
|
+
Now combine the two :)
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
result = Dredd.detect "all{ payment > 10 }.size.gt 0",
|
37
|
+
[
|
38
|
+
{ :payment => 0 },
|
39
|
+
{ :payment => 20 },
|
40
|
+
{ :payment => 0 }
|
41
|
+
]
|
42
|
+
result # => true
|
43
|
+
```
|
44
|
+
|
45
|
+
### Rules
|
46
|
+
|
47
|
+
Here's an assortment of queries possible with Dredd's DSL:
|
48
|
+
|
49
|
+
```
|
50
|
+
all.mean{ payment }
|
51
|
+
all{ payment > 10 }.sum{ payment }.is 20
|
52
|
+
first(2){ payment > 50 }
|
53
|
+
```
|
54
|
+
|
55
|
+
See live examples in `spec/dredd/query_spec.rb`
|
56
|
+
|
57
|
+
|
58
|
+
### Notes
|
59
|
+
|
60
|
+
Rules are not sandboxed yet. They will be, and till then - take it into consideration, thanks.
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
# Contributing
|
67
|
+
|
68
|
+
Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).
|
21
69
|
|
70
|
+
# Copyright
|
22
71
|
|
23
|
-
|
72
|
+
Copyright (c) 2014 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot). See MIT-LICENSE for further details.
|
24
73
|
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/lib/dredd/version.rb
CHANGED
data/spec/dredd/query_spec.rb
CHANGED
@@ -14,6 +14,16 @@ describe Dredd::Query do
|
|
14
14
|
q.execute([{:foo => 0},{:foo => 0}, {:foo => 60}]).must_equal(["foo" => 60])
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should select first" do
|
18
|
+
q = Dredd::Query.new("first(1){ foo }")
|
19
|
+
q.execute([{:foo => 0}, {:foo => 60}]).must_equal(["foo" => 0])
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should select last" do
|
23
|
+
q = Dredd::Query.new("last(1){ foo }")
|
24
|
+
q.execute([{:foo => 0}, {:foo => 60}]).must_equal(["foo" => 60])
|
25
|
+
end
|
26
|
+
|
17
27
|
it "should run aggregations on all" do
|
18
28
|
q = Dredd::Query.new("all.sum{ foo }")
|
19
29
|
q.execute([{:foo => 1},{:foo => 2}, {:foo => 60}]).must_equal(63)
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dredd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- jondot
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: hashie
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: statsample
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: bundler
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,43 +62,49 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rake
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- - '>='
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: '0'
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- - '>='
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '0'
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rr
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
|
-
- - '>='
|
83
|
+
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: '0'
|
76
86
|
type: :development
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
|
-
- - '>='
|
91
|
+
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
82
93
|
version: '0'
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: guard-minitest
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
|
-
- - '>='
|
99
|
+
- - ! '>='
|
88
100
|
- !ruby/object:Gem::Version
|
89
101
|
version: '0'
|
90
102
|
type: :development
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
|
-
- - '>='
|
107
|
+
- - ! '>='
|
95
108
|
- !ruby/object:Gem::Version
|
96
109
|
version: '0'
|
97
110
|
description: ''
|
@@ -119,26 +132,27 @@ files:
|
|
119
132
|
homepage: ''
|
120
133
|
licenses:
|
121
134
|
- MIT
|
122
|
-
metadata: {}
|
123
135
|
post_install_message:
|
124
136
|
rdoc_options: []
|
125
137
|
require_paths:
|
126
138
|
- lib
|
127
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
128
141
|
requirements:
|
129
|
-
- - '>='
|
142
|
+
- - ! '>='
|
130
143
|
- !ruby/object:Gem::Version
|
131
144
|
version: '0'
|
132
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
133
147
|
requirements:
|
134
|
-
- - '>='
|
148
|
+
- - ! '>='
|
135
149
|
- !ruby/object:Gem::Version
|
136
150
|
version: '0'
|
137
151
|
requirements: []
|
138
152
|
rubyforge_project:
|
139
|
-
rubygems_version:
|
153
|
+
rubygems_version: 1.8.23
|
140
154
|
signing_key:
|
141
|
-
specification_version:
|
155
|
+
specification_version: 3
|
142
156
|
summary: ''
|
143
157
|
test_files:
|
144
158
|
- spec/dredd/query_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: b0d4e39388a55b8ef0bf7410e33abcb3c544a577
|
4
|
-
data.tar.gz: e1582407cd7fa935bb50e825a790fa75192475cd
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 3ee9456d383cefee40908ea2e3b347c63023f2e38610295f95abc9b30ba9ebb47ffd64de2b9ab55a8dcd15f44c43bc028f47c7f16be76b6cb7ff02408ad4e760
|
7
|
-
data.tar.gz: 561771d6d4081f68fa0342f800fdca04d244872a9a9901aebd141861e53de348d3482140fd74c94d0b9e2fc3080742ff87666467d576f3295ebba711113c2b91
|