berns 3.0.1 → 3.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 984896367eb9ccf07e00f90254e53fe2785b29f01d66a249165896fd6cee4405
4
- data.tar.gz: 1dd55160c78351148ff1b3aa5fb534d611581c08e9763f216199a3de4103e060
3
+ metadata.gz: a0513b5d30f4b3b8cc581baa1d46a2bd64469d76224638cdcdb45fe3faab1e66
4
+ data.tar.gz: 857d58645cdad849eea710bc68bd3e5ab3695e9e0ba763b54392fa96956836dc
5
5
  SHA512:
6
- metadata.gz: d35a61f6003231911938482b27931e23a75d4e1edd932199ba284b283399e304d40595cd6ea69582bef6c5be29ed5a7940b5ead74db685b2e62be9ab053715e8
7
- data.tar.gz: 004f9541acfeda32484c9a34679d3f670395c601b128f29f45f8530d892064938345e38b3b3a9e7dbac45e2dc70d31c3d4bd8136e3db870f0a85c0e6fd569af2
6
+ metadata.gz: aa90410871bd7491fc665c55cb3527dfa7441c43962c2a50fab5f68fb0e87f9c5b2960e619aa97273d0f91164c9d7c6d63dda6ebd93534227e3b3f5a034fcf34
7
+ data.tar.gz: d8ed28163f684577aec0f8b1fe8010e9135e8c03ecabba2797a8e60640d55143763b9db0adf0f0258fd660faf7f6d975dc70f9c97dfa39691fc90a9b7e4945ed
data/README.org CHANGED
@@ -1,6 +1,6 @@
1
1
  * Berns
2
2
 
3
- [[https://badge.fury.io/rb/berns.svg]]
3
+ [[https://badge.fury.io/rb/berns][https://badge.fury.io/rb/berns.svg]]
4
4
 
5
5
  A utility library for generating HTML strings.
6
6
 
@@ -26,10 +26,7 @@ gem install berns
26
26
 
27
27
  ** Usage
28
28
 
29
- All standard and void HTML elements are defined as methods on Berns, so you can
30
- create e.g. a link with =Berns.a=. In addition, there are methods to sanitize
31
- strings i.e. remove HTML from them, convert hashes into a string of HTML
32
- attributes, and more.
29
+ Note that all return string values will be UTF-8 encoded.
33
30
 
34
31
  *** =void(tag, attributes)=
35
32
 
@@ -94,8 +91,8 @@ Berns.sanitize('This <span>should be clean</span>') # => 'This should be clean'
94
91
 
95
92
  *** Standard and void elements
96
93
 
97
- As mentioned above, all standard and void HTML elements are defined as singleton
98
- methods on the Berns module. Below is the full list of standard elements.
94
+ All standard and void HTML elements are defined as methods on Berns, so you can
95
+ create e.g. a link with =Berns.a=. Below is the full list of standard elements.
99
96
 
100
97
  #+begin_example
101
98
  a abbr address article aside audio b bdi bdo blockquote body button
data/ext/berns/berns.c CHANGED
@@ -30,7 +30,7 @@ static VALUE berns_escape_html(const VALUE self, VALUE string) {
30
30
  }
31
31
 
32
32
  static VALUE berns_to_attribute(const VALUE self, VALUE attribute, const VALUE value) {
33
- const VALUE empty = rb_str_new_cstr("");
33
+ const VALUE empty = rb_utf8_str_new_cstr("");
34
34
 
35
35
  VALUE escaped;
36
36
  VALUE key;
@@ -72,6 +72,10 @@ static VALUE berns_to_attribute(const VALUE self, VALUE attribute, const VALUE v
72
72
  keys = rb_funcall(value, rb_intern("keys"), 0);
73
73
  length = RARRAY_LEN(keys);
74
74
 
75
+ if (length == 0) {
76
+ return rb_utf8_str_new_cstr("");
77
+ }
78
+
75
79
  char *substring = NULL;
76
80
  size_t size = 0;
77
81
 
@@ -116,13 +120,13 @@ static VALUE berns_to_attribute(const VALUE self, VALUE attribute, const VALUE v
116
120
 
117
121
  stecpy(ptr, RSTRING_PTR(subkey), end);
118
122
 
119
- subattr = berns_to_attribute(self, rb_str_new_cstr(subname), subvalue);
123
+ subattr = berns_to_attribute(self, rb_utf8_str_new_cstr(subname), subvalue);
120
124
  size_t subattrlen = RSTRING_LEN(subattr);
121
125
 
122
126
  if (i > 0) {
123
127
  size = size + splen + subattrlen;
124
128
 
125
- char *tmp = realloc(substring, size);
129
+ char *tmp = realloc(substring, size + 1);
126
130
 
127
131
  if (tmp == NULL) {
128
132
  rb_raise(rb_eNoMemError, "Berns.to_attribute could not allocate sufficient memory.");
@@ -134,7 +138,7 @@ static VALUE berns_to_attribute(const VALUE self, VALUE attribute, const VALUE v
134
138
  stecpy(substring + size - subattrlen, RSTRING_PTR(subattr), substring + size + 1);
135
139
  } else {
136
140
  size = size + subattrlen;
137
- char *tmp = realloc(substring, size);
141
+ char *tmp = realloc(substring, size + 1);
138
142
 
139
143
  if (tmp == NULL) {
140
144
  rb_raise(rb_eNoMemError, "Berns.to_attribute could not allocate sufficient memory.");
@@ -146,7 +150,7 @@ static VALUE berns_to_attribute(const VALUE self, VALUE attribute, const VALUE v
146
150
  }
147
151
  }
148
152
 
149
- rstring = rb_str_new_cstr(substring);
153
+ rstring = rb_utf8_str_new_cstr(substring);
150
154
  free(substring);
151
155
 
152
156
  return rstring;
@@ -172,7 +176,7 @@ static VALUE berns_to_attribute(const VALUE self, VALUE attribute, const VALUE v
172
176
  ptr = stecpy(ptr, RSTRING_PTR(escaped), end);
173
177
  stecpy(ptr, close, end);
174
178
 
175
- return rb_str_new_cstr(string);
179
+ return rb_utf8_str_new_cstr(string);
176
180
  }
177
181
  }
178
182
 
@@ -188,7 +192,7 @@ static VALUE berns_to_attributes(const VALUE self, const VALUE attributes) {
188
192
  const VALUE length = RARRAY_LEN(keys);
189
193
 
190
194
  if (length == 0) {
191
- return rb_str_new_cstr("");
195
+ return rb_utf8_str_new_cstr("");
192
196
  }
193
197
 
194
198
  char *string = NULL;
@@ -230,7 +234,7 @@ static VALUE berns_to_attributes(const VALUE self, const VALUE attributes) {
230
234
  }
231
235
  }
232
236
 
233
- rstring = rb_str_new_cstr(string);
237
+ rstring = rb_utf8_str_new_cstr(string);
234
238
  free(string);
235
239
 
236
240
  return rstring;
@@ -288,7 +292,7 @@ static VALUE berns_internal_void(VALUE tag, VALUE attributes) {
288
292
 
289
293
  stecpy(ptr, close, end);
290
294
 
291
- return rb_str_new_cstr(string);
295
+ return rb_utf8_str_new_cstr(string);
292
296
  }
293
297
 
294
298
  static VALUE berns_internal_element(VALUE tag, VALUE attributes) {
@@ -310,11 +314,13 @@ static VALUE berns_internal_element(VALUE tag, VALUE attributes) {
310
314
  if (rb_block_given_p()) {
311
315
  content = rb_yield(Qnil);
312
316
 
313
- if (TYPE(content) == T_NIL) {
314
- content = rb_str_new_cstr("");
317
+ if (TYPE(content) == T_NIL || TYPE(content) == T_FALSE) {
318
+ content = rb_utf8_str_new_cstr("");
319
+ } else if (TYPE(content) != T_STRING) {
320
+ content = rb_funcall(content, rb_intern("to_s"), 0);
315
321
  }
316
322
  } else {
317
- content = rb_str_new_cstr("");
323
+ content = rb_utf8_str_new_cstr("");
318
324
  }
319
325
 
320
326
  StringValue(content);
@@ -357,7 +363,7 @@ static VALUE berns_internal_element(VALUE tag, VALUE attributes) {
357
363
  ptr = stecpy(ptr, RSTRING_PTR(tag), end);
358
364
  stecpy(ptr, close, end);
359
365
 
360
- return rb_str_new_cstr(string);
366
+ return rb_utf8_str_new_cstr(string);
361
367
  }
362
368
 
363
369
  static VALUE berns_void_element(int argc, VALUE *argv, VALUE self) {
@@ -367,77 +373,77 @@ static VALUE berns_void_element(int argc, VALUE *argv, VALUE self) {
367
373
 
368
374
  static VALUE berns_area_element(int argc, VALUE *argv, VALUE self) {
369
375
  rb_check_arity(argc, 0, 1);
370
- return berns_internal_void(rb_str_new_cstr("area"), argv[0]);
376
+ return berns_internal_void(rb_utf8_str_new_cstr("area"), argv[0]);
371
377
  }
372
378
 
373
379
  static VALUE berns_base_element(int argc, VALUE *argv, VALUE self) {
374
380
  rb_check_arity(argc, 0, 1);
375
- return berns_internal_void(rb_str_new_cstr("base"), argv[0]);
381
+ return berns_internal_void(rb_utf8_str_new_cstr("base"), argv[0]);
376
382
  }
377
383
 
378
384
  static VALUE berns_br_element(int argc, VALUE *argv, VALUE self) {
379
385
  rb_check_arity(argc, 0, 1);
380
- return berns_internal_void(rb_str_new_cstr("br"), argv[0]);
386
+ return berns_internal_void(rb_utf8_str_new_cstr("br"), argv[0]);
381
387
  }
382
388
 
383
389
  static VALUE berns_col_element(int argc, VALUE *argv, VALUE self) {
384
390
  rb_check_arity(argc, 0, 1);
385
- return berns_internal_void(rb_str_new_cstr("col"), argv[0]);
391
+ return berns_internal_void(rb_utf8_str_new_cstr("col"), argv[0]);
386
392
  }
387
393
 
388
394
  static VALUE berns_embed_element(int argc, VALUE *argv, VALUE self) {
389
395
  rb_check_arity(argc, 0, 1);
390
- return berns_internal_void(rb_str_new_cstr("embed"), argv[0]);
396
+ return berns_internal_void(rb_utf8_str_new_cstr("embed"), argv[0]);
391
397
  }
392
398
 
393
399
  static VALUE berns_hr_element(int argc, VALUE *argv, VALUE self) {
394
400
  rb_check_arity(argc, 0, 1);
395
- return berns_internal_void(rb_str_new_cstr("hr"), argv[0]);
401
+ return berns_internal_void(rb_utf8_str_new_cstr("hr"), argv[0]);
396
402
  }
397
403
 
398
404
  static VALUE berns_img_element(int argc, VALUE *argv, VALUE self) {
399
405
  rb_check_arity(argc, 0, 1);
400
- return berns_internal_void(rb_str_new_cstr("img"), argv[0]);
406
+ return berns_internal_void(rb_utf8_str_new_cstr("img"), argv[0]);
401
407
  }
402
408
 
403
409
  static VALUE berns_input_element(int argc, VALUE *argv, VALUE self) {
404
410
  rb_check_arity(argc, 0, 1);
405
- return berns_internal_void(rb_str_new_cstr("input"), argv[0]);
411
+ return berns_internal_void(rb_utf8_str_new_cstr("input"), argv[0]);
406
412
  }
407
413
 
408
414
  static VALUE berns_link_element(int argc, VALUE *argv, VALUE self) {
409
415
  rb_check_arity(argc, 0, 1);
410
- return berns_internal_void(rb_str_new_cstr("link"), argv[0]);
416
+ return berns_internal_void(rb_utf8_str_new_cstr("link"), argv[0]);
411
417
  }
412
418
 
413
419
  static VALUE berns_menuitem_element(int argc, VALUE *argv, VALUE self) {
414
420
  rb_check_arity(argc, 0, 1);
415
- return berns_internal_void(rb_str_new_cstr("menuitem"), argv[0]);
421
+ return berns_internal_void(rb_utf8_str_new_cstr("menuitem"), argv[0]);
416
422
  }
417
423
 
418
424
  static VALUE berns_meta_element(int argc, VALUE *argv, VALUE self) {
419
425
  rb_check_arity(argc, 0, 1);
420
- return berns_internal_void(rb_str_new_cstr("meta"), argv[0]);
426
+ return berns_internal_void(rb_utf8_str_new_cstr("meta"), argv[0]);
421
427
  }
422
428
 
423
429
  static VALUE berns_param_element(int argc, VALUE *argv, VALUE self) {
424
430
  rb_check_arity(argc, 0, 1);
425
- return berns_internal_void(rb_str_new_cstr("param"), argv[0]);
431
+ return berns_internal_void(rb_utf8_str_new_cstr("param"), argv[0]);
426
432
  }
427
433
 
428
434
  static VALUE berns_source_element(int argc, VALUE *argv, VALUE self) {
429
435
  rb_check_arity(argc, 0, 1);
430
- return berns_internal_void(rb_str_new_cstr("source"), argv[0]);
436
+ return berns_internal_void(rb_utf8_str_new_cstr("source"), argv[0]);
431
437
  }
432
438
 
433
439
  static VALUE berns_track_element(int argc, VALUE *argv, VALUE self) {
434
440
  rb_check_arity(argc, 0, 1);
435
- return berns_internal_void(rb_str_new_cstr("track"), argv[0]);
441
+ return berns_internal_void(rb_utf8_str_new_cstr("track"), argv[0]);
436
442
  }
437
443
 
438
444
  static VALUE berns_wbr_element(int argc, VALUE *argv, VALUE self) {
439
445
  rb_check_arity(argc, 0, 1);
440
- return berns_internal_void(rb_str_new_cstr("wbr"), argv[0]);
446
+ return berns_internal_void(rb_utf8_str_new_cstr("wbr"), argv[0]);
441
447
  }
442
448
 
443
449
  static VALUE berns_element(int argc, VALUE* argv, VALUE self) {
@@ -447,472 +453,472 @@ static VALUE berns_element(int argc, VALUE* argv, VALUE self) {
447
453
 
448
454
  static VALUE berns_a_element(int argc, VALUE* argv, VALUE self) {
449
455
  rb_check_arity(argc, 0, 1);
450
- return berns_internal_element(rb_str_new_cstr("a"), argv[0]);
456
+ return berns_internal_element(rb_utf8_str_new_cstr("a"), argv[0]);
451
457
  }
452
458
 
453
459
  static VALUE berns_abbr_element(int argc, VALUE* argv, VALUE self) {
454
460
  rb_check_arity(argc, 0, 1);
455
- return berns_internal_element(rb_str_new_cstr("abbr"), argv[0]);
461
+ return berns_internal_element(rb_utf8_str_new_cstr("abbr"), argv[0]);
456
462
  }
457
463
 
458
464
  static VALUE berns_address_element(int argc, VALUE* argv, VALUE self) {
459
465
  rb_check_arity(argc, 0, 1);
460
- return berns_internal_element(rb_str_new_cstr("address"), argv[0]);
466
+ return berns_internal_element(rb_utf8_str_new_cstr("address"), argv[0]);
461
467
  }
462
468
 
463
469
  static VALUE berns_article_element(int argc, VALUE* argv, VALUE self) {
464
470
  rb_check_arity(argc, 0, 1);
465
- return berns_internal_element(rb_str_new_cstr("article"), argv[0]);
471
+ return berns_internal_element(rb_utf8_str_new_cstr("article"), argv[0]);
466
472
  }
467
473
 
468
474
  static VALUE berns_aside_element(int argc, VALUE* argv, VALUE self) {
469
475
  rb_check_arity(argc, 0, 1);
470
- return berns_internal_element(rb_str_new_cstr("aside"), argv[0]);
476
+ return berns_internal_element(rb_utf8_str_new_cstr("aside"), argv[0]);
471
477
  }
472
478
 
473
479
  static VALUE berns_audio_element(int argc, VALUE* argv, VALUE self) {
474
480
  rb_check_arity(argc, 0, 1);
475
- return berns_internal_element(rb_str_new_cstr("audio"), argv[0]);
481
+ return berns_internal_element(rb_utf8_str_new_cstr("audio"), argv[0]);
476
482
  }
477
483
 
478
484
  static VALUE berns_b_element(int argc, VALUE* argv, VALUE self) {
479
485
  rb_check_arity(argc, 0, 1);
480
- return berns_internal_element(rb_str_new_cstr("b"), argv[0]);
486
+ return berns_internal_element(rb_utf8_str_new_cstr("b"), argv[0]);
481
487
  }
482
488
 
483
489
  static VALUE berns_bdi_element(int argc, VALUE* argv, VALUE self) {
484
490
  rb_check_arity(argc, 0, 1);
485
- return berns_internal_element(rb_str_new_cstr("bdi"), argv[0]);
491
+ return berns_internal_element(rb_utf8_str_new_cstr("bdi"), argv[0]);
486
492
  }
487
493
 
488
494
  static VALUE berns_bdo_element(int argc, VALUE* argv, VALUE self) {
489
495
  rb_check_arity(argc, 0, 1);
490
- return berns_internal_element(rb_str_new_cstr("bdo"), argv[0]);
496
+ return berns_internal_element(rb_utf8_str_new_cstr("bdo"), argv[0]);
491
497
  }
492
498
 
493
499
  static VALUE berns_blockquote_element(int argc, VALUE* argv, VALUE self) {
494
500
  rb_check_arity(argc, 0, 1);
495
- return berns_internal_element(rb_str_new_cstr("blockquote"), argv[0]);
501
+ return berns_internal_element(rb_utf8_str_new_cstr("blockquote"), argv[0]);
496
502
  }
497
503
 
498
504
  static VALUE berns_body_element(int argc, VALUE* argv, VALUE self) {
499
505
  rb_check_arity(argc, 0, 1);
500
- return berns_internal_element(rb_str_new_cstr("body"), argv[0]);
506
+ return berns_internal_element(rb_utf8_str_new_cstr("body"), argv[0]);
501
507
  }
502
508
 
503
509
  static VALUE berns_button_element(int argc, VALUE* argv, VALUE self) {
504
510
  rb_check_arity(argc, 0, 1);
505
- return berns_internal_element(rb_str_new_cstr("button"), argv[0]);
511
+ return berns_internal_element(rb_utf8_str_new_cstr("button"), argv[0]);
506
512
  }
507
513
 
508
514
  static VALUE berns_canvas_element(int argc, VALUE* argv, VALUE self) {
509
515
  rb_check_arity(argc, 0, 1);
510
- return berns_internal_element(rb_str_new_cstr("canvas"), argv[0]);
516
+ return berns_internal_element(rb_utf8_str_new_cstr("canvas"), argv[0]);
511
517
  }
512
518
 
513
519
  static VALUE berns_caption_element(int argc, VALUE* argv, VALUE self) {
514
520
  rb_check_arity(argc, 0, 1);
515
- return berns_internal_element(rb_str_new_cstr("caption"), argv[0]);
521
+ return berns_internal_element(rb_utf8_str_new_cstr("caption"), argv[0]);
516
522
  }
517
523
 
518
524
  static VALUE berns_cite_element(int argc, VALUE* argv, VALUE self) {
519
525
  rb_check_arity(argc, 0, 1);
520
- return berns_internal_element(rb_str_new_cstr("cite"), argv[0]);
526
+ return berns_internal_element(rb_utf8_str_new_cstr("cite"), argv[0]);
521
527
  }
522
528
 
523
529
  static VALUE berns_code_element(int argc, VALUE* argv, VALUE self) {
524
530
  rb_check_arity(argc, 0, 1);
525
- return berns_internal_element(rb_str_new_cstr("code"), argv[0]);
531
+ return berns_internal_element(rb_utf8_str_new_cstr("code"), argv[0]);
526
532
  }
527
533
 
528
534
  static VALUE berns_colgroup_element(int argc, VALUE* argv, VALUE self) {
529
535
  rb_check_arity(argc, 0, 1);
530
- return berns_internal_element(rb_str_new_cstr("colgroup"), argv[0]);
536
+ return berns_internal_element(rb_utf8_str_new_cstr("colgroup"), argv[0]);
531
537
  }
532
538
 
533
539
  static VALUE berns_datalist_element(int argc, VALUE* argv, VALUE self) {
534
540
  rb_check_arity(argc, 0, 1);
535
- return berns_internal_element(rb_str_new_cstr("datalist"), argv[0]);
541
+ return berns_internal_element(rb_utf8_str_new_cstr("datalist"), argv[0]);
536
542
  }
537
543
 
538
544
  static VALUE berns_dd_element(int argc, VALUE* argv, VALUE self) {
539
545
  rb_check_arity(argc, 0, 1);
540
- return berns_internal_element(rb_str_new_cstr("dd"), argv[0]);
546
+ return berns_internal_element(rb_utf8_str_new_cstr("dd"), argv[0]);
541
547
  }
542
548
 
543
549
  static VALUE berns_del_element(int argc, VALUE* argv, VALUE self) {
544
550
  rb_check_arity(argc, 0, 1);
545
- return berns_internal_element(rb_str_new_cstr("del"), argv[0]);
551
+ return berns_internal_element(rb_utf8_str_new_cstr("del"), argv[0]);
546
552
  }
547
553
 
548
554
  static VALUE berns_details_element(int argc, VALUE* argv, VALUE self) {
549
555
  rb_check_arity(argc, 0, 1);
550
- return berns_internal_element(rb_str_new_cstr("details"), argv[0]);
556
+ return berns_internal_element(rb_utf8_str_new_cstr("details"), argv[0]);
551
557
  }
552
558
 
553
559
  static VALUE berns_dfn_element(int argc, VALUE* argv, VALUE self) {
554
560
  rb_check_arity(argc, 0, 1);
555
- return berns_internal_element(rb_str_new_cstr("dfn"), argv[0]);
561
+ return berns_internal_element(rb_utf8_str_new_cstr("dfn"), argv[0]);
556
562
  }
557
563
 
558
564
  static VALUE berns_dialog_element(int argc, VALUE* argv, VALUE self) {
559
565
  rb_check_arity(argc, 0, 1);
560
- return berns_internal_element(rb_str_new_cstr("dialog"), argv[0]);
566
+ return berns_internal_element(rb_utf8_str_new_cstr("dialog"), argv[0]);
561
567
  }
562
568
 
563
569
  static VALUE berns_div_element(int argc, VALUE* argv, VALUE self) {
564
570
  rb_check_arity(argc, 0, 1);
565
- return berns_internal_element(rb_str_new_cstr("div"), argv[0]);
571
+ return berns_internal_element(rb_utf8_str_new_cstr("div"), argv[0]);
566
572
  }
567
573
 
568
574
  static VALUE berns_dl_element(int argc, VALUE* argv, VALUE self) {
569
575
  rb_check_arity(argc, 0, 1);
570
- return berns_internal_element(rb_str_new_cstr("dl"), argv[0]);
576
+ return berns_internal_element(rb_utf8_str_new_cstr("dl"), argv[0]);
571
577
  }
572
578
 
573
579
  static VALUE berns_dt_element(int argc, VALUE* argv, VALUE self) {
574
580
  rb_check_arity(argc, 0, 1);
575
- return berns_internal_element(rb_str_new_cstr("dt"), argv[0]);
581
+ return berns_internal_element(rb_utf8_str_new_cstr("dt"), argv[0]);
576
582
  }
577
583
 
578
584
  static VALUE berns_em_element(int argc, VALUE* argv, VALUE self) {
579
585
  rb_check_arity(argc, 0, 1);
580
- return berns_internal_element(rb_str_new_cstr("em"), argv[0]);
586
+ return berns_internal_element(rb_utf8_str_new_cstr("em"), argv[0]);
581
587
  }
582
588
 
583
589
  static VALUE berns_fieldset_element(int argc, VALUE* argv, VALUE self) {
584
590
  rb_check_arity(argc, 0, 1);
585
- return berns_internal_element(rb_str_new_cstr("fieldset"), argv[0]);
591
+ return berns_internal_element(rb_utf8_str_new_cstr("fieldset"), argv[0]);
586
592
  }
587
593
 
588
594
  static VALUE berns_figcaption_element(int argc, VALUE* argv, VALUE self) {
589
595
  rb_check_arity(argc, 0, 1);
590
- return berns_internal_element(rb_str_new_cstr("figcaption"), argv[0]);
596
+ return berns_internal_element(rb_utf8_str_new_cstr("figcaption"), argv[0]);
591
597
  }
592
598
 
593
599
  static VALUE berns_figure_element(int argc, VALUE* argv, VALUE self) {
594
600
  rb_check_arity(argc, 0, 1);
595
- return berns_internal_element(rb_str_new_cstr("figure"), argv[0]);
601
+ return berns_internal_element(rb_utf8_str_new_cstr("figure"), argv[0]);
596
602
  }
597
603
 
598
604
  static VALUE berns_footer_element(int argc, VALUE* argv, VALUE self) {
599
605
  rb_check_arity(argc, 0, 1);
600
- return berns_internal_element(rb_str_new_cstr("footer"), argv[0]);
606
+ return berns_internal_element(rb_utf8_str_new_cstr("footer"), argv[0]);
601
607
  }
602
608
 
603
609
  static VALUE berns_form_element(int argc, VALUE* argv, VALUE self) {
604
610
  rb_check_arity(argc, 0, 1);
605
- return berns_internal_element(rb_str_new_cstr("form"), argv[0]);
611
+ return berns_internal_element(rb_utf8_str_new_cstr("form"), argv[0]);
606
612
  }
607
613
 
608
614
  static VALUE berns_h1_element(int argc, VALUE* argv, VALUE self) {
609
615
  rb_check_arity(argc, 0, 1);
610
- return berns_internal_element(rb_str_new_cstr("h1"), argv[0]);
616
+ return berns_internal_element(rb_utf8_str_new_cstr("h1"), argv[0]);
611
617
  }
612
618
 
613
619
  static VALUE berns_h2_element(int argc, VALUE* argv, VALUE self) {
614
620
  rb_check_arity(argc, 0, 1);
615
- return berns_internal_element(rb_str_new_cstr("h2"), argv[0]);
621
+ return berns_internal_element(rb_utf8_str_new_cstr("h2"), argv[0]);
616
622
  }
617
623
 
618
624
  static VALUE berns_h3_element(int argc, VALUE* argv, VALUE self) {
619
625
  rb_check_arity(argc, 0, 1);
620
- return berns_internal_element(rb_str_new_cstr("h3"), argv[0]);
626
+ return berns_internal_element(rb_utf8_str_new_cstr("h3"), argv[0]);
621
627
  }
622
628
 
623
629
  static VALUE berns_h4_element(int argc, VALUE* argv, VALUE self) {
624
630
  rb_check_arity(argc, 0, 1);
625
- return berns_internal_element(rb_str_new_cstr("h4"), argv[0]);
631
+ return berns_internal_element(rb_utf8_str_new_cstr("h4"), argv[0]);
626
632
  }
627
633
 
628
634
  static VALUE berns_h5_element(int argc, VALUE* argv, VALUE self) {
629
635
  rb_check_arity(argc, 0, 1);
630
- return berns_internal_element(rb_str_new_cstr("h5"), argv[0]);
636
+ return berns_internal_element(rb_utf8_str_new_cstr("h5"), argv[0]);
631
637
  }
632
638
 
633
639
  static VALUE berns_h6_element(int argc, VALUE* argv, VALUE self) {
634
640
  rb_check_arity(argc, 0, 1);
635
- return berns_internal_element(rb_str_new_cstr("h6"), argv[0]);
641
+ return berns_internal_element(rb_utf8_str_new_cstr("h6"), argv[0]);
636
642
  }
637
643
 
638
644
  static VALUE berns_head_element(int argc, VALUE* argv, VALUE self) {
639
645
  rb_check_arity(argc, 0, 1);
640
- return berns_internal_element(rb_str_new_cstr("head"), argv[0]);
646
+ return berns_internal_element(rb_utf8_str_new_cstr("head"), argv[0]);
641
647
  }
642
648
 
643
649
  static VALUE berns_header_element(int argc, VALUE* argv, VALUE self) {
644
650
  rb_check_arity(argc, 0, 1);
645
- return berns_internal_element(rb_str_new_cstr("header"), argv[0]);
651
+ return berns_internal_element(rb_utf8_str_new_cstr("header"), argv[0]);
646
652
  }
647
653
 
648
654
  static VALUE berns_html_element(int argc, VALUE* argv, VALUE self) {
649
655
  rb_check_arity(argc, 0, 1);
650
- return berns_internal_element(rb_str_new_cstr("html"), argv[0]);
656
+ return berns_internal_element(rb_utf8_str_new_cstr("html"), argv[0]);
651
657
  }
652
658
 
653
659
  static VALUE berns_i_element(int argc, VALUE* argv, VALUE self) {
654
660
  rb_check_arity(argc, 0, 1);
655
- return berns_internal_element(rb_str_new_cstr("i"), argv[0]);
661
+ return berns_internal_element(rb_utf8_str_new_cstr("i"), argv[0]);
656
662
  }
657
663
 
658
664
  static VALUE berns_iframe_element(int argc, VALUE* argv, VALUE self) {
659
665
  rb_check_arity(argc, 0, 1);
660
- return berns_internal_element(rb_str_new_cstr("iframe"), argv[0]);
666
+ return berns_internal_element(rb_utf8_str_new_cstr("iframe"), argv[0]);
661
667
  }
662
668
 
663
669
  static VALUE berns_ins_element(int argc, VALUE* argv, VALUE self) {
664
670
  rb_check_arity(argc, 0, 1);
665
- return berns_internal_element(rb_str_new_cstr("ins"), argv[0]);
671
+ return berns_internal_element(rb_utf8_str_new_cstr("ins"), argv[0]);
666
672
  }
667
673
 
668
674
  static VALUE berns_kbd_element(int argc, VALUE* argv, VALUE self) {
669
675
  rb_check_arity(argc, 0, 1);
670
- return berns_internal_element(rb_str_new_cstr("kbd"), argv[0]);
676
+ return berns_internal_element(rb_utf8_str_new_cstr("kbd"), argv[0]);
671
677
  }
672
678
 
673
679
  static VALUE berns_label_element(int argc, VALUE* argv, VALUE self) {
674
680
  rb_check_arity(argc, 0, 1);
675
- return berns_internal_element(rb_str_new_cstr("label"), argv[0]);
681
+ return berns_internal_element(rb_utf8_str_new_cstr("label"), argv[0]);
676
682
  }
677
683
 
678
684
  static VALUE berns_legend_element(int argc, VALUE* argv, VALUE self) {
679
685
  rb_check_arity(argc, 0, 1);
680
- return berns_internal_element(rb_str_new_cstr("legend"), argv[0]);
686
+ return berns_internal_element(rb_utf8_str_new_cstr("legend"), argv[0]);
681
687
  }
682
688
 
683
689
  static VALUE berns_li_element(int argc, VALUE* argv, VALUE self) {
684
690
  rb_check_arity(argc, 0, 1);
685
- return berns_internal_element(rb_str_new_cstr("li"), argv[0]);
691
+ return berns_internal_element(rb_utf8_str_new_cstr("li"), argv[0]);
686
692
  }
687
693
 
688
694
  static VALUE berns_main_element(int argc, VALUE* argv, VALUE self) {
689
695
  rb_check_arity(argc, 0, 1);
690
- return berns_internal_element(rb_str_new_cstr("main"), argv[0]);
696
+ return berns_internal_element(rb_utf8_str_new_cstr("main"), argv[0]);
691
697
  }
692
698
 
693
699
  static VALUE berns_map_element(int argc, VALUE* argv, VALUE self) {
694
700
  rb_check_arity(argc, 0, 1);
695
- return berns_internal_element(rb_str_new_cstr("map"), argv[0]);
701
+ return berns_internal_element(rb_utf8_str_new_cstr("map"), argv[0]);
696
702
  }
697
703
 
698
704
  static VALUE berns_mark_element(int argc, VALUE* argv, VALUE self) {
699
705
  rb_check_arity(argc, 0, 1);
700
- return berns_internal_element(rb_str_new_cstr("mark"), argv[0]);
706
+ return berns_internal_element(rb_utf8_str_new_cstr("mark"), argv[0]);
701
707
  }
702
708
 
703
709
  static VALUE berns_menu_element(int argc, VALUE* argv, VALUE self) {
704
710
  rb_check_arity(argc, 0, 1);
705
- return berns_internal_element(rb_str_new_cstr("menu"), argv[0]);
711
+ return berns_internal_element(rb_utf8_str_new_cstr("menu"), argv[0]);
706
712
  }
707
713
 
708
714
  static VALUE berns_meter_element(int argc, VALUE* argv, VALUE self) {
709
715
  rb_check_arity(argc, 0, 1);
710
- return berns_internal_element(rb_str_new_cstr("meter"), argv[0]);
716
+ return berns_internal_element(rb_utf8_str_new_cstr("meter"), argv[0]);
711
717
  }
712
718
 
713
719
  static VALUE berns_nav_element(int argc, VALUE* argv, VALUE self) {
714
720
  rb_check_arity(argc, 0, 1);
715
- return berns_internal_element(rb_str_new_cstr("nav"), argv[0]);
721
+ return berns_internal_element(rb_utf8_str_new_cstr("nav"), argv[0]);
716
722
  }
717
723
 
718
724
  static VALUE berns_noscript_element(int argc, VALUE* argv, VALUE self) {
719
725
  rb_check_arity(argc, 0, 1);
720
- return berns_internal_element(rb_str_new_cstr("noscript"), argv[0]);
726
+ return berns_internal_element(rb_utf8_str_new_cstr("noscript"), argv[0]);
721
727
  }
722
728
 
723
729
  static VALUE berns_object_element(int argc, VALUE* argv, VALUE self) {
724
730
  rb_check_arity(argc, 0, 1);
725
- return berns_internal_element(rb_str_new_cstr("object"), argv[0]);
731
+ return berns_internal_element(rb_utf8_str_new_cstr("object"), argv[0]);
726
732
  }
727
733
 
728
734
  static VALUE berns_ol_element(int argc, VALUE* argv, VALUE self) {
729
735
  rb_check_arity(argc, 0, 1);
730
- return berns_internal_element(rb_str_new_cstr("ol"), argv[0]);
736
+ return berns_internal_element(rb_utf8_str_new_cstr("ol"), argv[0]);
731
737
  }
732
738
 
733
739
  static VALUE berns_optgroup_element(int argc, VALUE* argv, VALUE self) {
734
740
  rb_check_arity(argc, 0, 1);
735
- return berns_internal_element(rb_str_new_cstr("optgroup"), argv[0]);
741
+ return berns_internal_element(rb_utf8_str_new_cstr("optgroup"), argv[0]);
736
742
  }
737
743
 
738
744
  static VALUE berns_option_element(int argc, VALUE* argv, VALUE self) {
739
745
  rb_check_arity(argc, 0, 1);
740
- return berns_internal_element(rb_str_new_cstr("option"), argv[0]);
746
+ return berns_internal_element(rb_utf8_str_new_cstr("option"), argv[0]);
741
747
  }
742
748
 
743
749
  static VALUE berns_output_element(int argc, VALUE* argv, VALUE self) {
744
750
  rb_check_arity(argc, 0, 1);
745
- return berns_internal_element(rb_str_new_cstr("output"), argv[0]);
751
+ return berns_internal_element(rb_utf8_str_new_cstr("output"), argv[0]);
746
752
  }
747
753
 
748
754
  static VALUE berns_p_element(int argc, VALUE* argv, VALUE self) {
749
755
  rb_check_arity(argc, 0, 1);
750
- return berns_internal_element(rb_str_new_cstr("p"), argv[0]);
756
+ return berns_internal_element(rb_utf8_str_new_cstr("p"), argv[0]);
751
757
  }
752
758
 
753
759
  static VALUE berns_picture_element(int argc, VALUE* argv, VALUE self) {
754
760
  rb_check_arity(argc, 0, 1);
755
- return berns_internal_element(rb_str_new_cstr("picture"), argv[0]);
761
+ return berns_internal_element(rb_utf8_str_new_cstr("picture"), argv[0]);
756
762
  }
757
763
 
758
764
  static VALUE berns_pre_element(int argc, VALUE* argv, VALUE self) {
759
765
  rb_check_arity(argc, 0, 1);
760
- return berns_internal_element(rb_str_new_cstr("pre"), argv[0]);
766
+ return berns_internal_element(rb_utf8_str_new_cstr("pre"), argv[0]);
761
767
  }
762
768
 
763
769
  static VALUE berns_progress_element(int argc, VALUE* argv, VALUE self) {
764
770
  rb_check_arity(argc, 0, 1);
765
- return berns_internal_element(rb_str_new_cstr("progress"), argv[0]);
771
+ return berns_internal_element(rb_utf8_str_new_cstr("progress"), argv[0]);
766
772
  }
767
773
 
768
774
  static VALUE berns_q_element(int argc, VALUE* argv, VALUE self) {
769
775
  rb_check_arity(argc, 0, 1);
770
- return berns_internal_element(rb_str_new_cstr("q"), argv[0]);
776
+ return berns_internal_element(rb_utf8_str_new_cstr("q"), argv[0]);
771
777
  }
772
778
 
773
779
  static VALUE berns_rp_element(int argc, VALUE* argv, VALUE self) {
774
780
  rb_check_arity(argc, 0, 1);
775
- return berns_internal_element(rb_str_new_cstr("rp"), argv[0]);
781
+ return berns_internal_element(rb_utf8_str_new_cstr("rp"), argv[0]);
776
782
  }
777
783
 
778
784
  static VALUE berns_rt_element(int argc, VALUE* argv, VALUE self) {
779
785
  rb_check_arity(argc, 0, 1);
780
- return berns_internal_element(rb_str_new_cstr("rt"), argv[0]);
786
+ return berns_internal_element(rb_utf8_str_new_cstr("rt"), argv[0]);
781
787
  }
782
788
 
783
789
  static VALUE berns_ruby_element(int argc, VALUE* argv, VALUE self) {
784
790
  rb_check_arity(argc, 0, 1);
785
- return berns_internal_element(rb_str_new_cstr("ruby"), argv[0]);
791
+ return berns_internal_element(rb_utf8_str_new_cstr("ruby"), argv[0]);
786
792
  }
787
793
 
788
794
  static VALUE berns_s_element(int argc, VALUE* argv, VALUE self) {
789
795
  rb_check_arity(argc, 0, 1);
790
- return berns_internal_element(rb_str_new_cstr("s"), argv[0]);
796
+ return berns_internal_element(rb_utf8_str_new_cstr("s"), argv[0]);
791
797
  }
792
798
 
793
799
  static VALUE berns_samp_element(int argc, VALUE* argv, VALUE self) {
794
800
  rb_check_arity(argc, 0, 1);
795
- return berns_internal_element(rb_str_new_cstr("samp"), argv[0]);
801
+ return berns_internal_element(rb_utf8_str_new_cstr("samp"), argv[0]);
796
802
  }
797
803
 
798
804
  static VALUE berns_script_element(int argc, VALUE* argv, VALUE self) {
799
805
  rb_check_arity(argc, 0, 1);
800
- return berns_internal_element(rb_str_new_cstr("script"), argv[0]);
806
+ return berns_internal_element(rb_utf8_str_new_cstr("script"), argv[0]);
801
807
  }
802
808
 
803
809
  static VALUE berns_section_element(int argc, VALUE* argv, VALUE self) {
804
810
  rb_check_arity(argc, 0, 1);
805
- return berns_internal_element(rb_str_new_cstr("section"), argv[0]);
811
+ return berns_internal_element(rb_utf8_str_new_cstr("section"), argv[0]);
806
812
  }
807
813
 
808
814
  static VALUE berns_select_element(int argc, VALUE* argv, VALUE self) {
809
815
  rb_check_arity(argc, 0, 1);
810
- return berns_internal_element(rb_str_new_cstr("select"), argv[0]);
816
+ return berns_internal_element(rb_utf8_str_new_cstr("select"), argv[0]);
811
817
  }
812
818
 
813
819
  static VALUE berns_small_element(int argc, VALUE* argv, VALUE self) {
814
820
  rb_check_arity(argc, 0, 1);
815
- return berns_internal_element(rb_str_new_cstr("small"), argv[0]);
821
+ return berns_internal_element(rb_utf8_str_new_cstr("small"), argv[0]);
816
822
  }
817
823
 
818
824
  static VALUE berns_span_element(int argc, VALUE* argv, VALUE self) {
819
825
  rb_check_arity(argc, 0, 1);
820
- return berns_internal_element(rb_str_new_cstr("span"), argv[0]);
826
+ return berns_internal_element(rb_utf8_str_new_cstr("span"), argv[0]);
821
827
  }
822
828
 
823
829
  static VALUE berns_strong_element(int argc, VALUE* argv, VALUE self) {
824
830
  rb_check_arity(argc, 0, 1);
825
- return berns_internal_element(rb_str_new_cstr("strong"), argv[0]);
831
+ return berns_internal_element(rb_utf8_str_new_cstr("strong"), argv[0]);
826
832
  }
827
833
 
828
834
  static VALUE berns_style_element(int argc, VALUE* argv, VALUE self) {
829
835
  rb_check_arity(argc, 0, 1);
830
- return berns_internal_element(rb_str_new_cstr("style"), argv[0]);
836
+ return berns_internal_element(rb_utf8_str_new_cstr("style"), argv[0]);
831
837
  }
832
838
 
833
839
  static VALUE berns_sub_element(int argc, VALUE* argv, VALUE self) {
834
840
  rb_check_arity(argc, 0, 1);
835
- return berns_internal_element(rb_str_new_cstr("sub"), argv[0]);
841
+ return berns_internal_element(rb_utf8_str_new_cstr("sub"), argv[0]);
836
842
  }
837
843
 
838
844
  static VALUE berns_summary_element(int argc, VALUE* argv, VALUE self) {
839
845
  rb_check_arity(argc, 0, 1);
840
- return berns_internal_element(rb_str_new_cstr("summary"), argv[0]);
846
+ return berns_internal_element(rb_utf8_str_new_cstr("summary"), argv[0]);
841
847
  }
842
848
 
843
849
  static VALUE berns_table_element(int argc, VALUE* argv, VALUE self) {
844
850
  rb_check_arity(argc, 0, 1);
845
- return berns_internal_element(rb_str_new_cstr("table"), argv[0]);
851
+ return berns_internal_element(rb_utf8_str_new_cstr("table"), argv[0]);
846
852
  }
847
853
 
848
854
  static VALUE berns_tbody_element(int argc, VALUE* argv, VALUE self) {
849
855
  rb_check_arity(argc, 0, 1);
850
- return berns_internal_element(rb_str_new_cstr("tbody"), argv[0]);
856
+ return berns_internal_element(rb_utf8_str_new_cstr("tbody"), argv[0]);
851
857
  }
852
858
 
853
859
  static VALUE berns_td_element(int argc, VALUE* argv, VALUE self) {
854
860
  rb_check_arity(argc, 0, 1);
855
- return berns_internal_element(rb_str_new_cstr("td"), argv[0]);
861
+ return berns_internal_element(rb_utf8_str_new_cstr("td"), argv[0]);
856
862
  }
857
863
 
858
864
  static VALUE berns_template_element(int argc, VALUE* argv, VALUE self) {
859
865
  rb_check_arity(argc, 0, 1);
860
- return berns_internal_element(rb_str_new_cstr("template"), argv[0]);
866
+ return berns_internal_element(rb_utf8_str_new_cstr("template"), argv[0]);
861
867
  }
862
868
 
863
869
  static VALUE berns_textarea_element(int argc, VALUE* argv, VALUE self) {
864
870
  rb_check_arity(argc, 0, 1);
865
- return berns_internal_element(rb_str_new_cstr("textarea"), argv[0]);
871
+ return berns_internal_element(rb_utf8_str_new_cstr("textarea"), argv[0]);
866
872
  }
867
873
 
868
874
  static VALUE berns_tfoot_element(int argc, VALUE* argv, VALUE self) {
869
875
  rb_check_arity(argc, 0, 1);
870
- return berns_internal_element(rb_str_new_cstr("tfoot"), argv[0]);
876
+ return berns_internal_element(rb_utf8_str_new_cstr("tfoot"), argv[0]);
871
877
  }
872
878
 
873
879
  static VALUE berns_th_element(int argc, VALUE* argv, VALUE self) {
874
880
  rb_check_arity(argc, 0, 1);
875
- return berns_internal_element(rb_str_new_cstr("th"), argv[0]);
881
+ return berns_internal_element(rb_utf8_str_new_cstr("th"), argv[0]);
876
882
  }
877
883
 
878
884
  static VALUE berns_thead_element(int argc, VALUE* argv, VALUE self) {
879
885
  rb_check_arity(argc, 0, 1);
880
- return berns_internal_element(rb_str_new_cstr("thead"), argv[0]);
886
+ return berns_internal_element(rb_utf8_str_new_cstr("thead"), argv[0]);
881
887
  }
882
888
 
883
889
  static VALUE berns_time_element(int argc, VALUE* argv, VALUE self) {
884
890
  rb_check_arity(argc, 0, 1);
885
- return berns_internal_element(rb_str_new_cstr("time"), argv[0]);
891
+ return berns_internal_element(rb_utf8_str_new_cstr("time"), argv[0]);
886
892
  }
887
893
 
888
894
  static VALUE berns_title_element(int argc, VALUE* argv, VALUE self) {
889
895
  rb_check_arity(argc, 0, 1);
890
- return berns_internal_element(rb_str_new_cstr("title"), argv[0]);
896
+ return berns_internal_element(rb_utf8_str_new_cstr("title"), argv[0]);
891
897
  }
892
898
 
893
899
  static VALUE berns_tr_element(int argc, VALUE* argv, VALUE self) {
894
900
  rb_check_arity(argc, 0, 1);
895
- return berns_internal_element(rb_str_new_cstr("tr"), argv[0]);
901
+ return berns_internal_element(rb_utf8_str_new_cstr("tr"), argv[0]);
896
902
  }
897
903
 
898
904
  static VALUE berns_u_element(int argc, VALUE* argv, VALUE self) {
899
905
  rb_check_arity(argc, 0, 1);
900
- return berns_internal_element(rb_str_new_cstr("u"), argv[0]);
906
+ return berns_internal_element(rb_utf8_str_new_cstr("u"), argv[0]);
901
907
  }
902
908
 
903
909
  static VALUE berns_ul_element(int argc, VALUE* argv, VALUE self) {
904
910
  rb_check_arity(argc, 0, 1);
905
- return berns_internal_element(rb_str_new_cstr("ul"), argv[0]);
911
+ return berns_internal_element(rb_utf8_str_new_cstr("ul"), argv[0]);
906
912
  }
907
913
 
908
914
  static VALUE berns_var_element(int argc, VALUE* argv, VALUE self) {
909
915
  rb_check_arity(argc, 0, 1);
910
- return berns_internal_element(rb_str_new_cstr("var"), argv[0]);
916
+ return berns_internal_element(rb_utf8_str_new_cstr("var"), argv[0]);
911
917
  }
912
918
 
913
919
  static VALUE berns_video_element(int argc, VALUE* argv, VALUE self) {
914
920
  rb_check_arity(argc, 0, 1);
915
- return berns_internal_element(rb_str_new_cstr("video"), argv[0]);
921
+ return berns_internal_element(rb_utf8_str_new_cstr("video"), argv[0]);
916
922
  }
917
923
 
918
924
  void Init_berns() {
data/ext/mkmf.log ADDED
@@ -0,0 +1,7 @@
1
+ extconf.h is:
2
+ /* begin */
3
+ 1: #ifndef EXTCONF_H
4
+ 2: #define EXTCONF_H
5
+ 3: #endif
6
+ /* end */
7
+
Binary file
Binary file
data/lib/berns/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Berns
3
- VERSION = '3.0.1'
3
+ VERSION = '3.0.6'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berns
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Beck
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-04-15 00:00:00.000000000 Z
12
+ date: 2021-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cgi
@@ -109,6 +109,20 @@ dependencies:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop-packaging
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
112
126
  - !ruby/object:Gem::Dependency
113
127
  name: rubocop-performance
114
128
  requirement: !ruby/object:Gem::Requirement
@@ -146,19 +160,14 @@ extensions:
146
160
  - ext/berns/extconf.rb
147
161
  extra_rdoc_files: []
148
162
  files:
149
- - ".editorconfig"
150
- - ".github/workflows/main.yml"
151
- - ".gitignore"
152
- - ".rubocop.yml"
153
- - CHANGELOG.org
154
- - Gemfile
155
163
  - LICENSE.txt
156
164
  - README.org
157
- - Rakefile
158
- - berns.gemspec
159
165
  - ext/berns/berns.c
160
166
  - ext/berns/extconf.rb
167
+ - ext/mkmf.log
161
168
  - lib/berns.rb
169
+ - lib/berns/berns.bundle
170
+ - lib/berns/berns.so
162
171
  - lib/berns/version.rb
163
172
  homepage: https://github.com/evanleck/berns
164
173
  licenses:
data/.editorconfig DELETED
@@ -1,20 +0,0 @@
1
- # http://EditorConfig.org
2
- # This is the top most config file.
3
- root = true
4
-
5
- # All files
6
- [*]
7
-
8
- # Unix-style newlines with a newline ending every file
9
- end_of_line = lf
10
- insert_final_newline = true
11
-
12
- # Character set
13
- charset = utf-8
14
-
15
- # Trim extra whitespace.
16
- trim_trailing_whitespace = true
17
-
18
- # Soft tabs and 2 spaces.
19
- indent_style = space
20
- indent_size = 2
@@ -1,24 +0,0 @@
1
- name: Ruby
2
-
3
- on: [push,pull_request]
4
-
5
- jobs:
6
- test:
7
- strategy:
8
- fail-fast: false
9
- matrix:
10
- os: [ubuntu-latest, macos-latest]
11
- ruby-version: ['3.0', 2.7, 2.6, 2.5]
12
-
13
- runs-on: ${{ matrix.os }}
14
- steps:
15
- - uses: actions/checkout@v2
16
-
17
- - name: Set up Ruby ${{ matrix.ruby-version }}
18
- uses: ruby/setup-ruby@v1
19
- with:
20
- bundler-cache: true
21
- ruby-version: ${{ matrix.ruby-version }}
22
-
23
- - name: Run tests & lint
24
- run: bundle exec rake
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/.rubocop.yml DELETED
@@ -1,58 +0,0 @@
1
- # http://rubocop.readthedocs.io
2
- # https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
3
- require:
4
- - rubocop-minitest
5
- - rubocop-performance
6
- - rubocop-rake
7
-
8
- AllCops:
9
- DisplayCopNames: true
10
- DisplayStyleGuide: true
11
- ExtraDetails: true
12
- NewCops: enable
13
- TargetRubyVersion: 2.5
14
-
15
- Layout/ParameterAlignment:
16
- EnforcedStyle: with_fixed_indentation
17
-
18
- Layout/EmptyLineAfterMagicComment:
19
- Enabled: false
20
-
21
- Layout/FirstHashElementIndentation:
22
- EnforcedStyle: consistent
23
-
24
- Layout/MultilineOperationIndentation:
25
- EnforcedStyle: indented
26
-
27
- Layout/SpaceInsideStringInterpolation:
28
- EnforcedStyle: space
29
-
30
- Layout/LineLength:
31
- Enabled: false
32
-
33
- Metrics/AbcSize:
34
- Enabled: false
35
-
36
- Metrics/BlockLength:
37
- Enabled: false
38
-
39
- Metrics/ClassLength:
40
- Enabled: false
41
-
42
- Metrics/CyclomaticComplexity:
43
- Enabled: false
44
-
45
- Metrics/MethodLength:
46
- Enabled: false
47
-
48
- Metrics/ModuleLength:
49
- Enabled: false
50
-
51
- Metrics/PerceivedComplexity:
52
- Enabled: false
53
-
54
- Style/IfUnlessModifier:
55
- Enabled: false
56
-
57
- Style/Next:
58
- MinBodyLength: 8
data/CHANGELOG.org DELETED
@@ -1,129 +0,0 @@
1
- * Berns Changelog
2
-
3
- ** 3.0.0
4
-
5
- Version 3.0 is another mostly API-compatible refactor of Berns, this time in
6
- blazing fast C! I debated simply calling this version 2.1.0 but because it's a
7
- complete rewrite it didn't seem right to do a simple point release and there may
8
- be corner cases that I've not accounted for in this new C-backed version.
9
-
10
- Running the same benchmarks as from 2.0 but pitting 2.0 against 3.0 yields some
11
- great speed improvements, particularly for the =empty= and =simple= cases.
12
-
13
- /These benchmarks were performed on a desktop with a AMD Ryzen 5 3600X 6-Core
14
- Processor running Linux Mint 20.1 and kernel 5.4./
15
-
16
- Before:
17
-
18
- #+begin_example
19
- empty 1.668M (± 0.6%) i/s - 8.356M in 5.011099s
20
- simple 442.102k (± 1.3%) i/s - 2.214M in 5.008068s
21
- nested 267.716k (± 0.4%) i/s - 1.357M in 5.068747s
22
- #+end_example
23
-
24
- After:
25
-
26
- #+begin_example
27
- empty 3.573M (± 1.2%) i/s - 17.881M in 5.005001s
28
- simple 840.631k (± 0.6%) i/s - 4.253M in 5.059771s
29
- nested 267.281k (± 0.5%) i/s - 1.347M in 5.037887s
30
- #+end_example
31
-
32
- With both empty and simple attributes we see performance effectively double, and
33
- with nested attributes performance remains more or less the same.
34
-
35
- This is another set of fairly contrived benchmarks, testing a singleton method,
36
- =void= call, and =element= call against each other.
37
-
38
- Before:
39
-
40
- #+begin_example
41
- br 3.061M (± 0.8%) i/s - 15.613M in 5.100154s
42
- void("br") 6.141M (± 1.4%) i/s - 30.990M in 5.047338s
43
- element("div") 2.789M (± 0.6%) i/s - 14.171M in 5.080626s
44
- #+end_example
45
-
46
- After:
47
-
48
- #+begin_example
49
- br 8.155M (± 1.0%) i/s - 41.339M in 5.069681s
50
- void("br") 9.782M (± 1.5%) i/s - 49.096M in 5.020114s
51
- element("div") 6.769M (± 1.1%) i/s - 33.983M in 5.021362s
52
- #+end_example
53
-
54
- Lastly, benchmarking =to_attributes= with the following hash as the only
55
- argument shows about double the performance with 3.0.
56
-
57
- #+begin_src ruby
58
- ATTRS = { this: 'tag', should: 'work', data: { foo: 'bar', bar: { baz: 'foo' } } }.freeze
59
- #+end_src
60
-
61
- Before:
62
-
63
- #+begin_example
64
- to_attributes 228.829k (± 1.3%) i/s - 1.159M in 5.065714s
65
- #+end_example
66
-
67
- After:
68
-
69
- #+begin_example
70
- to_attributes 457.387k (± 1.2%) i/s - 2.305M in 5.041036s
71
- #+end_example
72
-
73
- ** 2.0.0
74
-
75
- Version 2.0 is a mostly API-compatible refactor of all of the core
76
- methods that make up Berns. The goal is to improve performance, mostly
77
- using mutable strings and inlining variables that were otherwise short
78
- lived.
79
-
80
- In addition, the target Ruby version has been raised to 2.5 or later.
81
- 2.4 has reached its end of life.
82
-
83
- Running this benchmarking code:
84
-
85
- #+begin_src ruby
86
- Benchmark.ips do |x|
87
- x.report('empty') { Berns.element(:a) { 'Link to something' } }
88
- x.report('simple') { Berns.element(:a, { href: 'Something', class: 'my-class' }) { 'Link to something' } }
89
- x.report('nested') { Berns.element(:a, { href: 'Something', class: 'my-class', data: { something: 'Else' } }) { 'Link to something' } }
90
-
91
- x.compare!
92
- end
93
- #+end_src
94
-
95
- Before:
96
-
97
- #+begin_example
98
- empty 993.521k (± 1.7%) i/s - 5.062M in 5.096368s
99
- simple 340.795k (± 0.4%) i/s - 1.729M in 5.074101s
100
- nested 215.160k (± 1.0%) i/s - 1.081M in 5.025324s
101
- #+end_example
102
-
103
- After:
104
-
105
- #+begin_example
106
- empty 1.769M (± 1.9%) i/s - 9.012M in 5.094973s
107
- simple 441.020k (± 1.0%) i/s - 2.233M in 5.063326s
108
- nested 280.255k (± 3.0%) i/s - 1.400M in 5.001009s
109
- #+end_example
110
-
111
- With empty attributes we see ~ 100% increase in iterations per second,
112
- with simple attributes we see ~ 30% increase in the same, and with
113
- nested attributes we see ~ 30% increase as well.
114
-
115
- ** 1.3.0
116
-
117
- With version 1.3, nested HTML attributes can be created with nil keys
118
- and boolean values to produce e.g. "data-foo data-foo-bar='whatever'"
119
- from =data: { foo: { nil => true, bar: 'whatever' } }=
120
-
121
- ** 1.2.0 - 1.2.2
122
-
123
- Starting with version 1.2, Berns will now HTML-escape all attribute
124
- values using =CGI.escapeHTML=. This should prevent attribute values from
125
- escaping themselves and injecting HTML into the DOM.
126
-
127
- ** 1.1.0
128
-
129
- - Add =#sanitize= method.
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
- source 'https://rubygems.org'
3
-
4
- # Specify your gem's dependencies in berns.gemspec
5
- gemspec
data/Rakefile DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'bundler/gem_tasks'
3
- require 'rake/extensiontask'
4
- require 'rake/testtask'
5
- require 'rubocop/rake_task'
6
-
7
- Rake::ExtensionTask.new 'berns' do |ext|
8
- ext.lib_dir = 'lib/berns'
9
- end
10
-
11
- Rake::TestTask.new(:test) do |t|
12
- t.deps = :compile
13
- t.libs << 'test'
14
- t.libs << 'lib'
15
- t.test_files = FileList['test/**/*_test.rb']
16
- end
17
-
18
- RuboCop::RakeTask.new
19
-
20
- task default: %i[test rubocop]
data/berns.gemspec DELETED
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative 'lib/berns/version'
3
-
4
- Gem::Specification.new do |spec|
5
- spec.name = 'berns'
6
- spec.version = Berns::VERSION
7
- spec.authors = ['Taylor Beck', 'Evan Lecklider']
8
- spec.email = ['beck.taylorg@gmail.com', 'evan@lecklider.com']
9
-
10
- spec.summary = 'A utility library for generating HTML strings.'
11
- spec.description = 'A utility library for generating HTML strings.'
12
- spec.homepage = 'https://github.com/evanleck/berns'
13
- spec.license = 'MIT'
14
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
15
-
16
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
18
- end
19
-
20
- spec.require_paths = ['lib']
21
- spec.extensions = %w[ext/berns/extconf.rb]
22
-
23
- spec.metadata = {
24
- 'bug_tracker_uri' => 'https://github.com/evanleck/berns/issues',
25
- 'source_code_uri' => 'https://github.com/evanleck/berns'
26
- }
27
-
28
- spec.add_dependency 'cgi'
29
-
30
- spec.add_development_dependency 'bundler'
31
- spec.add_development_dependency 'minitest'
32
- spec.add_development_dependency 'rake'
33
- spec.add_development_dependency 'rake-compiler'
34
- spec.add_development_dependency 'rubocop'
35
- spec.add_development_dependency 'rubocop-minitest'
36
- spec.add_development_dependency 'rubocop-performance'
37
- spec.add_development_dependency 'rubocop-rake'
38
- end