From 55286e06a94c7e19a1e9eddf35568ad743d68be0 Mon Sep 17 00:00:00 2001 From: Dan Weinand Date: Sat, 24 Aug 2019 23:25:14 -0700 Subject: [PATCH 1/5] Lock rails 5 to correct sqlite3 version Fixes Rails 5 build failures --- Appraisals | 1 + gemfiles/rails_5.0.gemfile | 1 + 2 files changed, 2 insertions(+) diff --git a/Appraisals b/Appraisals index 82d15ad..a98e42a 100644 --- a/Appraisals +++ b/Appraisals @@ -8,6 +8,7 @@ appraise 'rails-5.0' do gem 'rails', '>= 5.0.0', '< 5.1' + gem 'sqlite3', '~> 1.3.6' end appraise 'rails-5.1' do diff --git a/gemfiles/rails_5.0.gemfile b/gemfiles/rails_5.0.gemfile index 4c5cb4b..4f212f0 100644 --- a/gemfiles/rails_5.0.gemfile +++ b/gemfiles/rails_5.0.gemfile @@ -3,5 +3,6 @@ source "https://rubygems.org" gem "rails", ">= 5.0.0", "< 5.1" +gem "sqlite3", "~> 1.3.6" gemspec path: "../" From 8e2b3de984559bf462fbdbc2c01db688a380d0a9 Mon Sep 17 00:00:00 2001 From: Dan Weinand Date: Sat, 24 Aug 2019 23:43:50 -0700 Subject: [PATCH 2/5] Run builds against ruby 2.6 instead of head --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5d9a377..c9008d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ rvm: - 2.3 - 2.4 - 2.5 - - ruby-head + - 2.6 before_install: - gem install bundler From d427ca39b701fd96a1adac371a5d09c124d2b088 Mon Sep 17 00:00:00 2001 From: Dan Weinand Date: Sat, 24 Aug 2019 23:54:45 -0700 Subject: [PATCH 3/5] Run frozen string specs against ruby 2.6 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c9008d7..7856aae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ gemfile: matrix: include: - - rvm: ruby-head + - rvm: 2.6 env: RUBYOPT="--enable-frozen-string-literal" # allow_failures: # - rvm: ruby-head From 613a9fb49f0766d517fb2797b5b4fb3149939af6 Mon Sep 17 00:00:00 2001 From: Dan Weinand Date: Sun, 25 Aug 2019 01:18:19 -0700 Subject: [PATCH 4/5] Fix frozen string errors --- lib/awesome_print/ext/active_record.rb | 4 ++-- lib/awesome_print/formatters/array_formatter.rb | 2 +- lib/awesome_print/formatters/hash_formatter.rb | 2 +- lib/awesome_print/formatters/object_formatter.rb | 5 +++-- spec/formats_spec.rb | 8 ++++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/awesome_print/ext/active_record.rb b/lib/awesome_print/ext/active_record.rb index 2a4a362..0b7d9d6 100644 --- a/lib/awesome_print/ext/active_record.rb +++ b/lib/awesome_print/ext/active_record.rb @@ -55,7 +55,7 @@ module AwesomePrint hash end end - "#{object} " << awesome_hash(data) + "#{object} #{awesome_hash(data)}" end # Format ActiveRecord class object. @@ -95,7 +95,7 @@ module AwesomePrint end data.merge!({details: object.details, messages: object.messages}) - "#{object} " << awesome_hash(data) + "#{object} #{awesome_hash(data)}" end end end diff --git a/lib/awesome_print/formatters/array_formatter.rb b/lib/awesome_print/formatters/array_formatter.rb index 3340a77..4c96284 100644 --- a/lib/awesome_print/formatters/array_formatter.rb +++ b/lib/awesome_print/formatters/array_formatter.rb @@ -31,7 +31,7 @@ module AwesomePrint if options[:multiline] multiline_array else - '[ ' << array.map { |item| inspector.awesome(item) }.join(', ') << ' ]' + "[ #{array.map { |item| inspector.awesome(item) }.join(', ')} ]" end end diff --git a/lib/awesome_print/formatters/hash_formatter.rb b/lib/awesome_print/formatters/hash_formatter.rb index c29bb63..30bbcd4 100644 --- a/lib/awesome_print/formatters/hash_formatter.rb +++ b/lib/awesome_print/formatters/hash_formatter.rb @@ -73,7 +73,7 @@ module AwesomePrint keys.map! do |key| plain_single_line do - [inspector.awesome(key), hash[key]] + [String.new(inspector.awesome(key)), hash[key]] end end end diff --git a/lib/awesome_print/formatters/object_formatter.rb b/lib/awesome_print/formatters/object_formatter.rb index 49334f7..eca30d6 100644 --- a/lib/awesome_print/formatters/object_formatter.rb +++ b/lib/awesome_print/formatters/object_formatter.rb @@ -22,7 +22,7 @@ module AwesomePrint object.respond_to?(property) ? :reader : nil end if accessor - ["attr_#{accessor} :#{property}", var] + [String.new("attr_#{accessor} :#{property}"), var] else [var.to_s, var] end @@ -60,7 +60,8 @@ module AwesomePrint end def awesome_instance - str = object.send(options[:class_name]).to_s + str = String.new + str << object.send(options[:class_name]).to_s str << ":0x%08x" % (object.__id__ * 2) if options[:object_id] str end diff --git a/spec/formats_spec.rb b/spec/formats_spec.rb index 9427b44..ac83732 100644 --- a/spec/formats_spec.rb +++ b/spec/formats_spec.rb @@ -492,7 +492,7 @@ EOS describe 'File' do it 'should display a file (plain)' do File.open(__FILE__, 'r') do |f| - expect(f.ai(plain: true)).to eq("#{f.inspect}\n" << `ls -alF #{f.path}`.chop) + expect(f.ai(plain: true)).to eq("#{f.inspect}\n#{`ls -alF #{f.path}`.chop}") end end end @@ -501,7 +501,7 @@ EOS describe 'Dir' do it 'should display a direcory (plain)' do Dir.open(File.dirname(__FILE__)) do |d| - expect(d.ai(plain: true)).to eq("#{d.inspect}\n" << `ls -alF #{d.path}`.chop) + expect(d.ai(plain: true)).to eq("#{d.inspect}\n#{`ls -alF #{d.path}`.chop}") end end end @@ -694,7 +694,7 @@ EOS class My < File; end my = File.new('/dev/null') rescue File.new('nul') - expect(my.ai(plain: true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop) + expect(my.ai(plain: true)).to eq("#{my.inspect}\n#{`ls -alF #{my.path}`.chop}") end it 'inherited from Dir should be displayed as Dir' do @@ -702,7 +702,7 @@ EOS require 'tmpdir' my = My.new(Dir.tmpdir) - expect(my.ai(plain: true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop) + expect(my.ai(plain: true)).to eq("#{my.inspect}\n#{`ls -alF #{my.path}`.chop}") end it 'should handle a class that defines its own #send method' do From b0f4a65aeea97194ff7aa4ab0bf51bb2cea9969d Mon Sep 17 00:00:00 2001 From: Dan Weinand Date: Sun, 25 Aug 2019 01:31:43 -0700 Subject: [PATCH 5/5] Use rails 5.2 when testing frozen strings --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7856aae..d7eaa59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,7 @@ matrix: include: - rvm: 2.6 env: RUBYOPT="--enable-frozen-string-literal" - # allow_failures: - # - rvm: ruby-head + gemfile: gemfiles/rails_5.2.gemfile addons: code_climate: