Skip to content

Commit

Permalink
Merge pull request #9 from johnnyshields/remove-kernel-module
Browse files Browse the repository at this point in the history
Remove kernel module
  • Loading branch information
johnnyshields authored Oct 19, 2024
2 parents cf94f21 + a380322 commit 121655f
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 48 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI RSpec Test

on: [push, pull_request]

jobs:
build:
name: >-
${{ matrix.ruby }}
env:
CI: true
TESTOPTS: -v
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
ruby:
- 3.0
- 3.1
- 3.2
- 3.3
experimental: [false]
include:
- ruby: head
experimental: true

steps:
- name: repo checkout
uses: actions/checkout@v2

- name: load ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler: 2

- name: bundle install
run: bundle install --jobs 4 --retry 3

- name: test
timeout-minutes: 10
run: bundle exec rake test
continue-on-error: ${{ matrix.experimental }}
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.3.0 - 2024-10-20

* Remove `NaturalSort::Kernel` module.
* Drop support for Ruby 2.7 and prior.
* Add Github Actions and remove Travis CI.

## 1.2.0 - 2013-10-10

* DEPRECATION: deprecate `NaturalSort.naturalsort` and replace with `NaturalSort.sort`
Expand Down
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# NaturalSort

[![Build Status](https://secure.travis-ci.org/johnnyshields/naturalsort.png?branch=master)](http://travis-ci.org/johnnyshields/naturalsort)
[![Code Climate](https://codeclimate.com/github/johnnyshields/naturalsort.png)](https://codeclimate.com/github/johnnyshields/naturalsort)

NaturalSort is a simple library which implements a natural, human-friendly alphanumeric sort in Ruby.

## Examples

```ruby
%w(a1 a11 a12 a2 a21).natural_sort #=> %w(a1 a2 a11 a12 a21)
%w(a b c A B C).natural_sort #=> %w(A a B b C c)
%w(x__2 x_1).natural_sort #=> %w(x_1 x__2)
%w(x2-y08 x2-g8 x2-y7 x8-y8).natural_sort #=> %w(x2-g8 x2-y7 x2-y08 x8-y8)
%w(x02-y08 x02-g8 x2-y7 x8-y8).natural_sort #=> %w(x02-g8 x2-y7 x02-y08 x8-y8)
%w[a1 a11 a12 a2 a21].natural_sort #=> %w[a1 a2 a11 a12 a21]
%w[a b c A B C].natural_sort #=> %w[A a B b C c]
%w[x__2 x_1].natural_sort #=> %w[x_1 x__2]
%w[x2-y08 x2-g8 x2-y7 x8-y8].natural_sort #=> %w[x2-g8 x2-y7 x2-y08 x8-y8]
%w[x02-y08 x02-g8 x2-y7 x8-y8].natural_sort #=> %w[x02-g8 x2-y7 x02-y08 x8-y8]
```

## Features
Expand All @@ -35,7 +32,7 @@ gem 'naturalsort'
or to optionally extend Ruby native objects:

```ruby
gem 'naturalsort', :require => 'natural_sort_kernel'
gem 'naturalsort', require: 'natural_sort_kernel'
```

#### From Command Line
Expand All @@ -53,15 +50,15 @@ $ gem install naturalsort
```ruby
require 'natural_sort_kernel'

sorted = %w(a b c A B C).natural_sort
%w[a b c A B C].natural_sort
```

#### Use as a module function

```ruby
require 'natural_sort' # unless using Bundler

sorted = NaturalSort.sort %w(a b c d A B C D)
NaturalSort.sort %w[a b c d A B C D]
```

#### Use comparator function as a standalone
Expand All @@ -75,7 +72,7 @@ Adds `natural_sort` methods to Ruby native enumerable objects (Array, Hash, etc.

[person_1, person_2, person_3].sort{|a,b| NaturalSort.comparator(a.name, b.name)} #=> [person_3, person_2, person_1]

sorted = %w(a b c A B C).natural_sort
%w[a b c A B C].natural_sort
```

#### Include into your own objects
Expand All @@ -92,7 +89,7 @@ Can be used to add `#natural_sort` method to on any enumerable object or any obj
todo_list << 'Water plants'
todo_list << 'Feed dog'

todo_list.natural_sort #=> ['Feed dog', 'Wash car', 'Water plants']
todo_list.natural_sort #=> ['Feed dog', 'Wash car', 'Water plants']
```

## Authors
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'rubygems'
require './lib/natural_sort.rb'
require 'rake/testtask'

task :default => :test
task default: :test

Rake::TestTask.new do |t|
t.libs << 'test'
Expand Down
2 changes: 2 additions & 0 deletions lib/natural_sort.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'forwardable'
require 'natural_sort/version'
require 'natural_sort/engine'
Expand Down
2 changes: 2 additions & 0 deletions lib/natural_sort/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Public: The public interface for NaturalSort module
# For method descriptions refer to NaturalSort::Engine
#
Expand Down
2 changes: 2 additions & 0 deletions lib/natural_sort/engine.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Internal: Singleton module which sorts elements in a natural,
# human-friendly alphanumeric order.
module NaturalSort::Engine
Expand Down
9 changes: 1 addition & 8 deletions lib/natural_sort/kernel.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# Public: Adds #natural_sort instance method to Ruby Kernel enumerable objects.
#
# Examples
#
# require 'natural_sort_kernel'
# defined?(NaturalSort::Kernel) #=> true
# ['a', 'b', 'A', 'B'].natural_sort #=> ['A', 'a', 'B', 'b']
module NaturalSort::Kernel; end
# frozen_string_literal: true

module Enumerable
# Add #natural_sort method to Enumerable module.
Expand Down
4 changes: 3 additions & 1 deletion lib/natural_sort/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module NaturalSort
module Version
VERSION = '1.2.0'
VERSION = '1.3.0'
end
end
1 change: 1 addition & 0 deletions lib/natural_sort_kernel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

require 'natural_sort'
require 'natural_sort/kernel'
13 changes: 5 additions & 8 deletions naturalsort.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ require 'natural_sort/version'
Gem::Specification.new do |spec|
spec.name = 'naturalsort'
spec.version = NaturalSort::Version::VERSION
spec.authors = ['Benjamin Francisoud']
spec.email = ['pub.cog@gmail.com']
spec.authors = ['Johnny Shields']
spec.email = 'info@tablecheck.com'
spec.summary = %q{NaturalSort is a simple library which implements a natural, human-friendly alphanumeric sort in Ruby}
spec.description = %q{Example: %w(1 2a A1 a11 A12 a2 a21 x__2 X_1).natural_sort => %w(1 2a A1 a11 A12 a2 a21 x__2 X_1)}
spec.homepage = 'http://rubyforge.org/projects/naturalsort/'
spec.description = %q{Example: %w[1 2a A1 a11 A12 a2 a21 x__2 X_1].natural_sort => %w[1 2a A1 a11 A12 a2 a21 x__2 X_1]}
spec.homepage = 'https://github.com/johnnyshields/naturalsort'
spec.license = 'MIT'

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.files = Dir.glob('lib/**/*') + %w[CHANGELOG.md LICENSE README.md]
spec.require_paths = ['lib']

spec.add_development_dependency 'minitest'
Expand Down
3 changes: 3 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
gem 'minitest'
require 'minitest/autorun'

# Ruby 3.1 tests fail if Set is not explicitly loaded.
require 'set'

module TestHelper
SimpleUnsorted = %w(a b c d A B C D)
SimpleSorted = %w(A a B b C c D d)
Expand Down

0 comments on commit 121655f

Please sign in to comment.