diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .travis.yml | 17 | ||||
-rw-r--r-- | CONTRIBUTING.md | 39 | ||||
-rw-r--r-- | Gemfile | 11 | ||||
-rw-r--r-- | README.rdoc | 17 | ||||
-rw-r--r-- | Rakefile | 2 | ||||
-rw-r--r-- | VERSION | 1 | ||||
-rw-r--r-- | ipaddress.gemspec | 101 | ||||
-rw-r--r-- | lib/ipaddress/ipv4.rb | 14 | ||||
-rw-r--r-- | lib/ipaddress/ipv6.rb | 7 | ||||
-rw-r--r-- | lib/ipaddress/prefix.rb | 8 | ||||
-rw-r--r-- | tasks/jeweler.rake | 15 | ||||
-rw-r--r-- | test/ipaddress/ipv6_test.rb | 6 | ||||
-rw-r--r-- | test/test_helper.rb | 2 |
14 files changed, 191 insertions, 51 deletions
@@ -16,3 +16,5 @@ server.rb *.sw? /tmp/ /_yardoc/ +.idea/ +**/*.gem diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bb08cdb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: ruby +rvm: +- 2.3 +- 2.4 +install: +- gem install bundler +- gem uninstall rake -x +- gem install rake +- bundle install +script: +- uname -s +- rake test +- codeclimate-test-reporter +addons: + code_climate: + repo_token: + secure: Na2Ghl3W0IpUWAWx66V9skLie5MqiJWfn7muCSRkAYIVL/j9fR6jhhawOKlX0R6bg4byouOyLieDu9HWsv2EY5L7JweVspodRuuaJndxDQ1E5rOp0mU6vDl7kIqBeboX3AsivXDgcc8C8qvE+WD++vr3oEMg22c2/RIbt6ecJGs= diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..94f60b5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# 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) + +This gem is run by people who have jobs. So please understand if we can't always prioritize PRs and issues. + +You can help by making your code submissions. We can't promise a specific turnaround time, or that your code will be incorporated but all submissions are appreciated. + +## Steps to Submit a Pull Request + +* [Fork](https://help.github.com/articles/fork-a-repo) the project on GitHub. +* Make your feature addition or bug fix [in a feature branch](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches). (Include a description of your changes in the PR) +* Push your feature branch to GitHub. +* Send a [Pull Request](https://help.github.com/articles/using-pull-requests) + +## Style Guide + +We will require that you adhere to the [ruby-style-guide](https://github.com/bbatsov/ruby-style-guide) for your code submissions. + +## 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) + +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 + +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. + +``` +$ 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 @@ -1,3 +1,12 @@ source "https://rubygems.org" -gemspec +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 diff --git a/README.rdoc b/README.rdoc index 05698a0..7d9600a 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,7 +1,3 @@ -== <b>IPAddress 1.0 is currently under development and will be released soon! Stay tuned!</b> - ---- - = IPAddress IPAddress is a Ruby library designed to make the use of IPv4 and IPv6 @@ -18,10 +14,13 @@ examples of typical usage. == Requirements -* Ruby >= 1.8.7 (not tested with previous versions) -* Ruby 1.9.2 or later is strongly recommended +* Ruby 1.9.3 or later + +Please refer to {Travis CI}[https://travis-ci.org/ipaddress-gem/ipaddress] for Build Tests on specific versions of Ruby. + +{<img src="https://travis-ci.org/ipaddress-gem/ipaddress.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/ipaddress-gem/ipaddress] {<img src="https://codeclimate.com/github/ipaddress-gem/ipaddress/badges/gpa.svg" />}[https://codeclimate.com/github/ipaddress-gem/ipaddress] {<img src="https://www.versioneye.com/user/projects/57001305fcd19a0051853bde/badge.svg?style=flat" alt="Dependency Status" />}[https://www.versioneye.com/user/projects/57001305fcd19a0051853bde] -IPAddress 0.8.2 has been tested on: +IPAddress 0.8.2 was manually tested on: * ruby-1.8.7-p334 [ i386 ] * ree-1.8.7-2011.03 [ i386 ] @@ -32,9 +31,7 @@ IPAddress 0.8.2 has been tested on: * ruby-2.0.0-p353 [ x86_64-darwin14.0.0 ] * ruby-2.1.3-p242 [ x86_64-darwin14.0.0 ] -If you want to collaborate feel -free to send a small report to my email address, or -{join the discussion}[http://groups.google.com/group/ruby-ipaddress]. +If you want to contribute, please refer to {Contributing.md}[https://github.com/ipaddress-gem/ipaddress/blob/master/CONTRIBUTING.md]. == Installation @@ -64,3 +64,5 @@ task :todo do end egrep /(FIXME|TODO|TBD)/ end + +Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |raketask| load raketask } @@ -0,0 +1 @@ +0.8.3 diff --git a/ipaddress.gemspec b/ipaddress.gemspec index 2f66ccf..6b61e92 100644 --- a/ipaddress.gemspec +++ b/ipaddress.gemspec @@ -1,26 +1,83 @@ -# coding: utf-8 -lib = File.expand_path('../lib', __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'ipaddress/version' +# 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 -Gem::Specification.new do |spec| - spec.name = "ipaddress" - spec.version = Ipaddress::VERSION - spec.authors = ["bluemonk", "mikemackintosh"] - spec.email = ["ceresa@gmail.com"] - spec.summary = %q{IPv4/IPv6 address manipulation library} - spec.description = %q{IPAddress is a Ruby library designed to make manipulation - of IPv4 and IPv6 addresses both powerful and simple. It mantains - a layer of compatibility with Ruby's own IPAddr, while - addressing many of its issues.} - spec.homepage = "https://github.com/bluemonk/ipaddress" - spec.license = "MIT" +Gem::Specification.new do |s| + s.name = "ipaddress" + s.version = "0.8.3" - spec.files = `git ls-files -z`.split("\x0") - spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } - spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = ["lib"] + 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 mantains\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.rdoc", + "LICENSE.txt", + "README.rdoc" + ] + s.files = [ + ".document", + ".rock.yml", + ".travis.yml", + "CHANGELOG.rdoc", + "CONTRIBUTING.md", + "Gemfile", + "LICENSE.txt", + "README.rdoc", + "Rakefile", + "VERSION", + "ipaddress.gemspec", + "lib/ipaddress.rb", + "lib/ipaddress/ipv4.rb", + "lib/ipaddress/ipv6.rb", + "lib/ipaddress/mongoid.rb", + "lib/ipaddress/prefix.rb", + "lib/ipaddress/version.rb", + "tasks/jeweler.rake", + "test/ipaddress/ipv4_test.rb", + "test/ipaddress/ipv6_test.rb", + "test/ipaddress/mongoid_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" - spec.add_development_dependency "bundler" - spec.add_development_dependency "rake" + if s.respond_to? :specification_version then + s.specification_version = 4 + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q<bundler>, [">= 1.0"]) + s.add_development_dependency(%q<rake>, [">= 0"]) + s.add_development_dependency(%q<minitest>, [">= 5.8.4", "~> 5.8"]) + s.add_development_dependency(%q<pry>, [">= 0.10.1"]) + s.add_development_dependency(%q<travis>, [">= 1.8.2"]) + s.add_development_dependency(%q<jeweler>, [">= 2.0.1"]) + s.add_development_dependency(%q<codeclimate-test-reporter>, [">= 0"]) + else + s.add_dependency(%q<bundler>, [">= 1.0"]) + s.add_dependency(%q<rake>, [">= 0"]) + s.add_dependency(%q<minitest>, [">= 5.8.4", "~> 5.8"]) + s.add_dependency(%q<pry>, [">= 0.10.1"]) + s.add_dependency(%q<travis>, [">= 1.8.2"]) + s.add_dependency(%q<jeweler>, [">= 2.0.1"]) + s.add_dependency(%q<codeclimate-test-reporter>, [">= 0"]) + end + else + s.add_dependency(%q<bundler>, [">= 1.0"]) + s.add_dependency(%q<rake>, [">= 0"]) + s.add_dependency(%q<minitest>, [">= 5.8.4", "~> 5.8"]) + s.add_dependency(%q<pry>, [">= 0.10.1"]) + s.add_dependency(%q<travis>, [">= 1.8.2"]) + s.add_dependency(%q<jeweler>, [">= 2.0.1"]) + s.add_dependency(%q<codeclimate-test-reporter>, [">= 0"]) + end end + diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb index 5e456f6..5979489 100644 --- a/lib/ipaddress/ipv4.rb +++ b/lib/ipaddress/ipv4.rb @@ -637,20 +637,6 @@ module IPAddress; # # Checks if an IPv4 address objects belongs - # to a multicast network RFC3171 - # - # Example: - # - # ip = IPAddress "224.0.0.0/4" - # ip.multicast? - # #=> true - # - def multicast? - [self.class.new("224.0.0.0/4")].any? {|i| i.include? self} - end - - # - # Checks if an IPv4 address objects belongs # to a loopback network RFC1122 # # Example: diff --git a/lib/ipaddress/ipv6.rb b/lib/ipaddress/ipv6.rb index e6e8d04..2205de4 100644 --- a/lib/ipaddress/ipv6.rb +++ b/lib/ipaddress/ipv6.rb @@ -397,6 +397,13 @@ module IPAddress; @compressed end + # + # Returns true if the address is a link local address + # + def link_local? + @groups[0] == 0xfe80 + end + # # Returns true if the address is an unspecified address # diff --git a/lib/ipaddress/prefix.rb b/lib/ipaddress/prefix.rb index a0e3bb0..136f2d3 100644 --- a/lib/ipaddress/prefix.rb +++ b/lib/ipaddress/prefix.rb @@ -55,10 +55,10 @@ module IPAddress # # Sums two prefixes or a prefix to a - # number, returns a Fixnum + # number, returns a Integer # def +(oth) - if oth.is_a? Fixnum + if oth.is_a? Integer self.prefix + oth else self.prefix + oth.prefix @@ -68,10 +68,10 @@ module IPAddress # # Returns the difference between two # prefixes, or a prefix and a number, - # as a Fixnum + # as a Integer # def -(oth) - if oth.is_a? Fixnum + if oth.is_a? Integer self.prefix - oth else (self.prefix - oth.prefix).abs diff --git a/tasks/jeweler.rake b/tasks/jeweler.rake new file mode 100644 index 0000000..34d27ed --- /dev/null +++ b/tasks/jeweler.rake @@ -0,0 +1,15 @@ +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 mantains + 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/ipaddress/ipv6_test.rb b/test/ipaddress/ipv6_test.rb index 60f01eb..3c3da90 100644 --- a/test/ipaddress/ipv6_test.rb +++ b/test/ipaddress/ipv6_test.rb @@ -200,6 +200,12 @@ class IPv6Test < Minitest::Test assert_equal "1::1", @klass.new("1:0:0:0:0:0:0:1").compressed end + def test_method_link_local? + assert_equal true, @klass.new("fe80::1").link_local? + assert_equal true, @klass.new("fe80:ffff::1").link_local? + assert_equal false, @klass.new("fe81::1").link_local? + end + def test_method_unspecified? assert_equal true, @klass.new("::").unspecified? assert_equal false, @ip.unspecified? diff --git a/test/test_helper.rb b/test/test_helper.rb index 249ea52..4a80d3e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,5 +1,7 @@ require 'rubygems' require 'minitest/autorun' +require 'simplecov' +SimpleCov.start $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) |