Skip to content

Commit

Permalink
Merge pull request #1364 from lsegal/ruby3
Browse files Browse the repository at this point in the history
Add support for Ruby 3.0
  • Loading branch information
lsegal authored Dec 26, 2020
2 parents ea35d60 + e38755d commit 7fca83b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,14 @@ jobs:
bundle exec rake
env:
CI: true
build_ruby3:
name: "Ruby: 3.0 OS: Linux"
container: ruby:3.0-rc-alpine
steps:
- uses: actions/checkout@v2
- run: apk add -U build-base
- run: gem update --system --no-document --conservative
- run: bundle install --jobs=3 --retry=3
- run: ruby -v && bundle exec rake
env:
CI: true
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ group :development do
gem 'simplecov'
gem 'samus', '~> 3.0.9', :require => false
gem 'coveralls', :require => false
gem 'webrick'
end

group :asciidoc do
Expand Down
4 changes: 1 addition & 3 deletions lib/yard/templates/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def dup

def [](*args)
if args.first.is_a?(Range) || args.size > 1
obj = super(*args)
obj.name = name
return obj
return self.class.new(name, *super(*args))
elsif args.first.is_a?(Integer)
return super(*args)
end
Expand Down
1 change: 1 addition & 0 deletions rbs
Submodule rbs added at 4e5ee8
11 changes: 11 additions & 0 deletions spec/parser/ruby/ruby_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -539,5 +539,16 @@ class B
is_expected.to eq "#{condition_type} condition?; 42; end"
end
end

it "handles single-line method declaration syntax" do
YARD.parse_string <<-eof
class A
# Adds two numbers
def add(x) = x + 1
end
eof

expect(Registry.at('A#add').docstring).to eq('Adds two numbers')
end if RUBY_VERSION >= '3.'
end
end if HAVE_RIPPER
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,5 @@ def puts(str = '')
Kernel.srand config.seed
end

YARD::Logger
include YARD
15 changes: 5 additions & 10 deletions spec/templates/helpers/html_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,22 @@ def options
end

describe "#charset" do
after { Encoding.default_external = 'utf-8' if defined?(Encoding) }

it "returns foo if LANG=foo" do
expect(ENV).to receive(:[]).with('LANG').and_return('shift_jis') if YARD.ruby18?
expect(Encoding.default_external).to receive(:name).and_return('shift_jis') if defined?(Encoding)
Encoding.default_external = 'shift_jis' if defined?(Encoding)
expect(charset).to eq 'shift_jis'
end

['US-ASCII', 'ASCII-7BIT', 'ASCII-8BIT'].each do |type|
['US-ASCII', 'binary', 'ASCII-8BIT'].each do |type|
it "converts #{type} to iso-8859-1" do
expect(ENV).to receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
expect(Encoding.default_external).to receive(:name).and_return(type) if defined?(Encoding)
Encoding.default_external = type if defined?(Encoding)
expect(charset).to eq 'iso-8859-1'
end
end

it "supports utf8 as an encoding value for utf-8" do
type = 'utf8'
expect(ENV).to receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
expect(Encoding.default_external).to receive(:name).and_return(type) if defined?(Encoding)
expect(charset).to eq 'utf-8'
end

it "takes file encoding if there is a file" do
@file = OpenStruct.new(:contents => String.new('foo').force_encoding('sjis'))
# not the correct charset name, but good enough
Expand Down
1 change: 1 addition & 0 deletions yard-rbs-core
Submodule yard-rbs-core added at 7d9654

0 comments on commit 7fca83b

Please sign in to comment.