external_link_to 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d17abb5ad38408677624c2e779a6a43e97d47ad309f86a5aaeeb7bc1c57e08e3
4
+ data.tar.gz: 555cce05a2935d965e5a796da2d5da60fa70c4c4f967cfce7db08d45e328b3d3
5
+ SHA512:
6
+ metadata.gz: 518f4472196fbe155b793ea370b4668e72d51f18fb106b4e150c4e48e2680965dcebf8bf30ffcc14cd0cce646a40af16ffd89f1ea9849d09627aedca2ef505c5
7
+ data.tar.gz: 63a5cc0937ae7701f7d6e2117b38c56cb8e24e3de35fec8efc5f7819c20e5e9b25bfb3e9a954b7fae177b54c8f2b124b06b7057fbde6dca3a92a08e45f618bc5
@@ -0,0 +1 @@
1
+ custom: https://www.paypal.me/guillaumebriday
@@ -0,0 +1,16 @@
1
+ name: Lint
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ rubocop:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v1
10
+ - uses: actions/setup-ruby@v1
11
+ with:
12
+ ruby-version: 2.6.x
13
+ - run: |
14
+ gem install bundler --no-document
15
+ bundle install -j $(nproc) --quiet
16
+ bundle exec rubocop
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in external_link_to.gemspec
6
+ gemspec
@@ -0,0 +1,84 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ external_link_to (0.1.0)
5
+ actionpack
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (6.0.3.2)
11
+ actionview (= 6.0.3.2)
12
+ activesupport (= 6.0.3.2)
13
+ rack (~> 2.0, >= 2.0.8)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
+ actionview (6.0.3.2)
18
+ activesupport (= 6.0.3.2)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
+ activesupport (6.0.3.2)
24
+ concurrent-ruby (~> 1.0, >= 1.0.2)
25
+ i18n (>= 0.7, < 2)
26
+ minitest (~> 5.1)
27
+ tzinfo (~> 1.1)
28
+ zeitwerk (~> 2.2, >= 2.2.2)
29
+ ast (2.4.1)
30
+ builder (3.2.4)
31
+ concurrent-ruby (1.1.6)
32
+ crass (1.0.6)
33
+ erubi (1.9.0)
34
+ i18n (1.8.3)
35
+ concurrent-ruby (~> 1.0)
36
+ loofah (2.6.0)
37
+ crass (~> 1.0.2)
38
+ nokogiri (>= 1.5.9)
39
+ mini_portile2 (2.4.0)
40
+ minitest (5.14.1)
41
+ nokogiri (1.10.9)
42
+ mini_portile2 (~> 2.4.0)
43
+ parallel (1.19.2)
44
+ parser (2.7.1.4)
45
+ ast (~> 2.4.1)
46
+ rack (2.2.3)
47
+ rack-test (1.1.0)
48
+ rack (>= 1.0, < 3)
49
+ rails-dom-testing (2.0.3)
50
+ activesupport (>= 4.2.0)
51
+ nokogiri (>= 1.6)
52
+ rails-html-sanitizer (1.3.0)
53
+ loofah (~> 2.3)
54
+ rainbow (3.0.0)
55
+ regexp_parser (1.7.1)
56
+ rexml (3.2.4)
57
+ rubocop (0.86.0)
58
+ parallel (~> 1.10)
59
+ parser (>= 2.7.0.1)
60
+ rainbow (>= 2.2.2, < 4.0)
61
+ regexp_parser (>= 1.7)
62
+ rexml
63
+ rubocop-ast (>= 0.0.3, < 1.0)
64
+ ruby-progressbar (~> 1.7)
65
+ unicode-display_width (>= 1.4.0, < 2.0)
66
+ rubocop-ast (0.1.0)
67
+ parser (>= 2.7.0.1)
68
+ ruby-progressbar (1.10.1)
69
+ thread_safe (0.3.6)
70
+ tzinfo (1.2.7)
71
+ thread_safe (~> 0.1)
72
+ unicode-display_width (1.7.0)
73
+ zeitwerk (2.3.1)
74
+
75
+ PLATFORMS
76
+ ruby
77
+
78
+ DEPENDENCIES
79
+ bundler (~> 2.0)
80
+ external_link_to!
81
+ rubocop
82
+
83
+ BUNDLED WITH
84
+ 2.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Guillaume Briday
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/guillaumebriday)
2
+ ![](https://github.com/guillaumebriday/external_link_to/workflows/Lint/badge.svg)
3
+ [![](https://img.shields.io/gem/dt/external_link_to.svg)](https://rubygems.org/gems/external_link_to)
4
+ [![](https://img.shields.io/gem/v/external_link_to.svg)](https://rubygems.org/gems/external_link_to)
5
+ [![](https://img.shields.io/github/license/guillaumebriday/external_link_to.svg)](https://github.com/guillaumebriday/external_link_to)
6
+
7
+ # external_link_to
8
+
9
+ This gem provides a wrapper around the built in `ActionView::Helpers::UrlHelper#link_to` method available in Rails.
10
+ It creates a link tag with `target="_blank"` and `rel="noopener noreferrer"` attributes by default. Simple as that.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'external_link_to'
18
+ ```
19
+
20
+ And then execute:
21
+ ```bash
22
+ $ bundle
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ For instance, this link:
28
+ ```ruby
29
+ link_to 'Home', root_path, rel: 'noopener noreferrer', target: '_blank'
30
+ # => <a rel="noopener noreferrer" target="_blank" href="/">Profile</a>Home
31
+ ```
32
+
33
+ is exactly the same as:
34
+ ```ruby
35
+ external_link_to 'Home', root_path
36
+ # => <a rel="noopener noreferrer" target="_blank" href="/">Profile</a>Home
37
+ ```
38
+
39
+ Basicaly, if you want to open a link in a new tab, just replace `link_to` with `external_link_to`:
40
+
41
+ ```diff
42
+ - link_to 'Home', root_path
43
+ + external_link_to 'Home', root_path
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'rake/testtask'
5
+ require 'bundler/setup'
6
+
7
+ Rake::TestTask.new(:test) do |test|
8
+ test.libs << 'lib' << 'test'
9
+ test.pattern = 'test/**/*_test.rb'
10
+ test.verbose = true
11
+ end
12
+
13
+ task default: :test
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH << File.expand_path('lib', __dir__)
4
+ require 'external_link_to/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'external_link_to'
8
+ spec.version = ExternalLinkTo::VERSION
9
+ spec.authors = ['Guillaume Briday']
10
+ spec.email = ['guillaumebriday@gmail.com']
11
+
12
+ spec.summary = 'ActionView helper to easily render external links.'
13
+ spec.description = 'ActionView helper to easily render external links.'
14
+ spec.homepage = 'https://github.com/guillaumebriday/external_link_to'
15
+ spec.license = 'MIT'
16
+
17
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/guillaumebriday/external_link_to'
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_development_dependency 'bundler', '~> 2.0'
32
+ spec.add_development_dependency 'rubocop'
33
+
34
+ spec.add_dependency 'actionpack'
35
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'external_link_to/version'
4
+ require 'external_link_to/external_link_to'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExternalLinkTo # rubocop:disable Style/Documentation
4
+ def external_link_to(*args, &block)
5
+ name = block_given? ? capture(&block) : args.shift
6
+ options = args.shift || {}
7
+ html_options = args.shift || {}
8
+
9
+ url = url_for(options)
10
+
11
+ html_options[:rel] ||= 'noopener noreferrer'
12
+ html_options[:target] ||= '_blank'
13
+
14
+ link_to(name, url, html_options)
15
+ end
16
+ end
17
+
18
+ ActiveSupport.on_load :action_view do
19
+ include ExternalLinkTo
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExternalLinkTo
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: external_link_to
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Guillaume Briday
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: actionpack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: ActionView helper to easily render external links.
56
+ email:
57
+ - guillaumebriday@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".github/FUNDING.yml"
63
+ - ".github/workflows/lint.yml"
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - external_link_to.gemspec
72
+ - lib/external_link_to.rb
73
+ - lib/external_link_to/external_link_to.rb
74
+ - lib/external_link_to/version.rb
75
+ homepage: https://github.com/guillaumebriday/external_link_to
76
+ licenses:
77
+ - MIT
78
+ metadata:
79
+ homepage_uri: https://github.com/guillaumebriday/external_link_to
80
+ source_code_uri: https://github.com/guillaumebriday/external_link_to
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.7.10
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: ActionView helper to easily render external links.
101
+ test_files: []