adomain 0.2.0 → 0.2.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +52 -20
- data/lib/adomain/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ff6ad12bb0daeb96fbb1ce22ee09f4cf09c5f6a0ac3ef21336792c977e4dce1
|
4
|
+
data.tar.gz: be1e2cfa7e6a72b6595dc2d79e70f636cce95fc3fa9d4215a366b45e458a6baf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50d9e06e046e86d8f5e4f5fd9c58af82f101c62ddfff23a263571f2afc7315d5ea555da4ed52a4df33399c629baecbf0e98da6137b17b5487470a8cb991b4c62
|
7
|
+
data.tar.gz: b75ef3af5862e458d9389ce3bba1ba385d1bf528f30ae842c5c7121a9e818871203e728855aef1a4440f0f8060e6ed276ab42cee352e60dd0d93de93f3283ca1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,10 +13,12 @@ Adomain["https://www.xyz.com"]
|
|
13
13
|
# => "xyz.com"
|
14
14
|
```
|
15
15
|
|
16
|
-
Adomain returns the URL host, stripping 'www' by default,
|
17
|
-
|
16
|
+
Adomain returns the URL host, stripping 'www' by default,
|
17
|
+
scheming your URL if necessary (with "https://").
|
18
|
+
Optionally, you can strip subdomains or keep 'www' subdomains – see below.
|
18
19
|
|
19
|
-
[`Addressable::URI.parse`](https://github.com/sporkmonger/addressable#example-usage)
|
20
|
+
[`Addressable::URI.parse`](https://github.com/sporkmonger/addressable#example-usage)
|
21
|
+
performs the parsing.
|
20
22
|
|
21
23
|
## Other methods and options
|
22
24
|
|
@@ -41,36 +43,59 @@ Adomain.domain "http://abc.xyz.com" # => "xyz.com"
|
|
41
43
|
Adomain.subdomain_www "http://www.xyz.com" # => "www.xyz.com"
|
42
44
|
```
|
43
45
|
|
46
|
+
### Domain options
|
47
|
+
|
44
48
|
Optionally, each method accepts boolean values,
|
45
49
|
allowing you to contort the method to do something other
|
46
50
|
than what it says it does. Don't do this, unless you want to.
|
47
51
|
|
48
|
-
|
52
|
+
#### A gotcha: Adomain returns nil for some invalid values
|
49
53
|
|
50
|
-
Because Adomain adds a scheme to any string passed to it
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
Because Adomain adds a scheme to any string passed to it,
|
55
|
+
schemeless-but-otherwise valid strings do not raise errors.
|
56
|
+
Additionally, Adomain rescues InvalidURIError errors,
|
57
|
+
and instead returns nil.
|
54
58
|
|
55
59
|
```ruby
|
56
60
|
Adomain["hola"] # => nil
|
57
61
|
Adomain["::::::::"] # => nil
|
58
|
-
Adomain[""] # =>
|
59
|
-
Adomain["{}"] # =>
|
60
|
-
Gem::Version.new(Adomain::VERSION) >= Gem::Version.new(0.2) # => false
|
62
|
+
Adomain[""] # => nil
|
63
|
+
Adomain["{}"] # => nil
|
61
64
|
```
|
62
65
|
|
63
|
-
####
|
66
|
+
#### NOTE: InvalidURIError are now caught in >= version 0.2
|
64
67
|
|
65
|
-
|
66
|
-
and ignored. Nil
|
68
|
+
With 0.2 `Addressable::URI::InvalidURIError`s are now caught
|
69
|
+
and ignored. Nil is returned.
|
67
70
|
|
68
71
|
```ruby
|
69
72
|
Gem::Version.new(Adomain::VERSION) >= Gem::Version.new(0.2) # => true
|
70
73
|
Adomain["hola"] # => nil
|
71
74
|
Adomain["::::::::"] # => nil
|
72
|
-
Adomain[""] # => nil
|
73
|
-
Adomain["{}"] # => nil
|
75
|
+
Adomain[""] # => nil (formerly raised a Addressable::URI::InvalidURIError)
|
76
|
+
Adomain["{}"] # => nil (formerly raised a Addressable::URI::InvalidURIError)
|
77
|
+
```
|
78
|
+
|
79
|
+
### Convenience Addressable passthroughs
|
80
|
+
|
81
|
+
These methods are simply passed through to parsed
|
82
|
+
Addressable URI objects, and respond accordingly.
|
83
|
+
These are presented for your convenience, and will track with
|
84
|
+
your version of Addressable.
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
Adomain.path "http://www.xyz.com/pages/123" # => "/pages/123"
|
88
|
+
Adomain.path "{{{{{" # => "{{{{{"
|
89
|
+
Adomain.scheme "http://www.xyz.com/pages/123" # => "http"
|
90
|
+
Adomain.scheme "harrison:ford" # => "harrison"
|
91
|
+
```
|
92
|
+
|
93
|
+
However, they are rescued from InvalidURIError,
|
94
|
+
like in other parts of the gem.
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
Adomain.path "::::::::::::" #=> nil
|
98
|
+
Adomain.scheme "::::::::::::" #=> nil
|
74
99
|
```
|
75
100
|
|
76
101
|
## Installation
|
@@ -89,16 +114,23 @@ Or install it yourself as:
|
|
89
114
|
|
90
115
|
## Development
|
91
116
|
|
92
|
-
File bugs against the GitHub issue tracker and pull requests to match,
|
117
|
+
File bugs against the GitHub issue tracker and pull requests to match,
|
118
|
+
where possible.
|
93
119
|
|
94
120
|
## Contributing
|
95
121
|
|
96
|
-
Bug reports and pull requests are welcome on GitHub at
|
122
|
+
Bug reports and pull requests are welcome on GitHub at
|
123
|
+
https://github.com/samnissen/adomain. This project is intended to be a safe,
|
124
|
+
welcoming space for collaboration, and contributors are expected to adhere
|
125
|
+
to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
97
126
|
|
98
127
|
## License
|
99
128
|
|
100
|
-
The gem is available as open source under the terms of the
|
129
|
+
The gem is available as open source under the terms of the
|
130
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
101
131
|
|
102
132
|
## Code of Conduct
|
103
133
|
|
104
|
-
Everyone interacting in the Adomain project’s codebases, issue trackers,
|
134
|
+
Everyone interacting in the Adomain project’s codebases, issue trackers,
|
135
|
+
chat rooms and mailing lists is expected to follow the
|
136
|
+
[code of conduct](https://github.com/samnissen/adomain/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/adomain/version.rb
CHANGED