Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support ruby 2.4+ frozen string literals #174

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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