ultra-lite-tool 0.0.1

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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/haml-7.2.0/CHANGELOG.md +1705 -0
  3. data/haml-7.2.0/FAQ.md +147 -0
  4. data/haml-7.2.0/Gemfile +25 -0
  5. data/haml-7.2.0/MIT-LICENSE +20 -0
  6. data/haml-7.2.0/README.md +205 -0
  7. data/haml-7.2.0/REFERENCE.md +1309 -0
  8. data/haml-7.2.0/Rakefile +48 -0
  9. data/haml-7.2.0/bin/bench +66 -0
  10. data/haml-7.2.0/bin/console +10 -0
  11. data/haml-7.2.0/bin/ruby +3 -0
  12. data/haml-7.2.0/bin/setup +7 -0
  13. data/haml-7.2.0/bin/stackprof +27 -0
  14. data/haml-7.2.0/bin/test +24 -0
  15. data/haml-7.2.0/exe/haml +6 -0
  16. data/haml-7.2.0/haml.gemspec +45 -0
  17. data/haml-7.2.0/lib/haml/ambles.rb +20 -0
  18. data/haml-7.2.0/lib/haml/attribute_builder.rb +162 -0
  19. data/haml-7.2.0/lib/haml/attribute_compiler.rb +133 -0
  20. data/haml-7.2.0/lib/haml/attribute_parser.rb +116 -0
  21. data/haml-7.2.0/lib/haml/cli.rb +154 -0
  22. data/haml-7.2.0/lib/haml/compiler/children_compiler.rb +155 -0
  23. data/haml-7.2.0/lib/haml/compiler/comment_compiler.rb +51 -0
  24. data/haml-7.2.0/lib/haml/compiler/doctype_compiler.rb +52 -0
  25. data/haml-7.2.0/lib/haml/compiler/script_compiler.rb +114 -0
  26. data/haml-7.2.0/lib/haml/compiler/silent_script_compiler.rb +24 -0
  27. data/haml-7.2.0/lib/haml/compiler/tag_compiler.rb +76 -0
  28. data/haml-7.2.0/lib/haml/compiler.rb +97 -0
  29. data/haml-7.2.0/lib/haml/dynamic_merger.rb +67 -0
  30. data/haml-7.2.0/lib/haml/engine.rb +59 -0
  31. data/haml-7.2.0/lib/haml/error.rb +66 -0
  32. data/haml-7.2.0/lib/haml/escape.rb +13 -0
  33. data/haml-7.2.0/lib/haml/escape_any.rb +21 -0
  34. data/haml-7.2.0/lib/haml/filters/base.rb +12 -0
  35. data/haml-7.2.0/lib/haml/filters/cdata.rb +20 -0
  36. data/haml-7.2.0/lib/haml/filters/coffee.rb +17 -0
  37. data/haml-7.2.0/lib/haml/filters/css.rb +33 -0
  38. data/haml-7.2.0/lib/haml/filters/erb.rb +10 -0
  39. data/haml-7.2.0/lib/haml/filters/escaped.rb +22 -0
  40. data/haml-7.2.0/lib/haml/filters/javascript.rb +33 -0
  41. data/haml-7.2.0/lib/haml/filters/less.rb +20 -0
  42. data/haml-7.2.0/lib/haml/filters/markdown.rb +11 -0
  43. data/haml-7.2.0/lib/haml/filters/plain.rb +29 -0
  44. data/haml-7.2.0/lib/haml/filters/preserve.rb +22 -0
  45. data/haml-7.2.0/lib/haml/filters/ruby.rb +10 -0
  46. data/haml-7.2.0/lib/haml/filters/sass.rb +15 -0
  47. data/haml-7.2.0/lib/haml/filters/scss.rb +15 -0
  48. data/haml-7.2.0/lib/haml/filters/text_base.rb +25 -0
  49. data/haml-7.2.0/lib/haml/filters/tilt_base.rb +59 -0
  50. data/haml-7.2.0/lib/haml/filters.rb +75 -0
  51. data/haml-7.2.0/lib/haml/force_escape.rb +29 -0
  52. data/haml-7.2.0/lib/haml/helpers.rb +15 -0
  53. data/haml-7.2.0/lib/haml/html.rb +22 -0
  54. data/haml-7.2.0/lib/haml/identity.rb +13 -0
  55. data/haml-7.2.0/lib/haml/object_ref.rb +35 -0
  56. data/haml-7.2.0/lib/haml/parser.rb +991 -0
  57. data/haml-7.2.0/lib/haml/rails_helpers.rb +53 -0
  58. data/haml-7.2.0/lib/haml/rails_template.rb +62 -0
  59. data/haml-7.2.0/lib/haml/railtie.rb +10 -0
  60. data/haml-7.2.0/lib/haml/ruby_expression.rb +32 -0
  61. data/haml-7.2.0/lib/haml/string_splitter.rb +140 -0
  62. data/haml-7.2.0/lib/haml/template.rb +20 -0
  63. data/haml-7.2.0/lib/haml/temple_line_counter.rb +31 -0
  64. data/haml-7.2.0/lib/haml/util.rb +262 -0
  65. data/haml-7.2.0/lib/haml/version.rb +4 -0
  66. data/haml-7.2.0/lib/haml/whitespace.rb +8 -0
  67. data/haml-7.2.0/lib/haml.rb +9 -0
  68. data/ultra-lite-tool.gemspec +11 -0
  69. metadata +107 -0
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+ require 'tilt'
3
+
4
+ module Haml
5
+ class Filters
6
+ class TiltBase < Base
7
+ def self.render(name, source, indent_width: 0)
8
+ text = ::Tilt["t.#{name}"].new { source }.render
9
+ return text if indent_width == 0
10
+ if text.frozen?
11
+ text.gsub(/^/, ' ' * indent_width)
12
+ else
13
+ text.gsub!(/^/, ' ' * indent_width)
14
+ end
15
+ end
16
+
17
+ def explicit_require?(needed_registration)
18
+ Gem::Version.new(Tilt::VERSION) >= Gem::Version.new('2.0.0') &&
19
+ !Tilt.registered?(needed_registration)
20
+ end
21
+
22
+ private
23
+
24
+ # TODO: support interpolation
25
+ def precompiled_with_tilt(node, name)
26
+ src = ::Tilt["t.#{name}"].new { node.value[:text] }.send(:precompiled, {}).first
27
+ [:dynamic, src]
28
+ end
29
+
30
+ def compile_with_tilt(node, name, indent_width: 0)
31
+ if ::Haml::Util.contains_interpolation?(node.value[:text])
32
+ dynamic_compile(node, name, indent_width: indent_width)
33
+ else
34
+ static_compile(node, name, indent_width: indent_width)
35
+ end
36
+ end
37
+
38
+ def static_compile(node, name, indent_width: 0)
39
+ temple = [:multi, [:static, TiltBase.render(name, node.value[:text], indent_width: indent_width)]]
40
+ node.value[:text].split("\n").size.times do
41
+ temple << [:newline]
42
+ end
43
+ temple
44
+ end
45
+
46
+ def dynamic_compile(node, name, indent_width: 0)
47
+ # original: Haml::Filters#compile
48
+ text = ::Haml::Util.unescape_interpolation(node.value[:text]).gsub(/(\\+)n/) do |s|
49
+ escapes = $1.size
50
+ next s if escapes % 2 == 0
51
+ "#{'\\' * (escapes - 1)}\n"
52
+ end
53
+ text.prepend("\n").sub!(/\n"\z/, '"')
54
+
55
+ [:dynamic, "::Haml::Filters::TiltBase.render('#{name}', #{text}, indent_width: #{indent_width})"]
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+ require 'haml/filters/base'
3
+ require 'haml/filters/text_base'
4
+ require 'haml/filters/tilt_base'
5
+ require 'haml/filters/coffee'
6
+ require 'haml/filters/css'
7
+ require 'haml/filters/erb'
8
+ require 'haml/filters/escaped'
9
+ require 'haml/filters/javascript'
10
+ require 'haml/filters/less'
11
+ require 'haml/filters/markdown'
12
+ require 'haml/filters/plain'
13
+ require 'haml/filters/preserve'
14
+ require 'haml/filters/ruby'
15
+ require 'haml/filters/sass'
16
+ require 'haml/filters/scss'
17
+ require 'haml/filters/cdata'
18
+
19
+ module Haml
20
+ class Filters
21
+ @registered = {}
22
+
23
+ class << self
24
+ attr_reader :registered
25
+
26
+ def remove_filter(name)
27
+ registered.delete(name.to_s.downcase.to_sym)
28
+ if constants.map(&:to_s).include?(name.to_s)
29
+ remove_const name.to_sym
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def register(name, compiler)
36
+ registered[name] = compiler
37
+ end
38
+ end
39
+
40
+ register :coffee, Coffee
41
+ register :coffeescript, CoffeeScript
42
+ register :css, Css
43
+ register :erb, Erb
44
+ register :escaped, Escaped
45
+ register :javascript, Javascript
46
+ register :less, Less
47
+ register :markdown, Markdown
48
+ register :plain, Plain
49
+ register :preserve, Preserve
50
+ register :ruby, Ruby
51
+ register :sass, Sass
52
+ register :scss, Scss
53
+ register :cdata, Cdata
54
+
55
+ def initialize(options = {})
56
+ @options = options
57
+ @compilers = {}
58
+ end
59
+
60
+ def compile(node)
61
+ node.value[:text] ||= ''
62
+ find_compiler(node).compile(node)
63
+ end
64
+
65
+ private
66
+
67
+ def find_compiler(node)
68
+ name = node.value[:name].to_sym
69
+ compiler = Filters.registered[name]
70
+ raise FilterNotFound.new("FilterCompiler for '#{name}' was not found", node.line.to_i - 1) unless compiler
71
+
72
+ @compilers[name] ||= compiler.new(@options)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ require 'haml/escape'
3
+
4
+ module Haml
5
+ # This module allows Temple::Filter to dispatch :fescape on `#compile`.
6
+ module FescapeDispathcer
7
+ def on_fescape(flag, exp)
8
+ [:fescape, flag, compile(exp)]
9
+ end
10
+ end
11
+ ::Temple::Filter.include FescapeDispathcer
12
+
13
+ # Unlike Haml::Escape, this escapes value even if it's html_safe.
14
+ class ForceEscape < Escape
15
+ def initialize(opts = {})
16
+ super
17
+ @escape_code = options[:escape_code] || "::Haml::Util.escape_html((%s))"
18
+ @escaper = eval("proc {|v| #{@escape_code % 'v'} }")
19
+ end
20
+
21
+ alias_method :on_fescape, :on_escape
22
+
23
+ # ForceEscape doesn't touch :escape expression.
24
+ # This method is not used if it's inserted after Haml::Escape.
25
+ def on_escape(flag, exp)
26
+ [:escape, flag, compile(exp)]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ module Helpers
4
+ def self.preserve(input)
5
+ s = input.to_s.chomp("\n")
6
+ s.gsub!(/\n/, '&#x000A;')
7
+ s.delete!("\r")
8
+ s
9
+ end
10
+
11
+ def preserve(input)
12
+ Helpers.preserve(input)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class HTML < Temple::HTML::Fast
4
+ DEPRECATED_FORMATS = %i[html4 html5].freeze
5
+
6
+ def initialize(opts = {})
7
+ if DEPRECATED_FORMATS.include?(opts[:format])
8
+ opts = opts.dup
9
+ opts[:format] = :html
10
+ end
11
+ super(opts)
12
+ end
13
+
14
+ # This dispatcher supports Haml's "revealed" conditional comment.
15
+ def on_html_condcomment(condition, content, revealed = false)
16
+ on_html_comment [:multi,
17
+ [:static, "[#{condition}]>#{'<!-->' if revealed}"],
18
+ content,
19
+ [:static, "#{'<!--' if revealed}<![endif]"]]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ class Identity
4
+ def initialize
5
+ @unique_id = 0
6
+ end
7
+
8
+ def generate
9
+ @unique_id += 1
10
+ "_haml_compiler#{@unique_id}"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+ module Haml
3
+ module ObjectRef
4
+ class << self
5
+ def parse(args)
6
+ object, prefix = args
7
+ return {} unless object
8
+
9
+ suffix =
10
+ if object.respond_to?(:haml_object_ref)
11
+ object.haml_object_ref
12
+ else
13
+ underscore(object.class)
14
+ end
15
+ {
16
+ 'class' => [prefix, suffix].compact.join('_'),
17
+ 'id' => [prefix, suffix, object.id || 'new'].compact.join('_'),
18
+ }
19
+ end
20
+
21
+ private
22
+
23
+ # Haml::Buffer.underscore
24
+ def underscore(camel_cased_word)
25
+ word = camel_cased_word.to_s.dup
26
+ word.gsub!(/::/, '_')
27
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
28
+ word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
29
+ word.tr!('-', '_')
30
+ word.downcase!
31
+ word
32
+ end
33
+ end
34
+ end
35
+ end