Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
HarlemSquirrel authored Dec 19, 2024
2 parents e90b31a + 3472f78 commit 2aa9252
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: 3.3
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Lint files with Rubocop
run: |
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ jobs:
os:
- ubuntu
ruby:
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
- "head"
- "jruby-9.3"
- "jruby-9.4"
runs-on: ${{ matrix.os }}-latest
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inherit_from: .rubocop_todo.yml

AllCops:
NewCops: enable
TargetRubyVersion: 2.5
TargetRubyVersion: 3.0

Lint/RaiseException:
Enabled: true
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git', branch: :ma

gem 'bigdecimal'
gem 'fakefs', '~> 1.2'
gem 'nokogiri', '~> 1.10'
gem 'nokogiri', '~> 1.16.7'
gem 'pry'
gem 'rspec', '~> 3.9'
gem 'rubocop', '~> 1.20'
Expand Down
4 changes: 2 additions & 2 deletions amazing_print.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require 'amazing_print/version'
Gem::Specification.new do |s|
s.name = 'amazing_print'
s.version = AmazingPrint.version
s.required_ruby_version = '>= 2.5.0'
s.required_ruby_version = '>= 3.0.0'
s.authors = ['Michael Dvorkin', 'Kevin McCormack' 'Patrik Wenger']
s.email = '[email protected]'
s.homepage = 'https://github.com/amazing-print/amazing_print'
Expand All @@ -24,7 +24,7 @@ Gem::Specification.new do |s|
"changelog_uri" => "https://github.com/amazing-print/amazing_print/blob/master/CHANGELOG.md"
}

s.files = Dir['[A-Z]*[^~]'] + Dir['lib/**/*.rb'] + Dir['spec/**/*'] + ['.gitignore']
s.files = Dir['lib/**/*', 'rails/*', 'CHANGELOG.md', 'CONTRIBUTING.md', 'README.md']
s.executables = []
s.require_paths = ['lib']
end
3 changes: 0 additions & 3 deletions init.rb

This file was deleted.

4 changes: 2 additions & 2 deletions lib/amazing_print/ext/nobrainer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def cast_with_nobrainer(object, type)
#------------------------------------------------------------------------------
def awesome_nobrainer_class(object)
name = "#{awesome_simple(object, :class)} < #{awesome_simple(object.superclass, :class)}"
data = object.fields.map do |field, options|
data = object.fields.to_h do |field, options|
[field, (options[:type] || Object).to_s.underscore.to_sym]
end.to_h
end

name = "class #{awesome_simple(object.to_s, :class)}"
base = "< #{awesome_simple(object.superclass.to_s, :class)}"
Expand Down
8 changes: 4 additions & 4 deletions lib/amazing_print/formatters/mswin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def initialize(fname)
def mode
r = ['-'] * 6
r[0] = 'd' if @stat.directory?
r[1] = 'a' unless (@attrs & FILE_ATTRIBUTE_ARCHIVE).zero?
r[2] = 'r' unless (@attrs & FILE_ATTRIBUTE_READONLY).zero?
r[3] = 'h' unless (@attrs & FILE_ATTRIBUTE_HIDDEN).zero?
r[4] = 's' unless (@attrs & FILE_ATTRIBUTE_SYSTEM).zero?
r[1] = 'a' unless @attrs.nobits?(FILE_ATTRIBUTE_ARCHIVE)
r[2] = 'r' unless @attrs.nobits?(FILE_ATTRIBUTE_READONLY)
r[3] = 'h' unless @attrs.nobits?(FILE_ATTRIBUTE_HIDDEN)
r[4] = 's' unless @attrs.nobits?(FILE_ATTRIBUTE_SYSTEM)
r[5] = 'l' if File.symlink? @fname
r.join
end
Expand Down
2 changes: 1 addition & 1 deletion lib/amazing_print/formatters/object_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(object, inspector)

def format
vars = variables.map do |var|
property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
property = var.to_s[1..].to_sym # to_s because of some monkey patching done by Puppet.
accessor = if object.respond_to?(:"#{property}=")
object.respond_to?(property) ? :accessor : :writer
else
Expand Down
2 changes: 1 addition & 1 deletion lib/amazing_print/formatters/struct_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(struct, inspector)

def format
vars = variables.map do |var|
property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
property = var.to_s[1..].to_sym # to_s because of some monkey patching done by Puppet.
accessor = if struct.respond_to?(:"#{property}=")
struct.respond_to?(property) ? :accessor : :writer
else
Expand Down
11 changes: 0 additions & 11 deletions rails/init.rb

This file was deleted.

4 changes: 2 additions & 2 deletions spec/core_ext/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

RSpec.describe 'AmazingPrint logging extensions' do
subject(:logger) do
Logger.new('/dev/null')
Logger.new(File::NULL)
rescue Errno::ENOENT
Logger.new('nul')
Logger.new(File::NULL)
end

let(:object) { double }
Expand Down
10 changes: 5 additions & 5 deletions spec/ext/active_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
ActiveRecordData.raw_3_2_diana
end

if RUBY_PLATFORM == 'java' && !activerecord_6_1?
if RUBY_PLATFORM == 'java' && !activerecord_6_1? && !activerecord_7_0?
raw_object_string.gsub!(
'ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer',
'ArJdbc::SQLite3::SQLite3Integer'
Expand Down Expand Up @@ -172,7 +172,7 @@
ActiveRecordData.raw_3_2_multi
end

if RUBY_PLATFORM == 'java' && !activerecord_6_1?
if RUBY_PLATFORM == 'java' && !activerecord_6_1? && !activerecord_7_0?
raw_object_string.gsub!(
'ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer',
'ArJdbc::SQLite3::SQLite3Integer'
Expand Down Expand Up @@ -238,7 +238,7 @@ class SubUser < User {
if ActiveRecord::VERSION::STRING >= '3.2'
if RUBY_PLATFORM == 'java'
expect(out).to match(
/\s+first\(\*args,\s&block\)\s+#<Class:\w+>\s+\(ActiveRecord::Querying\)/
/\s+first\(\*\*,\s\?, &&\)\s+#</
)
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0')
expect(out).to match(
Expand Down Expand Up @@ -267,7 +267,7 @@ class SubUser < User {
out = @ap.awesome(User.methods.grep(/primary_key/))
if RUBY_PLATFORM == 'java'
expect(out).to match(
/\sprimary_key\(.*?\)\s+#<Class:\w+>\s\(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/
/\sprimary_key\(\)\s+#</
)
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
expect(out).to match(/\sprimary_key\(.*?\)\s+#<Class:User> \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
Expand All @@ -287,7 +287,7 @@ class SubUser < User {
if ActiveRecord::VERSION::MAJOR < 3
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
elsif RUBY_PLATFORM == 'java'
expect(out).to match(/\svalidate\(\*arg.*?\)\s+#<Class:\w+> \(ActiveModel::Validations::ClassMethods\)/)
expect(out).to match(/\svalidate\(\*args, &block\)\s+#</)
elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
expect(out).to match(/\svalidate\(\*arg.*?\)\s+#<Class:User> \(ActiveModel::Validations::ClassMethods\)/)
elsif (Gem::Version.new('2.6.7')..Gem::Version.new('2.7.1')).cover? Gem::Version.new(RUBY_VERSION)
Expand Down
6 changes: 3 additions & 3 deletions spec/formats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -691,16 +691,16 @@ class My < Hash; end
class My < File; end

my = begin
File.new('/dev/null')
File.new(File::NULL)
rescue StandardError
File.new('nul')
File.new(File::NULL)
end
expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + `ls -alF #{my.path}`.chop)
end

it 'inherited from File should be displayed as File', :mswin do
class My < File; end
my = My.new('nul') # it's /dev/null in Windows
my = My.new(File::NULL) # it's /dev/null in Windows
expect(my.ai(plain: true)).to eq("#{my.inspect}\n" + AmazingPrint::Formatters::GetChildItem.new(my.path).to_s)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each do |file|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each do |file|
require file
end

Expand Down

0 comments on commit 2aa9252

Please sign in to comment.