klenod-build 0.0.9 → 0.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/lib/klenod/build/plugins/haml_plugin/helper_source.rb +0 -6
- data/lib/klenod/build/plugins/haml_plugin/transformer/ruby_builder.rb +24 -3
- data/lib/klenod/build/plugins/haml_plugin/transformer.rb +1 -1
- data/lib/klenod/build/plugins/haml_plugin.rb +2 -5
- data/lib/klenod/build/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58fe212ce18825d676c6661925007d46a8e7c68785f1c4b2af82e377fdc25f94
|
|
4
|
+
data.tar.gz: fa1abefa0576d6e2944bb240597f10abc979e19004af881c4c8bc90e261a3d5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2178c1a71530cbc648000abf216ee1f72495006bf41626e0c9e592dda97985921fb41e4714c10ff08e87889b1d7ab6334815531922248d5ac51dcf155177732
|
|
7
|
+
data.tar.gz: 0ddc8e894a70a6cf94aa9100ded80f4833c1ce64824ea10557a1dcf1cb2f2e7aff89bb2084763222f81559b1a04d33229bda4bcd98bfedb537d73ea334cc0aa6
|
|
@@ -427,6 +427,10 @@ module Klenod
|
|
|
427
427
|
expression("HamlHelper.freeze_static(#{argument_source(value)})")
|
|
428
428
|
end
|
|
429
429
|
|
|
430
|
+
def class_values(values)
|
|
431
|
+
source_expressions(values)
|
|
432
|
+
end
|
|
433
|
+
|
|
430
434
|
def script_block(source, body, line_no: nil)
|
|
431
435
|
source = rewrite_ruby_source(source, nil)
|
|
432
436
|
ast_script_block(source, body) || raise_ruby_parse_error(source, line_no: line_no, context: "Could not build Ruby block from Haml script")
|
|
@@ -444,9 +448,26 @@ module Klenod
|
|
|
444
448
|
|
|
445
449
|
def silent_script_with_children(source, body)
|
|
446
450
|
source = rewrite_ruby_source(source, nil)
|
|
451
|
+
return_with_children = false
|
|
452
|
+
|
|
453
|
+
# A modifier return with an indented Haml block returns that block
|
|
454
|
+
# when the condition matches. Keeping the return and its children
|
|
455
|
+
# as sequential statements would instead evaluate the children
|
|
456
|
+
# after the modifier has fallen through.
|
|
457
|
+
if source == "return"
|
|
458
|
+
source = "return #{argument_source(body)}"
|
|
459
|
+
return_with_children = true
|
|
460
|
+
elsif (match = source.match(/\Areturn\s+(if|unless)\s+(.+)\z/))
|
|
461
|
+
branch, condition = match.captures
|
|
462
|
+
source = "#{branch} #{condition}\n#{indent("return #{argument_source(body)}", 2)}\nend"
|
|
463
|
+
return_with_children = true
|
|
464
|
+
end
|
|
465
|
+
|
|
447
466
|
statements = parse_statements(source)
|
|
448
467
|
return raise(ArgumentError, "Could not parse Haml silent script: #{source.inspect}") unless statements
|
|
449
468
|
|
|
469
|
+
return Fragment.new(source, statements) if return_with_children
|
|
470
|
+
|
|
450
471
|
node = ast_begin([*statement_body_for(statements), *statement_body_for(body)])
|
|
451
472
|
Fragment.new(["begin", indent(source, 2), indent(to_source(body), 2), "end"].join("\n"), node)
|
|
452
473
|
end
|
|
@@ -595,12 +616,12 @@ module Klenod
|
|
|
595
616
|
children = children.map { |child| expression_fragment(child) }
|
|
596
617
|
props = props.dup
|
|
597
618
|
attribute_splats = props.delete(:__klenod_attribute_splats__) || []
|
|
619
|
+
prop_sources = ["{#{keyword_props_source(props, mark: mark).join(", ")}}", *attribute_splats.map { |value| argument_source(value) }]
|
|
598
620
|
|
|
599
621
|
source_parts = [
|
|
600
622
|
to_source(tag),
|
|
601
623
|
*children.map { |child| argument_source(child) },
|
|
602
|
-
|
|
603
|
-
*attribute_splats.map { |value| "**#{argument_source(value)}" }
|
|
624
|
+
"**HamlHelper.merge_props(self.class, #{prop_sources.join(", ")})"
|
|
604
625
|
].compact
|
|
605
626
|
Fragment.new("#{to_source(factory)}[#{source_parts.join(", ")}]", nil)
|
|
606
627
|
end
|
|
@@ -680,7 +701,7 @@ module Klenod
|
|
|
680
701
|
def block_source(source, body)
|
|
681
702
|
body_source = to_source(body)
|
|
682
703
|
|
|
683
|
-
if source.include?("{")
|
|
704
|
+
if source.include?("{") && !source.end_with?(" do")
|
|
684
705
|
"#{source} #{body_source} }"
|
|
685
706
|
else
|
|
686
707
|
[source, indent(body_source, 2), "end"].join("\n")
|
|
@@ -33,7 +33,6 @@ module Klenod
|
|
|
33
33
|
I18N_OPTIONS = %i[class constant].freeze
|
|
34
34
|
HAML_HELPER_SPECIFIER = "virtual:klenod/haml_helper"
|
|
35
35
|
HAML_HELPER_MODULE_ID = ModuleId.new("#{HAML_HELPER_SPECIFIER}.rb", nil)
|
|
36
|
-
STATIC_CLASS_SOURCE_PATTERN = /^[ \t]*(?:%[-:\w]+)?(?:#[\w-]+)?\.[\w-]|[({][^)}\n]*\bclass\s*=/m
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
module HamlPlugin
|
|
@@ -51,7 +50,6 @@ module Klenod
|
|
|
51
50
|
I18N_OPTIONS = HamlPlugin::I18N_OPTIONS
|
|
52
51
|
HAML_HELPER_SPECIFIER = HamlPlugin::HAML_HELPER_SPECIFIER
|
|
53
52
|
HAML_HELPER_MODULE_ID = HamlPlugin::HAML_HELPER_MODULE_ID
|
|
54
|
-
STATIC_CLASS_SOURCE_PATTERN = HamlPlugin::STATIC_CLASS_SOURCE_PATTERN
|
|
55
53
|
|
|
56
54
|
def self.parse_haml(...)
|
|
57
55
|
HamlPlugin.parse_haml(...)
|
|
@@ -170,9 +168,8 @@ module Klenod
|
|
|
170
168
|
class_names_runtime_dependency = class_names_runtime_dependency(module_id)
|
|
171
169
|
dependencies << class_names_runtime_dependency
|
|
172
170
|
styles_source = styles_source_for(builder, style_dependencies, class_names_runtime_dependency: class_names_runtime_dependency)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
dependencies << haml_helper_dependency if haml_helper_dependency
|
|
171
|
+
haml_helper_dependency = haml_helper_dependency(module_id)
|
|
172
|
+
dependencies << haml_helper_dependency
|
|
176
173
|
translations_source = builder.frozen_literal(translations_for(context, module_id)).source
|
|
177
174
|
component_class_name = component_class_name(module_id)
|
|
178
175
|
import_rewriter =
|
data/lib/klenod/build/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: klenod-build
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrés Alin
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.0.
|
|
18
|
+
version: 0.0.10
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.0.
|
|
25
|
+
version: 0.0.10
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: async
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|