haml 5.1.1 → 5.1.2

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: b452821b37a39c122c73b034833f334367ea652bcbc9c8166fb4b146622766a2
4
- data.tar.gz: 41b11d87fa61bc35507519f25843284e07a6610bcc65e1beef5302590d925556
3
+ metadata.gz: 2ab71634acdfecb8525662d862961b21f26d77f32adf34457443b96aa5118b8d
4
+ data.tar.gz: 3eae0d107f253137df0583ead35dfee0d7840d3de616db50e0dbbd5734acbe27
5
5
  SHA512:
6
- metadata.gz: c68926aed4f1615985b6da508e8eafb4951162ab1064b94f5d2c17978390d82d2912098bdf74b90acfea1df1a21d711c0e3d14315394ebc7fa60341dd2c61975
7
- data.tar.gz: 499700814e3f72d7d7f033b80b9cd6b701ef07bcf46f1399ece0cf0dad5ddea6bbdff912775c3cd4e1506735cb7fd85cd1666903e69706968874b80788a2a9a7
6
+ metadata.gz: fb8005b129e6874259a4ff900579a13cbc42c3f64b13640856a219c9f69fbd2cfc77d8126231148c2ebc6b58883e8687a4f447603fd6cdfc41195bf08e1127c3
7
+ data.tar.gz: 813db45e219554933892a41e023419e9a1a0e10602ebdf525f7efc1f14fe6f2afa4ff96ac691a0d8552989016453e7ce553864fc778447e1f55725de43b53406
@@ -68,10 +68,6 @@ matrix:
68
68
  gemfile: test/gemfiles/Gemfile.rails-4.1.x
69
69
  - rvm: 2.6.3
70
70
  gemfile: test/gemfiles/Gemfile.rails-4.2.x
71
- - rvm: 2.6.3
72
- gemfile: test/gemfiles/Gemfile.rails-5.0.x
73
- - rvm: 2.6.3
74
- gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
75
71
  - rvm: ruby-head
76
72
  gemfile: test/gemfiles/Gemfile.rails-4.0.x
77
73
  - rvm: ruby-head
@@ -94,6 +90,8 @@ matrix:
94
90
  - rvm: jruby-9.2.7.0
95
91
  gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
96
92
  fast_finish: true
97
- before_install: gem i rubygems-update -v '<3' && update_rubygems # https://github.com/travis-ci/travis-ci/issues/8974
98
- before_install: gem i bundler -v '<2'
93
+ before_install:
94
+ - gem i rubygems-update -v '<3' && update_rubygems # https://github.com/travis-ci/travis-ci/issues/8974
95
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
96
+ - gem i bundler -v '<2'
99
97
  script: "bundle exec rake submodules test"
@@ -1,11 +1,18 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 5.1.2
4
+
5
+ Released on August 6, 2019
6
+ ([diff](https://github.com/haml/haml/compare/v5.1.1...v5.1.2)).
7
+
8
+ * Fix crash in some environments such as New Relic by unfreezing string literals for ParseNode#inspect. [#1016](https://github.com/haml/haml/pull/1016) (thanks [Jalyna](https://github.com/jalyna))
9
+
3
10
  ## 5.1.1
4
11
 
5
12
  Released on May 25, 2019
6
13
  ([diff](https://github.com/haml/haml/compare/v5.1.0...v5.1.1)).
7
14
 
8
- * Fix NameError bug for that happens on ruby 2.6.1-2.6.3 + haml 5.1.0 + rails 4.2.x + erubi. (Akira Matsuda)
15
+ * Fix NameError bug that happens on ruby 2.6.1-2.6.3 + haml 5.1.0 + rails < 5.1 + erubi. (Akira Matsuda)
9
16
 
10
17
  ## 5.1.0
11
18
 
data/Rakefile CHANGED
@@ -88,11 +88,7 @@ task :profile do
88
88
  end
89
89
 
90
90
  def gemfiles
91
- @gemfiles ||= begin
92
- Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].
93
- reject {|f| f =~ /\.lock$/}.
94
- reject {|f| RUBY_VERSION < '1.9.3' && f =~ /Gemfile.rails-(\d+).\d+.x/ && $1.to_i > 3}
95
- end
91
+ @gemfiles ||= Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].reject {|f| f =~ /\.lock$/}
96
92
  end
97
93
 
98
94
  def with_each_gemfile
@@ -16,7 +16,7 @@ module Haml
16
16
  TYPE = 1
17
17
  TEXT = 2
18
18
 
19
- IGNORED_TYPES = %i[on_sp on_ignored_nl]
19
+ IGNORED_TYPES = %i[on_sp on_ignored_nl].freeze
20
20
 
21
21
  class << self
22
22
  # @return [Boolean] - return true if AttributeParser.parse can be used.
@@ -188,30 +188,28 @@ module Haml
188
188
 
189
189
  if @options.html5?
190
190
  '<!DOCTYPE html>'
191
- else
192
- if @options.xhtml?
193
- if @node.value[:version] == "1.1"
194
- '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
195
- elsif @node.value[:version] == "5"
196
- '<!DOCTYPE html>'
197
- else
198
- case @node.value[:type]
199
- when "strict"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
200
- when "frameset"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'
201
- when "mobile"; '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">'
202
- when "rdfa"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">'
203
- when "basic"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">'
204
- else '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
205
- end
206
- end
207
-
208
- elsif @options.html4?
191
+ elsif @options.xhtml?
192
+ if @node.value[:version] == "1.1"
193
+ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
194
+ elsif @node.value[:version] == "5"
195
+ '<!DOCTYPE html>'
196
+ else
209
197
  case @node.value[:type]
210
- when "strict"; '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
211
- when "frameset"; '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
212
- else '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
198
+ when "strict"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
199
+ when "frameset"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'
200
+ when "mobile"; '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">'
201
+ when "rdfa"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">'
202
+ when "basic"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">'
203
+ else '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
213
204
  end
214
205
  end
206
+
207
+ elsif @options.html4?
208
+ case @node.value[:type]
209
+ when "strict"; '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
210
+ when "frameset"; '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
211
+ else '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
212
+ end
215
213
  end
216
214
  end
217
215
 
@@ -5,29 +5,29 @@ module Haml
5
5
  class Error < StandardError
6
6
 
7
7
  MESSAGES = {
8
- :bad_script_indent => '"%s" is indented at wrong level: expected %d, but was at %d.',
9
- :cant_run_filter => 'Can\'t run "%s" filter; you must require its dependencies first',
10
- :cant_use_tabs_and_spaces => "Indentation can't use both tabs and spaces.",
11
- :deeper_indenting => "The line was indented %d levels deeper than the previous line.",
12
- :filter_not_defined => 'Filter "%s" is not defined.',
13
- :gem_install_filter_deps => '"%s" filter\'s %s dependency missing: try installing it or adding it to your Gemfile',
14
- :illegal_element => "Illegal element: classes and ids must have values.",
15
- :illegal_nesting_content => "Illegal nesting: nesting within a tag that already has content is illegal.",
16
- :illegal_nesting_header => "Illegal nesting: nesting within a header command is illegal.",
17
- :illegal_nesting_line => "Illegal nesting: content can't be both given on the same line as %%%s and nested within it.",
18
- :illegal_nesting_plain => "Illegal nesting: nesting within plain text is illegal.",
19
- :illegal_nesting_self_closing => "Illegal nesting: nesting within a self-closing tag is illegal.",
20
- :inconsistent_indentation => "Inconsistent indentation: %s used for indentation, but the rest of the document was indented using %s.",
21
- :indenting_at_start => "Indenting at the beginning of the document is illegal.",
22
- :install_haml_contrib => 'To use the "%s" filter, please install the haml-contrib gem.',
23
- :invalid_attribute_list => 'Invalid attribute list: %s.',
24
- :invalid_filter_name => 'Invalid filter name ":%s".',
25
- :invalid_tag => 'Invalid tag: "%s".',
26
- :missing_if => 'Got "%s" with no preceding "if"',
27
- :no_ruby_code => "There's no Ruby code for %s to evaluate.",
28
- :self_closing_content => "Self-closing tags can't have content.",
29
- :unbalanced_brackets => 'Unbalanced brackets.',
30
- :no_end => <<-END
8
+ bad_script_indent: '"%s" is indented at wrong level: expected %d, but was at %d.',
9
+ cant_run_filter: 'Can\'t run "%s" filter; you must require its dependencies first',
10
+ cant_use_tabs_and_spaces: "Indentation can't use both tabs and spaces.",
11
+ deeper_indenting: "The line was indented %d levels deeper than the previous line.",
12
+ filter_not_defined: 'Filter "%s" is not defined.',
13
+ gem_install_filter_deps: '"%s" filter\'s %s dependency missing: try installing it or adding it to your Gemfile',
14
+ illegal_element: "Illegal element: classes and ids must have values.",
15
+ illegal_nesting_content: "Illegal nesting: nesting within a tag that already has content is illegal.",
16
+ illegal_nesting_header: "Illegal nesting: nesting within a header command is illegal.",
17
+ illegal_nesting_line: "Illegal nesting: content can't be both given on the same line as %%%s and nested within it.",
18
+ illegal_nesting_plain: "Illegal nesting: nesting within plain text is illegal.",
19
+ illegal_nesting_self_closing: "Illegal nesting: nesting within a self-closing tag is illegal.",
20
+ inconsistent_indentation: "Inconsistent indentation: %s used for indentation, but the rest of the document was indented using %s.",
21
+ indenting_at_start: "Indenting at the beginning of the document is illegal.",
22
+ install_haml_contrib: 'To use the "%s" filter, please install the haml-contrib gem.',
23
+ invalid_attribute_list: 'Invalid attribute list: %s.',
24
+ invalid_filter_name: 'Invalid filter name ":%s".',
25
+ invalid_tag: 'Invalid tag: "%s".',
26
+ missing_if: 'Got "%s" with no preceding "if"',
27
+ no_ruby_code: "There's no Ruby code for %s to evaluate.",
28
+ self_closing_content: "Self-closing tags can't have content.",
29
+ unbalanced_brackets: 'Unbalanced brackets.',
30
+ no_end: <<-END
31
31
  You don't need to use "- end" in Haml. Un-indent to close a block:
32
32
  - if foo?
33
33
  %strong Foo!
@@ -35,7 +35,7 @@ You don't need to use "- end" in Haml. Un-indent to close a block:
35
35
  Not foo.
36
36
  %p This line is un-indented, so it isn't part of the "if" block
37
37
  END
38
- }
38
+ }.freeze
39
39
 
40
40
  def self.message(key, *args)
41
41
  string = MESSAGES[key] or raise "[HAML BUG] No error messages for #{key}"
@@ -121,7 +121,7 @@ module Haml
121
121
  @options[:input], @options[:output] = input, output
122
122
  end
123
123
 
124
- COLORS = { :red => 31, :green => 32, :yellow => 33 }
124
+ COLORS = {red: 31, green: 32, yellow: 33}.freeze
125
125
 
126
126
  # Prints a status message about performing the given action,
127
127
  # colored using the given color (via terminal escapes) if possible.
@@ -593,7 +593,7 @@ MESSAGE
593
593
  end
594
594
 
595
595
  # Characters that need to be escaped to HTML entities from user input
596
- HTML_ESCAPE = { '&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;', "'" => '&#39;' }
596
+ HTML_ESCAPE = {'&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;', "'" => '&#39;'}.freeze
597
597
 
598
598
  HTML_ESCAPE_REGEX = /['"><&]/
599
599
 
@@ -5,44 +5,40 @@ module Haml
5
5
  # understands. Please see the {file:REFERENCE.md#options Haml Reference} to
6
6
  # learn how to set the options.
7
7
  class Options
8
-
9
8
  @valid_formats = [:html4, :html5, :xhtml]
10
-
11
9
  @buffer_option_keys = [:autoclose, :preserve, :attr_wrapper, :format,
12
10
  :encoding, :escape_html, :escape_filter_interpolations, :escape_attrs, :hyphenate_data_attrs, :cdata]
13
11
 
14
- # The default option values.
15
- # @return Hash
16
- def self.defaults
17
- @defaults ||= Haml::TempleEngine.options.to_hash.merge(encoding: 'UTF-8')
18
- end
12
+ class << self
13
+ # The default option values.
14
+ # @return Hash
15
+ def defaults
16
+ @defaults ||= Haml::TempleEngine.options.to_hash.merge(encoding: 'UTF-8')
17
+ end
19
18
 
20
- # An array of valid values for the `:format` option.
21
- # @return Array
22
- def self.valid_formats
23
- @valid_formats
24
- end
19
+ # An array of valid values for the `:format` option.
20
+ # @return Array
21
+ attr_reader :valid_formats
25
22
 
26
- # An array of keys that will be used to provide a hash of options to
27
- # {Haml::Buffer}.
28
- # @return Hash
29
- def self.buffer_option_keys
30
- @buffer_option_keys
31
- end
23
+ # An array of keys that will be used to provide a hash of options to
24
+ # {Haml::Buffer}.
25
+ # @return Hash
26
+ attr_reader :buffer_option_keys
32
27
 
33
- # Returns a subset of defaults: those that {Haml::Buffer} cares about.
34
- # @return [{Symbol => Object}] The options hash
35
- def self.buffer_defaults
36
- @buffer_defaults ||= buffer_option_keys.inject({}) do |hash, key|
37
- hash.merge(key => defaults[key])
28
+ # Returns a subset of defaults: those that {Haml::Buffer} cares about.
29
+ # @return [{Symbol => Object}] The options hash
30
+ def buffer_defaults
31
+ @buffer_defaults ||= buffer_option_keys.inject({}) do |hash, key|
32
+ hash.merge(key => defaults[key])
33
+ end
38
34
  end
39
- end
40
35
 
41
- def self.wrap(options)
42
- if options.is_a?(Options)
43
- options
44
- else
45
- Options.new(options)
36
+ def wrap(options)
37
+ if options.is_a?(Options)
38
+ options
39
+ else
40
+ Options.new(options)
41
+ end
46
42
  end
47
43
  end
48
44
 
@@ -139,7 +135,7 @@ module Haml
139
135
  # formatting errors.
140
136
  #
141
137
  # Defaults to `false`.
142
- attr_reader :remove_whitespace
138
+ attr_accessor :remove_whitespace
143
139
 
144
140
  # Whether or not attribute hashes and Ruby scripts designated by `=` or `~`
145
141
  # should be evaluated. If this is `true`, said scripts are rendered as empty
@@ -175,7 +171,7 @@ module Haml
175
171
  # Key is filter name in String and value is Class to use. Defaults to {}.
176
172
  attr_accessor :filters
177
173
 
178
- def initialize(values = {}, &block)
174
+ def initialize(values = {})
179
175
  defaults.each {|k, v| instance_variable_set :"@#{k}", v}
180
176
  values.each {|k, v| send("#{k}=", v) if defaults.has_key?(k) && !v.nil?}
181
177
  yield if block_given?
@@ -245,10 +241,6 @@ module Haml
245
241
  xhtml? || @cdata
246
242
  end
247
243
 
248
- def remove_whitespace=(value)
249
- @remove_whitespace = value
250
- end
251
-
252
244
  def encoding=(value)
253
245
  return unless value
254
246
  @encoding = value.is_a?(Encoding) ? value.name : value.to_s
@@ -61,7 +61,7 @@ module Haml
61
61
  SILENT_SCRIPT,
62
62
  ESCAPE,
63
63
  FILTER
64
- ]
64
+ ].freeze
65
65
 
66
66
  # The value of the character that designates that a line is part
67
67
  # of a multiline string.
@@ -75,8 +75,8 @@ module Haml
75
75
  #
76
76
  BLOCK_WITH_SPACES = /do\s*\|\s*[^\|]*\s+\|\z/
77
77
 
78
- MID_BLOCK_KEYWORDS = %w[else elsif rescue ensure end when]
79
- START_BLOCK_KEYWORDS = %w[if begin case unless]
78
+ MID_BLOCK_KEYWORDS = %w[else elsif rescue ensure end when].freeze
79
+ START_BLOCK_KEYWORDS = %w[if begin case unless].freeze
80
80
  # Try to parse assignments to block starters as best as possible
81
81
  START_BLOCK_KEYWORD_REGEX = /(?:\w+(?:,\s*\w+)*\s*=\s*)?(#{START_BLOCK_KEYWORDS.join('|')})/
82
82
  BLOCK_KEYWORD_REGEX = /^-?\s*(?:(#{MID_BLOCK_KEYWORDS.join('|')})|#{START_BLOCK_KEYWORD_REGEX.source})\b/
@@ -202,7 +202,7 @@ module Haml
202
202
  end
203
203
 
204
204
  def inspect
205
- %Q[(#{type} #{value.inspect}#{children.each_with_object('') {|c, s| s << "\n#{c.inspect.gsub!(/^/, ' ')}"}})]
205
+ %Q[(#{type} #{value.inspect}#{children.each_with_object(''.dup) {|c, s| s << "\n#{c.inspect.gsub!(/^/, ' ')}"}})].dup
206
206
  end
207
207
  end
208
208
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Haml
4
- VERSION = "5.1.1"
4
+ VERSION = "5.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.1
4
+ version: 5.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natalie Weizenbaum
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-05-25 00:00:00.000000000 Z
14
+ date: 2019-08-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: temple