Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test against latest rubies #3

Merged
merged 12 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/ruby.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Ruby CI

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

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: ["3.2", "3.1", "3.0", "2.7", "2.6"]

steps:
- uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/[email protected]
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies
run: bundle install
- name: Run tests
run: bundle exec rake
- name: rubocop
run: bundle exec rubocop
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
AllCops:
TargetRubyVersion: "2.6"
Exclude:
- "benchmark/**/*"
- "tmp/**/*"
StringLiterals:
Enabled: false
SupportedStyles:
Expand All @@ -6,3 +11,5 @@ StringLiterals:
LineLength:
Enabled: true
Max: 100
Style/AccessModifierDeclarations:
Enabled: false
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in ipconverter.gemspec
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rake/extensiontask'

ROOT = File.expand_path('..', __FILE__)
ROOT = File.expand_path(__dir__)

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

require 'benchmark'
require 'ipaddr'
require 'ipconverter'
Expand Down
6 changes: 3 additions & 3 deletions benchmark/str_to_int.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# frozen_string_literal: true

require 'benchmark'
require 'ipaddr'
require 'ipconverter'

def self.pack_unpack(ip)
ip.split('.').collect(&:to_i).pack('C*').unpack('N').first
ip.split('.').collect(&:to_i).pack('C*').unpack1('N')
end

# rubocop:disable AbcSize
def self.split_multiply(ip)
octets = ip.split('.').map(&:to_i)
octets[3] +
octets[2] * 256 +
octets[1] * 256 * 256 +
octets[0] * 256 * 256 * 256
end
# rubocop:enable AbcSize

def self.ipaddr_to_i(ip)
IPAddr.new(ip).to_i
Expand Down
2 changes: 2 additions & 0 deletions ext/ipconverter/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'mkmf'
extension_name = 'ipconverter'
dir_config(extension_name)
Expand Down
11 changes: 7 additions & 4 deletions ipconverter.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

lib = File.expand_path('../lib', __FILE__)
ext = File.expand_path('../ext', __FILE__)
lib = File.expand_path('lib', __dir__)
ext = File.expand_path('ext', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
$LOAD_PATH.unshift(ext) unless $LOAD_PATH.include?(ext)
require 'ipconverter/version'
Expand All @@ -16,15 +17,17 @@ string to integer'
spec.homepage = 'http://github.com/joshuawscott/ipconverter'
spec.license = 'MIT'

spec.required_ruby_version = ">= 2.6.0"

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.extensions = ['ext/ipconverter/extconf.rb']
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = %w[lib ext]

spec.add_development_dependency 'bundler', '~> 1.6'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'minitest', '~> 5'
spec.add_development_dependency 'rake', '~> 12.3'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rake-compiler', '~> 1.0'
spec.add_development_dependency 'rubocop', '~> 0.50'
end
2 changes: 2 additions & 0 deletions lib/ipconverter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'ipconverter/version'
require 'ipconverter/ipconverter'

Expand Down
4 changes: 3 additions & 1 deletion lib/ipconverter/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module IpConverter
VERSION = '0.3.1'.freeze
VERSION = '0.3.1'
end
2 changes: 2 additions & 0 deletions test/test_ipconverter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'ipconverter'
require 'minitest/autorun'

Expand Down