Skip to content

Commit 82708c0

Browse files
Get Github actions working
* fix duplicate variable * Create rubocop.yml * Satisfy some more rubocops * Fix trailing whitespace * Update README.md * Create YARD action * fix yard action * fix yard action * try this * remove yard from gemfile * Add a commit change action * Try to properly set up yard commiting * Remove step * use new checkout * Generate new YARD docs * Create YARD badge Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 4ee5279 commit 82708c0

14 files changed

+315
-170
lines changed

.github/workflows/yard.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# .github/workflows/rubocop.yml
2+
3+
name: YARD
4+
5+
on: [push, pull_request]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up Ruby 3.0.2
14+
uses: actions/setup-ruby@v1
15+
with:
16+
ruby-version: 3.0.2 # Replace with your ruby version
17+
- name: Gems Cache
18+
id: gem-cache
19+
uses: actions/cache@v1
20+
with:
21+
path: vendor/bundle
22+
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
23+
restore-keys: |
24+
${{ runner.os }}-gem-
25+
- name: Add YARD
26+
run: bundle add yard
27+
- name: Install
28+
run: bundle install
29+
- name: Run Yard
30+
run: yard doc -m markdown -o docs --exclude app/main.rb
31+
- uses: EndBug/add-and-commit@v7 # You can change this to use a specific version.
32+
with:
33+
# The arguments for the `git add` command (see the paragraph below for more info)
34+
# Default: '.'
35+
add: '*'
36+
37+
# The name of the custom committer you want to use, if different from the author of the commit.
38+
# Default: the name of the author (set with either author_name or default_author)
39+
committer_name: GitHub Actions
40+
41+
# The email of the custom committer you want to use, if different from the author of the commit.
42+
# Default: the email of the author (set with either author_email or default_author)
43+
committer_email: actions@github.com
44+
45+
# The local path to the directory where your repository is located. You should use actions/checkout first to set it up.
46+
# Default: '.'
47+
cwd: '.'
48+
49+
# Determines the way the action fills missing author name and email. Three options are available:
50+
# - github_actor -> UserName <UserName@users.noreply.github.com>
51+
# - user_info -> Your Display Name <your-actual@email.com>
52+
# - github_actions -> github-actions <email associated with the github logo>
53+
# Default: github_actor
54+
default_author: github_actions
55+
56+
# The message for the commit.
57+
# Default: 'Commit from GitHub Actions (name of the workflow)'
58+
message: 'Generate new YARD docs'
59+
60+
# The way the action should handle pathspec errors from the add and remove commands. Three options are available:
61+
# - ignore -> errors will be logged but the step won't fail
62+
# - exitImmediately -> the action will stop right away, and the step will fail
63+
# - exitAtEnd -> the action will go on, every pathspec error will be logged at the end, the step will fail.
64+
# Default: ignore
65+
pathspec_error_handling: ignore
66+
67+
# Arguments for the git pull command. Use NO-PULL to avoid the action pulling at all.
68+
# Default: '--no-rebase'
69+
pull: '--no-rebase'
70+
71+
# Whether to push the commit and, if any, its tags to the repo. It can also be used to set the git push arguments (see the paragraph below for more info)
72+
# Default: true
73+
push: true
74+
75+
# The arguments for the `git rm` command (see the paragraph below for more info)
76+
# Default: ''
77+
remove: ''
78+
79+
# Whether to use the --signoff option on `git commit` (only boolean values accepted*)
80+
# Default: false
81+
signoff: false
82+
83+
# Arguments for the git tag command (the tag name always needs to be the first word not preceded by an hyphen)
84+
# Default: ''
85+
tag: ''
86+

.rubocop.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
AllCops:
2+
Exclude:
3+
- 'app/main.rb'
4+
- Gemfile
5+
- Gemfile.lock
6+
7+
Layout/LineLength:
8+
Max: 150
9+
10+
Metrics/MethodLength:
11+
Max: 15
12+
13+
Style/GlobalVars:
14+
Enabled: false

.yardoc/checksums

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
app/lib/dinraal.rb e9fb7ef8f9f578b857e2aaa1f50011118a36f878

.yardoc/complete

Whitespace-only changes.

.yardoc/object_types

389 Bytes
Binary file not shown.

.yardoc/objects/root.dat

14.8 KB
Binary file not shown.

.yardoc/proxy_types

4 Bytes
Binary file not shown.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# dinraal
22

3-
[![Ruby - Rubocop](https://github.com/DSchaedler/dinraal/actions/workflows/rubocop.yml/badge.svg?branch=main)](https://github.com/DSchaedler/dinraal/actions/workflows/rubocop.yml)[![YARD](https://github.com/DSchaedler/dinraal/actions/workflows/yard.yml/badge.svg)](https://github.com/DSchaedler/dinraal/actions/workflows/yard.yml)
3+
[![Ruby - Rubocop](https://github.com/DSchaedler/dinraal/actions/workflows/rubocop.yml/badge.svg)](https://github.com/DSchaedler/dinraal/actions/workflows/rubocop.yml)[![YARD](https://github.com/DSchaedler/dinraal/actions/workflows/yard.yml/badge.svg)](https://github.com/DSchaedler/dinraal/actions/workflows/yard.yml)
44

55
Dinraal is a library for working with shapes in DragonRuby Game Toolkit. By default, DRGTK does not support rendering or working with any shapes outside of rectangles. Until now, other shapes have been provided by sprites.
66

app/lib/dinraal.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Module provides some Triangle generation and manipulation methods to DragonRuby Game Toolkit.
24
# By D Schaedler. Released under MIT License.
35
# https://github.com/DSchaedler/dinraal
@@ -130,7 +132,7 @@ def point_inside_triangle?(point:, triangle:)
130132
y3 = triangle[:y3]
131133

132134
triangle = [[x, y], [x2, y2], [x3, y3]]
133-
triangle = triangle.sort_by { |point| point[1] }
135+
triangle = triangle.sort_by { |sort_point| sort_point[1] }
134136
triangle = triangle.reverse
135137

136138
leg0 = [triangle[0], triangle[1]]
@@ -293,17 +295,24 @@ def triangle_raster(options = {})
293295

294296
def rectangle_inside_triangle?(rectangle:, triangle:)
295297
return false unless point_inside_triangle?(point: { x: rectangle[:x], y: rectangle[:y] }, triangle: triangle)
298+
296299
return false unless point_inside_triangle?(point: { x: rectangle[:x] + rectangle[:w], y: rectangle[:y] }, triangle: triangle)
300+
297301
return false unless point_inside_triangle?(point: { x: rectangle[:x], y: rectangle[:y] + rectangle[:h] }, triangle: triangle)
302+
298303
return false unless point_inside_triangle?(point: { x: rectangle[:x] + rectangle[:w], y: rectangle[:y] + rectangle[:h] }, triangle: triangle)
304+
299305
true
300306
end
301307

302308
def triangle_inside_triangle?(inner:, outer:)
303309
# Return true if tri1 is contained by tri2
304310
return false unless point_inside_triangle?(point: { x: inner[:x], y: inner[:y] }, triangle: outer)
311+
305312
return false unless point_inside_triangle?(point: { x: inner[:x2], y: inner[:y2] }, triangle: outer)
313+
306314
return false unless point_inside_triangle?(point: { x: inner[:x3], y: inner[:y3] }, triangle: outer)
315+
307316
true
308317
end
309318
end

0 commit comments

Comments
 (0)