Skip to content

Commit

Permalink
Merge pull request #458 from athityakumar/github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
avdv authored May 6, 2021
2 parents 6f4b0d3 + 22fb57a commit 2a6deed
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.6', '2.7', '3.0']

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
1 change: 1 addition & 0 deletions lib/colorls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'English'
require 'filesize'
require 'io/console'
require 'io/console/size'
require 'rainbow/ext/string'
require 'clocale'
require 'unicode/display_width'
Expand Down
13 changes: 11 additions & 2 deletions lib/colorls/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ def self.file_encoding
@file_encoding
end

@screen_width = IO.console.winsize[1]
@screen_width = 80 if @screen_width.zero?
def self.terminal_width
console = IO.console

width = IO.console_size[1]

return width if console.nil? || console.winsize[1].zero?

console.winsize[1]
end

@screen_width = terminal_width

def self.screen_width
@screen_width
Expand Down

0 comments on commit 2a6deed

Please sign in to comment.