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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 569306c1d30040a36691edb14d10dd202edd90ae
4
- data.tar.gz: 9e8a3cca376177beb1ca8bfeb4ee17776334ff0e
3
+ metadata.gz: b26748d9d31ccbf10fd4238cf41efa5457b47e90
4
+ data.tar.gz: 68a9e119599a4800f9d8f17e5d6320da6c2a6ae0
5
5
  SHA512:
6
- metadata.gz: 783a55829c621c019b81ec3b0af3a9b1c696608498bed06c3418bc0137474458e962c9765542729b8479620c48518ca8cfd8ba44e13c4988c86e989548fc94d0
7
- data.tar.gz: f53daacef940d209fbf99866fc4df388918507f8eb5642b855904776cb90a5054bb091cc4ee99a860648b151dbcf0b09ae0861f2d2a427dd720a774a0f5d4f7a
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
- begin
33
+ if RUBY_VERSION == '2.1.0' and RUBY_REVISION >= 40460
34
34
  URI.decode_www_form(self.query)
35
- rescue ArgumentError # fixed in ruby 2.1.0 r40460
36
- raise QueryParamWithoutValueError
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
 
@@ -12,7 +12,7 @@ module Truncator
12
12
  begin
13
13
  uri = URI(uri)
14
14
  rescue URI::InvalidURIError
15
- uri.sub!(/\Ahttp:\/\//, '') # remove http protocol
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
 
@@ -1,3 +1,3 @@
1
1
  module Truncator
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -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
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-21 00:00:00.000000000 Z
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.0.3
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: