true_url 0.0.1 → 0.0.2

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: 496c04ece239c5302c9548b0a4b7d93630125172
4
- data.tar.gz: 74c68ce403f401579bbc9b354b283595b5516302
3
+ metadata.gz: bfa4b7a52e702e5a1665ab7fcddceeba5fad7548
4
+ data.tar.gz: de4c238df43b8a0655c5c3a8f51b55923d41aecf
5
5
  SHA512:
6
- metadata.gz: cfbf6e4099c911e66ff6061ecd98b0e98c60b8411659904d57d76c9bf1b4a2da207f0a19b9f11597ff8bf22a8ae716a7d49706b0a46730b6e824c99e970542cd
7
- data.tar.gz: c186b1d04c781de99d61d64b9b3052e2f667ba140cba10c05db5e51ab0b43beddc0ee20d2318a534b84ed7ac8019294949a4fd18bcfe50a4492230431e13db6a
6
+ metadata.gz: d5afa12c6ed53aa0be33fb080231590bbe31f4d2745844e08484de1b45ed3b342ffd0e959bb4dbbddd08a43d7437bd20a3ff114e2fc5f513b33883361ccb6428
7
+ data.tar.gz: a3e5afd1bd3ff13a64a4cdb98194de7952c264635c438be8ea0f716726f8152cbc6e0fcc3f3171c7bd69030a56e97afd2052f1f5720dbc92ce04fac5a9b9fa06
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'spec/spec_helper.rb'
4
+
5
+ Metrics/LineLength:
6
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in true_url.gemspec
4
- gemspec
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in MetaInspector.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
7
+ gem 'rspec'
data/README.md CHANGED
@@ -1 +1,47 @@
1
- # true_url
1
+ [![Gem Version](https://badge.fury.io/rb/true_url.svg)](https://badge.fury.io/rb/true_url)
2
+ [![Code Climate](https://codeclimate.com/github/armchairtheorist/true_url/badges/gpa.svg)](https://codeclimate.com/github/armchairtheorist/true_url)
3
+ [![Build Status](https://travis-ci.org/armchairtheorist/true_url.svg?branch=master)](https://travis-ci.org/armchairtheorist/true_url)
4
+
5
+ # TrueURL
6
+
7
+ **TrueURL** helps normalize, clean and derive a canonical URL for any given URL. Unlike other similar projects, **TrueURL** uses a configurable multi-strategy approach, including tailored strategies for specific sites (e.g. YouTube, DailyMotion, Twitter, etc.) as well as general strategies (e.g. ```rel="canonical"```, etc.).
8
+
9
+ ## Installation
10
+
11
+ Install the gem from RubyGems:
12
+
13
+ ```bash
14
+ gem install true_url
15
+ ```
16
+
17
+ If you use Bundler, just add it to your Gemfile and run `bundle install`
18
+
19
+ ```ruby
20
+ gem 'true_url'
21
+ ```
22
+
23
+ I have only tested this gem on Ruby 2.3.0, but there shouldn't be any reason why it wouldn't work on earlier Ruby versions as well. **TrueURL** only requires the **Addressable** gem as a dependency. if page fetching is required, then the **HTTP** and **Nokogiri** gems are also required as dependencies.
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ x = TrueURL.new("https://youtu.be/RDocnbkHjhI?list=PLs4hTtftqnlAkiQNdWn6bbKUr-P1wuSm0")
29
+ puts x.canonical # => https://www.youtube.com/watch?v=RDocnbkHjhI
30
+
31
+ x = TrueURL.new("http://embed.nicovideo.jp/watch/sm25956031/script?w=490&h=307&redirect=1")
32
+ puts x.canonical # => http://www.nicovideo.jp/watch/sm25956031
33
+
34
+ x = TrueURL.new("http://t.co/fvaGuRa5Za")
35
+ puts x.canonical # => http://www.prdaily.com/Main/Articles/3_essential_skills_for_todays_PR_pro__18404.aspx
36
+ ```
37
+
38
+ ## Other URL Canonicalization Projects (for Ruby)
39
+
40
+ * [URLCanonicalize](https://github.com/dominicsayers/url_canonicalize)
41
+ * [UrlParser](https://github.com/activefx/url_parser)
42
+ * [PostRank URI](https://github.com/postrank-labs/postrank-uri)
43
+ * [Linkr](https://github.com/bbc/linkr)
44
+ * [Pope](https://github.com/socksforrobots/pope)
45
+
46
+ ## License
47
+ **TrueURL** is released under the [MIT license](MIT-LICENSE).
@@ -33,7 +33,7 @@ class TrueURL
33
33
  private
34
34
 
35
35
  def parse(url)
36
- (url.is_a? Addressable::URI) ? url : Addressable::URI.parse(url)
36
+ url.is_a?(Addressable::URI) ? url : Addressable::URI.parse(url)
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  class TrueURL
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
data/lib/true_url.rb CHANGED
@@ -102,7 +102,7 @@ class TrueURL
102
102
  def find_canonical_header(headers)
103
103
  return if headers['Link'].nil?
104
104
 
105
- links = (headers['Link'].is_a? String) ? [headers['Link']] : headers['Link']
105
+ links = headers['Link'].is_a?(String) ? [headers['Link']] : headers['Link']
106
106
  links.each { |link| return link.split(/[<>;]/)[1] if link.end_with?('rel="canonical"') }
107
107
  nil
108
108
  end
data/true_url.gemspec CHANGED
@@ -1,22 +1,22 @@
1
- require File.expand_path('../lib/true_url/version', __FILE__)
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'true_url'
5
- spec.version = TrueURL::VERSION
6
- spec.authors = ['Jonathan Wong']
7
- spec.email = ['jonathan@armchairtheorist.com']
8
- spec.summary = 'A multi-strategy approach to find the absolutely cleanest and most likely canonical URL of any given URL.'
9
- spec.homepage = 'http://github.com/armchairtheorist/true_url'
10
- spec.license = 'MIT'
11
-
12
- spec.files = `git ls-files`.split("\n")
13
- spec.test_files = `git ls-files -- {spec}/*`.split("\n")
14
- spec.require_paths = ['lib']
15
-
16
- spec.add_development_dependency 'rspec', '~> 0'
17
- spec.add_development_dependency 'rake', '~> 0'
18
- spec.add_development_dependency 'http', '~> 2.1', ">= 2.1.0"
19
- spec.add_development_dependency 'nokogiri', '~> 1.6', ">= 1.6.8"
20
-
21
- spec.add_runtime_dependency 'addressable', '~> 2.4', ">= 2.4.0"
22
- end
1
+ require File.expand_path('../lib/true_url/version', __FILE__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'true_url'
5
+ spec.version = TrueURL::VERSION
6
+ spec.authors = ['Jonathan Wong']
7
+ spec.email = ['jonathan@armchairtheorist.com']
8
+ spec.summary = 'A multi-strategy approach to find the absolutely cleanest and most likely canonical URL of any given URL.'
9
+ spec.homepage = 'http://github.com/armchairtheorist/true_url'
10
+ spec.license = 'MIT'
11
+
12
+ spec.files = `git ls-files`.split("\n")
13
+ spec.test_files = `git ls-files -- {spec}/*`.split("\n")
14
+ spec.require_paths = ['lib']
15
+
16
+ spec.add_development_dependency 'rspec', '~> 0'
17
+ spec.add_development_dependency 'rake', '~> 0'
18
+ spec.add_development_dependency 'http', '~> 2.1', '>= 2.1.0'
19
+ spec.add_development_dependency 'nokogiri', '~> 1.6', '>= 1.6.8'
20
+
21
+ spec.add_runtime_dependency 'addressable', '~> 2.4', '>= 2.4.0'
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: true_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Wong
@@ -107,6 +107,8 @@ extra_rdoc_files: []
107
107
  files:
108
108
  - ".gitignore"
109
109
  - ".rspec"
110
+ - ".rubocop.yml"
111
+ - ".travis.yml"
110
112
  - Gemfile
111
113
  - LICENSE.txt
112
114
  - README.md