truncator 0.1.4 → 0.1.5
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/lib/truncator/extended_uri.rb +7 -3
- data/lib/truncator/url_parser.rb +2 -2
- data/lib/truncator/version.rb +1 -1
- data/spec/url_parser_spec.rb +8 -0
- 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: b26748d9d31ccbf10fd4238cf41efa5457b47e90
|
4
|
+
data.tar.gz: 68a9e119599a4800f9d8f17e5d6320da6c2a6ae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c6b0b3cc8c5d32923dadc242aa71dfca80a434826f3a4794293b9ba52bd7464c5882f5f3fd74a9611f13f00abd3245abbe5cb88636844c0f64b4cc024ac99a4
|
7
|
+
data.tar.gz: a7d553fbb838564c596e139d010cfa07e4c88ad99e127805252166415377196dee46cb12bbfcc361ec7323b68044a57f0109ddf2b044c2feb7398fe2bab1fbfb
|
@@ -30,10 +30,14 @@ module Truncator
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def query_parameters
|
33
|
-
|
33
|
+
if RUBY_VERSION == '2.1.0' and RUBY_REVISION >= 40460
|
34
34
|
URI.decode_www_form(self.query)
|
35
|
-
|
36
|
-
|
35
|
+
else
|
36
|
+
begin
|
37
|
+
URI.decode_www_form(self.query)
|
38
|
+
rescue ArgumentError # fixed in ruby 2.1.0 r40460
|
39
|
+
raise QueryParamWithoutValueError
|
40
|
+
end
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
data/lib/truncator/url_parser.rb
CHANGED
@@ -12,7 +12,7 @@ module Truncator
|
|
12
12
|
begin
|
13
13
|
uri = URI(uri)
|
14
14
|
rescue URI::InvalidURIError
|
15
|
-
uri.sub
|
15
|
+
uri = uri.sub(/\Ahttp:\/\//, '') # remove http protocol
|
16
16
|
return uri.truncate(truncation_length)
|
17
17
|
end
|
18
18
|
|
@@ -48,7 +48,7 @@ module Truncator
|
|
48
48
|
|
49
49
|
uri.special_format
|
50
50
|
|
51
|
-
rescue Truncator::ExtendedURI::QueryParamWithoutValueError
|
51
|
+
rescue Truncator::ExtendedURI::QueryParamWithoutValueError # for ruby <2.1.0 r40460
|
52
52
|
return uri.to_s.truncate(truncation_length)
|
53
53
|
end
|
54
54
|
|
data/lib/truncator/version.rb
CHANGED
data/spec/url_parser_spec.rb
CHANGED
@@ -176,6 +176,14 @@ describe Truncator::UrlParser do
|
|
176
176
|
it 'should just perform a basic truncation after removing http://' do
|
177
177
|
Truncator::UrlParser.shorten_url(dangerous_url, 30).should == 'www.first.army.mil/family/c...'
|
178
178
|
end
|
179
|
+
|
180
|
+
context 'string is frozen' do
|
181
|
+
let(:frozen_string) { dangerous_url.freeze }
|
182
|
+
|
183
|
+
it "shouldn't raise exception" do
|
184
|
+
expect { Truncator::UrlParser.shorten_url(frozen_string, 30)}.not_to raise_exception
|
185
|
+
end
|
186
|
+
end
|
179
187
|
end
|
180
188
|
|
181
189
|
context 'when URL contains query param with no value' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: truncator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- freemanoid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -108,8 +108,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.1.11
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Truncate urls as much as possible
|
115
115
|
test_files: []
|
116
|
+
has_rdoc:
|