simple_active_link_to 1.0.4 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5196cc1a406bf131cfb61681ae45e7864728268c133c2119ae40c4a216cb72b3
4
- data.tar.gz: 55f77caa6c4affa3eb4c27b64d85310e81e8f99b950bd2e06a820b89e35ae7fa
3
+ metadata.gz: 4ee7d38d7d8e2969e92e9b321691ae59909aa9eea01dc99d32bfd038c17aaa51
4
+ data.tar.gz: 00be5598705e2cfdf357bacc4cc84a1fd0c517130774ef0c56ce5f753c94c0be
5
5
  SHA512:
6
- metadata.gz: b286eceb0d2524868adc437ed090fa796f6698cd1da59d112336bfd4ebbe6fbc989642264ea6f8802e6100f90321a944a8e3b1d9193413cbf0702b0477113cc3
7
- data.tar.gz: ac412b3ee3c47d1554aec4bb55015eae311b7a2824a2f14eed01d4821038462dcdde9dc023899b8b17be4a2ac621358fd5c6775a01f9b0579a42e9d05451752f
6
+ metadata.gz: 4c742be3260769116b75cab5c24491f0a67fcb9982bc6b49109c87ad107d2a912c25005f90dac0dcf552f4ce7dd6fd0bce2bfa226ef7890d11448546afb3244b
7
+ data.tar.gz: 10979d2be24cae63f91cae04b229affb84bd338cb4ada349e1414fcb58a7ae8a166f420844eb4da41985de98e08afd47266b30cbe4079612361971bf220e1e6e
@@ -2,9 +2,13 @@ name: Ruby Gem
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ master ]
5
+ branches: [ master, dev ]
6
+ paths-ignore:
7
+ - "**/README.md"
6
8
  pull_request:
7
- branches: [ master ]
9
+ branches: [ master, dev ]
10
+ paths-ignore:
11
+ - "**/README.md"
8
12
 
9
13
  jobs:
10
14
  tests:
@@ -12,17 +16,28 @@ jobs:
12
16
  runs-on: ubuntu-latest
13
17
  strategy:
14
18
  matrix:
15
- ruby: [2.5, 2.6, 2.7]
16
- rails: ['5.0', '5.1', '5.2', '6.0']
19
+ ruby: [2.5, 2.6, 2.7, 3.0]
20
+ rails: ['5.0', '5.1', '5.2', '6.0', '6.1']
17
21
  steps:
18
- - uses: actions/checkout@v2
19
- - name: Set up Ruby 2.5
20
- uses: ruby/setup-ruby@v1
21
- with:
22
- ruby-version: ${{ matrix.ruby }}
23
- - name: Bundle install
24
- run: bundle install
25
- env:
26
- BUNDLE_GEMFILE: "test/gemfiles/${{ matrix.rails }}.gemfile"
27
- - run: bundle exec rake
28
-
22
+ - uses: actions/checkout@v2
23
+ - name: always-upload-cache
24
+ # You may pin to the exact commit or the version.
25
+ # uses: pat-s/always-upload-cache@8bf65902d2f73eea094eb913323ef6fb84f4bcb8
26
+ uses: pat-s/always-upload-cache@v2.1.3
27
+ with:
28
+ # A list of files, directories, and wildcard patterns to cache and restore
29
+ path: $(pwd)/vendor/bundle
30
+ key: ${{ runner.os }}-gems-${{ hashFiles('test/gemfiles/*.gemfile') }}
31
+ restore-keys: |
32
+ ${{ runner.os }}-gems-
33
+ - name: Set up Ruby
34
+ uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: ${{ matrix.ruby }}
37
+ - name: Bundle install
38
+ run: |
39
+ bundle config path $(pwd)/vendor/bundle
40
+ bundle install --jobs 4 --retry 3
41
+ env:
42
+ BUNDLE_GEMFILE: "test/gemfiles/${{ matrix.rails }}.gemfile"
43
+ - run: bundle exec rake
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
+ .bundle
2
+
1
3
  .DS_Store
2
4
  Gemfile.lock
data/README.md CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  `simple_active_link_to` is a wrapper for [link_to](http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to), with active state by adding an extra css class `active` by default.
4
4
 
5
- This project is fork of [active_link_to](https://github.com/comfy/active_link_to), but without wrap tag, and some code improvement.
5
+ This gem works like [active_link_to](https://github.com/comfy/active_link_to), but with additional ```active_disable``` option and without wrap tag.
6
6
 
7
7
  [![Gem Version](https://img.shields.io/gem/v/simple_active_link_to.svg?style=flat)](http://rubygems.org/gems/simple_active_link_to)
8
8
  [![Gem Downloads](https://img.shields.io/gem/dt/simple_active_link_to.svg?style=flat)](http://rubygems.org/gems/simple_active_link_to)
9
9
 
10
- Tested with ruby >= 2.5.x <= 2.7.x and rails >= 5.0 <= 6.0
10
+ Tested with ruby 2.5 to 2.7 and rails 5.0 to 6.1
11
11
 
12
12
  ## Installation
13
13
  add `gem 'simple_active_link_to'` to Gemfile and run `bundle install`.
14
14
 
15
- or using `bundle add` command
15
+ or if you want to add with bundle command
16
16
 
17
17
  `bundle add simple_active_link_to`
18
18
 
@@ -125,6 +125,14 @@ simple_active_link_to 'Users', users_path, active_disable: true
125
125
  # => <span class="active">Users</span>
126
126
  ```
127
127
 
128
+ or you want to append it with hash (`#`) at the end of url, it will be useful when you use Turbolinks
129
+ and don't want the link load the page content
130
+
131
+ ```ruby
132
+ simple_active_link_to 'Users', users_path, active_disable: :hash
133
+ # => <a href="/users" class="active">Users</a>
134
+ ```
135
+
128
136
  ## Helper Methods
129
137
  You may directly use methods that `simple_active_link_to` relies on.
130
138
 
@@ -12,7 +12,7 @@ module SimpleActiveLinkTo
12
12
  # :active => Boolean | Symbol | Regex | Controller/Action Pair
13
13
  # :class_active => String
14
14
  # :class_inactive => String
15
- # :active_disable => Boolean
15
+ # :active_disable => Boolean | :hash
16
16
  # Example usage:
17
17
  # simple_active_link_to('/users', class_active: 'enabled')
18
18
  def simple_active_link_to(name = nil, options = nil, html_options = nil, &block)
@@ -41,7 +41,12 @@ module SimpleActiveLinkTo
41
41
 
42
42
  if is_active_link?(url, active_options[:active])
43
43
  link_options[:'aria-current'] = 'page'
44
- return content_tag(:span, name, link_options) if active_options[:active_disable] == true
44
+ case active_options[:active_disable]
45
+ when true
46
+ return content_tag(:span, name, link_options)
47
+ when :hash
48
+ url += "#"
49
+ end
45
50
  end
46
51
 
47
52
  link_to(name, url, link_options)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleActiveLinkTo
4
- VERSION = "1.0.4"
4
+ VERSION = "1.1.0"
5
5
  end
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec path: "../../"
4
+
5
+ gem "actionpack", "~> 6.1.0"
@@ -9,6 +9,10 @@ class SimpleActiveLinkToTest < MiniTest::Test
9
9
  refute is_active_link?('/', false)
10
10
  end
11
11
 
12
+ def test_is_active_link_handle_empty_string
13
+ assert is_active_link?('', true)
14
+ end
15
+
12
16
  def test_is_active_link_symbol_inclusive
13
17
  set_path('/root')
14
18
  assert is_active_link?('/root', :inclusive)
@@ -186,12 +190,18 @@ class SimpleActiveLinkToTest < MiniTest::Test
186
190
  assert_html link, 'a.off[href="/other"]', 'label'
187
191
  end
188
192
 
189
- def test_active_link_to_with_active_disable
193
+ def test_active_link_to_with_active_disable_as_true
190
194
  set_path('/root')
191
195
  link = simple_active_link_to('label', '/root', active_disable: true)
192
196
  assert_html link, 'span.active', 'label'
193
197
  end
194
198
 
199
+ def test_active_link_to_with_active_disable_as_hash
200
+ set_path('/root')
201
+ link = simple_active_link_to('label', '/root', active_disable: :hash)
202
+ assert_html link, 'a.active[href="/root#"]', 'label'
203
+ end
204
+
195
205
  def test_should_not_modify_passed_params
196
206
  set_path('/root')
197
207
  params = {class: 'testing', active: :inclusive}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_active_link_to
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fajarullah
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-24 00:00:00.000000000 Z
11
+ date: 2021-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -117,6 +117,7 @@ files:
117
117
  - test/gemfiles/5.1.gemfile
118
118
  - test/gemfiles/5.2.gemfile
119
119
  - test/gemfiles/6.0.gemfile
120
+ - test/gemfiles/6.1.gemfile
120
121
  - test/simple_active_link_to_test.rb
121
122
  - test/test_helper.rb
122
123
  homepage: http://github.com/frullah/simple_active_link_to
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubygems_version: 3.1.2
142
+ rubygems_version: 3.1.4
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: ActionView helper to render currently active links