diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..6a73aaa --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,23 @@ +name: CI +on: + push: + branches: [master] + pull_request: + branches: [master] +jobs: + test: + runs-on: ubuntu-latest + env: + BUNDLE_DEPLOYMENT: "false" # do not fail test when bumping release without bundling + strategy: + matrix: + ruby: [ '2.5', '2.6', '2.7', '3.0' ] # lowest must match ruby version in gemspec + task: [ 'default' ] + name: ${{ matrix.ruby }} rake ${{ matrix.task }} + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - run: bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 06daf0d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: ruby -cache: bundler -sudo: false -branches: - only: master -matrix: - fast_finish: true -rvm: - - 2.0.0 - - 2.1.6 - - 2.2.4 - - 2.3.0 - diff --git a/Gemfile.lock b/Gemfile.lock index afdc407..7e83b21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,20 +6,21 @@ PATH GEM remote: https://rubygems.org/ specs: - bump (0.5.0) - diff-lcs (1.2.5) - rake (10.3.2) - rspec (2.14.1) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - rspec-core (2.14.8) - rspec-expectations (2.14.5) + bump (0.10.0) + diff-lcs (1.4.4) + rake (13.0.6) + rspec (2.99.0) + rspec-core (~> 2.99.0) + rspec-expectations (~> 2.99.0) + rspec-mocks (~> 2.99.0) + rspec-core (2.99.2) + rspec-expectations (2.99.2) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.6) + rspec-mocks (2.99.4) PLATFORMS - ruby + x86_64-darwin-19 + x86_64-linux DEPENDENCIES bump @@ -28,4 +29,4 @@ DEPENDENCIES rspec (~> 2) BUNDLED WITH - 1.11.2 + 2.2.16 diff --git a/Readme.md b/Readme.md index 0127e6b..9215143 100644 --- a/Readme.md +++ b/Readme.md @@ -8,8 +8,8 @@ Pipeable Ruby - forget about grep / sed / awk / wc ... use pure, readable Ruby! # select lines longer than five letters ls -1 | pru 'size > 5' - # passthrough - ls -1 | pru self + # 2nd to last character + ls -1 | pru self[2..-1] ## Reduce - all lines as Array @@ -20,8 +20,8 @@ Pipeable Ruby - forget about grep / sed / awk / wc ... use pure, readable Ruby! # are the more than five lines? ls -1 | pru -r 'size > 5' - # passthrough - ls -1 | pru -r self + # get 2nd to last line + ls -1 | pru -r self[2..-1] ## Map and Reduce @@ -117,8 +117,8 @@ Gemsets Working with rvm / many gemsets -> only install once (or use standalone binary) - rvm 1.9.2 exec gem install pru - echo 'alias pru="rvm 1.9.2 exec pru"' >> ~/.bash_profile + rvm 2.7.7 exec gem install pru + echo 'alias pru="rvm 2.7.2 exec pru"' >> ~/.bash_profile [Contributors](http://github.com/grosser/pru/contributors) diff --git a/lib/pru/core_ext/array.rb b/lib/pru/core_ext/array.rb index 0e4f206..7880f5e 100644 --- a/lib/pru/core_ext/array.rb +++ b/lib/pru/core_ext/array.rb @@ -11,8 +11,8 @@ def sum(method = nil, &block) end end unless method_defined?(:sum) - def mean(method = nil, &block) - sum(method, &block) / size.to_f + def mean(*args, &block) + sum(*args, &block) / size.to_f end unless method_defined?(:mean) def grouped diff --git a/pru.gemspec b/pru.gemspec index bf053a8..84f0b3a 100644 --- a/pru.gemspec +++ b/pru.gemspec @@ -10,4 +10,5 @@ Gem::Specification.new name, Pru::VERSION do |s| s.files = `git ls-files lib`.split("\n") s.license = "MIT" s.executables = ["pru"] + s.required_ruby_version = '>= 2.5' # must match lowest in .github/workflows/actions.yml end