ext_ipaddr 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 489e2b7c5c0b4b23ad5897f4804a53bcc7675319
4
- data.tar.gz: f0b9de82f716849545655954e905ec6b17806fd8
3
+ metadata.gz: eea797206f51f6fa299d481abbc27ae74673aa9c
4
+ data.tar.gz: c839320f6dee41c947c6620448cadbaad19cbd7b
5
5
  SHA512:
6
- metadata.gz: 2cf40c1b9232ab710c6ab3f94a55e8aaf0430e82bb553fa1dd29beed95057e4493bf65b3cfafbade7261124e077e58fb6788015cbeefa3eacfde3851af39f833
7
- data.tar.gz: af6fb99eaeb8d33f14c594069c1c1a99bf257be79cdcc6ab4c62bec3ba7ad0dcdfcf7a2b3f63c7f73e029157e60cc19972d8476cff289c3bda314acc0b20e6e9
6
+ metadata.gz: 1be9cbf914fe405b1ec39372a5df49887c303b1befefd5b42a480b1203ae28716aa507e69442ac7078fee5f165d171342a985de1f8bdb0e605ece634a1042fb8
7
+ data.tar.gz: 84dd39e7f48da2bda984c72140a65d457b96d42ce86c58cef0c9e3474565a75590aecaba69f57fe0bb03a97988293710beac01c10378ea888cb5a4bf3d3273aa
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.3
4
+ - 2.1.5
5
+ - 2.0.0
4
6
  before_install: gem install bundler -v 1.10.6
data/README.md CHANGED
@@ -1,8 +1,27 @@
1
1
  # ExtIPAddr
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ext_ipaddr`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Gem Version](https://badge.fury.io/rb/ext_ipaddr.svg)](https://badge.fury.io/rb/ext_ipaddr)
4
+ [![Build Status](https://travis-ci.org/s2ugimot/ext_ipaddr.svg?branch=master)](https://travis-ci.org/s2ugimot/ext_ipaddr)
5
+
6
+ Monkey patch for ruby built-in IPAddr class to make it support CIDR notation.
7
+
8
+ ```ruby
9
+ IPAddr.new('192.0.2.1/24')
10
+ # => #<IPAddr: IPv4:192.0.2.1/255.255.255.0>
11
+
12
+ IPAddr.new('2001:db8::1/64')
13
+ # => #<IPAddr: IPv6:2001:0db8:0000:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:0000:0000:0000:0000>
14
+ ```
15
+
16
+
17
+ ## Why we need this?
18
+
19
+ This gem is intended to use with ActiveRecord and PostgreSQL.
20
+ With this gem installed, you can store IP address with prefix length information (e.g. "192.0.2.1/24", "2001:db8::1/64") into inet type columns.
21
+
22
+ ActiveRecord itself supports PostgreSQL inet type since Rails 4, but it maps to ruby built-in IPAddr class which does not support CIDR notation by default.
23
+ This gem enables it by tweaking IPAddr class.
4
24
 
5
- TODO: Delete this and the text above, and describe your gem
6
25
 
7
26
  ## Installation
8
27
 
@@ -20,17 +39,32 @@ Or install it yourself as:
20
39
 
21
40
  $ gem install ext_ipaddr
22
41
 
42
+
23
43
  ## Usage
24
44
 
25
- TODO: Write usage instructions here
45
+ ```ruby
46
+ require 'ext_ipaddr'
47
+
48
+ IPAddr.new('192.0.2.1/24')
49
+ # => #<IPAddr: IPv4:192.0.2.1/255.255.255.0>
26
50
 
27
- ## Development
51
+ IPAddr.new('2001:db8::1/64')
52
+ # => #<IPAddr: IPv6:2001:0db8:0000:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:0000:0000:0000:0000>
28
53
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+ IPAddr.new('2001:db8::1/64').to_cidr_s
55
+ # => "2001:db8::1/64"
30
56
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+ IPAddr.new('2001:db8::1/64').prefix_length
58
+ # => 64
32
59
 
33
- ## Contributing
60
+ IPAddr.new('192.0.2.1/24') == IPAddr.new('192.0.2.1/24')
61
+ # => true
34
62
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ext_ipaddr.
63
+ IPAddr.new('192.0.2.1/24') == IPAddr.new('192.0.2.1/32')
64
+ # => false
65
+ ```
66
+
67
+
68
+ ## Contributing
36
69
 
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/s2ugimot/ext_ipaddr
data/ext_ipaddr.gemspec CHANGED
@@ -8,9 +8,10 @@ Gem::Specification.new do |spec|
8
8
  spec.version = ExtIPAddr::VERSION
9
9
  spec.authors = ["Shu Sugimoto"]
10
10
  spec.email = ["shu@su.gimo.to"]
11
+ spec.licenses = ['MIT']
11
12
 
12
- spec.summary = %q{Monkey patch for built-in IPAddr class: CIDR support}
13
- spec.description = %q{Monkey patch for built-in IPAddr class: CIDR support}
13
+ spec.summary = %q{Monkey patch for ruby built-in IPAddr class to make it support CIDR notation}
14
+ spec.description = %q{Monkey patch for ruby built-in IPAddr class to make it support CIDR notation}
14
15
  spec.homepage = "https://github.com/s2ugimot/ext_ipaddr"
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
data/lib/ext_ipaddr.rb CHANGED
@@ -29,7 +29,7 @@ IPAddr.class_eval do
29
29
  IPAddr.new(@mask_addr, @family)
30
30
  end
31
31
 
32
- def prefix
32
+ def prefix_length
33
33
  begin_addr = (@addr & @mask_addr)
34
34
 
35
35
  case @family
@@ -45,7 +45,7 @@ IPAddr.class_eval do
45
45
  end
46
46
 
47
47
  def to_cidr_s
48
- return to_s + "/#{prefix}"
48
+ return to_s + "/#{prefix_length}"
49
49
  end
50
50
 
51
51
  def ==(other)
@@ -1,3 +1,3 @@
1
1
  module ExtIPAddr
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ext_ipaddr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shu Sugimoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-17 00:00:00.000000000 Z
11
+ date: 2015-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: 'Monkey patch for built-in IPAddr class: CIDR support'
69
+ description: Monkey patch for ruby built-in IPAddr class to make it support CIDR notation
70
70
  email:
71
71
  - shu@su.gimo.to
72
72
  executables: []
@@ -85,7 +85,8 @@ files:
85
85
  - lib/ext_ipaddr.rb
86
86
  - lib/ext_ipaddr/version.rb
87
87
  homepage: https://github.com/s2ugimot/ext_ipaddr
88
- licenses: []
88
+ licenses:
89
+ - MIT
89
90
  metadata: {}
90
91
  post_install_message:
91
92
  rdoc_options: []
@@ -103,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  version: '0'
104
105
  requirements: []
105
106
  rubyforge_project:
106
- rubygems_version: 2.4.5.1
107
+ rubygems_version: 2.2.2
107
108
  signing_key:
108
109
  specification_version: 4
109
- summary: 'Monkey patch for built-in IPAddr class: CIDR support'
110
+ summary: Monkey patch for ruby built-in IPAddr class to make it support CIDR notation
110
111
  test_files: []