diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ecac63ae2..ce6c419db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] # 3.0 is interpreted as 3 - ruby: ["3.0", 3.1, 3.2, 3.3, 3.4] + ruby: ["3.0", 3.1, 3.2, 3.3, 3.4, "4.0"] include: - os: ubuntu-latest container: ruby:2.2 diff --git a/Gemfile b/Gemfile index 1048c3434..771068f7e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,12 @@ source 'https://rubygems.org' group :development do + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0') + gem 'benchmark' + gem 'irb' + gem 'logger' + gem 'ostruct' + end gem 'rspec', '>= 3.11.0' gem 'rake' gem 'rdoc', '= 6.1.2.1' diff --git a/lib/yard/rubygems/specification.rb b/lib/yard/rubygems/specification.rb index 905ba067a..1701ce046 100644 --- a/lib/yard/rubygems/specification.rb +++ b/lib/yard/rubygems/specification.rb @@ -11,7 +11,7 @@ def has_yardoc @has_rdoc == 'yard' end - undef has_rdoc? + undef has_rdoc? if method_defined?(:has_rdoc?) def has_rdoc? (@has_rdoc ||= true) && @has_rdoc != 'yard' end diff --git a/spec/handlers/ruby/base_spec.rb b/spec/handlers/ruby/base_spec.rb index 3121bf801..20871281f 100644 --- a/spec/handlers/ruby/base_spec.rb +++ b/spec/handlers/ruby/base_spec.rb @@ -37,7 +37,7 @@ class StringHandler < Handlers::Ruby::Base handles "x" end allow(Handlers::Base).to receive(:subclasses).and_return [StringHandler] - ast = Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast + ast = YARD::Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast valid StringHandler, ast[0][0][0] invalid StringHandler, ast[0][1] end @@ -56,7 +56,7 @@ class RegexHandler < Handlers::Ruby::Base handles(/^if x ==/) end allow(Handlers::Base).to receive(:subclasses).and_return [RegexHandler] - ast = Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast + ast = YARD::Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast valid RegexHandler, ast invalid RegexHandler, ast[0][1] end @@ -75,7 +75,7 @@ class MethCallHandler < Handlers::Ruby::Base handles method_call(:meth) end allow(Handlers::Base).to receive(:subclasses).and_return [MethCallHandler] - ast = Parser::Ruby::RubyParser.parse(<<-"eof").ast + ast = YARD::Parser::Ruby::RubyParser.parse(<<-"eof").ast meth # 0 meth() # 1 meth(1,2,3) # 2 diff --git a/yard.gemspec b/yard.gemspec index fa43eff9b..81831c81b 100644 --- a/yard.gemspec +++ b/yard.gemspec @@ -20,4 +20,8 @@ Gem::Specification.new do |s| s.executables = ['yard', 'yardoc', 'yri'] s.license = 'MIT' if s.respond_to?(:license=) s.metadata['yard.run'] = 'yri' + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('4.0.0') + s.add_dependency 'irb' + s.add_dependency 'logger' + end end