addressablerer 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.
@@ -0,0 +1,39 @@
1
+ require 'addressabler/uri_deprecation'
2
+
3
+ describe Addressabler, "deprecation" do
4
+ describe "TLDS" do
5
+ it "returns public TLDS" do
6
+ Addressabler::TLDS.should == Addressabler.public_tlds
7
+ end
8
+
9
+ it "warns about the deprecated TLD constant" do
10
+ Addressabler.should_receive(:deprecation_warning)
11
+ Addressabler::TLDS
12
+ end
13
+ end
14
+ end
15
+
16
+ describe Addressable::URI, "deprecation" do
17
+ describe "custom_tlds" do
18
+ it "returns the Addressabler custom_tlds" do
19
+ Addressabler.custom_tlds = {foo: "bar"}
20
+ Addressable::URI.custom_tlds.should == {foo: "bar"}
21
+ end
22
+
23
+ it "sets the Addressabler custom_tlds" do
24
+ Addressable::URI.custom_tlds = {gert: "B. Frobe"}
25
+ Addressabler.custom_tlds.should == {gert: "B. Frobe"}
26
+ end
27
+
28
+ it "warns about the deprecated custom_tlds getter" do
29
+ Addressabler.should_receive(:deprecation_warning)
30
+ Addressable::URI.custom_tlds
31
+ end
32
+
33
+ it "warns about the deprecated custom_tlds setter" do
34
+ Addressabler.should_receive(:deprecation_warning)
35
+ Addressable::URI.custom_tlds = {bring_me: "a sandwich"}
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,116 @@
1
+ require 'addressabler/uri'
2
+
3
+ describe Addressabler::URI do
4
+ it "does not prevent Addressable::URI from parsing" do
5
+ uri = Addressable::URI.parse("http://www.google.com/path?foo=bar#anchor")
6
+ uri.should be_instance_of(Addressable::URI)
7
+ end
8
+
9
+ it "resets when the host changes" do
10
+ uri = Addressable::URI.heuristic_parse("www.google.com")
11
+ uri.tld.should == 'com'
12
+ uri.domain.should == 'google'
13
+ uri.subdomain.should == 'www'
14
+ uri.host = 'www2.google.co.uk'
15
+ uri.tld.should == 'co.uk'
16
+ uri.domain.should == 'google'
17
+ uri.subdomain.should == 'www2'
18
+ end
19
+
20
+ it "does not explode on empty strings" do
21
+ uri = Addressable::URI.parse("")
22
+ uri.host.should be_nil
23
+ uri.domain.should be_nil
24
+ uri.tld.should be_nil
25
+ uri.subdomain.should be_nil
26
+ end
27
+
28
+ describe "#tld" do
29
+ it "returns a TLD" do
30
+ uri = Addressable::URI.parse("http://www.google.com/path?foo=bar#anchor")
31
+ uri.tld.should == 'com'
32
+ end
33
+
34
+ it "knows about complex TLDs" do
35
+ uri = Addressable::URI.parse("http://www.foo.bar.baz.co.uk/gjadgsg#sdgs?adg=f")
36
+ uri.tld.should == 'co.uk'
37
+ end
38
+
39
+ it "knows about newer TLDs" do
40
+ uri = Addressable::URI.parse("http://www.bart-blabla.cc")
41
+ uri.tld.should == 'cc'
42
+ end
43
+
44
+ it "doesn't know non-existant TLDs" do
45
+ uri = Addressable::URI.parse("http://www.bart-blabla.foobar")
46
+ uri.tld.should == ''
47
+ end
48
+
49
+ it "accepts custom TLDs" do
50
+ Addressabler.custom_tlds = { 'foobar' => {} }
51
+ uri = Addressable::URI.parse("http://www.bart-blabla.foobar")
52
+ uri.tld.should == 'foobar'
53
+ end
54
+
55
+ it "accepts nested custom TLDs" do
56
+ Addressabler.custom_tlds = { 'bar' => { 'foo' => {} } }
57
+ uri = Addressable::URI.parse("http://www.bart-blabla.foo.bar")
58
+ uri.tld.should == 'foo.bar'
59
+ end
60
+
61
+ it "is changeable" do
62
+ uri = Addressable::URI.heuristic_parse("www.google.com")
63
+ uri.tld = 'co.uk'
64
+ uri.to_s.should == 'http://www.google.co.uk'
65
+ end
66
+ end
67
+
68
+ describe "#domain" do
69
+ it "returns the domain" do
70
+ uri = Addressable::URI.heuristic_parse("i.am.a.subdomain.co.uk")
71
+ uri.domain.should == "subdomain"
72
+ end
73
+
74
+ it "is changeable" do
75
+ uri = Addressable::URI.heuristic_parse("www.google.com")
76
+ uri.domain = 'amazon'
77
+ uri.to_s.should == 'http://www.amazon.com'
78
+ end
79
+ end
80
+
81
+ describe "#subdomain" do
82
+ it "returns the subdomain" do
83
+ uri = Addressable::URI.heuristic_parse("i.am.a.subdomain.co.uk")
84
+ uri.subdomain.should == "i.am.a"
85
+ end
86
+
87
+ it "is changeable" do
88
+ uri = Addressable::URI.heuristic_parse("www.google.com")
89
+ uri.subdomain = 'www2'
90
+ uri.to_s.should == 'http://www2.google.com'
91
+ end
92
+
93
+ it "is blank when none exists" do
94
+ uri = Addressable::URI.parse("http://google.com")
95
+ uri.host.should == "google.com"
96
+ uri.domain.should == "google"
97
+ uri.tld.should == "com"
98
+ uri.subdomain.should == ""
99
+ end
100
+ end
101
+
102
+ describe "#query_hash" do
103
+ it "supports adding keys to the query" do
104
+ uri = Addressable::URI.parse("http://www.foo.bar.baz.co.uk/gjadgsg?adg=f")
105
+ uri.query_hash.should == {'adg' => 'f'}
106
+ uri.query_hash[:foo] = "bar"
107
+ uri.to_s.should == "http://www.foo.bar.baz.co.uk/gjadgsg?adg=f&foo=bar"
108
+ end
109
+
110
+ it "supports adding nested values to the query" do
111
+ uri = Addressable::URI.parse("http://www.amazon.ca")
112
+ uri.query_hash[:foo] = {:bar => "baz", :sommat => [:else, 1, true, false]}
113
+ uri.to_s.should == "http://www.amazon.ca?foo[bar]=baz&foo[sommat][]=else&foo[sommat][]=1&foo[sommat][]=true&foo[sommat][]=false"
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,18 @@
1
+ require "addressabler"
2
+
3
+ describe Addressabler do
4
+ describe ".parse_tlds" do
5
+ it "doesn't return private TLDs by default" do
6
+ host = 'fwefweewf.blogspot.com'
7
+ tld = Addressabler.parse_tld(host)
8
+ tld.should == 'com'
9
+ end
10
+
11
+ it "can switch private tlds on" do
12
+ Addressabler.use_private_tlds = true
13
+ host = 'fwefweewf.blogspot.com'
14
+ tld = Addressabler.parse_tld(host)
15
+ tld.should == 'blogspot.com'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ require 'rspec/autorun'
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: addressablerer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Flip Sasser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: addressable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.3'
27
+ description: "\n Addressabler extends the Addressable::URI class to provide information
28
+ about, and manipulation of, specific parts of URI strings. It adds a `tld' method,
29
+ a `domain' method,\n and a `subdomain' method.\n\nIt also allows users to easily
30
+ modify the URL's query values as a hash.\n \n This is a fork to ensure the
31
+ gem works in Ruby versions > 1.9.3.\n "
32
+ email: flip@x451.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files:
36
+ - LICENSE
37
+ - README.md
38
+ files:
39
+ - CHANGELOG.md
40
+ - LICENSE
41
+ - README.md
42
+ - lib/addressabler.rb
43
+ - lib/addressabler/query.rb
44
+ - lib/addressabler/uri.rb
45
+ - lib/addressabler/uri_deprecation.rb
46
+ - lib/tlds
47
+ - spec/addressable/idna_spec.rb
48
+ - spec/addressable/net_http_compat_spec.rb
49
+ - spec/addressable/template_spec.rb
50
+ - spec/addressable/uri_spec.rb
51
+ - spec/addressabler/uri_deprecation_spec.rb
52
+ - spec/addressabler/uri_spec.rb
53
+ - spec/addressabler_spec.rb
54
+ - spec/spec_helper.rb
55
+ homepage: http://github.com/flipsasser/addressabler
56
+ licenses: []
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.2.0
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: An Addressable::URI extension adding support for TLDs and query part editing
78
+ test_files:
79
+ - spec/addressable/idna_spec.rb
80
+ - spec/addressable/net_http_compat_spec.rb
81
+ - spec/addressable/template_spec.rb
82
+ - spec/addressable/uri_spec.rb
83
+ - spec/addressabler/uri_deprecation_spec.rb
84
+ - spec/addressabler/uri_spec.rb
85
+ - spec/addressabler_spec.rb
86
+ - spec/spec_helper.rb