rails-patterns 0.5.0 → 0.6.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 +62 -61
- data/VERSION +1 -1
- data/lib/patterns/query.rb +20 -15
- data/rails-patterns.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a30afb3f25ef523a75a54887fc9ff48f7567ac8
|
4
|
+
data.tar.gz: b3d71af078c2287b6c1f6e16bc140d267879b49b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bb36981deb575dd7e900bb41c14d89e230c60ea67896b87643ed332923cf13b32880599111c672d0591f01836fc81d2e87381337ec100d304fdf726e93f67ac
|
7
|
+
data.tar.gz: debed57e679b131544e8b7c76f95944f0128570f71f3959187fbce79081a2848a9c2e8cfdbc257855df15f3d80b2c717c94d958428d0d23ad472825e1bf23d92
|
data/Gemfile.lock
CHANGED
@@ -1,59 +1,61 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionpack (5.
|
5
|
-
actionview (= 5.
|
6
|
-
activesupport (= 5.
|
4
|
+
actionpack (5.1.4)
|
5
|
+
actionview (= 5.1.4)
|
6
|
+
activesupport (= 5.1.4)
|
7
7
|
rack (~> 2.0)
|
8
|
-
rack-test (
|
8
|
+
rack-test (>= 0.6.3)
|
9
9
|
rails-dom-testing (~> 2.0)
|
10
10
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
11
|
-
actionview (5.
|
12
|
-
activesupport (= 5.
|
11
|
+
actionview (5.1.4)
|
12
|
+
activesupport (= 5.1.4)
|
13
13
|
builder (~> 3.1)
|
14
|
-
|
14
|
+
erubi (~> 1.4)
|
15
15
|
rails-dom-testing (~> 2.0)
|
16
16
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
17
|
-
activemodel (5.
|
18
|
-
activesupport (= 5.
|
19
|
-
activerecord (5.
|
20
|
-
activemodel (= 5.
|
21
|
-
activesupport (= 5.
|
22
|
-
arel (~>
|
23
|
-
activesupport (5.
|
17
|
+
activemodel (5.1.4)
|
18
|
+
activesupport (= 5.1.4)
|
19
|
+
activerecord (5.1.4)
|
20
|
+
activemodel (= 5.1.4)
|
21
|
+
activesupport (= 5.1.4)
|
22
|
+
arel (~> 8.0)
|
23
|
+
activesupport (5.1.4)
|
24
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
25
|
i18n (~> 0.7)
|
26
26
|
minitest (~> 5.1)
|
27
27
|
tzinfo (~> 1.1)
|
28
|
-
addressable (2.
|
29
|
-
|
28
|
+
addressable (2.5.2)
|
29
|
+
public_suffix (>= 2.0.2, < 4.0)
|
30
|
+
arel (8.0.0)
|
30
31
|
axiom-types (0.1.1)
|
31
32
|
descendants_tracker (~> 0.0.4)
|
32
33
|
ice_nine (~> 0.11.0)
|
33
34
|
thread_safe (~> 0.3, >= 0.3.1)
|
34
35
|
builder (3.2.3)
|
35
|
-
coderay (1.1.
|
36
|
+
coderay (1.1.2)
|
36
37
|
coercible (1.0.0)
|
37
38
|
descendants_tracker (~> 0.0.1)
|
38
39
|
concurrent-ruby (1.0.5)
|
40
|
+
crass (1.0.3)
|
39
41
|
descendants_tracker (0.0.4)
|
40
42
|
thread_safe (~> 0.3, >= 0.3.1)
|
41
43
|
diff-lcs (1.3)
|
42
44
|
equalizer (0.0.11)
|
43
|
-
|
44
|
-
faraday (0.
|
45
|
+
erubi (1.7.0)
|
46
|
+
faraday (0.12.2)
|
45
47
|
multipart-post (>= 1.2, < 3)
|
46
48
|
git (1.3.0)
|
47
|
-
github_api (0.
|
48
|
-
addressable (~> 2.4
|
49
|
+
github_api (0.18.2)
|
50
|
+
addressable (~> 2.4)
|
49
51
|
descendants_tracker (~> 0.0.4)
|
50
|
-
faraday (~> 0.8
|
51
|
-
hashie (>= 3.
|
52
|
-
mime-types (>= 1.16, < 3.0)
|
52
|
+
faraday (~> 0.8)
|
53
|
+
hashie (~> 3.5, >= 3.5.2)
|
53
54
|
oauth2 (~> 1.0)
|
54
|
-
hashie (3.5.
|
55
|
-
highline (1.7.
|
56
|
-
i18n (0.
|
55
|
+
hashie (3.5.7)
|
56
|
+
highline (1.7.10)
|
57
|
+
i18n (0.9.1)
|
58
|
+
concurrent-ruby (~> 1.0)
|
57
59
|
ice_nine (0.11.2)
|
58
60
|
juwelier (2.1.3)
|
59
61
|
builder
|
@@ -66,56 +68,55 @@ GEM
|
|
66
68
|
rdoc
|
67
69
|
semver
|
68
70
|
jwt (1.5.6)
|
69
|
-
loofah (2.
|
71
|
+
loofah (2.1.1)
|
72
|
+
crass (~> 1.0.2)
|
70
73
|
nokogiri (>= 1.5.9)
|
71
|
-
method_source (0.
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
multi_json (1.12.1)
|
74
|
+
method_source (0.9.0)
|
75
|
+
mini_portile2 (2.3.0)
|
76
|
+
minitest (5.11.1)
|
77
|
+
multi_json (1.13.1)
|
76
78
|
multi_xml (0.6.0)
|
77
79
|
multipart-post (2.0.0)
|
78
|
-
nokogiri (1.
|
79
|
-
mini_portile2 (~> 2.
|
80
|
-
oauth2 (1.
|
81
|
-
faraday (>= 0.8, < 0.
|
80
|
+
nokogiri (1.8.1)
|
81
|
+
mini_portile2 (~> 2.3.0)
|
82
|
+
oauth2 (1.4.0)
|
83
|
+
faraday (>= 0.8, < 0.13)
|
82
84
|
jwt (~> 1.0)
|
83
85
|
multi_json (~> 1.3)
|
84
86
|
multi_xml (~> 0.5)
|
85
87
|
rack (>= 1.2, < 3)
|
86
|
-
pry (0.
|
88
|
+
pry (0.11.3)
|
87
89
|
coderay (~> 1.1.0)
|
88
|
-
method_source (~> 0.
|
89
|
-
slop (~> 3.4)
|
90
|
+
method_source (~> 0.9.0)
|
90
91
|
pry-rails (0.3.6)
|
91
92
|
pry (>= 0.10.4)
|
92
|
-
|
93
|
-
rack
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
93
|
+
public_suffix (3.0.1)
|
94
|
+
rack (2.0.3)
|
95
|
+
rack-test (0.8.2)
|
96
|
+
rack (>= 1.0, < 3)
|
97
|
+
rails-dom-testing (2.0.3)
|
98
|
+
activesupport (>= 4.2.0)
|
99
|
+
nokogiri (>= 1.6)
|
98
100
|
rails-html-sanitizer (1.0.3)
|
99
101
|
loofah (~> 2.0)
|
100
|
-
rake (12.
|
101
|
-
rdoc (
|
102
|
-
rspec (3.
|
103
|
-
rspec-core (~> 3.
|
104
|
-
rspec-expectations (~> 3.
|
105
|
-
rspec-mocks (~> 3.
|
106
|
-
rspec-core (3.
|
107
|
-
rspec-support (~> 3.
|
108
|
-
rspec-expectations (3.
|
102
|
+
rake (12.3.0)
|
103
|
+
rdoc (6.0.1)
|
104
|
+
rspec (3.7.0)
|
105
|
+
rspec-core (~> 3.7.0)
|
106
|
+
rspec-expectations (~> 3.7.0)
|
107
|
+
rspec-mocks (~> 3.7.0)
|
108
|
+
rspec-core (3.7.1)
|
109
|
+
rspec-support (~> 3.7.0)
|
110
|
+
rspec-expectations (3.7.0)
|
109
111
|
diff-lcs (>= 1.2.0, < 2.0)
|
110
|
-
rspec-support (~> 3.
|
111
|
-
rspec-mocks (3.
|
112
|
+
rspec-support (~> 3.7.0)
|
113
|
+
rspec-mocks (3.7.0)
|
112
114
|
diff-lcs (>= 1.2.0, < 2.0)
|
113
|
-
rspec-support (~> 3.
|
114
|
-
rspec-support (3.
|
115
|
+
rspec-support (~> 3.7.0)
|
116
|
+
rspec-support (3.7.0)
|
115
117
|
semver (1.0.1)
|
116
|
-
slop (3.6.0)
|
117
118
|
thread_safe (0.3.6)
|
118
|
-
tzinfo (1.2.
|
119
|
+
tzinfo (1.2.4)
|
119
120
|
thread_safe (~> 0.1)
|
120
121
|
virtus (1.0.5)
|
121
122
|
axiom-types (~> 0.1)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/patterns/query.rb
CHANGED
@@ -6,17 +6,17 @@ module Patterns
|
|
6
6
|
|
7
7
|
def initialize(*args)
|
8
8
|
@options = args.extract_options!
|
9
|
-
@relation = args.first ||
|
9
|
+
@relation = args.first || base_relation
|
10
10
|
|
11
11
|
if relation.nil?
|
12
12
|
raise(
|
13
|
-
|
14
|
-
|
13
|
+
RelationRequired,
|
14
|
+
"Queries require a base relation defined. Use .queries method to define relation."
|
15
15
|
)
|
16
16
|
elsif !relation.is_a?(ActiveRecord::Relation)
|
17
17
|
raise(
|
18
|
-
|
19
|
-
|
18
|
+
RelationRequired,
|
19
|
+
"Queries accept only ActiveRecord::Relation as input"
|
20
20
|
)
|
21
21
|
end
|
22
22
|
end
|
@@ -29,20 +29,25 @@ module Patterns
|
|
29
29
|
query.tap do |relation|
|
30
30
|
unless relation.is_a?(ActiveRecord::Relation)
|
31
31
|
raise(
|
32
|
-
|
33
|
-
|
32
|
+
RelationRequired,
|
33
|
+
"#query method should return object of ActiveRecord::Relation class"
|
34
34
|
)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.queries(subject)
|
40
|
-
self.base_relation =
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
self.base_relation = subject
|
41
|
+
end
|
42
|
+
|
43
|
+
def base_relation
|
44
|
+
return nil if self.class.base_relation.nil?
|
45
|
+
|
46
|
+
if self.class.base_relation.is_a?(ActiveRecord::Relation)
|
47
|
+
self.class.base_relation
|
48
|
+
elsif self.class.base_relation < ActiveRecord::Base
|
49
|
+
self.class.base_relation.all
|
50
|
+
end
|
46
51
|
end
|
47
52
|
|
48
53
|
private
|
@@ -55,8 +60,8 @@ module Patterns
|
|
55
60
|
|
56
61
|
def query
|
57
62
|
raise(
|
58
|
-
|
59
|
-
|
63
|
+
NotImplementedError,
|
64
|
+
"You need to implement #query method which returns ActiveRecord::Relation object"
|
60
65
|
)
|
61
66
|
end
|
62
67
|
end
|
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.6.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.6.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 = "2018-01-18"
|
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 = [
|
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.6.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: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|