From 64cb4ca5ffb3268bd00852148bd82cc5aca2df82 Mon Sep 17 00:00:00 2001 From: Javier Aranda Date: Sun, 3 Mar 2024 13:33:29 +0100 Subject: [PATCH] Refactor of gem files and rake tasks --- .gitignore | 23 ++------- CHANGELOG.md | 15 +++++- CONTRIBUTING.md | 29 ++++++----- Gemfile | 15 ++---- Gemfile.lock | 31 ++++++++++++ LICENSE.txt | 2 +- README.md | 43 +++++----------- Rakefile | 72 +++++++++----------------- VERSION | 1 - bin/console | 7 +++ bin/rake | 27 ++++++++++ bin/setup | 6 +++ ipaddress.gemspec | 107 ++++++++++++--------------------------- lib/ipaddress.rb | 1 + lib/ipaddress/version.rb | 2 +- tasks/jeweler.rake | 15 ------ test/test_helper.rb | 6 ++- 17 files changed, 183 insertions(+), 219 deletions(-) create mode 100644 Gemfile.lock delete mode 100644 VERSION create mode 100755 bin/console create mode 100755 bin/rake create mode 100755 bin/setup delete mode 100644 tasks/jeweler.rake diff --git a/.gitignore b/.gitignore index 1c2e4bf..65ee199 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,3 @@ -*.a -/.bundle/ -*.bundle -/coverage/ -/doc/ -.DS_Store -/Gemfile.lock -ipaddr.html -mkmf.log -*.o -/pkg/ -rdoc -server.rb -*.so -/spec/reports/ -*.sw? -/tmp/ -/_yardoc/ -.idea/ -**/*.gem +/coverage +/pkg +/rdoc diff --git a/CHANGELOG.md b/CHANGELOG.md index 5be521e..48c0650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ -Changelog -========= +# Changelog + +## unreleased + +### Added +- Add `bin/*` scripts for better development tasks + +### Changed +- **Breaking** Change `Ipaddress::VERSION` to `IPAddress::VERSION` to match the gem main module +- Use `Gemfile` for development dependencies and add `Gemfile.lock` under control version +- Cleanup and improvement of the gemspec +- Cleanup of `Rakefile` +- Changes in `README.md` and `CONTRIBUTING.md` files to reflect the new development process ## 0.8.3 - 2016-02-17 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 94f60b5..fe8e054 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,8 @@ # Contributing to the IPAddress Gem -[![Build Status](https://travis-ci.org/ipaddress-gem/ipaddress.svg?branch=master)](https://travis-ci.org/ipaddress-gem/ipaddress) [![Code Climate](https://codeclimate.com/github/ipaddress-gem/ipaddress/badges/gpa.svg)](https://codeclimate.com/github/ipaddress-gem/ipaddress) [![Dependency Status](https://www.versioneye.com/user/projects/57001305fcd19a0051853bde/badge.svg?style=flat)](https://www.versioneye.com/user/projects/57001305fcd19a0051853bde) +[![Build Status](https://github.com/ipaddress-gem/ipaddress/actions/workflows/tests/badge.svg)](https://github.com/ipaddress-gem/ipaddress/actions) +[![Code Climate](https://codeclimate.com/github/ipaddress-gem/ipaddress/badges/gpa.svg)](https://codeclimate.com/github/ipaddress-gem/ipaddress) +[![Dependency Status](https://www.versioneye.com/user/projects/57001305fcd19a0051853bde/badge.svg?style=flat)](https://www.versioneye.com/user/projects/57001305fcd19a0051853bde) This gem is run by people who have jobs. So please understand if we can't always prioritize PRs and issues. @@ -17,23 +19,22 @@ You can help by making your code submissions. We can't promise a specific turna We will require that you adhere to the [ruby-style-guide](https://github.com/bbatsov/ruby-style-guide) for your code submissions. +## Testing + +To run the tests you need to have: + +1. The development dependencies installed with `bin/setup`. +2. Then just run the command `bin/rake test`. + ## Test Coverage -All submissions of code must include test coverage which describes intent and expected behavior. The test suite used by this gem is [Minitest](https://github.com/seattlerb/minitest) +All submissions of code must include test coverage which describes intent and expected behavior. +The test suite used by this gem is [Minitest](https://github.com/seattlerb/minitest) Unit tests are expected to execute quickly. We will ask you to revise any long-running tests. -We intend to add [Travis CI](https://travis-ci.org/) for automatic execution of branch tests. - -## Versioning: Jeweler and Semantic Versioning +## Versioning -This repo uses [semantic versioning](http://semver.org/) implemented by the [Jeweler Gem](https://github.com/technicalpickles/jeweler). Please do not update the version by editting files, instead, you may increment or modify the version using the Rake tasks added by Jeweler. +This repo uses [semantic versioning](http://semver.org/). -``` -$ rake -T | grep version -rake version # Displays the current version -rake version:bump:major # Bump the major version by 1 -rake version:bump:minor # Bump the a minor version by 1 -rake version:bump:patch # Bump the patch version by 1 -rake version:write # Writes out an explicit version -``` \ No newline at end of file +Before release, update version in `lib/ipaddress/version.rb` file. diff --git a/Gemfile b/Gemfile index e479aab..49d759e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,7 @@ source "https://rubygems.org" -group :development do - gem 'bundler', '>= 1.0' - gem 'rake', '10.5.0' - gem 'minitest', '~> 5.8', '>= 5.8.4' - gem 'pry', '>= 0.10.1' - gem 'travis', '>= 1.8.2' - gem 'jeweler', '>=2.0.1' - gem 'codeclimate-test-reporter' - gem 'simplecov' -end +gemspec + +gem "minitest" +gem "rake" +gem "simplecov", require: false diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..61bd1d5 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,31 @@ +PATH + remote: . + specs: + ipaddress (0.8.3) + +GEM + remote: https://rubygems.org/ + specs: + docile (1.4.0) + minitest (5.22.2) + rake (13.1.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + +PLATFORMS + arm64-darwin + x86_64-darwin + x86_64-linux + +DEPENDENCIES + ipaddress! + minitest + rake + simplecov + +BUNDLED WITH + 2.5.6 diff --git a/LICENSE.txt b/LICENSE.txt index 943eee1..cc32e02 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2009-2015 Marco Ceresa +Copyright (c) 2009-today Marco Ceresa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index 357ec21..9713054 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # IPAddress +[![Build Status](https://github.com/ipaddress-gem/ipaddress/actions/workflows/tests/badge.svg)](https://github.com/ipaddress-gem/ipaddress/actions) +[![Code Climate](https://codeclimate.com/github/ipaddress-gem/ipaddress/badges/gpa.svg)](https://codeclimate.com/github/ipaddress-gem/ipaddress) +[![Dependency Status](https://www.versioneye.com/user/projects/57001305fcd19a0051853bde/badge.svg?style=flat)](https://www.versioneye.com/user/projects/57001305fcd19a0051853bde) + IPAddress is a Ruby library designed to make the use of IPv4 and IPv6 addresses simple, powerful and enjoyable. It provides a complete set of methods to handle IP addresses for any need, from simple scripting to full @@ -10,35 +14,11 @@ typical usage. ## Requirements -* Ruby 1.9.3 or later +* Ruby 3.1.0 or later -Please refer to [Travis CI](https://travis-ci.org/ipaddress-gem/ipaddress) for +Please refer to [Github Actions](https://travis-ci.org/ipaddress-gem/ipaddress/actions) for Build Tests on specific versions of Ruby. -[](https://travis-ci.org/ipaddress-gem/ipaddress) [](https://codeclimate.com/github/ipaddress-gem/ipaddress) [Dependency Status](https://www.versioneye.com/user/projects/57001305fcd19a0051853bde) - -IPAddress 0.8.2 was manually tested on: - -* ruby-1.8.7-p334 [ i386 ] -* ree-1.8.7-2011.03 [ i386 ] -* rbx-head [ ] -* jruby-1.6.1 [ linux-i386-java ] -* ruby-1.9.1-p431 [ i386 ] -* ruby-1.9.2-p180 [ i386 ] -* ruby-2.0.0-p353 [ x86_64-darwin14.0.0 ] -* ruby-2.1.3-p242 [ x86_64-darwin14.0.0 ] - - -If you want to contribute, please refer to -[Contributing.md](https://github.com/ipaddress-gem/ipaddress/blob/master/CONTR -IBUTING.md). - ## Installation This gem is installed like any other: @@ -57,11 +37,10 @@ The code is fully documented with RDoc. You can generate the documentation with Rake: ```bash -$ rake rdoc +$ bin/rake rdoc ``` -The latest documentation can be found online at -[this address][https://rubydoc.info/gems/ipaddress/] +The latest documentation can be found online at [RubyDoc](https://rubydoc.info/gems/ipaddress/) ## Introduction via examples @@ -1036,6 +1015,10 @@ in addition to provide an organic API with logical separation and code structure We hope that IPAddress will address all these issues and meet all your needs in network programming. +## Contributing + +If you want to contribute, please refer to [CONTRIBUTING.md](CONTRIBUTING.md). + ## Community Want to join the community? @@ -1054,4 +1037,4 @@ and Steve Rawlinson for their support, feedback and bug reports. ## Copyright Copyright (c) 2009-today Marco Ceresa and Mike Mackintosh. -See LICENSE for details. +See [LICENSE.txt](LICENSE.txt) for details. diff --git a/Rakefile b/Rakefile index 220a4da..d68e3cb 100644 --- a/Rakefile +++ b/Rakefile @@ -1,34 +1,26 @@ -require 'rubygems' -require 'rake' -require 'rake/clean' require "bundler/gem_tasks" +require "rake/clean" +require "rake/testtask" +require "rdoc/task" - -require 'rake/testtask' -Rake::TestTask.new(:test) do |test| - test.libs << 'lib' << 'test' - test.pattern = 'test/**/*_test.rb' - test.verbose = true - test.warning = true -end - -begin - require 'rcov/rcovtask' - Rcov::RcovTask.new do |test| - test.libs << 'test' - test.pattern = 'test/**/*_test.rb' - test.verbose = true - end -rescue LoadError - task :rcov do - abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" +desc "Look for TODO and FIXME tags in the code" +task :todo do + def egrep(pattern) + Dir['**/*.rb'].each do |fn| + count = 0 + open(fn) do |f| + while line = f.gets + count += 1 + if line =~ pattern + puts "#{fn}:#{count}:#{line}" + end + end + end + end end + egrep /(FIXME|TODO|TBD)/ end - -task :default => :test - -require 'rdoc/task' Rake::RDocTask.new do |rdoc| if File.exist?('VERSION.yml') config = YAML.load(File.read('VERSION.yml')) @@ -43,27 +35,11 @@ Rake::RDocTask.new do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -desc "Open an irb session preloaded with this library" -task :console do - sh "irb -rubygems -I lib -r ipaddress.rb" -end - -desc "Look for TODO and FIXME tags in the code" -task :todo do - def egrep(pattern) - Dir['**/*.rb'].each do |fn| - count = 0 - open(fn) do |f| - while line = f.gets - count += 1 - if line =~ pattern - puts "#{fn}:#{count}:#{line}" - end - end - end - end - end - egrep /(FIXME|TODO|TBD)/ +Rake::TestTask.new(:test) do |test| + test.libs << 'lib' << 'test' + test.pattern = 'test/**/*_test.rb' + test.verbose = true + test.warning = true end -Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |raketask| load raketask } +task :default => :test diff --git a/VERSION b/VERSION deleted file mode 100644 index ee94dd8..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.8.3 diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..7f7309a --- /dev/null +++ b/bin/console @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "irb" +require "ipaddress" + +IRB.start diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..4eb7d7b --- /dev/null +++ b/bin/rake @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rake", "rake") diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..cf4ad25 --- /dev/null +++ b/bin/setup @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install diff --git a/ipaddress.gemspec b/ipaddress.gemspec index b17d1fb..8bc0497 100644 --- a/ipaddress.gemspec +++ b/ipaddress.gemspec @@ -1,81 +1,36 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' -# -*- encoding: utf-8 -*- -# stub: ipaddress 0.8.3 ruby lib +require_relative "lib/ipaddress/version" -Gem::Specification.new do |s| - s.name = "ipaddress" - s.version = "0.8.3" +Gem::Specification.new do |spec| + # Information + spec.name = "ipaddress" + spec.version = IPAddress::VERSION + spec.summary = "IPv4/IPv6 address manipulation library" + spec.description = <<~DESC + IPAddress is a Ruby library designed to make manipulation + of IPv4 and IPv6 addresses both powerful and simple. It maintains + a layer of compatibility with Ruby's own IPAddr, while + addressing many of its issues. + DESC + spec.homepage = "https://github.com/ipaddress-gem/ipaddress" + spec.license = "MIT" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib"] - s.authors = ["bluemonk", "mikemackintosh"] - s.date = "2016-03-23" - s.description = "IPAddress is a Ruby library designed to make manipulation\n of IPv4 and IPv6 addresses both powerful and simple. It maintains\n a layer of compatibility with Ruby's own IPAddr, while\n addressing many of its issues." - s.email = "ceresa@gmail.com" - s.extra_rdoc_files = [ - "CHANGELOG.md", - "LICENSE.txt", - "README.md" - ] - s.files = [ - ".document", - ".rock.yml", - ".travis.yml", - "CHANGELOG.md", - "CONTRIBUTING.md", - "Gemfile", - "LICENSE.txt", - "README.md", - "Rakefile", - "VERSION", - "ipaddress.gemspec", - "lib/ipaddress.rb", - "lib/ipaddress/ipv4.rb", - "lib/ipaddress/ipv6.rb", - "lib/ipaddress/prefix.rb", - "lib/ipaddress/version.rb", - "tasks/jeweler.rake", - "test/ipaddress/ipv4_test.rb", - "test/ipaddress/ipv6_test.rb", - "test/ipaddress/prefix_test.rb", - "test/ipaddress_test.rb", - "test/test_helper.rb" - ] - s.homepage = "https://github.com/bluemonk/ipaddress" - s.licenses = ["MIT"] - s.rubygems_version = "2.4.6" - s.summary = "IPv4/IPv6 address manipulation library" + # Ownership + spec.authors = ["bluemonk", "mikemackintosh"] + spec.email = "ceresa@gmail.com" - if s.respond_to? :specification_version then - s.specification_version = 4 + # Metadata + spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues" + spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md" + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["mailing_list_uri"] = "#{spec.homepage}/discussions" + spec.metadata["source_code_uri"] = "#{spec.homepage}/tree/v#{spec.version}" - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q, [">= 1.0"]) - s.add_development_dependency(%q, [">= 0"]) - s.add_development_dependency(%q, [">= 5.8.4", "~> 5.8"]) - s.add_development_dependency(%q, [">= 0.10.1"]) - s.add_development_dependency(%q, [">= 1.8.2"]) - s.add_development_dependency(%q, [">= 2.0.1"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 1.0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 5.8.4", "~> 5.8"]) - s.add_dependency(%q, [">= 0.10.1"]) - s.add_dependency(%q, [">= 1.8.2"]) - s.add_dependency(%q, [">= 2.0.1"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 1.0"]) - s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 5.8.4", "~> 5.8"]) - s.add_dependency(%q, [">= 0.10.1"]) - s.add_dependency(%q, [">= 1.8.2"]) - s.add_dependency(%q, [">= 2.0.1"]) - s.add_dependency(%q, [">= 0"]) - end -end + # Gem + spec.files = Dir["lib/**/*", "CHANGELOG.md", "LICENSE.txt", "README.md"] + + # Ruby + spec.required_ruby_version = "~> 3.1" + # Documentation + spec.extra_rdoc_files = ["CHANGELOG.md", "LICENSE.txt", "README.md"] +end diff --git a/lib/ipaddress.rb b/lib/ipaddress.rb index 39c69f2..967bbf8 100644 --- a/lib/ipaddress.rb +++ b/lib/ipaddress.rb @@ -11,6 +11,7 @@ require 'ipaddress/ipv4' require 'ipaddress/ipv6' +require 'ipaddress/version' module IPAddress diff --git a/lib/ipaddress/version.rb b/lib/ipaddress/version.rb index f637ef8..6164e53 100644 --- a/lib/ipaddress/version.rb +++ b/lib/ipaddress/version.rb @@ -1,3 +1,3 @@ -module Ipaddress +module IPAddress VERSION = "0.8.3" end diff --git a/tasks/jeweler.rake b/tasks/jeweler.rake deleted file mode 100644 index eda8319..0000000 --- a/tasks/jeweler.rake +++ /dev/null @@ -1,15 +0,0 @@ -require 'jeweler' -Jeweler::Tasks.new do |gem| - # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options - gem.name = "ipaddress" - gem.summary = %q{IPv4/IPv6 address manipulation library} - gem.description = %q{IPAddress is a Ruby library designed to make manipulation - of IPv4 and IPv6 addresses both powerful and simple. It maintains - a layer of compatibility with Ruby's own IPAddr, while - addressing many of its issues.} - gem.email = "ceresa@gmail.com" - gem.homepage = "https://github.com/bluemonk/ipaddress" - gem.authors = ["bluemonk", "mikemackintosh"] - gem.license = "MIT" -end -Jeweler::RubygemsDotOrgTasks.new diff --git a/test/test_helper.rb b/test/test_helper.rb index 4a80d3e..bfa96d5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,11 @@ require 'rubygems' require 'minitest/autorun' require 'simplecov' -SimpleCov.start + +SimpleCov.start do + add_filter "/test/" + add_filter "/vendor/bundle/" +end $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))