Skip to content

Commit

Permalink
Modernize gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Sep 11, 2024
1 parent 7adeff4 commit b060d36
Show file tree
Hide file tree
Showing 23 changed files with 186 additions and 76 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/documentation-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Documentation Coverage

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm
COVERAGE: PartialSummary

jobs:
validate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true

- name: Validate coverage
timeout-minutes: 5
run: bundle exec bake decode:index:coverage lib
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: bundle exec bake utopia:project:static --force no

- name: Upload documentation artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: docs

Expand All @@ -55,4 +55,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
uses: actions/deploy-pages@v4
24 changes: 24 additions & 0 deletions .github/workflows/rubocop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: RuboCop

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true

- name: Run RuboCop
timeout-minutes: 10
run: bundle exec rubocop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Coverage
name: Test Coverage

on: [push, pull_request]

Expand Down Expand Up @@ -33,8 +33,8 @@ jobs:
- name: Run tests
timeout-minutes: 5
run: bundle exec bake test

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: coverage-${{matrix.os}}-${{matrix.ruby}}
path: .covered.db
Expand All @@ -50,7 +50,7 @@ jobs:
ruby-version: "3.3"
bundler-cache: true

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4

- name: Validate coverage
timeout-minutes: 5
Expand Down
53 changes: 53 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
AllCops:
DisabledByDefault: true

Layout/IndentationStyle:
Enabled: true
EnforcedStyle: tabs

Layout/InitialIndentation:
Enabled: true

Layout/IndentationWidth:
Enabled: true
Width: 1

Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: normal

Layout/BlockAlignment:
Enabled: true

Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line

Layout/BeginEndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line

Layout/ElseAlignment:
Enabled: true

Layout/DefEndAlignment:
Enabled: true

Layout/CaseIndentation:
Enabled: true

Layout/CommentIndentation:
Enabled: true

Layout/EmptyLinesAroundClassBody:
Enabled: true

Layout/EmptyLinesAroundModuleBody:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
2 changes: 1 addition & 1 deletion config/sus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

require 'covered/sus'
require "covered/sus"
include Covered::Sus
4 changes: 3 additions & 1 deletion gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2023-2024, by Samuel Williams.

source 'https://rubygems.org'
source "https://rubygems.org"

gemspec

Expand All @@ -17,6 +17,8 @@
group :test do
gem "sus"
gem "covered"
gem "decode"
gem "rubocop"

gem "bake-test"
gem "bake-test-external"
Expand Down
6 changes: 3 additions & 3 deletions io-stream.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
spec.authors = ["Samuel Williams"]
spec.license = "MIT"

spec.cert_chain = ['release.cert']
spec.signing_key = File.expand_path('~/.gem/release.pem')
spec.cert_chain = ["release.cert"]
spec.signing_key = File.expand_path("~/.gem/release.pem")

spec.homepage = "https://github.com/socketry/io-stream"

Expand All @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
"source_code_uri" => "https://github.com/socketry/io-stream.git",
}

spec.files = Dir.glob(['{lib}/**/*', '*.md'], File::FNM_DOTMATCH, base: __dir__)
spec.files = Dir.glob(["{lib}/**/*", "*.md"], File::FNM_DOTMATCH, base: __dir__)

spec.required_ruby_version = ">= 3.1"
end
4 changes: 2 additions & 2 deletions lib/io/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Released under the MIT License.
# Copyright, 2023-2024, by Samuel Williams.

require_relative 'stream/version'
require_relative 'stream/buffered'
require_relative "stream/version"
require_relative "stream/buffered"

class IO
module Stream
Expand Down
2 changes: 1 addition & 1 deletion lib/io/stream/buffered.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

require_relative 'generic'
require_relative "generic"

module IO::Stream
class Buffered < Generic
Expand Down
14 changes: 7 additions & 7 deletions lib/io/stream/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# Released under the MIT License.
# Copyright, 2023-2024, by Samuel Williams.

require_relative 'string_buffer'
require_relative "string_buffer"

require_relative 'shim/buffered'
require_relative 'shim/readable'
require_relative 'shim/timeout'
require_relative "shim/buffered"
require_relative "shim/readable"
require_relative "shim/timeout"

require_relative 'openssl'
require_relative "openssl"

module IO::Stream
# The default block size for IO buffers. Defaults to 64KB (typical pipe buffer size).
BLOCK_SIZE = ENV.fetch('IO_STREAM_BLOCK_SIZE', 1024*64).to_i
BLOCK_SIZE = ENV.fetch("IO_STREAM_BLOCK_SIZE", 1024*64).to_i

# The maximum read size when appending to IO buffers. Defaults to 8MB.
MAXIMUM_READ_SIZE = ENV.fetch('IO_STREAM_MAXIMUM_READ_SIZE', BLOCK_SIZE * 128).to_i
MAXIMUM_READ_SIZE = ENV.fetch("IO_STREAM_MAXIMUM_READ_SIZE", BLOCK_SIZE * 128).to_i

class Generic
def initialize(block_size: BLOCK_SIZE, maximum_read_size: MAXIMUM_READ_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion lib/io/stream/openssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

require 'openssl'
require "openssl"

module OpenSSL
module SSL
Expand Down
4 changes: 2 additions & 2 deletions lib/io/stream/shim/buffered.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def buffered=(value)
end
end

require 'socket'
require "socket"

unless BasicSocket.method_defined?(:buffered?, false)
class BasicSocket
Expand Down Expand Up @@ -50,7 +50,7 @@ def buffered=(value)
end
end

require 'stringio'
require "stringio"

unless StringIO.method_defined?(:buffered?, false)
class StringIO
Expand Down
6 changes: 3 additions & 3 deletions lib/io/stream/shim/readable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def readable?
end
end

require 'socket'
require "socket"

class BasicSocket
unless method_defined?(:readable?, false)
Expand All @@ -32,7 +32,7 @@ def readable?
end
end

require 'stringio'
require "stringio"

class StringIO
unless method_defined?(:readable?, false)
Expand All @@ -42,7 +42,7 @@ def readable?
end
end

require 'openssl'
require "openssl"

class OpenSSL::SSL::SSLSocket
unless method_defined?(:readable?, false)
Expand Down
3 changes: 3 additions & 0 deletions lib/io/stream/shim/timeout.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

class IO
unless const_defined?(:TimeoutError)
# Compatibility shim.
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ We welcome contributions to this project.

### Developer Certificate of Origin

This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.

### Contributor Covenant
### Community Guidelines

This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.

## See Also

Expand Down
4 changes: 2 additions & 2 deletions test/io/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

require 'io/stream'
require "io/stream"

describe IO::Stream do
it "can wrap an IO object" do
Expand All @@ -22,4 +22,4 @@

expect(stream2).to be_equal(stream)
end
end
end
Loading

0 comments on commit b060d36

Please sign in to comment.