spark-component 1.0.0.pre.alpha.1 → 1.0.0.pre.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7531fb1b2668f9d7aa7fc2b76653f4f87638cbffb919d4fcc556192e14c87a5e
4
- data.tar.gz: 34882f3cac0dbc33f6fbfcbebb9195c7564ffdd2e94a82145c7c76e4f8a24bea
3
+ metadata.gz: ec7ce0537ea5b7b2ca514cc478dc3a1bf49ba8fb7cd333e1a73bec5531bfedbc
4
+ data.tar.gz: dd62d7e6de7a10e1967131e7dcd0c1a9c619f3110b63fe04ee9ce7b501f3a6fe
5
5
  SHA512:
6
- metadata.gz: be3f47247ba35d4ee29525eaa93ffee5025c605c4d585a7f7573e680a61d68ad43595e6ebf10ba8a79375f5aa9059577ec29161717cea1e2ffc02a5d2ffb3505
7
- data.tar.gz: fe98c4fdab4bc3bf36c2e8748d695e725e4e6ab66bfbeb2c9f33d6c5657a009db5bcc02b197955fdd1b62a893ca7c42515f3bb343265b97564179570bc308dc1
6
+ metadata.gz: 304f0c80b85c11474524b3956659fd83fc5d3dec9f16092561120dbea608c31c11238557070e5448e8c8e6db8358441c4983eb383a7c3c2db77ed84e15519c80
7
+ data.tar.gz: 3099d522662b9dba6cbb1b837e3e07d0e6f87a823f6930887b819c22d45f65d0528eae2a309d653b693f8454f1fb542efa7199ecbd88c63c13599e50518a3213
data/.rubocop.yml CHANGED
@@ -26,7 +26,7 @@ Metrics/ClassLength:
26
26
  - 'lib/spark_components/element.rb'
27
27
 
28
28
  Layout/TrailingBlankLines:
29
- EnforcedStyle: final_blank_line
29
+ EnforcedStyle: final_newline
30
30
 
31
31
  Naming/VariableNumber:
32
32
  EnforcedStyle: snake_case
data/Gemfile CHANGED
@@ -7,4 +7,3 @@ gemspec
7
7
 
8
8
  gem "pry-byebug", group: %i[development test]
9
9
  gem "rails", "~> 6.0.0"
10
-
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spark-component (1.0.0.pre.alpha.1)
4
+ spark-component (1.0.0.pre.alpha.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/Rakefile CHANGED
@@ -14,4 +14,3 @@ Rake::TestTask.new(:bench) do |t|
14
14
  end
15
15
 
16
16
  task default: :test
17
-
data/bin/console CHANGED
@@ -13,4 +13,3 @@ require "spark/component"
13
13
 
14
14
  require "irb"
15
15
  IRB.start(__FILE__)
16
-
@@ -40,4 +40,3 @@ module Spark
40
40
  end
41
41
  end
42
42
  end
43
-
@@ -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
-
@@ -54,4 +54,3 @@ module Spark
54
54
  end
55
55
  end
56
56
  end
57
-
@@ -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
-
@@ -70,4 +70,3 @@ module Spark
70
70
  end
71
71
  end
72
72
  end
73
-
@@ -42,4 +42,3 @@ module Spark
42
42
  end
43
43
  end
44
44
  end
45
-
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Spark
4
4
  module Component
5
- VERSION = "1.0.0.pre.alpha.1"
5
+ VERSION = "1.0.0.pre.alpha.2"
6
6
  end
7
7
  end
8
-
@@ -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::Element unless base < Spark::Component::Element
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
-
@@ -38,4 +38,3 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "rubocop"
39
39
  spec.add_development_dependency "slim"
40
40
  end
41
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha.1
4
+ version: 1.0.0.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis