ipconverter 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/Rakefile +2 -0
- data/ext/ipconverter/ipconverter.c +7 -7
- data/lib/ipconverter/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35d504928af695671d8144143e89352318257797
|
4
|
+
data.tar.gz: 2209fc9ad9a7198c04e7432f1082dfc9baa49467
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 801b267b6b1316cc979a26d78662d0ecef5579aa160c90925488174783af33920eef1c7e3d1b7c164fe3126f646e561dabf8ff937d7d0c79ac656c3ea69d5789
|
7
|
+
data.tar.gz: 8a39dd4ec289ae550de076791d58ce113886baa4602091d302f7b13fcf32f3fca765cc68f9f40dca3267742b31ec4c59940222cf02bc7e0b5143eb201c348e39
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ Library to deal with IP Address conversions/manipulation, such as converting
|
|
4
4
|
a string representation like "192.168.2.1" to its integer representation
|
5
5
|
(3232236033)
|
6
6
|
|
7
|
+
Tested with Ruby >= 1.9.3.
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
@@ -31,6 +33,15 @@ IpConverter.str_to_int "192.168.2"
|
|
31
33
|
=> raises ArgumentError
|
32
34
|
```
|
33
35
|
|
36
|
+
## Running the tests
|
37
|
+
|
38
|
+
Clone the repo
|
39
|
+
```
|
40
|
+
bundle install
|
41
|
+
bundle exec rake compile
|
42
|
+
bundle exec rake test
|
43
|
+
```
|
44
|
+
|
34
45
|
## Contributing
|
35
46
|
|
36
47
|
1. Fork it ( https://github.com/joshuawscott/ipconverter/fork )
|
data/Rakefile
CHANGED
@@ -48,21 +48,21 @@ VALUE method_str_to_int(VALUE _module_, VALUE ip_string) {
|
|
48
48
|
// value and stores that in result.
|
49
49
|
static int
|
50
50
|
ip_string_to_long(char c_string[], uint32_t *result) {
|
51
|
-
|
51
|
+
uint32_t i, found_octets;
|
52
52
|
char junk;
|
53
|
-
|
53
|
+
uint32_t octets[4];
|
54
54
|
|
55
55
|
found_octets = sscanf((char*)c_string, "%d.%d.%d.%d%c", (int*)&octets[3], (int*)&octets[2], (int*)&octets[1], (int*)&octets[0], &junk);
|
56
56
|
|
57
57
|
// If we didn't find exactly 4 octets, bail out, unless the extra is whitespace
|
58
|
-
if (found_octets != 4
|
58
|
+
if (found_octets != 4
|
59
59
|
&& !(found_octets == 5 && junk == ' ')) {
|
60
60
|
return 0;
|
61
61
|
}
|
62
62
|
|
63
63
|
// If any of the octets are not in-range, bail out
|
64
64
|
for (i = 0; i < 4; i++) {
|
65
|
-
if (octets[i] > 255
|
65
|
+
if (octets[i] > 255) {
|
66
66
|
return 0;
|
67
67
|
}
|
68
68
|
}
|
@@ -76,14 +76,14 @@ ip_string_to_long(char c_string[], uint32_t *result) {
|
|
76
76
|
* IpConverter.int_to_str(ip_addr_integer) -> String
|
77
77
|
*
|
78
78
|
* Converts the passed integer into an IPv4 address string.
|
79
|
-
*
|
79
|
+
*
|
80
80
|
* Raises ArugmentError if number is negative, or greater than the maximum
|
81
81
|
* possible value for an IPv4 address (4294967295)
|
82
82
|
*
|
83
83
|
* Example:
|
84
84
|
* IpConverter.int_to_str(3232236033)
|
85
85
|
* => "192.168.2.1"
|
86
|
-
*
|
86
|
+
*
|
87
87
|
*/
|
88
88
|
VALUE
|
89
89
|
method_int_to_str(VALUE _module_, VALUE ip_fixnum) {
|
@@ -104,7 +104,7 @@ ip_long_to_string(uint32_t ip, char c_string[]) {
|
|
104
104
|
bytes[0] = ip & 0xFF;
|
105
105
|
bytes[1] = (ip >> 8) & 0xFF;
|
106
106
|
bytes[2] = (ip >> 16) & 0xFF;
|
107
|
-
bytes[3] = (ip >> 24) & 0xFF;
|
107
|
+
bytes[3] = (ip >> 24) & 0xFF;
|
108
108
|
|
109
109
|
sprintf(c_string, "%d.%d.%d.%d", bytes[3], bytes[2], bytes[1], bytes[0]);
|
110
110
|
}
|
data/lib/ipconverter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipconverter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Scott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,9 +111,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.2.3
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Utilities for working with IP addresses
|
118
118
|
test_files:
|
119
119
|
- test/test_ipconverter.rb
|
120
|
+
has_rdoc:
|