lite-component 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +31 -29
- data/README.md +14 -0
- data/lib/lite/component/base.rb +6 -0
- data/lib/lite/component/collection.rb +3 -1
- data/lib/lite/component/version.rb +1 -1
- 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: f2e349c98dc9b50bbf5c354f02dedb88b628fe1b54bdaa70cf8b2b03526b1c7e
|
|
4
|
+
data.tar.gz: c0887f8f7bd44e9b05e98f55fe95a8e6758b671a190a4ad43117223847394d99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d64ba9b39cebe86641897b412eaf51c9ecd13a01b57d63a80dff6f995f26be1e88c73bd14e7b374eb1b99b6f3035e4a592adf21e0d7ece238a2c981bdac8d99
|
|
7
|
+
data.tar.gz: be52c6a40ca8f3c23f2b96ec8e60327a6b338c6426d6e78f3d59453f7f2837af39669f7aa5d07f4e8e90f4e9446b14755968babeeb0974359a275551d4d47988
|
data/.rubocop.yml
CHANGED
|
@@ -14,6 +14,10 @@ Layout/EmptyLinesAroundModuleBody:
|
|
|
14
14
|
EnforcedStyle: empty_lines_except_namespace
|
|
15
15
|
Layout/LineLength:
|
|
16
16
|
Max: 100
|
|
17
|
+
Lint/RaiseException:
|
|
18
|
+
Enabled: true
|
|
19
|
+
Lint/StructNewOverride:
|
|
20
|
+
Enabled: true
|
|
17
21
|
Metrics/BlockLength:
|
|
18
22
|
Enabled: false
|
|
19
23
|
Metrics/ClassLength:
|
|
@@ -30,3 +34,9 @@ Style/Documentation:
|
|
|
30
34
|
Enabled: false
|
|
31
35
|
Style/ExpandPathArguments:
|
|
32
36
|
Enabled: false
|
|
37
|
+
Style/HashEachMethods:
|
|
38
|
+
Enabled: true
|
|
39
|
+
Style/HashTransformKeys:
|
|
40
|
+
Enabled: true
|
|
41
|
+
Style/HashTransformValues:
|
|
42
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.0.10] - 2020-04-06
|
|
10
|
+
### Added
|
|
11
|
+
- Added `render?` method for checking complex logic
|
|
12
|
+
|
|
9
13
|
## [1.0.9] - 2020-01-08
|
|
10
14
|
### Added
|
|
11
15
|
- Added block support to yield other components
|
data/Gemfile.lock
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
lite-component (1.0.
|
|
4
|
+
lite-component (1.0.10)
|
|
5
5
|
actionview
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
actionpack (6.0.2.
|
|
11
|
-
actionview (= 6.0.2.
|
|
12
|
-
activesupport (= 6.0.2.
|
|
10
|
+
actionpack (6.0.2.2)
|
|
11
|
+
actionview (= 6.0.2.2)
|
|
12
|
+
activesupport (= 6.0.2.2)
|
|
13
13
|
rack (~> 2.0, >= 2.0.8)
|
|
14
14
|
rack-test (>= 0.6.3)
|
|
15
15
|
rails-dom-testing (~> 2.0)
|
|
16
16
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
17
|
-
actionview (6.0.2.
|
|
18
|
-
activesupport (= 6.0.2.
|
|
17
|
+
actionview (6.0.2.2)
|
|
18
|
+
activesupport (= 6.0.2.2)
|
|
19
19
|
builder (~> 3.1)
|
|
20
20
|
erubi (~> 1.4)
|
|
21
21
|
rails-dom-testing (~> 2.0)
|
|
22
22
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
23
|
-
activesupport (6.0.2.
|
|
23
|
+
activesupport (6.0.2.2)
|
|
24
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
25
25
|
i18n (>= 0.7, < 2)
|
|
26
26
|
minitest (~> 5.1)
|
|
@@ -29,31 +29,31 @@ GEM
|
|
|
29
29
|
ast (2.4.0)
|
|
30
30
|
builder (3.2.4)
|
|
31
31
|
colorize (0.8.1)
|
|
32
|
-
concurrent-ruby (1.1.
|
|
33
|
-
crass (1.0.
|
|
32
|
+
concurrent-ruby (1.1.6)
|
|
33
|
+
crass (1.0.6)
|
|
34
34
|
diff-lcs (1.3)
|
|
35
35
|
erubi (1.9.0)
|
|
36
|
-
fasterer (0.8.
|
|
36
|
+
fasterer (0.8.3)
|
|
37
37
|
colorize (~> 0.7)
|
|
38
38
|
ruby_parser (>= 3.14.1)
|
|
39
39
|
generator_spec (0.9.4)
|
|
40
40
|
activesupport (>= 3.0.0)
|
|
41
41
|
railties (>= 3.0.0)
|
|
42
|
-
i18n (1.
|
|
42
|
+
i18n (1.8.2)
|
|
43
43
|
concurrent-ruby (~> 1.0)
|
|
44
44
|
jaro_winkler (1.5.4)
|
|
45
|
-
loofah (2.
|
|
45
|
+
loofah (2.5.0)
|
|
46
46
|
crass (~> 1.0.2)
|
|
47
47
|
nokogiri (>= 1.5.9)
|
|
48
|
-
method_source (0.
|
|
48
|
+
method_source (1.0.0)
|
|
49
49
|
mini_portile2 (2.4.0)
|
|
50
|
-
minitest (5.
|
|
51
|
-
nokogiri (1.10.
|
|
50
|
+
minitest (5.14.0)
|
|
51
|
+
nokogiri (1.10.9)
|
|
52
52
|
mini_portile2 (~> 2.4.0)
|
|
53
53
|
parallel (1.19.1)
|
|
54
|
-
parser (2.7.0
|
|
54
|
+
parser (2.7.1.0)
|
|
55
55
|
ast (~> 2.4.0)
|
|
56
|
-
rack (2.
|
|
56
|
+
rack (2.2.2)
|
|
57
57
|
rack-test (1.1.0)
|
|
58
58
|
rack (>= 1.0, < 3)
|
|
59
59
|
rails-dom-testing (2.0.3)
|
|
@@ -61,48 +61,50 @@ GEM
|
|
|
61
61
|
nokogiri (>= 1.6)
|
|
62
62
|
rails-html-sanitizer (1.3.0)
|
|
63
63
|
loofah (~> 2.3)
|
|
64
|
-
railties (6.0.2.
|
|
65
|
-
actionpack (= 6.0.2.
|
|
66
|
-
activesupport (= 6.0.2.
|
|
64
|
+
railties (6.0.2.2)
|
|
65
|
+
actionpack (= 6.0.2.2)
|
|
66
|
+
activesupport (= 6.0.2.2)
|
|
67
67
|
method_source
|
|
68
68
|
rake (>= 0.8.7)
|
|
69
69
|
thor (>= 0.20.3, < 2.0)
|
|
70
70
|
rainbow (3.0.0)
|
|
71
71
|
rake (13.0.1)
|
|
72
|
+
rexml (3.2.4)
|
|
72
73
|
rspec (3.9.0)
|
|
73
74
|
rspec-core (~> 3.9.0)
|
|
74
75
|
rspec-expectations (~> 3.9.0)
|
|
75
76
|
rspec-mocks (~> 3.9.0)
|
|
76
77
|
rspec-core (3.9.1)
|
|
77
78
|
rspec-support (~> 3.9.1)
|
|
78
|
-
rspec-expectations (3.9.
|
|
79
|
+
rspec-expectations (3.9.1)
|
|
79
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
80
81
|
rspec-support (~> 3.9.0)
|
|
81
82
|
rspec-mocks (3.9.1)
|
|
82
83
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
83
84
|
rspec-support (~> 3.9.0)
|
|
84
85
|
rspec-support (3.9.2)
|
|
85
|
-
rubocop (0.
|
|
86
|
+
rubocop (0.81.0)
|
|
86
87
|
jaro_winkler (~> 1.5.1)
|
|
87
88
|
parallel (~> 1.10)
|
|
88
89
|
parser (>= 2.7.0.1)
|
|
89
90
|
rainbow (>= 2.2.2, < 4.0)
|
|
91
|
+
rexml
|
|
90
92
|
ruby-progressbar (~> 1.7)
|
|
91
|
-
unicode-display_width (>= 1.4.0, <
|
|
93
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
92
94
|
rubocop-performance (1.5.2)
|
|
93
95
|
rubocop (>= 0.71.0)
|
|
94
|
-
rubocop-rspec (1.
|
|
96
|
+
rubocop-rspec (1.38.1)
|
|
95
97
|
rubocop (>= 0.68.1)
|
|
96
98
|
ruby-progressbar (1.10.1)
|
|
97
|
-
ruby_parser (3.14.
|
|
99
|
+
ruby_parser (3.14.2)
|
|
98
100
|
sexp_processor (~> 4.9)
|
|
99
|
-
sexp_processor (4.
|
|
101
|
+
sexp_processor (4.14.1)
|
|
100
102
|
thor (1.0.1)
|
|
101
103
|
thread_safe (0.3.6)
|
|
102
|
-
tzinfo (1.2.
|
|
104
|
+
tzinfo (1.2.7)
|
|
103
105
|
thread_safe (~> 0.1)
|
|
104
|
-
unicode-display_width (1.
|
|
105
|
-
zeitwerk (2.
|
|
106
|
+
unicode-display_width (1.7.0)
|
|
107
|
+
zeitwerk (2.3.0)
|
|
106
108
|
|
|
107
109
|
PLATFORMS
|
|
108
110
|
ruby
|
data/README.md
CHANGED
|
@@ -104,6 +104,20 @@ Render collection of components just as you would render collections of partials
|
|
|
104
104
|
<%= component("comment_card", collection: @comments, spacer_template: "components/spacer") %>
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
If you can skip rendering by evaluating complex logic in the `render?` method:
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
# app/components/alert_component.rb
|
|
111
|
+
|
|
112
|
+
class AlertComponent < Lite::Component::Base
|
|
113
|
+
|
|
114
|
+
def render?
|
|
115
|
+
object.some_complex_check?
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
```
|
|
120
|
+
|
|
107
121
|
### Context
|
|
108
122
|
|
|
109
123
|
All components include `ActionView::Context` which will give you access to request context such as
|
data/lib/lite/component/base.rb
CHANGED
|
@@ -66,6 +66,8 @@ module Lite
|
|
|
66
66
|
alias l locals
|
|
67
67
|
|
|
68
68
|
def render
|
|
69
|
+
return unless render?
|
|
70
|
+
|
|
69
71
|
collection = options.delete(:collection)
|
|
70
72
|
return render_content if collection.nil? || !collection.respond_to?(:each)
|
|
71
73
|
|
|
@@ -76,6 +78,10 @@ module Lite
|
|
|
76
78
|
)
|
|
77
79
|
end
|
|
78
80
|
|
|
81
|
+
def render?
|
|
82
|
+
true
|
|
83
|
+
end
|
|
84
|
+
|
|
79
85
|
def render_content
|
|
80
86
|
context.render(options)
|
|
81
87
|
end
|
|
@@ -44,8 +44,10 @@ module Lite
|
|
|
44
44
|
collection.each_with_object([]).with_index do |(object, array), index|
|
|
45
45
|
component.iteration = Lite::Component::Iteration.new(collection_size, index)
|
|
46
46
|
component.options.deep_merge!(locals: { object: object, iteration: component.iteration })
|
|
47
|
+
content = component.render_content
|
|
48
|
+
next if content.nil?
|
|
47
49
|
|
|
48
|
-
array <<
|
|
50
|
+
array << content
|
|
49
51
|
next unless spacer_template && !component.iteration.last?
|
|
50
52
|
|
|
51
53
|
array << component.context.render(spacer_template)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lite-component
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Gomez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-04-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionview
|