Skip to content

Commit

Permalink
Merge pull request #1 from ydah/support-ruby25
Browse files Browse the repository at this point in the history
Support Ruby 2.5 ~ 3.4
  • Loading branch information
ydah authored Feb 1, 2025
2 parents fe2986d + ce401d0 commit 094f400
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 19 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ on:
push:
branches:
- main

pull_request:

jobs:
build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
ruby-versions:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
engine: cruby
min_version: 2.5
test:
needs: ruby-versions
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
ruby:
- '3.4'

ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake
- run: exe/railroad_diagrams --format=svg
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/choice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def text_diagram
else
[]
end
diagram_td = diagram_td.append_below(item_td, separator, move_entry:, move_exit:)
diagram_td = diagram_td.append_below(item_td, separator, move_entry: move_entry, move_exit: move_exit)
end
diagram_td
end
Expand Down
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def format(x, y, _width)
text: @text
)
if @href
a = DiagramItem.new('a', attrs: { 'xlink:href' => @href }, text:).add(self)
a = DiagramItem.new('a', attrs: { 'xlink:href' => @href }, text: text).add(self)
text.add(a)
else
text.add(self)
Expand Down
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/diagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def format(padding_top = 20, padding_right = nil, padding_bottom = nil, padding_
def text_diagram
separator, = TextDiagram.get_parts(['separator'])
diagram_td = @items[0].text_diagram
@items[1..].each do |item|
@items[1..-1].each do |item|
item_td = item.text_diagram
item_td.expand(1, 1, 0, 0) if item.needs_space
diagram_td = diagram_td.append_right(separator)
Expand Down
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/diagram_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def write_svg(write)
write.call(" #{name}=\"#{RailroadDiagrams.escape_attr(value)}\"")
end
write.call('>')
write.call("\n") if @name in %w[g svg]
write.call("\n") if %w[g svg].include?(@name)
@children.each do |child|
if child.is_a?(DiagramItem) || child.is_a?(Path) || child.is_a?(Style)
child.write_svg(write)
Expand Down
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/diagram_multi_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RailroadDiagrams
class DiagramMultiContainer < DiagramItem
def initialize(name, items, attrs = nil, text = nil)
super(name, attrs:, text:)
super(name, attrs: attrs, text: text)
@items = items.map { |item| wrap_string(item) }
end

Expand Down
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/horizontal_choice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def format(x, y, width)

# lower track
lower_span =
@items[1..].sum { |item| item.width + (item.needs_space ? 20 : 0) } +
@items[1..-1].sum { |item| item.width + (item.needs_space ? 20 : 0) } +
((@items.size - 2) * AR * 2) +
(last.height.positive? ? AR : 0) -
AR
Expand Down
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/multiple_choice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def format(x, y, width)
Path.new(x + 30 + AR + @inner_width, y + @height).right(AR).add(self)

# Do the elements that curve below
below = @items[(@default + 1)..] || []
below = @items[(@default + 1)..-1] || []
distance_from_y = [10 + AR, default.height + default.down + VS + below.first.up].max if below.any?

below.each_with_index do |item, i|
Expand Down
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/non_terminal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def format(x, y, width)
attrs: {
'xlink:href' => @href
},
text:
text: text
).add(self)
text.add(a)
else
Expand Down
2 changes: 1 addition & 1 deletion lib/railroad_diagrams/terminal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def format(x, y, width)
text: @text
)
if @href
a = DiagramItem.new('a', attrs: { 'xlink:href' => @href }, text:).add(self)
a = DiagramItem.new('a', attrs: { 'xlink:href' => @href }, text: text).add(self)
text.add(a)
else
text.add(self)
Expand Down
2 changes: 1 addition & 1 deletion railroad_diagrams.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.description = 'Generate SVG railroad syntax diagrams, like on JSON.org.'
spec.homepage = "https://github.com/ydah/railroad_diagrams"
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.1.0'
spec.required_ruby_version = '>= 2.5.0'

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
Expand Down

0 comments on commit 094f400

Please sign in to comment.