rippersnapper 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 375d36e17fdc3427684d78503a5259bff5c9c8ca
4
- data.tar.gz: 3bfc53363e6842b565ea9d5c1827419195c3cc1f
3
+ metadata.gz: 7202bdd1f9dc7fa438a08db2f2a6e09482033ee5
4
+ data.tar.gz: 287f5995cb970c67673b50ac2982215ea8fe6515
5
5
  SHA512:
6
- metadata.gz: 7bda7e69321ab8d4a584f52f22b9c5c63bc1b7b965e792233939bfac6336ff8b51929986f6c1aa0f4be665fc1c6d40d9e7953ec6a8a1b6100e1d383b3f99fe48
7
- data.tar.gz: 0c22b9a03958c690749029435c3bf7a60c2215d86fb2aa1c302bed87e0a051bb4e5413799f1a606e7f1a8d55eafea2b16fe8fb36d7780d700fd3655a3872bff2
6
+ metadata.gz: 1861dada6eb732b7b5bf1eeee82e83bc1168ef06385ffa9c3aa619d645b6eee6a5d975519d6273fefd5c3db75da284d3085551d619cda24f43f7289dc295d3ba
7
+ data.tar.gz: a7d4a01f0ea5e3319a6517a432d86d460b7aa8348dc4b35eb963aec412f661cb661d893095bb5ee0f64e08d2cdcc233439ab81f80c33bc81840dd8f328f38f5c
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ gemfile:
3
+ - Gemfile
4
+ script:
5
+ - bundle exec rspec
6
+ rvm:
7
+ - ruby-head
8
+ - 2.1.0
9
+ - 2.0.0
10
+ - 1.9.3
11
+ - jruby-19mode
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Rippersnapper
2
2
 
3
+ [![Build Status](https://travis-ci.org/mwoods79/rippersnapper.svg?branch=master)](https://travis-ci.org/mwoods79/rippersnapper)
4
+ [![Code Climate](https://codeclimate.com/github/mwoods79/rippersnapper.png)](https://codeclimate.com/github/mwoods79/rippersnapper)
5
+
3
6
  ![Rippersnapper](https://github.com/mwoods79/rippersnapper/raw/master/rippersnapper.jpg)
4
7
 
5
8
  Rippersnapper transforms into a weird upright bipedal shark creature. His finned
@@ -35,7 +38,7 @@ Or install it yourself as:
35
38
 
36
39
  ## Notable differences between Rippersnapper and [Domainatrix](https://github.com/pauldix/domainatrix)
37
40
 
38
- One of Rippersnappers goals is to be a compatable API with Domainatrix, but
41
+ One of Rippersnappers goals is to be a compatible API with Domainatrix, but
39
42
  there are some differences.
40
43
 
41
44
  1. Rippersnapper chose the method name `suffix` instead of `public_suffix`.
@@ -2,6 +2,7 @@ require "rippersnapper/version"
2
2
  require "rippersnapper/suffix_file_reader"
3
3
  require "rippersnapper/url"
4
4
  require "rippersnapper/domain_parser"
5
+ require "rippersnapper/ip_parser"
5
6
 
6
7
  module Rippersnapper
7
8
  def self.parse url
@@ -0,0 +1,23 @@
1
+ module Rippersnapper
2
+ class IpParser
3
+
4
+ attr_reader :host
5
+
6
+ def initialize host
7
+ @host = host
8
+ end
9
+
10
+ def suffix
11
+ ""
12
+ end
13
+
14
+ def domain
15
+ host
16
+ end
17
+
18
+ def subdomain
19
+ ""
20
+ end
21
+
22
+ end
23
+ end
@@ -20,6 +20,12 @@ module Rippersnapper
20
20
  @uri ||= URI.parse url
21
21
  end
22
22
 
23
+ # Used to see if the host is an IP address
24
+ # @return [Boolean] true represents an ip address for host
25
+ def ip?
26
+ !!(host =~ /^\d+\.\d+\.\d+\.\d+$/)
27
+ end
28
+
23
29
  # If url has a scheme use it if not assume http
24
30
  # @return [String] The url to be processed
25
31
  def url
@@ -84,7 +90,7 @@ module Rippersnapper
84
90
  private
85
91
 
86
92
  def parsed_domain
87
- @parsed_domain ||= DomainParser.new host
93
+ @parsed_domain ||= ip? ? IpParser.new(host) : DomainParser.new(host)
88
94
  end
89
95
  end
90
96
  end
@@ -1,3 +1,3 @@
1
1
  module Rippersnapper
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -56,5 +56,16 @@ module Rippersnapper
56
56
  its(:subdomain) { should eq "" }
57
57
  its(:port) { should be_nil }
58
58
  end
59
+
60
+ context "whith ip address" do
61
+ subject { Url.new "http://10.0.1.1/" }
62
+ its(:url) { should eq "http://10.0.1.1/" }
63
+ its(:path) { should eq "/" }
64
+ its(:scheme) { should eq "http" }
65
+ its(:host) { should eq "10.0.1.1" }
66
+ its(:suffix) { should eq "" }
67
+ its(:domain) { should eq "10.0.1.1" }
68
+ its(:subdomain) { should eq "" }
69
+ end
59
70
  end
60
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rippersnapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,12 +61,14 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".travis.yml"
64
65
  - Gemfile
65
66
  - LICENSE.txt
66
67
  - README.md
67
68
  - Rakefile
68
69
  - lib/rippersnapper.rb
69
70
  - lib/rippersnapper/domain_parser.rb
71
+ - lib/rippersnapper/ip_parser.rb
70
72
  - lib/rippersnapper/public_suffix.dat
71
73
  - lib/rippersnapper/suffix_file_reader.rb
72
74
  - lib/rippersnapper/url.rb