From 4e99526c25f649894c5227b5c3d39e7eec7f35b0 Mon Sep 17 00:00:00 2001 From: Gerard Caulfield Date: Wed, 9 Nov 2016 13:39:25 +1100 Subject: [PATCH] Fix spacing inoconsistencies which conflict with style guide This is also so that Hound can be introduced without it bugging people about issues in existing code. --- If git-blame brought you here you may want to read this, the problem is with git-blame, not this change. Try running these two lines just once: `` git config --global alias.praise 'log -p -M --follow --stat --' git config --global alias.praise-line 'log -p -M --pretty=format:"%h (%an %ai)" -L' `` Now in future you can use `git praise ` or if you want to see the evolution of a specific line or range of lines `git praise-line ::` Some examples you should try: `` git praise lib/awesome_print/version.rb git praise-line 8:8:lib/awesome_print/version.rb `` Inspiration for these aliases: http://blog.andrewray.me/a-better-git-blame/` --- lib/awesome_print/core_ext/string.rb | 4 +-- lib/awesome_print/ext/mongo_mapper.rb | 6 ++-- lib/awesome_print/ext/mongoid.rb | 2 +- lib/awesome_print/ext/nobrainer.rb | 2 +- lib/awesome_print/ext/nokogiri.rb | 2 +- lib/awesome_print/ext/sequel.rb | 4 +-- lib/awesome_print/formatter.rb | 8 ++--- .../formatters/array_formatter.rb | 4 +-- .../formatters/base_formatter.rb | 4 +-- .../formatters/hash_formatter.rb | 4 +-- .../formatters/object_formatter.rb | 6 ++-- .../formatters/struct_formatter.rb | 4 +-- spec/colors_spec.rb | 2 +- spec/core_ext/logger_spec.rb | 4 +-- spec/core_ext/string_spec.rb | 8 ++--- spec/ext/action_view_spec.rb | 2 +- spec/ext/active_record_spec.rb | 6 ++-- spec/ext/active_support_spec.rb | 2 +- spec/ext/mongo_mapper_spec.rb | 6 ++-- spec/ext/mongoid_spec.rb | 8 ++--- spec/ext/nobrainer_spec.rb | 4 +-- spec/ext/nokogiri_spec.rb | 6 ++-- spec/ext/ripple_spec.rb | 2 +- spec/formats_spec.rb | 26 +++++++-------- spec/methods_spec.rb | 32 +++++++++---------- spec/misc_spec.rb | 20 ++++++------ spec/objects_spec.rb | 2 +- 27 files changed, 90 insertions(+), 90 deletions(-) diff --git a/lib/awesome_print/core_ext/string.rb b/lib/awesome_print/core_ext/string.rb index dece9be..ef590f0 100644 --- a/lib/awesome_print/core_ext/string.rb +++ b/lib/awesome_print/core_ext/string.rb @@ -17,11 +17,11 @@ class String %w(gray red green yellow blue purple cyan white).zip( %w(black darkred darkgreen brown navy darkmagenta darkcyan slategray)).each_with_index do |(color, shade), i| define_method color do |*html| - html[0] ? %Q|#{self}| : "\e[1;#{30+i}m#{self}\e[0m" + html[0] ? %Q|#{self}| : "\e[1;#{30 + i}m#{self}\e[0m" end define_method "#{color}ish" do |*html| - html[0] ? %Q|#{self}| : "\e[0;#{30+i}m#{self}\e[0m" + html[0] ? %Q|#{self}| : "\e[0;#{30 + i}m#{self}\e[0m" end end diff --git a/lib/awesome_print/ext/mongo_mapper.rb b/lib/awesome_print/ext/mongo_mapper.rb index 6533ced..42d8edb 100644 --- a/lib/awesome_print/ext/mongo_mapper.rb +++ b/lib/awesome_print/ext/mongo_mapper.rb @@ -18,7 +18,7 @@ module AwesomePrint cast = cast_without_mongo_mapper(object, type) if defined?(::MongoMapper::Document) - if object.is_a?(Class) && (object.ancestors & [ ::MongoMapper::Document, ::MongoMapper::EmbeddedDocument ]).size > 0 + if object.is_a?(Class) && (object.ancestors & [::MongoMapper::Document, ::MongoMapper::EmbeddedDocument]).size > 0 cast = :mongo_mapper_class elsif object.is_a?(::MongoMapper::Document) || object.is_a?(::MongoMapper::EmbeddedDocument) cast = :mongo_mapper_instance @@ -65,7 +65,7 @@ module AwesomePrint return object.inspect if !defined?(::ActiveSupport::OrderedHash) return awesome_object(object) if @options[:raw] - data = object.keys.keys.sort_by{|k| k}.inject(::ActiveSupport::OrderedHash.new) do |hash, name| + data = object.keys.keys.sort_by { |k| k }.inject(::ActiveSupport::OrderedHash.new) do |hash, name| hash[name] = object[name] hash end @@ -93,7 +93,7 @@ module AwesomePrint return object.inspect if !defined?(::ActiveSupport::OrderedHash) return awesome_object(object) if @options[:raw] - association = object.class.name.split('::').last.titleize.downcase.sub(/ association$/,'') + association = object.class.name.split('::').last.titleize.downcase.sub(/ association$/, '') association = "embeds #{association}" if object.embeddable? class_name = object.class_name diff --git a/lib/awesome_print/ext/mongoid.rb b/lib/awesome_print/ext/mongoid.rb index 2610e47..229c943 100644 --- a/lib/awesome_print/ext/mongoid.rb +++ b/lib/awesome_print/ext/mongoid.rb @@ -48,7 +48,7 @@ module AwesomePrint hash[c[0].to_sym] = c[1] hash end - data = {errors: object.errors, attributes: data} if !object.errors.empty? + data = { errors: object.errors, attributes: data } if !object.errors.empty? "#{object} #{awesome_hash(data)}" end diff --git a/lib/awesome_print/ext/nobrainer.rb b/lib/awesome_print/ext/nobrainer.rb index a558d8b..9ad37b9 100644 --- a/lib/awesome_print/ext/nobrainer.rb +++ b/lib/awesome_print/ext/nobrainer.rb @@ -38,7 +38,7 @@ module AwesomePrint #------------------------------------------------------------------------------ def awesome_nobrainer_document(object) data = object.inspectable_attributes.symbolize_keys - data = {errors: object.errors, attributes: data} if object.errors.present? + data = { errors: object.errors, attributes: data } if object.errors.present? "#{object} #{awesome_hash(data)}" end end diff --git a/lib/awesome_print/ext/nokogiri.rb b/lib/awesome_print/ext/nokogiri.rb index 6f72f25..fe7fc9d 100644 --- a/lib/awesome_print/ext/nokogiri.rb +++ b/lib/awesome_print/ext/nokogiri.rb @@ -15,7 +15,7 @@ module AwesomePrint #------------------------------------------------------------------------------ def cast_with_nokogiri(object, type) cast = cast_without_nokogiri(object, type) - if (defined?(::Nokogiri::XML::Node) && object.is_a?(::Nokogiri::XML::Node)) || + if (defined?(::Nokogiri::XML::Node) && object.is_a?(::Nokogiri::XML::Node)) || (defined?(::Nokogiri::XML::NodeSet) && object.is_a?(::Nokogiri::XML::NodeSet)) cast = :nokogiri_xml_node end diff --git a/lib/awesome_print/ext/sequel.rb b/lib/awesome_print/ext/sequel.rb index f273d65..9b50f1b 100644 --- a/lib/awesome_print/ext/sequel.rb +++ b/lib/awesome_print/ext/sequel.rb @@ -32,7 +32,7 @@ module AwesomePrint hash[c[0].to_sym] = c[1] hash end - data = {errors: object.errors, values: data} if !object.errors.empty? + data = { errors: object.errors, values: data } if !object.errors.empty? "#{object} #{awesome_hash(data)}" end @@ -45,7 +45,7 @@ module AwesomePrint # Format Sequel Model class. #------------------------------------------------------------------------------ def awesome_sequel_model_class(object) - data = object.db_schema.inject({}) {|h, (name,data)| h.merge(name => data[:db_type])} + data = object.db_schema.inject({}) { |h, (name, data)| h.merge(name => data[:db_type]) } "class #{object} < #{object.superclass} " << awesome_hash(data) end end diff --git a/lib/awesome_print/formatter.rb b/lib/awesome_print/formatter.rb index 7ccc401..2d87b94 100644 --- a/lib/awesome_print/formatter.rb +++ b/lib/awesome_print/formatter.rb @@ -11,7 +11,7 @@ module AwesomePrint attr_reader :inspector, :options - CORE = [ :array, :bigdecimal, :class, :dir, :file, :hash, :method, :rational, :set, :struct, :unboundmethod ] + CORE = [:array, :bigdecimal, :class, :dir, :file, :hash, :method, :rational, :set, :struct, :unboundmethod] def initialize(inspector) @inspector = inspector @@ -88,7 +88,7 @@ module AwesomePrint end def awesome_method(m) - Formatters::MethodFormatter.new(m, @inspector).format + Formatters::MethodFormatter.new(m, @inspector).format end alias :awesome_unboundmethod :awesome_method @@ -107,7 +107,7 @@ module AwesomePrint # Utility methods. #------------------------------------------------------------------------------ def convert_to_hash(object) - if ! object.respond_to?(:to_hash) + if !object.respond_to?(:to_hash) return nil end @@ -116,7 +116,7 @@ module AwesomePrint end hash = object.to_hash - if ! hash.respond_to?(:keys) || ! hash.respond_to?('[]') + if !hash.respond_to?(:keys) || !hash.respond_to?('[]') return nil end diff --git a/lib/awesome_print/formatters/array_formatter.rb b/lib/awesome_print/formatters/array_formatter.rb index 4d31456..4e1d50c 100644 --- a/lib/awesome_print/formatters/array_formatter.rb +++ b/lib/awesome_print/formatters/array_formatter.rb @@ -31,7 +31,7 @@ module AwesomePrint data = limited(data, width) if should_be_limited? "[\n" << data.join(",\n") << "\n#{outdent}]" else - '[ ' << array.map{ |item| inspector.awesome(item) }.join(', ') << ' ]' + '[ ' << array.map { |item| inspector.awesome(item) }.join(', ') << ' ]' end end @@ -51,7 +51,7 @@ module AwesomePrint method_tuple(object.instance_method(name)) rescue nil # Rescue to avoid NameError when the method is not end # available (ex. File.lchmod on Ubuntu 12). end - tuple || [ name.to_s, '(?)', '?' ] # Return WTF default if all the above fails. + tuple || [name.to_s, '(?)', '?'] # Return WTF default if all the above fails. end width = (tuples.size - 1).to_s.size diff --git a/lib/awesome_print/formatters/base_formatter.rb b/lib/awesome_print/formatters/base_formatter.rb index ea9066d..05353f8 100644 --- a/lib/awesome_print/formatters/base_formatter.rb +++ b/lib/awesome_print/formatters/base_formatter.rb @@ -50,7 +50,7 @@ module AwesomePrint tail = head - (limit - 1) % 2 # Add the proper elements to the temp array and format the separator. - temp = data[0, head] + [ nil ] + data[-tail, tail] + temp = data[0, head] + [nil] + data[-tail, tail] if is_hash temp[head] = "#{indent}#{data[head].strip} .. #{data[data.length - tail - 1].strip}" @@ -97,7 +97,7 @@ module AwesomePrint owner = "#{klass}#{unbound}".gsub('(', ' (') end - [ method.name.to_s, "(#{args.join(', ')})", owner.to_s ] + [method.name.to_s, "(#{args.join(', ')})", owner.to_s] end # diff --git a/lib/awesome_print/formatters/hash_formatter.rb b/lib/awesome_print/formatters/hash_formatter.rb index 584976d..cf398c8 100644 --- a/lib/awesome_print/formatters/hash_formatter.rb +++ b/lib/awesome_print/formatters/hash_formatter.rb @@ -19,11 +19,11 @@ module AwesomePrint keys = keys.sort { |a, b| a.to_s <=> b.to_s } if options[:sort_keys] data = keys.map do |key| plain_single_line do - [ inspector.awesome(key), hash[key] ] + [inspector.awesome(key), hash[key]] end end - width = data.map { |key, | key.size }.max || 0 + width = data.map { |key, _value| key.size }.max || 0 width += indentation if options[:indent] > 0 data = data.map do |key, value| diff --git a/lib/awesome_print/formatters/object_formatter.rb b/lib/awesome_print/formatters/object_formatter.rb index a5c8823..3ab3429 100644 --- a/lib/awesome_print/formatters/object_formatter.rb +++ b/lib/awesome_print/formatters/object_formatter.rb @@ -22,9 +22,9 @@ module AwesomePrint object.respond_to?(property) ? :reader : nil end if accessor - [ "attr_#{accessor} :#{property}", var ] + ["attr_#{accessor} :#{property}", var] else - [ var.to_s, var ] + [var.to_s, var] end end @@ -53,7 +53,7 @@ module AwesomePrint end end - private + private def valid_instance_var?(variable_name) variable_name.to_s.start_with?('@') diff --git a/lib/awesome_print/formatters/struct_formatter.rb b/lib/awesome_print/formatters/struct_formatter.rb index 94710bd..86cee9a 100644 --- a/lib/awesome_print/formatters/struct_formatter.rb +++ b/lib/awesome_print/formatters/struct_formatter.rb @@ -22,9 +22,9 @@ module AwesomePrint struct.respond_to?(property) ? :reader : nil end if accessor - [ "attr_#{accessor} :#{property}", var ] + ["attr_#{accessor} :#{property}", var] else - [ var.to_s, var ] + [var.to_s, var] end end diff --git a/spec/colors_spec.rb b/spec/colors_spec.rb index 0a3456c..c0c51ae 100644 --- a/spec/colors_spec.rb +++ b/spec/colors_spec.rb @@ -16,7 +16,7 @@ RSpec.describe 'AwesomePrint' do before do ENV['TERM'] = 'xterm-colors' ENV.delete('ANSICON') - @arr = [ 1, :two, 'three', [ nil, [ true, false] ] ] + @arr = [1, :two, 'three', [nil, [true, false]]] end describe 'default settings (no forced colors)' do diff --git a/spec/core_ext/logger_spec.rb b/spec/core_ext/logger_spec.rb index 36ad858..ed2d756 100644 --- a/spec/core_ext/logger_spec.rb +++ b/spec/core_ext/logger_spec.rb @@ -15,12 +15,12 @@ RSpec.describe 'AwesomePrint logging extensions' do expect(object).to receive(:ai) @logger.ap object end - + describe 'the log level' do before do AwesomePrint.defaults = {} end - + it 'should fallback to the default :debug log level' do expect(@logger).to receive(:debug) @logger.ap(nil) diff --git a/spec/core_ext/string_spec.rb b/spec/core_ext/string_spec.rb index ae98354..b7f1b47 100644 --- a/spec/core_ext/string_spec.rb +++ b/spec/core_ext/string_spec.rb @@ -1,19 +1,19 @@ require 'spec_helper' RSpec.describe 'String extensions' do - [ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i| + [:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white].each_with_index do |color, i| it "should have #{color} color" do - expect(color.to_s.send(color)).to eq("\e[1;#{30+i}m#{color}\e[0m") + expect(color.to_s.send(color)).to eq("\e[1;#{30 + i}m#{color}\e[0m") end it "should have #{color}ish color" do - expect(color.to_s.send(:"#{color}ish")).to eq("\e[0;#{30+i}m#{color}\e[0m") + expect(color.to_s.send(:"#{color}ish")).to eq("\e[0;#{30 + i}m#{color}\e[0m") end end it 'should have black and pale colors' do expect('black'.send(:black)).to eq('black'.send(:grayish)) - expect('pale'.send(:pale)).to eq('pale'.send(:whiteish)) + expect('pale'.send(:pale)).to eq('pale'.send(:whiteish)) expect('pale'.send(:pale)).to eq("\e[0;37mpale\e[0m") expect('whiteish'.send(:whiteish)).to eq("\e[0;37mwhiteish\e[0m") end diff --git a/spec/ext/action_view_spec.rb b/spec/ext/action_view_spec.rb index 7dde0da..c772d81 100644 --- a/spec/ext/action_view_spec.rb +++ b/spec/ext/action_view_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'AwesomePrint ActionView extensions', skip: ->{ !ExtVerifier.has_rails? }.call do +RSpec.describe 'AwesomePrint ActionView extensions', skip: -> { !ExtVerifier.has_rails? }.call do before do @view = ActionView::Base.new diff --git a/spec/ext/active_record_spec.rb b/spec/ext/active_record_spec.rb index 585519e..4a1dd17 100644 --- a/spec/ext/active_record_spec.rb +++ b/spec/ext/active_record_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'active_record_helper' -RSpec.describe 'AwesomePrint/ActiveRecord', skip: ->{ !ExtVerifier.has_rails? }.call do +RSpec.describe 'AwesomePrint/ActiveRecord', skip: -> { !ExtVerifier.has_rails? }.call do describe 'ActiveRecord instance, attributes only (default)' do before do ActiveRecord::Base.default_timezone = :utc @@ -30,7 +30,7 @@ RSpec.describe 'AwesomePrint/ActiveRecord', skip: ->{ !ExtVerifier.has_rails? }. end it 'display multiple records' do - out = @ap.awesome([ @diana, @laura ]) + out = @ap.awesome([@diana, @laura]) str = <<-EOS.strip [ [0] # { @@ -150,7 +150,7 @@ EOS end it 'display multiple records' do - out = @ap.awesome([ @diana, @laura ]) + out = @ap.awesome([@diana, @laura]) raw_object_string = if activerecord_5_0? diff --git a/spec/ext/active_support_spec.rb b/spec/ext/active_support_spec.rb index d39fabe..f14299d 100644 --- a/spec/ext/active_support_spec.rb +++ b/spec/ext/active_support_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'AwesomePrint::ActiveSupport', skip: ->{ !ExtVerifier.has_rails? }.call do +RSpec.describe 'AwesomePrint::ActiveSupport', skip: -> { !ExtVerifier.has_rails? }.call do before do @ap = AwesomePrint::Inspector.new end diff --git a/spec/ext/mongo_mapper_spec.rb b/spec/ext/mongo_mapper_spec.rb index 1ca1c44..b9da6f0 100644 --- a/spec/ext/mongo_mapper_spec.rb +++ b/spec/ext/mongo_mapper_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'AwesomePrint/MongoMapper', skip: ->{ !ExtVerifier.has_mongo_mapper? }.call do +RSpec.describe 'AwesomePrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_mapper? }.call do if ExtVerifier.has_mongo_mapper? before :all do class MongoUser @@ -12,8 +12,8 @@ RSpec.describe 'AwesomePrint/MongoMapper', skip: ->{ !ExtVerifier.has_mongo_mapp end after :all do - Object.instance_eval{ remove_const :MongoUser } - Object.instance_eval{ remove_const :Chamelion } + Object.instance_eval { remove_const :MongoUser } + Object.instance_eval { remove_const :Chamelion } end end diff --git a/spec/ext/mongoid_spec.rb b/spec/ext/mongoid_spec.rb index a37b751..2eb29c8 100644 --- a/spec/ext/mongoid_spec.rb +++ b/spec/ext/mongoid_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'AwesomePrint/Mongoid', skip: ->{ !ExtVerifier.has_mongoid? }.call do +RSpec.describe 'AwesomePrint/Mongoid', skip: -> { !ExtVerifier.has_mongoid? }.call do if ExtVerifier.has_mongoid? before :all do @@ -13,8 +13,8 @@ RSpec.describe 'AwesomePrint/Mongoid', skip: ->{ !ExtVerifier.has_mongoid? }.cal end after :all do - Object.instance_eval{ remove_const :MongoUser } - Object.instance_eval{ remove_const :Chamelion } + Object.instance_eval { remove_const :MongoUser } + Object.instance_eval { remove_const :Chamelion } end end @@ -34,7 +34,7 @@ RSpec.describe 'AwesomePrint/Mongoid', skip: ->{ !ExtVerifier.has_mongoid? }.cal :last_name => "Capone" } EOS - expect(out).to be_similar_to(str, {skip_bson: true}) + expect(out).to be_similar_to(str, { skip_bson: true }) end it 'should print the class' do diff --git a/spec/ext/nobrainer_spec.rb b/spec/ext/nobrainer_spec.rb index a83c5d8..e08c83b 100644 --- a/spec/ext/nobrainer_spec.rb +++ b/spec/ext/nobrainer_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'AwesomePrint/NoBrainer', skip: ->{ !ExtVerifier.has_nobrainer? }.call do +RSpec.describe 'AwesomePrint/NoBrainer', skip: -> { !ExtVerifier.has_nobrainer? }.call do if ExtVerifier.has_nobrainer? before :all do @@ -21,7 +21,7 @@ RSpec.describe 'AwesomePrint/NoBrainer', skip: ->{ !ExtVerifier.has_nobrainer? } end after :all do - Object.instance_eval{ remove_const :SomeModel } + Object.instance_eval { remove_const :SomeModel } end end diff --git a/spec/ext/nokogiri_spec.rb b/spec/ext/nokogiri_spec.rb index 00072b9..33aa001 100644 --- a/spec/ext/nokogiri_spec.rb +++ b/spec/ext/nokogiri_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'AwesomePrint/Nokogiri' do it 'should colorize tags' do xml = Nokogiri::XML('

') - expect(xml.ai).to eq <<-EOS + expect(xml.ai).to eq <<-EOS \e[1;32m \e[0m<\e[1;36mhtml\e[0m>\e[1;32m \e[0m<\e[1;36mbody\e[0m>\e[1;32m @@ -15,7 +15,7 @@ RSpec.describe 'AwesomePrint/Nokogiri' do it 'should colorize contents' do xml = Nokogiri::XML('

Hello

') - expect(xml.ai).to eq <<-EOS + expect(xml.ai).to eq <<-EOS \e[1;32m \e[0m<\e[1;36mhtml\e[0m>\e[1;32m \e[0m<\e[1;36mbody\e[0m>\e[1;32m @@ -27,7 +27,7 @@ RSpec.describe 'AwesomePrint/Nokogiri' do it 'should colorize class and id' do xml = Nokogiri::XML('

') - expect(xml.ai).to eq <<-EOS + expect(xml.ai).to eq <<-EOS \e[1;32m \e[0m<\e[1;36mhtml\e[0m>\e[1;32m \e[0m<\e[1;36mbody\e[0m>\e[1;32m diff --git a/spec/ext/ripple_spec.rb b/spec/ext/ripple_spec.rb index d69f21e..01eef65 100644 --- a/spec/ext/ripple_spec.rb +++ b/spec/ext/ripple_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe 'AwesomePrint/Ripple', skip: ->{ !ExtVerifier.has_ripple? }.call do +RSpec.describe 'AwesomePrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call do if ExtVerifier.has_ripple? before :all do diff --git a/spec/formats_spec.rb b/spec/formats_spec.rb index dddb83e..9427b44 100644 --- a/spec/formats_spec.rb +++ b/spec/formats_spec.rb @@ -6,7 +6,7 @@ require 'set' RSpec.describe 'AwesomePrint' do describe 'Array' do before do - @arr = [ 1, :two, 'three', [ nil, [ true, false] ] ] + @arr = [1, :two, 'three', [nil, [true, false]]] end it 'empty array' do @@ -127,7 +127,7 @@ EOS #------------------------------------------------------------------------------ describe 'Nested Array' do before do - @arr = [ 1, 2 ] + @arr = [1, 2] @arr << @arr end @@ -384,7 +384,7 @@ EOS #------------------------------------------------------------------------------ describe 'Hash with several keys' do before do - @hash = {'b' => 'b', :a => 'a', :z => 'z', 'alpha' => 'alpha'} + @hash = { 'b' => 'b', :a => 'a', :z => 'z', 'alpha' => 'alpha' } end it 'plain multiline' do @@ -439,7 +439,7 @@ EOS end it 'nested hash keys should be indented (array of hashes)' do - arr = [ { a: 1, bb: 22, ccc: 333}, { 1 => :a, 22 => :bb, 333 => :ccc} ] + arr = [{ a: 1, bb: 22, ccc: 333 }, { 1 => :a, 22 => :bb, 333 => :ccc }] out = arr.ai(plain: true, indent: -4, sort_keys: true) expect(out).to eq <<-EOS.strip [ @@ -458,7 +458,7 @@ EOS end it 'nested hash keys should be indented (hash of hashes)' do - arr = { first: { a: 1, bb: 22, ccc: 333}, second: { 1 => :a, 22 => :bb, 333 => :ccc} } + arr = { first: { a: 1, bb: 22, ccc: 333 }, second: { 1 => :a, 22 => :bb, 333 => :ccc } } out = arr.ai(plain: true, indent: -4, sort_keys: true) expect(out).to eq <<-EOS.strip { @@ -543,7 +543,7 @@ EOS #------------------------------------------------------------------------------ describe 'Set' do before do - @arr = [1, :two, 'three' ] + @arr = [1, :two, 'three'] @set = Set.new(@arr) end @@ -569,19 +569,19 @@ EOS end else # Prior to Ruby 1.9 the order of set values is unpredicatble. it 'plain multiline' do - expect(@set.sort_by{ |x| x.to_s }.ai(plain: true)).to eq(@arr.sort_by{ |x| x.to_s }.ai(plain: true)) + expect(@set.sort_by { |x| x.to_s }.ai(plain: true)).to eq(@arr.sort_by { |x| x.to_s }.ai(plain: true)) end it 'plain multiline indented' do - expect(@set.sort_by{ |x| x.to_s }.ai(plain: true, indent: 1)).to eq(@arr.sort_by{ |x| x.to_s }.ai(plain: true, indent: 1)) + expect(@set.sort_by { |x| x.to_s }.ai(plain: true, indent: 1)).to eq(@arr.sort_by { |x| x.to_s }.ai(plain: true, indent: 1)) end it 'plain single line' do - expect(@set.sort_by{ |x| x.to_s }.ai(plain: true, multiline: false)).to eq(@arr.sort_by{ |x| x.to_s }.ai(plain: true, multiline: false)) + expect(@set.sort_by { |x| x.to_s }.ai(plain: true, multiline: false)).to eq(@arr.sort_by { |x| x.to_s }.ai(plain: true, multiline: false)) end it 'colored multiline (default)' do - expect(@set.sort_by{ |x| x.to_s }.ai).to eq(@arr.sort_by{ |x| x.to_s }.ai) + expect(@set.sort_by { |x| x.to_s }.ai).to eq(@arr.sort_by { |x| x.to_s }.ai) end end end @@ -648,13 +648,13 @@ EOS #------------------------------------------------------------------------------ describe 'Inherited from standard Ruby classes' do after do - Object.instance_eval{ remove_const :My } if defined?(My) + Object.instance_eval { remove_const :My } if defined?(My) end it 'inherited from Array should be displayed as Array' do class My < Array; end - my = My.new([ 1, :two, 'three', [ nil, [ true, false ] ] ]) + my = My.new([1, :two, 'three', [nil, [true, false]]]) expect(my.ai(plain: true)).to eq <<-EOS.strip [ [0] 1, @@ -674,7 +674,7 @@ EOS it 'inherited from Hash should be displayed as Hash' do class My < Hash; end - my = My[ { 1 => { sym: { 'str' => { [1, 2, 3] => { { k: :v } => Hash } } } } } ] + my = My[{ 1 => { sym: { 'str' => { [1, 2, 3] => { { k: :v } => Hash } } } } }] expect(my.ai(plain: true)).to eq <<-EOS.strip { 1 => { diff --git a/spec/methods_spec.rb b/spec/methods_spec.rb index 81eb64b..29db921 100644 --- a/spec/methods_spec.rb +++ b/spec/methods_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' RSpec.describe 'Single method' do after do - Object.instance_eval{ remove_const :Hello } if defined?(Hello) + Object.instance_eval { remove_const :Hello } if defined?(Hello) end it 'plain: should handle a method with no arguments' do @@ -65,7 +65,7 @@ RSpec.describe 'Single method' do it 'color: should handle an unbound method' do class Hello - def world(a,b); end + def world(a, b); end end method = Hello.instance_method(:world) if RUBY_VERSION < '1.9.2' @@ -78,7 +78,7 @@ end RSpec.describe 'Object methods' do after do - Object.instance_eval{ remove_const :Hello } if defined?(Hello) + Object.instance_eval { remove_const :Hello } if defined?(Hello) end describe 'object.methods' do @@ -130,7 +130,7 @@ RSpec.describe 'Object methods' do it 'no index: should handle object.protected_methods' do class Hello protected - def m3(a,b); end + def m3(a, b); end end if RUBY_VERSION < '1.9.2' expect(Hello.new.protected_methods.ai(plain: true, index: false)).to eq("[\n m3(arg1, arg2) Hello\n]") @@ -156,7 +156,7 @@ RSpec.describe 'Object methods' do it 'no index: should handle object.private_methods' do class Hello private - def m3(a,b); end + def m3(a, b); end end out = Hello.new.private_methods.ai(plain: true).split("\n").grep(/m\d/) if RUBY_VERSION < '1.9.2' @@ -182,7 +182,7 @@ RSpec.describe 'Object methods' do it 'no index: should handle object.singleton_methods' do class Hello - def self.m3(a,b); end + def self.m3(a, b); end end out = Hello.singleton_methods.ai(plain: true, index: false).split("\n").grep(/m\d/) if RUBY_VERSION < '1.9.2' @@ -196,7 +196,7 @@ end RSpec.describe 'Class methods' do after do - Object.instance_eval{ remove_const :Hello } if defined?(Hello) + Object.instance_eval { remove_const :Hello } if defined?(Hello) end describe 'class.instance_methods' do @@ -212,7 +212,7 @@ RSpec.describe 'Class methods' do it 'no index: should handle unbound class.instance_methods' do class Hello - def m3(a,b); end + def m3(a, b); end end out = Hello.instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/) if RUBY_VERSION < '1.9.2' @@ -236,7 +236,7 @@ RSpec.describe 'Class methods' do it 'no index: should handle class.public_instance_methods' do class Hello - def m3(a,b); end + def m3(a, b); end end out = Hello.public_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/) if RUBY_VERSION < '1.9.2' @@ -262,7 +262,7 @@ RSpec.describe 'Class methods' do it 'no index: should handle class.protected_instance_methods' do class Hello protected - def m3(a,b); end + def m3(a, b); end end out = Hello.protected_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/) if RUBY_VERSION < '1.9.2' @@ -288,7 +288,7 @@ RSpec.describe 'Class methods' do it 'no index: should handle class.private_instance_methods' do class Hello private - def m3(a,b); end + def m3(a, b); end end out = Hello.private_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/) if RUBY_VERSION < '1.9.2' @@ -307,7 +307,7 @@ if RUBY_VERSION >= '1.9.2' end after do - Object.instance_eval{ remove_const :Hello } if defined?(Hello) + Object.instance_eval { remove_const :Hello } if defined?(Hello) end it '()' do @@ -354,8 +354,8 @@ end RSpec.describe 'Methods arrays' do after do - Object.instance_eval{ remove_const :Hello } if defined?(Hello) - Object.instance_eval{ remove_const :World } if defined?(World) + Object.instance_eval { remove_const :Hello } if defined?(Hello) + Object.instance_eval { remove_const :World } if defined?(World) end it 'obj1.methods - obj2.methods should be awesome printed' do @@ -432,11 +432,11 @@ RSpec.describe 'Methods arrays' do end hello = Hello.new - expect((hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }).to eq([ :him, :his ]) + expect((hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }).to eq([:him, :his]) end it 'appending garbage to methods array should not raise error' do - arr = 42.methods << [ :wtf ] + arr = 42.methods << [:wtf] expect { arr.ai(plain: true) }.not_to raise_error if RUBY_VERSION < '1.9.2' expect(arr.ai(plain: true)).to match(/\s+wtf\(\?\)\s+\?/) # [ :wtf ].to_s => "wtf" diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 5606d43..58d5012 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -87,7 +87,7 @@ RSpec.describe 'AwesomePrint' do end it 'wraps multiline ap output with
 tag with colorized ' do
-      markup = [ 1, :two, 'three' ]
+      markup = [1, :two, 'three']
       expect(markup.ai(html: true)).to eq <<-EOS.strip_heredoc.strip
         
[
             [0] 1,
@@ -98,7 +98,7 @@ RSpec.describe 'AwesomePrint' do
     end
 
     it 'wraps hash ap output with only an outer 
 tag' do
-      markup = [ { 'hello' => 'world' } ]
+      markup = [{ 'hello' => 'world' }]
       expect(markup.ai(html: true)).to eq <<-EOS.strip_heredoc.strip
         
[
             [0] {
@@ -191,7 +191,7 @@ RSpec.describe 'AwesomePrint' do
       ENV.delete('RAILS_ENV')
       expect(AwesomePrint.console?).to eq(true)
       expect(AwesomePrint.rails_console?).to eq(false)
-      Object.instance_eval{ remove_const :IRB }
+      Object.instance_eval { remove_const :IRB }
     end
 
     it 'should detect Pry' do
@@ -199,7 +199,7 @@ RSpec.describe 'AwesomePrint' do
       ENV.delete('RAILS_ENV')
       expect(AwesomePrint.console?).to eq(true)
       expect(AwesomePrint.rails_console?).to eq(false)
-      Object.instance_eval{ remove_const :Pry }
+      Object.instance_eval { remove_const :Pry }
     end
 
     it 'should detect Rails::Console' do
@@ -207,8 +207,8 @@ RSpec.describe 'AwesomePrint' do
       module Rails; class Console; end; end
       expect(AwesomePrint.console?).to eq(true)
       expect(AwesomePrint.rails_console?).to eq(true)
-      Object.instance_eval{ remove_const :IRB }
-      Object.instance_eval{ remove_const :Rails }
+      Object.instance_eval { remove_const :IRB }
+      Object.instance_eval { remove_const :Rails }
     end
 
     it "should detect ENV['RAILS_ENV']" do
@@ -216,19 +216,19 @@ RSpec.describe 'AwesomePrint' do
       ENV['RAILS_ENV'] = 'development'
       expect(AwesomePrint.console?).to eq(true)
       expect(AwesomePrint.rails_console?).to eq(true)
-      Object.instance_eval{ remove_const :Pry }
+      Object.instance_eval { remove_const :Pry }
     end
 
     it 'should return the actual object when *not* running under console' do
-      expect(capture! { ap([ 1, 2, 3 ]) }).to eq([ 1, 2, 3 ])
+      expect(capture! { ap([1, 2, 3]) }).to eq([1, 2, 3])
       expect(capture! { ap({ a: 1 }) }).to eq({ a: 1 })
     end
 
     it 'should return nil when running under console' do
       class IRB; end
-      expect(capture! { ap([ 1, 2, 3 ]) }).to eq(nil)
+      expect(capture! { ap([1, 2, 3]) }).to eq(nil)
       expect(capture! { ap({ a: 1 }) }).to eq(nil)
-      Object.instance_eval{ remove_const :IRB }
+      Object.instance_eval { remove_const :IRB }
     end
 
     it 'handles NoMethodError on IRB implicit #ai' do
diff --git a/spec/objects_spec.rb b/spec/objects_spec.rb
index 8ea411f..fd5e534 100644
--- a/spec/objects_spec.rb
+++ b/spec/objects_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
 
 RSpec.describe 'Objects' do
   after do
-    Object.instance_eval{ remove_const :Hello } if defined?(Hello)
+    Object.instance_eval { remove_const :Hello } if defined?(Hello)
   end
 
   describe 'Formatting an object' do