rails-patterns 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +73 -61
- data/README.md +1 -0
- data/VERSION +1 -1
- data/lib/patterns/ruleset.rb +0 -4
- data/rails-patterns.gemspec +3 -3
- data/spec/patterns/ruleset_spec.rb +12 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbe1da3d0914915666930f116e9d74b0c20cd5f75184f3d4e5304231fdb98784
|
4
|
+
data.tar.gz: 60f796148cfcb353aa5071936ecf9203bd8895183feccc14a80baaa31705eeef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c53d800f009d26c834a88d672a6f6461cd88d16b3e13d086d1da40d20c88e6f457a878f40b297a22ffab921081863f6c29002b032fefb02d8fd890ba7a51f69
|
7
|
+
data.tar.gz: e3a6563d3a5e6c081491be1e4d2839d6d5a7f17d5f5af2980ffac2732fc9cd15bd00976ca68f99322e3d6ba559d70bbab56c2168880dc89c03ed29f1c39511e5
|
data/Gemfile.lock
CHANGED
@@ -1,53 +1,66 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionpack (6.
|
5
|
-
actionview (= 6.
|
6
|
-
activesupport (= 6.
|
7
|
-
rack (~> 2.0, >= 2.0.
|
4
|
+
actionpack (6.1.4.1)
|
5
|
+
actionview (= 6.1.4.1)
|
6
|
+
activesupport (= 6.1.4.1)
|
7
|
+
rack (~> 2.0, >= 2.0.9)
|
8
8
|
rack-test (>= 0.6.3)
|
9
9
|
rails-dom-testing (~> 2.0)
|
10
10
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
11
|
-
actionview (6.
|
12
|
-
activesupport (= 6.
|
11
|
+
actionview (6.1.4.1)
|
12
|
+
activesupport (= 6.1.4.1)
|
13
13
|
builder (~> 3.1)
|
14
14
|
erubi (~> 1.4)
|
15
15
|
rails-dom-testing (~> 2.0)
|
16
16
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
17
|
-
activemodel (6.
|
18
|
-
activesupport (= 6.
|
19
|
-
activerecord (6.
|
20
|
-
activemodel (= 6.
|
21
|
-
activesupport (= 6.
|
22
|
-
activesupport (6.
|
17
|
+
activemodel (6.1.4.1)
|
18
|
+
activesupport (= 6.1.4.1)
|
19
|
+
activerecord (6.1.4.1)
|
20
|
+
activemodel (= 6.1.4.1)
|
21
|
+
activesupport (= 6.1.4.1)
|
22
|
+
activesupport (6.1.4.1)
|
23
23
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
|
-
i18n (>=
|
25
|
-
minitest (
|
26
|
-
tzinfo (~>
|
27
|
-
zeitwerk (~> 2.
|
28
|
-
addressable (2.
|
24
|
+
i18n (>= 1.6, < 2)
|
25
|
+
minitest (>= 5.1)
|
26
|
+
tzinfo (~> 2.0)
|
27
|
+
zeitwerk (~> 2.3)
|
28
|
+
addressable (2.8.0)
|
29
29
|
public_suffix (>= 2.0.2, < 5.0)
|
30
30
|
axiom-types (0.1.1)
|
31
31
|
descendants_tracker (~> 0.0.4)
|
32
32
|
ice_nine (~> 0.11.0)
|
33
33
|
thread_safe (~> 0.3, >= 0.3.1)
|
34
34
|
builder (3.2.4)
|
35
|
-
coderay (1.1.
|
35
|
+
coderay (1.1.3)
|
36
36
|
coercible (1.0.0)
|
37
37
|
descendants_tracker (~> 0.0.1)
|
38
|
-
concurrent-ruby (1.1.
|
38
|
+
concurrent-ruby (1.1.9)
|
39
39
|
crass (1.0.6)
|
40
40
|
descendants_tracker (0.0.4)
|
41
41
|
thread_safe (~> 0.3, >= 0.3.1)
|
42
|
-
diff-lcs (1.
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
diff-lcs (1.4.4)
|
43
|
+
erubi (1.10.0)
|
44
|
+
faraday (1.8.0)
|
45
|
+
faraday-em_http (~> 1.0)
|
46
|
+
faraday-em_synchrony (~> 1.0)
|
47
|
+
faraday-excon (~> 1.1)
|
48
|
+
faraday-httpclient (~> 1.0.1)
|
46
49
|
faraday-net_http (~> 1.0)
|
50
|
+
faraday-net_http_persistent (~> 1.1)
|
51
|
+
faraday-patron (~> 1.0)
|
52
|
+
faraday-rack (~> 1.0)
|
47
53
|
multipart-post (>= 1.2, < 3)
|
48
|
-
ruby2_keywords
|
54
|
+
ruby2_keywords (>= 0.0.4)
|
55
|
+
faraday-em_http (1.0.0)
|
56
|
+
faraday-em_synchrony (1.0.0)
|
57
|
+
faraday-excon (1.1.0)
|
58
|
+
faraday-httpclient (1.0.1)
|
49
59
|
faraday-net_http (1.0.1)
|
50
|
-
|
60
|
+
faraday-net_http_persistent (1.2.0)
|
61
|
+
faraday-patron (1.0.0)
|
62
|
+
faraday-rack (1.0.0)
|
63
|
+
git (1.9.1)
|
51
64
|
rchardet (~> 1.8)
|
52
65
|
github_api (0.19.0)
|
53
66
|
addressable (~> 2.4)
|
@@ -57,7 +70,7 @@ GEM
|
|
57
70
|
oauth2 (~> 1.0)
|
58
71
|
hashie (3.6.0)
|
59
72
|
highline (2.0.3)
|
60
|
-
i18n (1.8.
|
73
|
+
i18n (1.8.11)
|
61
74
|
concurrent-ruby (~> 1.0)
|
62
75
|
ice_nine (0.11.2)
|
63
76
|
juwelier (2.4.9)
|
@@ -72,20 +85,20 @@ GEM
|
|
72
85
|
rake
|
73
86
|
rdoc
|
74
87
|
semver2
|
75
|
-
jwt (2.
|
88
|
+
jwt (2.3.0)
|
76
89
|
kamelcase (0.0.2)
|
77
90
|
semver2 (~> 3)
|
78
|
-
loofah (2.
|
91
|
+
loofah (2.13.0)
|
79
92
|
crass (~> 1.0.2)
|
80
93
|
nokogiri (>= 1.5.9)
|
81
|
-
method_source (0.
|
82
|
-
mini_portile2 (2.
|
83
|
-
minitest (5.14.
|
94
|
+
method_source (1.0.0)
|
95
|
+
mini_portile2 (2.6.1)
|
96
|
+
minitest (5.14.4)
|
84
97
|
multi_json (1.15.0)
|
85
98
|
multi_xml (0.6.0)
|
86
99
|
multipart-post (2.1.1)
|
87
|
-
nokogiri (1.
|
88
|
-
mini_portile2 (~> 2.
|
100
|
+
nokogiri (1.12.5)
|
101
|
+
mini_portile2 (~> 2.6.1)
|
89
102
|
racc (~> 1.4)
|
90
103
|
oauth2 (1.4.7)
|
91
104
|
faraday (>= 0.8, < 2.0)
|
@@ -93,52 +106,51 @@ GEM
|
|
93
106
|
multi_json (~> 1.3)
|
94
107
|
multi_xml (~> 0.5)
|
95
108
|
rack (>= 1.2, < 3)
|
96
|
-
pry (0.
|
97
|
-
coderay (~> 1.1
|
98
|
-
method_source (~>
|
99
|
-
pry-rails (0.3.
|
109
|
+
pry (0.14.1)
|
110
|
+
coderay (~> 1.1)
|
111
|
+
method_source (~> 1.0)
|
112
|
+
pry-rails (0.3.9)
|
100
113
|
pry (>= 0.10.4)
|
101
|
-
psych (4.0.
|
114
|
+
psych (4.0.2)
|
102
115
|
public_suffix (4.0.6)
|
103
|
-
racc (1.
|
116
|
+
racc (1.6.0)
|
104
117
|
rack (2.2.3)
|
105
118
|
rack-test (1.1.0)
|
106
119
|
rack (>= 1.0, < 3)
|
107
120
|
rails-dom-testing (2.0.3)
|
108
121
|
activesupport (>= 4.2.0)
|
109
122
|
nokogiri (>= 1.6)
|
110
|
-
rails-html-sanitizer (1.
|
123
|
+
rails-html-sanitizer (1.4.2)
|
111
124
|
loofah (~> 2.3)
|
112
|
-
rake (13.0.
|
125
|
+
rake (13.0.6)
|
113
126
|
rchardet (1.8.0)
|
114
|
-
rdoc (6.3.
|
115
|
-
redis (4.1
|
116
|
-
rspec (3.
|
117
|
-
rspec-core (~> 3.
|
118
|
-
rspec-expectations (~> 3.
|
119
|
-
rspec-mocks (~> 3.
|
120
|
-
rspec-core (3.
|
121
|
-
rspec-support (~> 3.
|
122
|
-
rspec-expectations (3.
|
127
|
+
rdoc (6.3.3)
|
128
|
+
redis (4.5.1)
|
129
|
+
rspec (3.10.0)
|
130
|
+
rspec-core (~> 3.10.0)
|
131
|
+
rspec-expectations (~> 3.10.0)
|
132
|
+
rspec-mocks (~> 3.10.0)
|
133
|
+
rspec-core (3.10.1)
|
134
|
+
rspec-support (~> 3.10.0)
|
135
|
+
rspec-expectations (3.10.1)
|
123
136
|
diff-lcs (>= 1.2.0, < 2.0)
|
124
|
-
rspec-support (~> 3.
|
125
|
-
rspec-mocks (3.
|
137
|
+
rspec-support (~> 3.10.0)
|
138
|
+
rspec-mocks (3.10.2)
|
126
139
|
diff-lcs (>= 1.2.0, < 2.0)
|
127
|
-
rspec-support (~> 3.
|
128
|
-
rspec-support (3.
|
129
|
-
rspec_junit_formatter (0.
|
140
|
+
rspec-support (~> 3.10.0)
|
141
|
+
rspec-support (3.10.3)
|
142
|
+
rspec_junit_formatter (0.4.1)
|
130
143
|
rspec-core (>= 2, < 4, != 2.12.0)
|
131
|
-
ruby2_keywords (0.0.
|
144
|
+
ruby2_keywords (0.0.5)
|
132
145
|
semver2 (3.4.2)
|
133
146
|
thread_safe (0.3.6)
|
134
|
-
tzinfo (
|
135
|
-
|
136
|
-
virtus (
|
147
|
+
tzinfo (2.0.4)
|
148
|
+
concurrent-ruby (~> 1.0)
|
149
|
+
virtus (2.0.0)
|
137
150
|
axiom-types (~> 0.1)
|
138
151
|
coercible (~> 1.0)
|
139
152
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
140
|
-
|
141
|
-
zeitwerk (2.3.0)
|
153
|
+
zeitwerk (2.5.1)
|
142
154
|
|
143
155
|
PLATFORMS
|
144
156
|
ruby
|
data/README.md
CHANGED
@@ -369,6 +369,7 @@ Use it when:
|
|
369
369
|
* Override `#not_applicable?` when method is applicable only under some specific conditions. Is `false` by default.
|
370
370
|
* Rule requires a subject as first argument.
|
371
371
|
* Multiple rules and rulesets can be combined into new ruleset as both share same interface and can be used interchangeably (composite pattern).
|
372
|
+
* By default empty ruleset is satisfied.
|
372
373
|
|
373
374
|
#### Forcing rules
|
374
375
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.11.0
|
data/lib/patterns/ruleset.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module Patterns
|
2
2
|
class Ruleset
|
3
|
-
class EmptyRuleset < StandardError; end
|
4
|
-
|
5
3
|
class << self
|
6
4
|
attr_accessor :rule_names
|
7
5
|
end
|
@@ -19,8 +17,6 @@ module Patterns
|
|
19
17
|
end
|
20
18
|
|
21
19
|
def initialize(subject = nil)
|
22
|
-
raise EmptyRuleset if self.class.rules.empty?
|
23
|
-
|
24
20
|
@rules = self.class.rules.map { |rule| rule.new(subject) }
|
25
21
|
end
|
26
22
|
|
data/rails-patterns.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: rails-patterns 0.
|
5
|
+
# stub: rails-patterns 0.11.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "rails-patterns".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.11.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Stevo".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2022-02-09"
|
15
15
|
s.description = "A collection of lightweight, standardized, rails-oriented patterns.".freeze
|
16
16
|
s.email = "b.kosmowski@selleo.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -1,21 +1,4 @@
|
|
1
1
|
RSpec.describe Patterns::Ruleset do
|
2
|
-
context 'when empty ruleset is initialized' do
|
3
|
-
it 'raises an error' do
|
4
|
-
empty_ruleset_klass = Class.new(Patterns::Ruleset)
|
5
|
-
custom_ruleset_klass = Class.new(Patterns::Ruleset)
|
6
|
-
subject = double
|
7
|
-
|
8
|
-
with_mocked_rules do |rules|
|
9
|
-
rules << mock_rule(:rule_1)
|
10
|
-
custom_ruleset_klass.add_rule(:rule_1)
|
11
|
-
|
12
|
-
expect { custom_ruleset_klass.new(subject) }.not_to raise_error
|
13
|
-
end
|
14
|
-
|
15
|
-
expect { empty_ruleset_klass.new(subject) }.to raise_error Patterns::Ruleset::EmptyRuleset
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
2
|
describe '#forceable?' do
|
20
3
|
context 'all rules are forceable' do
|
21
4
|
it 'returns true' do
|
@@ -208,6 +191,18 @@ RSpec.describe Patterns::Ruleset do
|
|
208
191
|
end
|
209
192
|
end
|
210
193
|
end
|
194
|
+
|
195
|
+
context 'ruleset has no rules' do
|
196
|
+
it 'returns true' do
|
197
|
+
with_mocked_rules do |_rules|
|
198
|
+
subject = double
|
199
|
+
|
200
|
+
custom_ruleset_klass = Class.new(Patterns::Ruleset)
|
201
|
+
|
202
|
+
expect(custom_ruleset_klass.new(subject).satisfied?).to eq true
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
211
206
|
end
|
212
207
|
|
213
208
|
describe '#each' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-patterns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stevo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|