pakyow-presenter 1.0.0.rc1 → 1.0.0.rc2

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: 1bd0c274a2f3fdcfc17a93a8390f6e785280815105100977f2e57770d44b3bb3
4
- data.tar.gz: 270e993fbfd4ff58aac7ad070ab050e8b21029204e6a356ebf0fc82cd268aa25
3
+ metadata.gz: b391d208e0ea90895a7b1ffc21a12669d1d69cbc49094a188cd4f8394c277520
4
+ data.tar.gz: 6117f575c858ebcacc6ca6c75dc861abf05063f1fc08adc7ab010b8f974cd5df
5
5
  SHA512:
6
- metadata.gz: 30cd88cf117723d9800598412000b59b1a4d825a3a6766250209ba5e7ac902c579273f0160ddc055e2339342e0d7fa96e6ff91474e73d3273d7666e8bf4581e0
7
- data.tar.gz: aef3ab5a380c55076f59e6947096a7c4e92c7c630263ca96627a1cd78cd9d99f11b870db904f169d109804346a81944593b4f0da818d45c99a2c1e793b7d7562
6
+ metadata.gz: 26371318843936b528aea061116151e032de10387e92e5cb3c93d0565a497478409afb98a5965eaf91722820afd20ab13ba030e21a2a1f6f7ae0cc110c2531f9
7
+ data.tar.gz: f8366c589e71899bd7b1234adc7888205108321a5acf16708be42442972d769ef76aa96422f49208b8c0366dabb81086b610d88127cc5eb40a6fa39d58a463cd
@@ -12,12 +12,14 @@ module Pakyow
12
12
 
13
13
  apply_extension do
14
14
  unless ancestors.include?(Plugin)
15
- after "load", "load.presenter" do
15
+ after "initialize", "initialize.presenter", priority: :high do
16
16
  state(:templates) << Templates.new(
17
17
  :default,
18
18
  config.presenter.path,
19
19
  processor: ProcessorCaller.new(
20
- state(:processor)
20
+ state(:processor).map { |processor|
21
+ processor.new(self)
22
+ }
21
23
  )
22
24
  )
23
25
 
@@ -30,6 +32,34 @@ module Pakyow
30
32
  @plugs.each(&:load_frontend)
31
33
  end
32
34
  end
35
+
36
+ # Build presenter classes for compound components.
37
+ #
38
+ after "initialize", priority: :high do
39
+ state(:templates).each do |templates|
40
+ templates.each do |template|
41
+ template.object.each_significant_node(:component, descend: true) do |node|
42
+ if node.label(:components).count > 1
43
+ component_classes = node.label(:components).each_with_object([]) { |component_label, arr|
44
+ component_class = state(:component).find { |component|
45
+ component.__object_name.name == component_label[:name]
46
+ }
47
+
48
+ if component_class
49
+ arr << component_class
50
+ end
51
+ }
52
+
53
+ if component_classes.count > 1
54
+ state(:presenter) << Actions::RenderComponents.find_or_build_compound_presenter(
55
+ self, component_classes
56
+ )
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
33
63
  end
34
64
  end
35
65
  end
@@ -69,34 +69,6 @@ module Pakyow
69
69
  end
70
70
  end
71
71
 
72
- # Build presenter classes for compound components.
73
- #
74
- after :initialize, priority: :high do
75
- state(:templates).each do |templates|
76
- templates.each do |template|
77
- template.object.each_significant_node(:component, descend: true) do |node|
78
- if node.label(:components).count > 1
79
- component_classes = node.label(:components).each_with_object([]) { |component_label, arr|
80
- component_class = state(:component).find { |component|
81
- component.__object_name.name == component_label[:name]
82
- }
83
-
84
- if component_class
85
- arr << component_class
86
- end
87
- }
88
-
89
- if component_classes.count > 1
90
- state(:presenter) << Actions::RenderComponents.find_or_build_compound_presenter(
91
- self, component_classes
92
- )
93
- end
94
- end
95
- end
96
- end
97
- end
98
- end
99
-
100
72
  def presenter_for_context(presenter_class, context)
101
73
  presenter_class.new(
102
74
  context.view, app: context.app, presentables: context.presentables
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "pakyow/support/class_state"
4
+
3
5
  module Pakyow
4
6
  module Presenter
5
7
  class ProcessorCaller
@@ -9,12 +11,12 @@ module Pakyow
9
11
 
10
12
  def process(content, extension)
11
13
  processors_for_extension(extension).each do |processor|
12
- content = processor.process(content)
14
+ content = processor.call(content)
13
15
  end
14
16
 
15
17
  unless extension == :html
16
18
  processors_for_extension(:html).each do |processor|
17
- content = processor.process(content)
19
+ content = processor.call(content)
18
20
  end
19
21
  end
20
22
 
@@ -33,7 +35,7 @@ module Pakyow
33
35
 
34
36
  def normalize(instances)
35
37
  instances.each_with_object({}) { |instance, processors|
36
- instance.extensions.each do |extension|
38
+ instance.class.extensions.each do |extension|
37
39
  (processors[extension] ||= []) << instance
38
40
  end
39
41
  }
@@ -41,20 +43,42 @@ module Pakyow
41
43
  end
42
44
 
43
45
  class Processor
46
+ extend Support::ClassState
47
+ class_state :name
48
+ class_state :block
49
+ class_state :extensions, default: [], getter: false
50
+
44
51
  extend Support::Makeable
45
52
 
46
- class << self
47
- attr_reader :name, :extensions, :block
53
+ def initialize(app)
54
+ @app = app
55
+ end
56
+
57
+ def call(content)
58
+ self.class.process(content)
59
+ end
48
60
 
61
+ class << self
49
62
  def make(name, *extensions, **kwargs, &block)
50
- # name is expected to also be an extension
63
+ # Name is expected to also be an extension.
64
+ #
51
65
  extensions.unshift(name).map!(&:to_sym)
66
+
52
67
  super(name, extensions: extensions, block: block, **kwargs) {}
53
68
  end
54
69
 
55
70
  def process(content)
56
71
  block.call(content)
57
72
  end
73
+
74
+ def extensions(*extensions)
75
+ if extensions.any?
76
+ @extensions ||= []
77
+ @extensions.concat(extensions.map(&:to_sym)).uniq
78
+ else
79
+ @extensions
80
+ end
81
+ end
58
82
  end
59
83
  end
60
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakyow-presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-03 00:00:00.000000000 Z
12
+ date: 2019-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pakyow-core
@@ -17,42 +17,42 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.0.0.rc1
20
+ version: 1.0.0.rc2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 1.0.0.rc1
27
+ version: 1.0.0.rc2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: pakyow-routing
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 1.0.0.rc1
34
+ version: 1.0.0.rc2
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 1.0.0.rc1
41
+ version: 1.0.0.rc2
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: pakyow-support
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 1.0.0.rc1
48
+ version: 1.0.0.rc2
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 1.0.0.rc1
55
+ version: 1.0.0.rc2
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: oga
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -173,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  - !ruby/object:Gem::Version
174
174
  version: 1.3.1
175
175
  requirements: []
176
- rubyforge_project:
177
- rubygems_version: 2.7.6
176
+ rubygems_version: 3.0.3
178
177
  signing_key:
179
178
  specification_version: 4
180
179
  summary: Pakyow Presenter