embiggen 0.1.1 → 0.2.0

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: 47bfb5ace689946c57eb0595e0aa5c9992a6fe70
4
- data.tar.gz: 7a1d1441cf49e8b785c9c63ed9f07899d08d0283
3
+ metadata.gz: e042af897bb6b3d3f859ef7f8b98b2baa82a549c
4
+ data.tar.gz: de3ac88d70c05591727ba4cbd291dea762add074
5
5
  SHA512:
6
- metadata.gz: ac5abe95ea7a88f6e93d8815b91c963362fe671fbb1334d4b8e104d06bac61cf846ce2fb7ee9bdf6a73a8d9b33e1c26a417b63ef4d6d228097aa9ee8136aeb64
7
- data.tar.gz: 40a02c961adffd16f0f06b4d0851817ba8fc9f21ed08f3383831118e2ee1a101a91fd574e9b60751e99452b9000be6fd2ac81b3eeacb2d4d34108f97c2f444a7
6
+ metadata.gz: 52ea1b1bdd91f6d958ff730e94dafa63475794b28803743fce061980288bd9d75d80f1937eaad6c998d7b6b967daf9c274500e3fa6979f590a5044ec121f20b7
7
+ data.tar.gz: 920c7a714f80a7d75ade6a8982a68c6791bc4bfda7aca81e7956469a2d8ec0e1d92c9c71995577bf6ef319d2a45c62e352b8f4fe8ef415e1f88b39e33023c3c1
data/README.md CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
  A Ruby library to expand shortened URLs.
4
4
 
5
- **Current version:** 0.1.1
5
+ **Current version:** 0.2.0
6
6
  **Supported Ruby versions:** 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2
7
7
 
8
8
  ## Installation
9
9
 
10
10
  ```
11
- gem install embiggen -v '~> 0.1'
11
+ gem install embiggen -v '~> 0.2'
12
12
  ```
13
13
 
14
14
  Or, in your `Gemfile`:
15
15
 
16
16
  ```ruby
17
- gem 'embiggen', '~> 0.1'
17
+ gem 'embiggen', '~> 0.2'
18
18
  ```
19
19
 
20
20
  ## Usage
data/lib/embiggen/uri.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'embiggen/configuration'
2
+ require 'addressable/uri'
2
3
  require 'net/http'
3
4
 
4
5
  module Embiggen
@@ -6,7 +7,7 @@ module Embiggen
6
7
  attr_reader :uri
7
8
 
8
9
  def initialize(uri)
9
- @uri = uri.is_a?(::URI::Generic) ? uri : URI(uri.to_s)
10
+ @uri = URI(::Addressable::URI.parse(uri).normalize.to_s)
10
11
  end
11
12
 
12
13
  def expand(request_options = {})
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'embiggen'
2
3
 
3
4
  module Embiggen
@@ -30,6 +31,24 @@ module Embiggen
30
31
  expect(uri.expand).to eq(URI('http://us.macmillan.com/books/9781466879980'))
31
32
  end
32
33
 
34
+ it 'expands URIs with encoded locations' do
35
+ stub_redirect('http://bit.ly/1ciyUPh',
36
+ 'http://www.example.com/%C3%A9%20%C3%BC')
37
+
38
+ uri = described_class.new('http://bit.ly/1ciyUPh')
39
+
40
+ expect(uri.expand).to eq(URI('http://www.example.com/%C3%A9%20%C3%BC'))
41
+ end
42
+
43
+ it 'expands URIs with unencoded locations' do
44
+ stub_redirect('http://bit.ly/1ciyUPh',
45
+ 'http://www.example.com/é ü')
46
+
47
+ uri = described_class.new('http://bit.ly/1ciyUPh')
48
+
49
+ expect(uri.expand).to eq(URI('http://www.example.com/%C3%A9%20%C3%BC'))
50
+ end
51
+
33
52
  it 'does not expand unshortened URIs' do
34
53
  uri = described_class.new(URI('http://www.altmetric.com'))
35
54
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embiggen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Mucur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-25 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement