hamlit 2.14.1-java → 2.14.6-java

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: 12e7f9d445db00655f325ed05d5be2890b7ef3eb2db14607c82d10f37921d85d
4
- data.tar.gz: aba41ac7a5d489acce14d157d0f36dd8f0308d32c22348d0ccb70bdf4c93c6aa
3
+ metadata.gz: bbd4b98036dd20111bf9c090c074677b36a79e1a7475c3ffcd2dd6f5b24bdb27
4
+ data.tar.gz: a91c794059370a1cb3f1d38a26a9940a050d864f734619719a091a38cebc0d49
5
5
  SHA512:
6
- metadata.gz: cda20fa1c3a3f5148f88fde34009b642dfaff2f54bd938125489dc715da351baab227818e5eacaa88f4d3dc974b83ee8f28d5210e3b2edde833ff7f4ad9e47b4
7
- data.tar.gz: 5481a01d7a890d3392c50c35e24de66f324578ba2ba3588dbe33d00cddaa7a5f78fe2a6a972584a04aba8b300cdd417a9e5bacfcc2756ee9d4877356fc8037f0
6
+ metadata.gz: 963b99f583edca5097b27eaf991be2a22796f9f298c22e3ae27b2bb1a3db4ad2ed050ae7021758222e10c21c1ff70f754113d602a478743b4c649120d53776f9
7
+ data.tar.gz: 1653a1aa2aa3251f4bb89c9c7f6f57df01ee69d97fdeb482030850e0e16e69ef522cea4d2996c627e399b82d1a5d0bc4ae67e5532e79610abb473152eb0b1057
@@ -0,0 +1 @@
1
+ github: k0kubun
@@ -13,24 +13,28 @@ on:
13
13
  jobs:
14
14
  test:
15
15
  runs-on: ubuntu-latest
16
- container: ${{ matrix.ruby }}
17
16
  strategy:
18
17
  fail-fast: false
19
18
  matrix:
20
19
  ruby:
21
- - ruby:2.5
22
- - ruby:2.6
23
- - ruby:2.7
24
- - ruby:3.0
25
- # TODO: add jruby and truffleruby
20
+ - '2.5'
21
+ - '2.6'
22
+ - '2.7'
23
+ - '3.0'
24
+ - jruby
25
+ - truffleruby-head
26
26
  steps:
27
27
  - uses: actions/checkout@v2
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
28
32
  - uses: actions/cache@v2
29
33
  with:
30
34
  path: vendor/bundle
31
35
  key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
32
36
  restore-keys: ${{ runner.os }}-gems-
33
- - run: apt-get update && apt-get install -y nodejs # For execjs
37
+ - run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
34
38
  - name: bundle install
35
39
  run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
36
40
  - run: bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -4,6 +4,40 @@ All notable changes to this project will be documented in this file. This
4
4
  project adheres to [Semantic Versioning](http://semver.org/). This change log is based upon
5
5
  [keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog).
6
6
 
7
+ ## [2.14.6](https://github.com/k0kubun/hamlit/compare/v2.14.4...v2.14.5) - 2021-03-23
8
+
9
+ ### Fixed
10
+
11
+ - Optimize v2.14.5's implementation a little
12
+
13
+ ## [2.14.5](https://github.com/k0kubun/hamlit/compare/v2.14.4...v2.14.5) - 2021-03-23
14
+
15
+ ### Added
16
+
17
+ - Support `config.action_view.annotate_rendered_view_with_filenames = true` of Rails 6.1
18
+ *Thanks to @kirin121*
19
+
20
+ ## [2.14.4](https://github.com/k0kubun/hamlit/compare/v2.14.3...v2.14.4) - 2021-02-01
21
+
22
+ ### Fixed
23
+
24
+ - Prevent another SEGV in a C extension after `GC.compact` [#177](https://github.com/k0kubun/hamlit/issues/177)
25
+ *Thanks to @stanhu*
26
+
27
+ ## [2.14.3](https://github.com/k0kubun/hamlit/compare/v2.14.2...v2.14.3) - 2021-01-24
28
+
29
+ ### Fixed
30
+
31
+ - Ensure the Rails initializer is called before `:load_config_initializers` [#176](https://github.com/k0kubun/hamlit/issues/176)
32
+ *Thanks to @sunny*
33
+
34
+ ## [2.14.2](https://github.com/k0kubun/hamlit/compare/v2.14.1...v2.14.2) - 2021-01-21
35
+
36
+ ### Fixed
37
+
38
+ - Prevent SEGV in a C extension after `GC.compact` [#171](https://github.com/k0kubun/hamlit/issues/171)
39
+ *Thanks to @stanhu*
40
+
7
41
  ## [2.14.1](https://github.com/k0kubun/hamlit/compare/v2.14.0...v2.14.1) - 2021-01-07
8
42
 
9
43
  ### Added
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Hamlit
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/hamlit.svg)](http://badge.fury.io/rb/hamlit)
4
- [![Build Status](https://travis-ci.org/k0kubun/hamlit.svg?branch=master)](https://travis-ci.org/k0kubun/hamlit)
5
4
  [![test](https://github.com/k0kubun/hamlit/workflows/test/badge.svg)](https://github.com/k0kubun/hamlit/actions?query=workflow%3Atest)
6
5
 
7
6
  Hamlit is a high performance [Haml](https://github.com/haml/haml) implementation.
data/ext/hamlit/hamlit.c CHANGED
@@ -6,15 +6,9 @@
6
6
 
7
7
  VALUE mAttributeBuilder, mObjectRef;
8
8
  static ID id_flatten, id_keys, id_parse, id_prepend, id_tr, id_uniq_bang;
9
- static ID id_aria, id_data, id_equal, id_hyphen, id_space, id_underscore;
10
- static ID id_boolean_attributes, id_xhtml;
9
+ static ID id_xhtml;
11
10
 
12
- static VALUE str_aria() { return rb_const_get(mAttributeBuilder, id_aria); }
13
- static VALUE str_data() { return rb_const_get(mAttributeBuilder, id_data); }
14
- static VALUE str_equal() { return rb_const_get(mAttributeBuilder, id_equal); }
15
- static VALUE str_hyphen() { return rb_const_get(mAttributeBuilder, id_hyphen); }
16
- static VALUE str_space() { return rb_const_get(mAttributeBuilder, id_space); }
17
- static VALUE str_underscore() { return rb_const_get(mAttributeBuilder, id_underscore); }
11
+ static VALUE str_aria, str_data, str_equal, str_hyphen, str_space, str_underscore;
18
12
 
19
13
  static void
20
14
  delete_falsey_values(VALUE values)
@@ -51,7 +45,7 @@ hyphenate(VALUE str)
51
45
 
52
46
  for (i = 0; i < RSTRING_LEN(str); i++) {
53
47
  if (RSTRING_PTR(str)[i] == '_') {
54
- rb_str_update(str, i, 1, str_hyphen());
48
+ rb_str_update(str, i, 1, str_hyphen);
55
49
  }
56
50
  }
57
51
  return str;
@@ -97,7 +91,7 @@ hamlit_build_id(VALUE escape_attrs, VALUE values)
97
91
  values = rb_funcall(values, id_flatten, 0);
98
92
  delete_falsey_values(values);
99
93
 
100
- attr_value = rb_ary_join(values, str_underscore());
94
+ attr_value = rb_ary_join(values, str_underscore);
101
95
  return escape_attribute(escape_attrs, attr_value);
102
96
  }
103
97
 
@@ -110,7 +104,7 @@ hamlit_build_single_class(VALUE escape_attrs, VALUE value)
110
104
  case T_ARRAY:
111
105
  value = rb_funcall(value, id_flatten, 0);
112
106
  delete_falsey_values(value);
113
- value = rb_ary_join(value, str_space());
107
+ value = rb_ary_join(value, str_space);
114
108
  break;
115
109
  default:
116
110
  if (RTEST(value)) {
@@ -154,7 +148,7 @@ hamlit_build_multi_class(VALUE escape_attrs, VALUE values)
154
148
 
155
149
  rb_funcall(buf, id_uniq_bang, 0);
156
150
 
157
- return escape_attribute(escape_attrs, rb_ary_join(buf, str_space()));
151
+ return escape_attribute(escape_attrs, rb_ary_join(buf, str_space));
158
152
  }
159
153
 
160
154
  static VALUE
@@ -285,7 +279,7 @@ hamlit_build_data(VALUE escape_attrs, VALUE quote, VALUE values, VALUE key_str)
285
279
 
286
280
  switch (value) {
287
281
  case Qtrue:
288
- rb_str_concat(buf, str_space());
282
+ rb_str_concat(buf, str_space);
289
283
  rb_str_concat(buf, key);
290
284
  break;
291
285
  case Qnil:
@@ -293,9 +287,9 @@ hamlit_build_data(VALUE escape_attrs, VALUE quote, VALUE values, VALUE key_str)
293
287
  case Qfalse:
294
288
  break; // noop
295
289
  default:
296
- rb_str_concat(buf, str_space());
290
+ rb_str_concat(buf, str_space);
297
291
  rb_str_concat(buf, key);
298
- rb_str_concat(buf, str_equal());
292
+ rb_str_concat(buf, str_equal);
299
293
  rb_str_concat(buf, quote);
300
294
  rb_str_concat(buf, escape_attribute(escape_attrs, to_s(value)));
301
295
  rb_str_concat(buf, quote);
@@ -348,13 +342,10 @@ merge_all_attrs(VALUE hashes)
348
342
  }
349
343
 
350
344
  int
351
- is_boolean_attribute(VALUE key)
345
+ is_boolean_attribute(VALUE key, VALUE boolean_attributes)
352
346
  {
353
- VALUE boolean_attributes;
354
347
  if (str_eq(rb_str_substr(key, 0, 5), "data-", 5)) return 1;
355
348
  if (str_eq(rb_str_substr(key, 0, 5), "aria-", 5)) return 1;
356
-
357
- boolean_attributes = rb_const_get(mAttributeBuilder, id_boolean_attributes);
358
349
  return RTEST(rb_ary_includes(boolean_attributes, key));
359
350
  }
360
351
 
@@ -379,13 +370,13 @@ hamlit_build_for_class(VALUE escape_attrs, VALUE quote, VALUE buf, VALUE values)
379
370
  void
380
371
  hamlit_build_for_data(VALUE escape_attrs, VALUE quote, VALUE buf, VALUE values)
381
372
  {
382
- rb_str_concat(buf, hamlit_build_data(escape_attrs, quote, values, str_data()));
373
+ rb_str_concat(buf, hamlit_build_data(escape_attrs, quote, values, str_data));
383
374
  }
384
375
 
385
376
  void
386
377
  hamlit_build_for_aria(VALUE escape_attrs, VALUE quote, VALUE buf, VALUE values)
387
378
  {
388
- rb_str_concat(buf, hamlit_build_data(escape_attrs, quote, values, str_aria()));
379
+ rb_str_concat(buf, hamlit_build_data(escape_attrs, quote, values, str_aria));
389
380
  }
390
381
 
391
382
  void
@@ -424,7 +415,7 @@ hamlit_build_for_boolean(VALUE escape_attrs, VALUE quote, VALUE format, VALUE bu
424
415
  }
425
416
 
426
417
  static VALUE
427
- hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE object_ref, VALUE hashes)
418
+ hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE boolean_attributes, VALUE object_ref, VALUE hashes)
428
419
  {
429
420
  long i;
430
421
  VALUE attrs, buf, key, keys, value;
@@ -445,7 +436,7 @@ hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE object_ref, VA
445
436
  hamlit_build_for_data(escape_attrs, quote, buf, value);
446
437
  } else if (str_eq(key, "aria", 4)) {
447
438
  hamlit_build_for_aria(escape_attrs, quote, buf, value);
448
- } else if (is_boolean_attribute(key)) {
439
+ } else if (is_boolean_attribute(key, boolean_attributes)) {
449
440
  hamlit_build_for_boolean(escape_attrs, quote, format, buf, key, value);
450
441
  } else {
451
442
  hamlit_build_for_others(escape_attrs, quote, buf, key, value);
@@ -485,7 +476,7 @@ rb_hamlit_build_aria(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self))
485
476
  rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS);
486
477
  rb_scan_args(argc - 2, argv + 2, "*", &array);
487
478
 
488
- return hamlit_build_data(argv[0], argv[1], array, str_aria());
479
+ return hamlit_build_data(argv[0], argv[1], array, str_aria);
489
480
  }
490
481
 
491
482
  static VALUE
@@ -496,7 +487,7 @@ rb_hamlit_build_data(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self))
496
487
  rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS);
497
488
  rb_scan_args(argc - 2, argv + 2, "*", &array);
498
489
 
499
- return hamlit_build_data(argv[0], argv[1], array, str_data());
490
+ return hamlit_build_data(argv[0], argv[1], array, str_data);
500
491
  }
501
492
 
502
493
  static VALUE
@@ -504,10 +495,10 @@ rb_hamlit_build(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self))
504
495
  {
505
496
  VALUE array;
506
497
 
507
- rb_check_arity(argc, 4, UNLIMITED_ARGUMENTS);
508
- rb_scan_args(argc - 4, argv + 4, "*", &array);
498
+ rb_check_arity(argc, 5, UNLIMITED_ARGUMENTS);
499
+ rb_scan_args(argc - 5, argv + 5, "*", &array);
509
500
 
510
- return hamlit_build(argv[0], argv[1], argv[2], argv[3], array);
501
+ return hamlit_build(argv[0], argv[1], argv[2], argv[3], argv[4], array);
511
502
  }
512
503
 
513
504
  void
@@ -533,22 +524,14 @@ Init_hamlit(void)
533
524
  id_prepend = rb_intern("prepend");
534
525
  id_tr = rb_intern("tr");
535
526
  id_uniq_bang = rb_intern("uniq!");
536
-
537
- id_aria = rb_intern("ARIA");
538
- id_data = rb_intern("DATA");
539
- id_equal = rb_intern("EQUAL");
540
- id_hyphen = rb_intern("HYPHEN");
541
- id_space = rb_intern("SPACE");
542
- id_underscore = rb_intern("UNDERSCORE");
543
-
544
- id_boolean_attributes = rb_intern("BOOLEAN_ATTRIBUTES");
545
- id_xhtml = rb_intern("xhtml");
546
-
547
- rb_const_set(mAttributeBuilder, id_aria, rb_obj_freeze(rb_str_new_cstr("aria")));
548
- rb_const_set(mAttributeBuilder, id_data, rb_obj_freeze(rb_str_new_cstr("data")));
549
- rb_const_set(mAttributeBuilder, id_equal, rb_obj_freeze(rb_str_new_cstr("=")));
550
- rb_const_set(mAttributeBuilder, id_hyphen, rb_obj_freeze(rb_str_new_cstr("-")));
551
- rb_const_set(mAttributeBuilder, id_space, rb_obj_freeze(rb_str_new_cstr(" ")));
552
- rb_const_set(mAttributeBuilder, id_underscore, rb_obj_freeze(rb_str_new_cstr("_")));
527
+ id_xhtml = rb_intern("xhtml");
528
+
529
+ // Consider using rb_interned_str() once we stop supporting Ruby 2.7.
530
+ rb_gc_register_mark_object(str_aria = rb_obj_freeze(rb_str_new_cstr("aria")));
531
+ rb_gc_register_mark_object(str_data = rb_obj_freeze(rb_str_new_cstr("data")));
532
+ rb_gc_register_mark_object(str_equal = rb_obj_freeze(rb_str_new_cstr("=")));
533
+ rb_gc_register_mark_object(str_hyphen = rb_obj_freeze(rb_str_new_cstr("-")));
534
+ rb_gc_register_mark_object(str_space = rb_obj_freeze(rb_str_new_cstr(" ")));
535
+ rb_gc_register_mark_object(str_underscore = rb_obj_freeze(rb_str_new_cstr("_")));
553
536
  }
554
537
  #endif
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module Hamlit
3
+ class Ambles < Temple::Filter
4
+ define_options :preamble, :postamble
5
+
6
+ def initialize(*)
7
+ super
8
+ @preamble = options[:preamble]
9
+ @postamble = options[:postamble]
10
+ end
11
+
12
+ def call(ast)
13
+ ret = [:multi]
14
+ ret << [:static, @preamble] if @preamble
15
+ ret << ast
16
+ ret << [:static, @postamble] if @postamble
17
+ ret
18
+ end
19
+ end
20
+ end
@@ -13,7 +13,7 @@ module Hamlit::AttributeBuilder
13
13
  # TruffleRuby does not implement `rb_ary_sort_bang`, etc.
14
14
  if /java/ === RUBY_PLATFORM || RUBY_ENGINE == 'truffleruby'
15
15
  class << self
16
- def build(escape_attrs, quote, format, object_ref, *hashes)
16
+ def build(escape_attrs, quote, format, boolean_attributes, object_ref, *hashes)
17
17
  hashes << Hamlit::ObjectRef.parse(object_ref) if object_ref
18
18
  buf = []
19
19
  hash = merge_all_attrs(hashes)
@@ -27,7 +27,7 @@ module Hamlit::AttributeBuilder
27
27
  buf << " class=#{quote}#{build_class(escape_attrs, *hash[key])}#{quote}"
28
28
  when 'data'.freeze
29
29
  buf << build_data(escape_attrs, quote, *hash[key])
30
- when *BOOLEAN_ATTRIBUTES, /\Adata-/
30
+ when *boolean_attributes, /\Adata-/
31
31
  build_boolean!(escape_attrs, quote, format, buf, key, hash[key])
32
32
  else
33
33
  buf << " #{key}=#{quote}#{escape_html(escape_attrs, hash[key].to_s)}#{quote}"
@@ -31,7 +31,10 @@ module Hamlit
31
31
  attrs = []
32
32
  attrs.unshift(node.value[:attributes].inspect) if node.value[:attributes] != {}
33
33
 
34
- args = [@escape_attrs.inspect, "#{@quote.inspect}.freeze", @format.inspect].push(node.value[:object_ref]) + attrs
34
+ args = [
35
+ @escape_attrs.inspect, "#{@quote.inspect}.freeze", @format.inspect,
36
+ '::Hamlit::AttributeBuilder::BOOLEAN_ATTRIBUTES', node.value[:object_ref],
37
+ ] + attrs
35
38
  [:html, :attrs, [:dynamic, "::Hamlit::AttributeBuilder.build(#{args.join(', ')}, #{node.value[:dynamic_attributes].to_literal})"]]
36
39
  end
37
40
 
data/lib/hamlit/engine.rb CHANGED
@@ -6,6 +6,7 @@ require 'hamlit/html'
6
6
  require 'hamlit/escapable'
7
7
  require 'hamlit/force_escapable'
8
8
  require 'hamlit/dynamic_merger'
9
+ require 'hamlit/ambles'
9
10
 
10
11
  module Hamlit
11
12
  class Engine < Temple::Engine
@@ -30,6 +31,7 @@ module Hamlit
30
31
  use Escapable
31
32
  use ForceEscapable
32
33
  filter :ControlFlow
34
+ use Ambles
33
35
  filter :MultiFlattener
34
36
  filter :StaticMerger
35
37
  use DynamicMerger
@@ -33,6 +33,11 @@ module Hamlit
33
33
  options = options.merge(format: :xhtml)
34
34
  end
35
35
 
36
+ if ActionView::Base.try(:annotate_rendered_view_with_filenames) && template.format == :html
37
+ options[:preamble] = "<!-- BEGIN #{template.short_identifier} -->\n"
38
+ options[:postamble] = "<!-- END #{template.short_identifier} -->\n"
39
+ end
40
+
36
41
  Engine.new(options).call(source)
37
42
  end
38
43
 
@@ -3,7 +3,7 @@ require 'rails'
3
3
 
4
4
  module Hamlit
5
5
  class Railtie < ::Rails::Railtie
6
- initializer :hamlit do |app|
6
+ initializer :hamlit, before: :load_config_initializers do |app|
7
7
  require 'hamlit/rails_template'
8
8
  end
9
9
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hamlit
3
- VERSION = '2.14.1'
3
+ VERSION = '2.14.6'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamlit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.1
4
+ version: 2.14.6
5
5
  platform: java
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-08 00:00:00.000000000 Z
11
+ date: 2021-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -256,6 +256,7 @@ executables:
256
256
  extensions: []
257
257
  extra_rdoc_files: []
258
258
  files:
259
+ - ".github/FUNDING.yml"
259
260
  - ".github/workflows/test.yml"
260
261
  - ".gitignore"
261
262
  - CHANGELOG.md
@@ -312,6 +313,7 @@ files:
312
313
  - ext/hamlit/hescape.h
313
314
  - hamlit.gemspec
314
315
  - lib/hamlit.rb
316
+ - lib/hamlit/ambles.rb
315
317
  - lib/hamlit/attribute_builder.rb
316
318
  - lib/hamlit/attribute_compiler.rb
317
319
  - lib/hamlit/attribute_parser.rb