Skip to content

Commit

Permalink
Merge pull request #79 from hackclub/fix-tests-for-ruby-3
Browse files Browse the repository at this point in the history
Add ruby 3.1 / 3.2 to test matrix + fix failing GH action tests for 2.6 / 2.7
  • Loading branch information
jasonlong authored Apr 5, 2023
2 parents 47fed7f + ab53719 commit c243dc9
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: [2.6, 2.7, '3.0', head]
ruby: [2.6, 2.7, '3.0', 3.1, 3.2, head]

runs-on: ubuntu-latest

Expand All @@ -23,6 +23,7 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
rubygems: latest
bundler-cache: true

- name: Run tests
Expand Down
1 change: 0 additions & 1 deletion geo_pattern.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Gem::Specification.new do |spec|

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.required_ruby_version = ">= 2.6"
Expand Down
2 changes: 1 addition & 1 deletion lib/geo_pattern/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module GeoPattern
module Helpers
def require_files_matching_pattern(pattern)
Dir.glob(pattern).each { |f| require_relative f }
Dir.glob(pattern).sort.each { |f| require_relative f }
end

# Makes an underscored, lowercase form from the expression in the string.
Expand Down
4 changes: 2 additions & 2 deletions lib/geo_pattern/structure_generators/chevrons_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
6 changes: 3 additions & 3 deletions lib/geo_pattern/structure_generators/diamonds_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand All @@ -31,7 +31,7 @@ def generate_structure
"stroke-opacity" => stroke_opacity
}

dx = y % 2 == 0 ? 0 : diamond_width / 2
dx = (y % 2 == 0) ? 0 : diamond_width / 2

svg.polyline(diamond, styles.merge(
"transform" => "translate(#{x * diamond_width - diamond_width / 2 + dx}, #{diamond_height / 2 * y - diamond_height / 2})"
Expand Down
8 changes: 4 additions & 4 deletions lib/geo_pattern/structure_generators/hexagons_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
dy = x % 2 == 0 ? y * hex_height : y * hex_height + hex_height / 2
dy = (x % 2 == 0) ? y * hex_height : y * hex_height + hex_height / 2
opacity = opacity(val)
fill = fill_color(val)

Expand All @@ -43,7 +43,7 @@ def generate_structure

# Add an extra row at the end that matches the first row, for tiling.
if y == 0
dy = x % 2 == 0 ? 6 * hex_height : 6 * hex_height + hex_height / 2
dy = (x % 2 == 0) ? 6 * hex_height : 6 * hex_height + hex_height / 2
svg.polyline(hex, styles.merge("transform" => "translate(#{x * side_length * 1.5 - hex_width / 2}, #{dy - hex_height / 2})"))
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def after_initialize

def generate_structure
i = 0
(0..3).each do |y|
(0..3).each do |x|
4.times do |y|
4.times do |x|
if x.even?
if y.even?
draw_outer_mosaic_tile(x * triangle_size * 2, y * triangle_size * 2, triangle_size, hex_val(i, 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
4 changes: 2 additions & 2 deletions lib/geo_pattern/structure_generators/octagons_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
6 changes: 3 additions & 3 deletions lib/geo_pattern/structure_generators/plus_signs_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
dx = y % 2 == 0 ? 0 : 1
dx = (y % 2 == 0) ? 0 : 1

styles = {
"fill" => fill,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def after_initialize
end

def generate_structure
(0..35).each do |i|
36.times do |i|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
4 changes: 2 additions & 2 deletions lib/geo_pattern/structure_generators/squares_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def after_initialize
end

def generate_structure
(0..19).each do |i|
20.times do |i|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand Down
8 changes: 4 additions & 4 deletions lib/geo_pattern/structure_generators/triangles_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
fill = fill_color(val)
Expand All @@ -33,9 +33,9 @@ def generate_structure
}

rotation = if y % 2 == 0
x % 2 == 0 ? 180 : 0
(x % 2 == 0) ? 180 : 0
else
x % 2 != 0 ? 180 : 0
(x % 2 != 0) ? 180 : 0
end

svg.polyline(triangle, styles.merge(
Expand Down
8 changes: 4 additions & 4 deletions lib/geo_pattern/structure_generators/xes_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def after_initialize

def generate_structure
i = 0
(0..5).each do |y|
(0..5).each do |x|
6.times do |y|
6.times do |x|
val = hex_val(i, 1)
opacity = opacity(val)
dy = x % 2 == 0 ? y * x_size - x_size * 0.5 : y * x_size - x_size * 0.5 + x_size / 4
dy = (x % 2 == 0) ? y * x_size - x_size * 0.5 : y * x_size - x_size * 0.5 + x_size / 4
fill = fill_color(val)

styles = {
Expand All @@ -44,7 +44,7 @@ def generate_structure

# Add an extra row on the bottom that matches the first row, for tiling.
if y == 0
dy = x % 2 == 0 ? 6 * x_size - x_size / 2 : 6 * x_size - x_size / 2 + x_size / 4
dy = (x % 2 == 0) ? 6 * x_size - x_size / 2 : 6 * x_size - x_size / 2 + x_size / 4
svg.group(x_shape, styles.merge(
"transform" => "translate(#{x * x_size / 2 - x_size / 2},#{dy - 6 * x_size / 2}) rotate(45, #{x_size / 2}, #{x_size / 2})"
))
Expand Down
2 changes: 1 addition & 1 deletion spec/pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let(:background_body) { %(<rect x="0" y="0" width="100%" height="100%" fill="rgb(121, 131, 76)" />) }
let(:structure) { instance_double("GeoPattern::Structure") }
let(:structure_image) { instance_double("GeoPattern::SvgImage") }
let(:structure_body) { %(<path d=\"M0 53 C 28.0 0, 52.0 0, 80 53 S 132.0 106, 160 53 S 212.0 0, 240.0, 53\" fill=\"none\" stroke=\"#222\" style=\"opacity:0.046;stroke-width:6px;\" transform=\"translate(-40, -79.5)\" />) }
let(:structure_body) { %(<path d="M0 53 C 28.0 0, 52.0 0, 80 53 S 132.0 106, 160 53 S 212.0 0, 240.0, 53" fill="none" stroke="#222" style="opacity:0.046;stroke-width:6px;" transform="translate(-40, -79.5)" />) }

it { expect(pattern).not_to be_nil }

Expand Down

0 comments on commit c243dc9

Please sign in to comment.