Skip to content

Commit

Permalink
support ruby 2.4+ frozen string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Mar 15, 2018
1 parent 1cbdff3 commit 823a3f6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ language: ruby
before_install:
- gem install bundler

rvm:
- 1.9.3
- 2.0.0
- 2.3.1
- ruby-head
matrix:
include:
- os: linux
rvm: 1.9.3
- os: linux
rvm: 2.0.0
- os: linux
rvm: 2.3.0
- os: linux
rvm: ruby-head
env:
- TEST_RUBYOPT_FROZEN_STRING_LITERAL=1
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ Bundler::GemHelper.install_tasks

Rake::TestTask.new

if ENV['TEST_RUBYOPT_FROZEN_STRING_LITERAL'] # see .travis.yml
ENV['RUBYOPT'] = "--enable-frozen-string-literal --debug=frozen-string-literal"
puts "enabling frozen string literals"
end

task :default => [:test]
2 changes: 1 addition & 1 deletion lib/sanitize/css.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def property!(prop)
return nil unless @config[:properties].include?(name)

nodes = prop[:children].dup
combined_value = ''
combined_value = String.new

nodes.each do |child|
value = child[:value]
Expand Down
4 changes: 2 additions & 2 deletions test/test_sanitize_css.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@

describe '#tree!' do
it 'should sanitize a Crass CSS parse tree' do
tree = Crass.parse("@import url(foo.css);\n" <<
tree = Crass.parse(String.new("@import url(foo.css);\n") <<
".foo { background: #fff; font: 16pt 'Comic Sans MS'; }\n" <<
"#bar { top: 125px; background: green; }")

@custom.tree!(tree).must_be_same_as tree

Crass::Parser.stringify(tree).must_equal "\n" <<
Crass::Parser.stringify(tree).must_equal String.new("\n") <<
".foo { background: #fff; }\n" <<
"#bar { background: green; }"
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
end

it 'should strip language tag code point characters' do
str = 'a'
str = String.new 'a'
(0xE0000..0xE007F).each {|n| str << [n].pack('U') }
str << 'b'

Expand Down

0 comments on commit 823a3f6

Please sign in to comment.