haml 5.2.1 → 6.0.0.beta.2

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/test.yml +40 -0
  4. data/.gitignore +16 -16
  5. data/CHANGELOG.md +19 -0
  6. data/Gemfile +18 -11
  7. data/MIT-LICENSE +1 -1
  8. data/REFERENCE.md +10 -3
  9. data/Rakefile +94 -93
  10. data/bin/bench +66 -0
  11. data/bin/console +11 -0
  12. data/bin/ruby +3 -0
  13. data/bin/setup +7 -0
  14. data/bin/stackprof +27 -0
  15. data/bin/test +24 -0
  16. data/exe/haml +6 -0
  17. data/ext/haml/extconf.rb +10 -0
  18. data/ext/haml/haml.c +537 -0
  19. data/ext/haml/hescape.c +108 -0
  20. data/ext/haml/hescape.h +20 -0
  21. data/haml.gemspec +39 -37
  22. data/lib/haml/ambles.rb +20 -0
  23. data/lib/haml/attribute_builder.rb +140 -129
  24. data/lib/haml/attribute_compiler.rb +85 -192
  25. data/lib/haml/attribute_parser.rb +86 -126
  26. data/lib/haml/cli.rb +154 -0
  27. data/lib/haml/compiler/children_compiler.rb +126 -0
  28. data/lib/haml/compiler/comment_compiler.rb +39 -0
  29. data/lib/haml/compiler/doctype_compiler.rb +46 -0
  30. data/lib/haml/compiler/script_compiler.rb +116 -0
  31. data/lib/haml/compiler/silent_script_compiler.rb +24 -0
  32. data/lib/haml/compiler/tag_compiler.rb +76 -0
  33. data/lib/haml/compiler.rb +63 -296
  34. data/lib/haml/dynamic_merger.rb +67 -0
  35. data/lib/haml/engine.rb +42 -227
  36. data/lib/haml/error.rb +5 -4
  37. data/lib/haml/escapable.rb +6 -70
  38. data/lib/haml/filters/base.rb +12 -0
  39. data/lib/haml/filters/cdata.rb +20 -0
  40. data/lib/haml/filters/coffee.rb +17 -0
  41. data/lib/haml/filters/css.rb +33 -0
  42. data/lib/haml/filters/erb.rb +10 -0
  43. data/lib/haml/filters/escaped.rb +22 -0
  44. data/lib/haml/filters/javascript.rb +33 -0
  45. data/lib/haml/filters/less.rb +20 -0
  46. data/lib/haml/filters/markdown.rb +11 -0
  47. data/lib/haml/filters/plain.rb +29 -0
  48. data/lib/haml/filters/preserve.rb +22 -0
  49. data/lib/haml/filters/ruby.rb +10 -0
  50. data/lib/haml/filters/sass.rb +15 -0
  51. data/lib/haml/filters/scss.rb +15 -0
  52. data/lib/haml/filters/text_base.rb +25 -0
  53. data/lib/haml/filters/tilt_base.rb +49 -0
  54. data/lib/haml/filters.rb +54 -378
  55. data/lib/haml/force_escapable.rb +29 -0
  56. data/lib/haml/helpers.rb +3 -697
  57. data/lib/haml/html.rb +22 -0
  58. data/lib/haml/identity.rb +13 -0
  59. data/lib/haml/object_ref.rb +30 -0
  60. data/lib/haml/parser.rb +157 -22
  61. data/lib/haml/rails_helpers.rb +51 -0
  62. data/lib/haml/rails_template.rb +55 -0
  63. data/lib/haml/railtie.rb +7 -40
  64. data/lib/haml/ruby_expression.rb +32 -0
  65. data/lib/haml/string_splitter.rb +20 -0
  66. data/lib/haml/template.rb +15 -34
  67. data/lib/haml/temple_line_counter.rb +2 -1
  68. data/lib/haml/util.rb +17 -15
  69. data/lib/haml/version.rb +1 -2
  70. data/lib/haml.rb +8 -20
  71. metadata +211 -58
  72. data/.gitmodules +0 -3
  73. data/.travis.yml +0 -111
  74. data/.yardopts +0 -22
  75. data/TODO +0 -24
  76. data/benchmark.rb +0 -70
  77. data/bin/haml +0 -9
  78. data/lib/haml/.gitattributes +0 -1
  79. data/lib/haml/buffer.rb +0 -238
  80. data/lib/haml/exec.rb +0 -347
  81. data/lib/haml/generator.rb +0 -42
  82. data/lib/haml/helpers/action_view_extensions.rb +0 -60
  83. data/lib/haml/helpers/action_view_mods.rb +0 -132
  84. data/lib/haml/helpers/action_view_xss_mods.rb +0 -60
  85. data/lib/haml/helpers/safe_erubi_template.rb +0 -20
  86. data/lib/haml/helpers/safe_erubis_template.rb +0 -33
  87. data/lib/haml/helpers/xss_mods.rb +0 -114
  88. data/lib/haml/options.rb +0 -273
  89. data/lib/haml/plugin.rb +0 -37
  90. data/lib/haml/sass_rails_filter.rb +0 -47
  91. data/lib/haml/template/options.rb +0 -27
  92. data/lib/haml/temple_engine.rb +0 -123
  93. data/yard/default/.gitignore +0 -1
  94. data/yard/default/fulldoc/html/css/common.sass +0 -15
  95. data/yard/default/layout/html/footer.erb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3182fca5b2f85849a1abd849d3352858834737b83b7d57d4d29c19e84518f1c
4
- data.tar.gz: ea005149aeccb8247ff121a4a33b3118d289f18ed5f12b101fd739892fb4edae
3
+ metadata.gz: 6964b87cfc74066321cba0147ad79d0384bb5f28bc2e5a1fff8b4dc2f49ea0d2
4
+ data.tar.gz: e0ce73fab6bc19bf808b892ceff3fcd838b78fb2d78239cc0255185b46fadc8b
5
5
  SHA512:
6
- metadata.gz: e8fcd8c9cb45217a405820c13d69330ef53c82aa22b25026d0886937505a5dc101803c55087f74cc5467a1930f43bd5ab6fd7d44d69e1234aeab06db634b8fdd
7
- data.tar.gz: b8c0f35f75c6beac4e27c7066eefbf8385346abecbdab2cb3303b2ea2a3f19dfc2d209f171c0801d383d9bc3bd526721e674939e808ec2763712bbd94c7110d8
6
+ metadata.gz: ee2ed54cab4219c44a1a1c135b76a57551d418ed15039deab855f09dc36fc288df7c81a1866372e2c7edf94bb5a8c993cd9b0b5ebd7a16be6fa72833f5449a2f
7
+ data.tar.gz: ad13e3fc711a7416f7433da206f82574fa5aa5d02662234549e8738200a82f19321ed3176cded723f599861fab911970308a53db9337c750bdbc9996d9009fa2
@@ -0,0 +1 @@
1
+ github: haml
@@ -0,0 +1,40 @@
1
+ name: test
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ types:
8
+ - opened
9
+ - synchronize
10
+ - reopened
11
+ schedule:
12
+ - cron: "00 15 * * *"
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ ruby:
19
+ - '2.5'
20
+ - '2.6'
21
+ - '2.7'
22
+ - '3.0'
23
+ - '3.1'
24
+ - jruby
25
+ - truffleruby-head
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ - uses: actions/cache@v2
33
+ with:
34
+ path: vendor/bundle
35
+ key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
36
+ restore-keys: ${{ runner.os }}-gems-
37
+ - run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
38
+ - name: bundle install
39
+ run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
40
+ - run: bundle exec rake test
data/.gitignore CHANGED
@@ -1,19 +1,19 @@
1
- /.idea
1
+ /.bundle/
2
2
  /.yardoc
3
- /coverage
4
- /doc
5
- /log
6
- /pkg
7
- /test/rails
8
- /test/gemfiles/*.lock
9
- /.haml
10
- /site
11
- *.rbc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /.idea
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ /haml/
12
12
  .sass-cache
13
- .rbenv-version
14
- .rbx
15
13
  .ruby-version
16
- .rvmrc
17
- Gemfile.lock
18
- tmp
19
- .bundle/
14
+ *.bundle
15
+ *.so
16
+ *.su
17
+ *.a
18
+ *.o
19
+ *.swp
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 6.0.0
4
+
5
+ Not released yet
6
+ ([diff](https://github.com/haml/haml/compare/v5.2.2...main)).
7
+
8
+ * Replace the implementation with Hamlit
9
+ * Haml 6 is about 1.7x faster than Haml 5 in [this benchmark](benchmark/slim/run-benchmarks.rb).
10
+ * The parser is kept as is, but everything else is replaced.
11
+ * The `haml` CLI interface was also replaced.
12
+ * All Haml helpers except for `preserve` are removed.
13
+ * Some legacy Rails integration is removed.
14
+
15
+ ## 5.2.2
16
+
17
+ Released on July 27, 2021
18
+ ([diff](https://github.com/haml/haml/compare/v5.2.1...v5.2.2)).
19
+
20
+ * Support `config.action_view.annotate_rendered_view_with_filenames = true` of Rails 6.1
21
+
3
22
  ## 5.2.1
4
23
 
5
24
  Released on November 30, 2020
data/Gemfile CHANGED
@@ -1,16 +1,23 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ # Specify your gem's dependencies in haml.gemspec
2
9
  gemspec
3
10
 
4
- gem "m"
5
- gem "pry"
6
- gem "simplecov"
11
+ gem 'benchmark-ips', '2.3.0'
12
+ gem 'maxitest'
13
+ gem 'pry'
7
14
 
8
- group :docs do
9
- gem "yard"
10
- gem "kramdown"
11
- gem "sass"
12
- end
15
+ if /java/ === RUBY_PLATFORM # JRuby
16
+ gem 'pandoc-ruby'
17
+ else
18
+ gem 'redcarpet'
13
19
 
14
- platform :mri do
15
- gem "ruby-prof"
20
+ if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
21
+ gem 'stackprof'
22
+ end
16
23
  end
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2019 Hampton Catlin and Natalie Weizenbaum
1
+ Copyright (c) 2006-2021 Hampton Catlin, Natalie Weizenbaum and Takashi Kokubun
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/REFERENCE.md CHANGED
@@ -107,13 +107,20 @@ output.
107
107
  In Rails, options can be set by setting the {Haml::Template#options Haml::Template.options}
108
108
  hash in an initializer:
109
109
 
110
- # config/initializers/haml.rb
111
- Haml::Template.options[:format] = :html5
110
+ ```ruby
111
+ # config/initializers/haml.rb
112
+ Haml::Template.options[:format] = :html5
113
+
114
+ # Avoid escaping attributes which are already escaped
115
+ Haml::Template.options[:escape_attrs] = :once
116
+ ```
112
117
 
113
118
  Outside Rails, you can set them by configuring them globally in
114
119
  Haml::Options.defaults:
115
120
 
116
- Haml::Options.defaults[:format] = :html5
121
+ ```ruby
122
+ Haml::Options.defaults[:format] = :html5
123
+ ```
117
124
 
118
125
  In sinatra specifically, you can set them in global config with:
119
126
  ```ruby
data/Rakefile CHANGED
@@ -1,115 +1,116 @@
1
- require "rake/clean"
2
- require "rake/testtask"
3
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+
3
+ #
4
+ # Prepend DevKit into compilation phase
5
+ #
6
+ if Gem.win_platform?
7
+ desc 'Activates DevKit'
8
+ task :devkit do
9
+ begin
10
+ require 'devkit'
11
+ rescue LoadError
12
+ abort 'Failed to load DevKit required for compilation'
13
+ end
14
+ end
15
+ task compile: :devkit
16
+ end
4
17
 
5
- task :default => :test
18
+ require 'rake/testtask'
19
+ if /java/ === RUBY_PLATFORM
20
+ # require 'rake/javaextensiontask'
21
+ # Rake::JavaExtensionTask.new(:haml) do |ext|
22
+ # ext.ext_dir = 'ext/java'
23
+ # ext.lib_dir = 'lib/haml'
24
+ # end
6
25
 
7
- # FIXME: Redefining :test task to run test/options_test.rb in isolated process since it depends on whether Rails is loaded or not.
8
- # Remove this task when we finished changing escape_html option to be true by default.
9
- isolated_test = Rake::TestTask.new do |t|
10
- t.libs << 'test'
11
- t.test_files = %w[test/options_test.rb]
12
- t.warning = true
13
- t.verbose = true
14
- end
15
- Rake::TestTask.new do |t|
16
- t.libs << 'test'
17
- t.test_files = Dir['test/*_test.rb'] + Dir['test/haml-spec/*_test.rb'] + Dir['test/cases/*_test.rb'] - isolated_test.file_list
18
- t.warning = true
19
- t.verbose = true
26
+ task :compile do
27
+ # dummy for now
28
+ end
29
+ else
30
+ require 'rake/extensiontask'
31
+ Rake::ExtensionTask.new(:haml) do |ext|
32
+ ext.lib_dir = 'lib/haml'
33
+ end
20
34
  end
21
35
 
22
- CLEAN.replace %w(pkg doc coverage .yardoc test/haml vendor)
36
+ Dir['benchmark/*.rake'].each { |b| import(b) }
23
37
 
24
- desc "Benchmark Haml against ERB. TIMES=n sets the number of runs, default is 1000."
25
- task :benchmark do
26
- sh "ruby benchmark.rb #{ENV['TIMES']}"
38
+ namespace :haml do
39
+ Rake::TestTask.new do |t|
40
+ t.libs << 'lib' << 'test'
41
+ files = Dir['test/haml/*_test.rb']
42
+ files << 'test/haml/haml-spec/*_test.rb'
43
+ t.ruby_opts = %w[-rtest_helper]
44
+ t.test_files = files
45
+ t.verbose = true
46
+ end
27
47
  end
28
48
 
29
- task :submodules do
30
- if File.exist?(File.dirname(__FILE__) + "/.git")
31
- sh %{git submodule sync}
32
- sh %{git submodule update --init --recursive}
49
+ namespace :hamlit do
50
+ Rake::TestTask.new do |t|
51
+ t.libs << 'lib' << 'test'
52
+ t.ruby_opts = %w[-rtest_helper]
53
+ t.test_files = Dir['test/hamlit/**/*_test.rb']
54
+ t.verbose = true
33
55
  end
34
56
  end
35
57
 
36
- namespace :doc do
37
- task :sass do
38
- require 'sass'
39
- Dir["yard/default/**/*.sass"].each do |sass|
40
- File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
41
- f.write(Sass::Engine.new(File.read(sass)).render)
42
- end
43
- end
58
+ namespace :test do
59
+ Rake::TestTask.new(:all) do |t|
60
+ t.libs << 'lib' << 'test'
61
+ files = Dir['test/hamlit/**/*_test.rb']
62
+ files += Dir['test/haml/*_test.rb']
63
+ files << 'test/haml/haml-spec/*_test.rb'
64
+ t.ruby_opts = %w[-rtest_helper]
65
+ t.test_files = files
66
+ t.verbose = true
44
67
  end
45
68
 
46
- desc "List all undocumented methods and classes."
47
- task :undocumented do
48
- command = 'yard --list --query '
49
- command << '"object.docstring.blank? && '
50
- command << '!(object.type == :method && object.is_alias?)"'
51
- sh command
69
+ Rake::TestTask.new(:spec) do |t|
70
+ t.libs << 'lib' << 'test'
71
+ t.ruby_opts = %w[-rtest_helper]
72
+ t.test_files = %w[test/haml/haml-spec/ugly_test.rb test/haml/haml-spec/pretty_test.rb]
73
+ t.verbose = true
52
74
  end
53
- end
54
-
55
- desc "Generate documentation"
56
- task(:doc => 'doc:sass') {sh "yard"}
57
-
58
- desc "Generate documentation incrementally"
59
- task(:redoc) {sh "yard -c"}
60
-
61
- desc <<END
62
- Profile Haml.
63
- TIMES=n sets the number of runs. Defaults to 1000.
64
- FILE=str sets the file to profile. Defaults to 'standard'
65
- OUTPUT=str sets the ruby-prof output format.
66
- Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
67
- END
68
- task :profile do
69
- times = (ENV['TIMES'] || '1000').to_i
70
- file = ENV['FILE'] || 'test/templates/standard.haml'
71
75
 
72
- require 'bundler/setup'
73
- require 'ruby-prof'
74
- require 'haml'
75
- file = File.read(File.expand_path("../#{file}", __FILE__))
76
- obj = Object.new
77
- Haml::Engine.new(file).def_method(obj, :render)
78
- result = RubyProf.profile { times.times { obj.render } }
79
-
80
- RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
81
- end
82
-
83
- def gemfiles
84
- @gemfiles ||= Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].reject {|f| f =~ /\.lock$/}
85
- end
76
+ Rake::TestTask.new(:engine) do |t|
77
+ t.libs << 'lib' << 'test'
78
+ t.ruby_opts = %w[-rtest_helper]
79
+ t.test_files = %w[test/haml/engine_test.rb]
80
+ t.verbose = true
81
+ end
86
82
 
87
- def with_each_gemfile
88
- gemfiles.each do |gemfile|
89
- Bundler.with_clean_env do
90
- puts "Using gemfile: #{gemfile}"
91
- ENV['BUNDLE_GEMFILE'] = gemfile
92
- yield
93
- end
83
+ Rake::TestTask.new(:filters) do |t|
84
+ t.libs << 'lib' << 'test'
85
+ t.ruby_opts = %w[-rtest_helper]
86
+ t.test_files = %w[test/haml/filters_test.rb]
87
+ t.verbose = true
94
88
  end
95
- end
96
89
 
97
- namespace :test do
98
- namespace :bundles do
99
- desc "Install all dependencies necessary to test Haml."
100
- task :install do
101
- with_each_gemfile {sh "bundle"}
102
- end
90
+ Rake::TestTask.new(:helper) do |t|
91
+ t.libs << 'lib' << 'test'
92
+ t.ruby_opts = %w[-rtest_helper]
93
+ t.test_files = %w[test/haml/helper_test.rb]
94
+ t.verbose = true
95
+ end
103
96
 
104
- desc "Update all dependencies for testing Haml."
105
- task :update do
106
- with_each_gemfile {sh "bundle update"}
107
- end
97
+ Rake::TestTask.new(:template) do |t|
98
+ t.libs << 'lib' << 'test'
99
+ t.ruby_opts = %w[-rtest_helper]
100
+ t.test_files = %w[test/haml/template_test.rb]
101
+ t.verbose = true
108
102
  end
103
+ end
109
104
 
110
- desc "Test all supported versions of rails. This takes a while."
111
- task :rails_compatibility => 'test:bundles:install' do
112
- with_each_gemfile {sh "bundle exec rake test"}
105
+ desc 'bench task for CI'
106
+ task bench: :compile do
107
+ if ENV['SLIM_BENCH'] == '1'
108
+ cmd = %w[bundle exec ruby benchmark/slim/run-benchmarks.rb]
109
+ else
110
+ cmd = ['bin/bench', 'bench', ('-c' if ENV['COMPILE'] == '1'), *ENV['TEMPLATE'].split(',')].compact
113
111
  end
114
- task :rc => :rails_compatibility
112
+ exit system(*cmd)
115
113
  end
114
+
115
+ task default: %w[compile hamlit:test]
116
+ task test: %w[compile test:all]
data/bin/bench ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'haml'
5
+ require 'thor'
6
+ require 'benchmark/ips'
7
+ require_relative '../benchmark/utils/benchmark_ips_extension'
8
+
9
+ class Bench < Thor
10
+ class_option :show_template, type: :boolean, aliases: ['-t']
11
+
12
+ desc 'bench HAML', 'Benchmark haml template'
13
+ option :compile, type: :boolean, aliases: ['-c']
14
+ option :show_code, type: :boolean, aliases: ['-s']
15
+ def bench(*files)
16
+ files.each { |file| render(file) }
17
+ files.each { |file| compile(file) if options[:compile] }
18
+ files.each { |file| code(file) if options[:show_code] }
19
+ end
20
+
21
+ desc 'compile HAML', 'Benchmark compilation'
22
+ def compile(file)
23
+ puts "#{?= * 49}\n Compilation: #{file}\n#{?= * 49}"
24
+ haml = File.read(file)
25
+
26
+ Benchmark.ips do |x|
27
+ x.report("haml v#{Haml::VERSION}") { Haml::Engine.new.call(haml) }
28
+ x.compare!
29
+ end
30
+ end
31
+
32
+ desc 'render HAML', 'Benchmark rendering'
33
+ def render(file)
34
+ puts "#{?= * 49}\n Rendering: #{file}\n#{?= * 49}"
35
+ haml = File.read(file)
36
+ puts haml + "\n" if options[:show_template]
37
+ object = Object.new
38
+ ruby_file = file.gsub(/\.haml\z/, '.rb')
39
+ if File.exist?(ruby_file)
40
+ object.instance_eval(File.read(ruby_file))
41
+ end
42
+
43
+ object.instance_eval "def haml; #{Haml::Engine.new.call(haml)}; end"
44
+
45
+ Benchmark.ips do |x|
46
+ x.report("haml v#{Haml::VERSION}") { object.haml }
47
+ x.compare!
48
+ end
49
+ end
50
+
51
+ desc 'code HAML', 'Show compiled code'
52
+ def code(file)
53
+ haml = File.read(file)
54
+ puts "\n#{?= * 49}\n Haml Source: #{file}\n#{?= * 49}"
55
+ puts Haml::Engine.new.call(haml)
56
+ end
57
+
58
+ private
59
+
60
+ def method_missing(*args)
61
+ return super if args.length > 1
62
+ render(args.first.to_s)
63
+ end
64
+ end
65
+
66
+ Bench.start
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'hamlit'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require 'pry'
11
+ Pry.start
data/bin/ruby ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec ruby -Ilib:test -rtest_helper $@
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/bin/stackprof ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'hamlit'
5
+ require 'stackprof'
6
+
7
+ def open_flamegraph(report)
8
+ temp = `mktemp /tmp/stackflame-XXXXXXXX`.strip
9
+ data_path = "#{temp}.js"
10
+ system("mv #{temp} #{data_path}")
11
+
12
+ File.open(data_path, 'w') do |f|
13
+ report.print_flamegraph(f)
14
+ end
15
+
16
+ viewer_path = File.join(`bundle show stackprof`.strip, 'lib/stackprof/flamegraph/viewer.html')
17
+ url = "file://#{viewer_path}?data=#{data_path}"
18
+ system(%Q[osascript -e 'open location "#{url}"'])
19
+ end
20
+
21
+ haml = File.read(ARGV.first)
22
+ StackProf.start(mode: :wall, interval: 1, raw: false)
23
+ Hamlit::Engine.new.call(haml)
24
+ StackProf.stop
25
+
26
+ report = StackProf::Report.new(StackProf.results)
27
+ report.print_text(false)
data/bin/test ADDED
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+
3
+ VERSIONS=(
4
+ 2.1.10
5
+ 2.2.5
6
+ 2.3.1
7
+ )
8
+
9
+ set -e
10
+ trap 'echo "${VERSIONS[2]}" > .ruby-version' 0
11
+
12
+ function test_with() {
13
+ version=$1
14
+ rbenv local $version
15
+ if ! bundle check > /dev/null; then
16
+ bundle install
17
+ fi
18
+ ruby -v
19
+ bundle exec rake test
20
+ }
21
+
22
+ for version in ${VERSIONS[@]}; do
23
+ test_with $version
24
+ done
data/exe/haml ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path('../lib', __dir__)
4
+ require 'haml/cli'
5
+
6
+ Haml::CLI.start(ARGV)
@@ -0,0 +1,10 @@
1
+ require 'mkmf'
2
+
3
+ $CFLAGS << ' -Wall -Wextra'
4
+
5
+ $srcs = %w[
6
+ haml.c
7
+ hescape.c
8
+ ]
9
+
10
+ create_makefile('haml/haml')