spark_engine 1.2.8 → 1.2.9

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: f7557689cf486b1692155cd6263c3c11ab70ff3c3a3e0a008a08f5969bebdf34
4
- data.tar.gz: 93088a86f2abe6b96841070cc3645c8858ba5ba8a940a697e2bb312db1ce3726
3
+ metadata.gz: 517d9135194b594223815ccfdd158a389fffcde671e037b191b9462725b060e1
4
+ data.tar.gz: d629ce93d47645c2e9f65269ccaabf50a849e12f9c39e40248a870735a6bcdbd
5
5
  SHA512:
6
- metadata.gz: 1951941c433f9ee1efdcda3c316f649d98e0e2c4b69cd85db7bc47e94f8d4f8d9b0c76afa2fa2d2f348c3640a8ccff0862b33df8988f0f5cb199c39bde011f85
7
- data.tar.gz: 26ba3d5d75644c35b9ee9732a8bbbba9c09045e304b22295803e8a9874dfb0d4c80ffe56acdcabc8c86c0c95fb2ec8c61870334b7cd6c54cfc38f2103b19d113
6
+ metadata.gz: 32a7666db7a2c1640762d0996b68e1cbe02be194d123a7e14fea2bf7f5df3664b3c6225cabf2eec92d11f4394b63b719ccf14e2482dd30c18c9e75672809a4b5
7
+ data.tar.gz: a4c1b56772f399a9bb07939290c0cb954b3de2baca9a34649585d0f7fda39744519543963d72ae9f0854483fe18f74ba92ac70a197defd7b3ebde5acac070823
data/lib/spark_engine.rb CHANGED
@@ -10,6 +10,8 @@ require "spark_engine/sass/importer"
10
10
  require "spark_engine/config_data"
11
11
 
12
12
  module SparkEngine
13
+ autoload :BlockHelper, 'spark_engine/helpers/block_helper'
14
+
13
15
  extend self
14
16
  attr_accessor :plugin
15
17
 
@@ -0,0 +1,110 @@
1
+ # From: https://github.com/nachokb/block_helpers
2
+ # Inlined becuase the project is inactive and current forks aren't published to RubyGems.org
3
+ #
4
+ module SparkEngine
5
+
6
+ class BlockHelper
7
+
8
+ class << self
9
+
10
+ def inherited(klass)
11
+ # Define the helper method
12
+ # e.g. for a class:
13
+ # class HelloHelper < BlockHelpers::Base
14
+ # #.....
15
+ # end
16
+ #
17
+ # then we define a helper method 'hello_helper'
18
+ #
19
+ method_name = klass.name.split('::').last.underscore
20
+ klass.parent.class_eval %(
21
+ def #{method_name}(*args, &block)
22
+
23
+ # Get the current helper object which has all the normal helper methods
24
+ if self.is_a?(SparkEngine::BlockHelper)
25
+ top_level_helper = self.helper
26
+ parent_block_helper = self
27
+ else
28
+ top_level_helper = self
29
+ parent_block_helper = nil
30
+ end
31
+
32
+ # We need to save the current helper and parent block helper in the class so that
33
+ # it's visible to the renderer's 'initialize' method...
34
+ #{klass.name}.current_helper = top_level_helper
35
+ #{klass.name}.current_parent_block_helper = parent_block_helper
36
+ renderer = #{klass.name}.new(*args)
37
+ # ...then set them anyway on the renderer so that renderer methods can use it
38
+ renderer.send(:helper=, top_level_helper)
39
+ renderer.send(:parent=, parent_block_helper)
40
+
41
+ body = block ? capture(renderer, &block) : nil
42
+ processed_body = renderer.display(body)
43
+ if processed_body
44
+
45
+ if ::Rails::VERSION::MAJOR >= 3
46
+ return processed_body
47
+ elsif top_level_helper.method(:concat).arity == 2
48
+ concat processed_body, binding
49
+ else
50
+ concat processed_body
51
+ end
52
+
53
+ end
54
+ renderer
55
+ end
56
+ )
57
+ end
58
+
59
+ attr_accessor :current_helper, :current_parent_block_helper
60
+
61
+ end
62
+
63
+ def display(body)
64
+ body
65
+ end
66
+
67
+ def respond_to?(method, include_all = false)
68
+ super or helper.respond_to?(method, include_all)
69
+ end
70
+
71
+ protected
72
+
73
+ attr_writer :helper, :parent
74
+
75
+ # For nested block helpers
76
+ def parent
77
+ @parent ||= self.class.current_parent_block_helper
78
+ end
79
+
80
+ def helper
81
+ @helper ||= self.class.current_helper
82
+ end
83
+
84
+ def method_missing(method, *args, &block)
85
+ if helper.respond_to?(method)
86
+ self.class_eval "def #{method}(*args, &block); helper.send('#{method}', *args, &block); end"
87
+ self.send(method, *args, &block)
88
+ else
89
+ super
90
+ end
91
+ end
92
+
93
+ def capture(*args)
94
+ # ActiveSupport 3.1 breaks capture method (defines it on all objects)
95
+ # so we have to resort to rewrite it
96
+ if Rails.version < "3.1"
97
+ ActionView::Helpers::CaptureHelper.capture(renderer, &block)
98
+ else
99
+ value = nil
100
+ buffer = with_output_buffer { value = yield(*args) }
101
+ if string = buffer.presence || value and string.is_a?(String)
102
+ ERB::Util.html_escape string
103
+ end
104
+ end
105
+ end
106
+
107
+ end
108
+
109
+ end
110
+
@@ -1,3 +1,3 @@
1
1
  module SparkEngine
2
- VERSION = "1.2.8"
2
+ VERSION = "1.2.9"
3
3
  end
data/spark_engine.gemspec CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_runtime_dependency 'sass', '~> 3.4'
21
21
  spec.add_runtime_dependency 'esvg', '~> 4.2'
22
- spec.add_runtime_dependency 'block_helpers', '~> 0.3'
23
22
  spec.add_runtime_dependency 'colorize', '~> 0.8'
24
23
  spec.add_runtime_dependency 'bundler', '~> 1.10'
25
24
  spec.add_runtime_dependency 'autoprefixer-rails', '>= 8.0', '< 10'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.2'
41
- - !ruby/object:Gem::Dependency
42
- name: block_helpers
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.3'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.3'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: colorize
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +170,7 @@ files:
184
170
  - lib/spark_engine/command/npm.rb
185
171
  - lib/spark_engine/config_data.rb
186
172
  - lib/spark_engine/helpers/asset_helpers.rb
173
+ - lib/spark_engine/helpers/block_helper.rb
187
174
  - lib/spark_engine/helpers/layout_helpers.rb
188
175
  - lib/spark_engine/middleware.rb
189
176
  - lib/spark_engine/plugin.rb