spark-component 1.0.0.pre.alpha.1 → 1.0.0.pre.alpha.2
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 +1 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +0 -1
- data/bin/console +0 -1
- data/lib/spark/component/attr.rb +0 -1
- data/lib/spark/component/attribute.rb +4 -1
- data/lib/spark/component/classname.rb +0 -1
- data/lib/spark/component/element.rb +9 -17
- data/lib/spark/component/integration/action_view_component.rb +0 -1
- data/lib/spark/component/tag_attr.rb +0 -1
- data/lib/spark/component/version.rb +1 -2
- data/lib/spark/component.rb +3 -2
- data/spark-component.gemspec +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec7ce0537ea5b7b2ca514cc478dc3a1bf49ba8fb7cd333e1a73bec5531bfedbc
|
4
|
+
data.tar.gz: dd62d7e6de7a10e1967131e7dcd0c1a9c619f3110b63fe04ee9ce7b501f3a6fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 304f0c80b85c11474524b3956659fd83fc5d3dec9f16092561120dbea608c31c11238557070e5448e8c8e6db8358441c4983eb383a7c3c2db77ed84e15519c80
|
7
|
+
data.tar.gz: 3099d522662b9dba6cbb1b837e3e07d0e6f87a823f6930887b819c22d45f65d0528eae2a309d653b693f8454f1fb542efa7199ecbd88c63c13599e50518a3213
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/spark/component/attr.rb
CHANGED
@@ -58,6 +58,10 @@ module Spark
|
|
58
58
|
base.extend(ClassMethods)
|
59
59
|
end
|
60
60
|
|
61
|
+
def initialize(*attrs)
|
62
|
+
initialize_attributes(*attrs)
|
63
|
+
end
|
64
|
+
|
61
65
|
# Assign instance variables for attributes defined by the class
|
62
66
|
def initialize_attributes(attrs = nil)
|
63
67
|
attrs ||= {}
|
@@ -194,4 +198,3 @@ module Spark
|
|
194
198
|
end
|
195
199
|
end
|
196
200
|
end
|
197
|
-
|
@@ -8,7 +8,6 @@ module Spark
|
|
8
8
|
class Error < StandardError; end
|
9
9
|
|
10
10
|
def self.included(base)
|
11
|
-
base.include(Spark::Component::Attribute)
|
12
11
|
base.extend(Spark::Component::Element::ClassMethods)
|
13
12
|
|
14
13
|
%i[_parent _block view_context].each do |name|
|
@@ -17,16 +16,23 @@ module Spark
|
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
19
|
+
# Initialize method on components must call super
|
20
20
|
def initialize(attrs = nil)
|
21
21
|
# Extract core element attributes
|
22
|
+
# Ensure that elements have references to their:
|
23
|
+
# - parent: enables elements to interact with their parent component
|
24
|
+
# - block: used in render_self
|
25
|
+
# - view_context, sets the view context for an element (in Rails)
|
26
|
+
#
|
22
27
|
unless attrs.nil? || attrs.empty?
|
23
28
|
@_parent = attrs.delete(:_parent)
|
24
29
|
@_block = attrs.delete(:_block)
|
25
30
|
@view_context = attrs.delete(:_view)
|
26
31
|
end
|
27
32
|
|
28
|
-
initialize_attributes(attrs)
|
29
33
|
initialize_elements
|
34
|
+
|
35
|
+
# Call Attributes.initialze
|
30
36
|
super
|
31
37
|
end
|
32
38
|
|
@@ -193,7 +199,6 @@ module Spark
|
|
193
199
|
# If an element extends a component, extend that component's class and include the necessary modules
|
194
200
|
def extend_class(component, &config)
|
195
201
|
base = Class.new(component || Spark::Component::Element::Base, &config)
|
196
|
-
# base.include(Spark::Component::Element)
|
197
202
|
define_model_name(base) if defined?(ActiveModel)
|
198
203
|
|
199
204
|
return base unless component
|
@@ -232,22 +237,9 @@ module Spark
|
|
232
237
|
# Base class for non-component elements
|
233
238
|
class Base
|
234
239
|
include ActiveModel::Validations if defined?(ActiveModel)
|
235
|
-
|
236
|
-
def initialize(attrs = nil)
|
237
|
-
# Extract core element attributes
|
238
|
-
unless attrs.nil? || attrs.empty?
|
239
|
-
@_parent = attrs.delete(:_parent)
|
240
|
-
@_block = attrs.delete(:_block)
|
241
|
-
@view_context = attrs.delete(:_view)
|
242
|
-
end
|
243
|
-
|
244
|
-
initialize_attributes(attrs)
|
245
|
-
initialize_elements
|
246
|
-
end
|
247
|
-
|
240
|
+
include Spark::Component::Attribute
|
248
241
|
include Spark::Component::Element
|
249
242
|
end
|
250
243
|
end
|
251
244
|
end
|
252
245
|
end
|
253
|
-
|
data/lib/spark/component.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "spark/component/version"
|
4
|
+
require "spark/component/attribute"
|
4
5
|
require "spark/component/element"
|
5
6
|
|
6
7
|
if defined?(ActionView::Component::Base)
|
@@ -10,7 +11,8 @@ end
|
|
10
11
|
module Spark
|
11
12
|
module Component
|
12
13
|
def self.included(base)
|
13
|
-
base.include Spark::Component::
|
14
|
+
base.include Spark::Component::Attribute
|
15
|
+
base.include Spark::Component::Element
|
14
16
|
|
15
17
|
# If an Integration is defeind include its modules if the component extends
|
16
18
|
# the defined base class
|
@@ -20,4 +22,3 @@ module Spark
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
23
|
-
|
data/spark-component.gemspec
CHANGED