simple_active_link_to 1.0.1 → 1.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
  SHA256:
3
- metadata.gz: c2fc2f2a0baac9582848c238f5bbfb336d0829226b53f24fe50c3ed59e70ac5b
4
- data.tar.gz: 197483dc1ed0902110ed3549379db959e300850548becdf3eecc8fd29d824a32
3
+ metadata.gz: b1daf4ee0af356ebe31c54f1a18911f6b0b94228b9a3703cbdc064785595cb44
4
+ data.tar.gz: d740a7746f0327c55fd576abf6107fa9bb3fc5893c5cc1e10dab0dc18da53944
5
5
  SHA512:
6
- metadata.gz: 481c153155351ffd7f0344d62e800913383d3fe58499baea5a016008d3ba1d49543148ab9a9040953d1ff92bc3bd988b7580a16c9dd4a5f1fa7824852368d470
7
- data.tar.gz: 6442363c9c5a5f0c872886ab8eb24fcb4ab34db9950bfd604a08edc58a891dfe8d836d47b875ac31f7be89529e9befc56f287e2f4c601a808101373d54d233c6
6
+ metadata.gz: df30e6aef083dfd01c8b282256d3de83a063aead51f2c3112a927941c57fa7c1ac32a11eda07b46f18f025df5c1ebfbe037ff20720d421b623c9f2b4b6c47934
7
+ data.tar.gz: b97fb762f8f26339e58d5b84cdbf1c4f71e364cb06fc315951841341e429a213c9cdf09ecbca7ec247323655c8dcded6a06c76a7c644e9f494a60b0abb4cbaef
@@ -0,0 +1,24 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+ name: Test + Build
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby 2.4
17
+ uses: actions/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.4.x
20
+
21
+ - name: Install bundle gems
22
+ run: bundle install
23
+ - name: Test
24
+ run: bundle exec rake
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # simple_active_link_to
2
2
 
3
- Creates a link tag of the given name using a URL created by the set of options. Please see documentation for [link_to](http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to), `simple_active_link_to` is basically a wrapper for it. This method accepts an optional :active parameter that dictates if the given link will have an extra css class attached that marks it as 'active'.
3
+ `simple_active_link_to` is a wrapper for [link_to](http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to), but with active state by adding an extra css class `active` by default.
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.
4
6
 
5
7
  [![Gem Version](https://img.shields.io/gem/v/simple_active_link_to.svg?style=flat)](http://rubygems.org/gems/simple_active_link_to)
6
8
  [![Gem Downloads](https://img.shields.io/gem/dt/simple_active_link_to.svg?style=flat)](http://rubygems.org/gems/simple_active_link_to)
7
- [![Build Status](https://img.shields.io/travis/comfy/simple_active_link_to.svg?style=flat)](https://travis-ci.org/comfy/simple_active_link_to)
8
- [![Gitter](https://badges.gitter.im/comfy/comfortable-mexican-sofa.svg)](https://gitter.im/comfy/comfortable-mexican-sofa)
9
9
 
10
- support ruby >= 2.4
10
+ Require ruby >= 2.4
11
11
 
12
12
  ## Installation
13
13
  add `gem 'simple_active_link_to'` to Gemfile and run `bundle install`.
@@ -16,8 +16,6 @@ or using `bundle add` command
16
16
 
17
17
  `bundle add simple_active_link_to`
18
18
 
19
- For older Rails apps add `config.gem 'simple_active_link_to'` in config/environment.rb and run `rake gems:install`. Or just checkout this repo into /vendor/plugins directory.
20
-
21
19
  ## Super Simple Example
22
20
  Here's a link that will have a class attached if it happens to be rendered
23
21
  on page with path `/users` or any child of that page, like `/users/123`
@@ -143,7 +141,3 @@ is_active_link?(users_path, :inclusive)
143
141
  active_link_to_class(users_path, active: :inclusive)
144
142
  # => 'active'
145
143
  ```
146
-
147
- ### Copyright
148
-
149
- Copyright (c) 2009-18 Oleg Khabarov. See LICENSE for details.
@@ -1,31 +1,20 @@
1
1
  module SimpleActiveLinkTo
2
+ ACTIVE_OPTIONS = %i[active class_active class_inactive active_disable].freeze
3
+
2
4
  # Wrapper around link_to. Accepts following params:
3
5
  # :active => Boolean | Symbol | Regex | Controller/Action Pair
4
6
  # :class_active => String
5
7
  # :class_inactive => String
6
8
  # :active_disable => Boolean
7
- # :wrap_tag => Symbol
8
9
  # Example usage:
9
10
  # simple_active_link_to('/users', class_active: 'enabled')
10
- # simple_active_link_to(users_path, active: :exclusive, wrap_tag: :li)
11
11
  def simple_active_link_to(*args, &block)
12
12
  name = block_given? ? capture(&block) : args.shift
13
- options = args.shift || {}
14
- html_options = args.shift || {}
15
-
16
- url = url_for(options)
17
-
18
- active_options = {}
19
- link_options = {}
20
- html_options.each do |k, v|
21
- if %i[active class_active class_inactive active_disable].member?(k)
22
- active_options[k] = v
23
- else
24
- link_options[k] = v
25
- end
26
- end
13
+ url = url_for(args.shift)
14
+ link_options = args.shift&.dup || {}
15
+ active_options = link_options.extract!(*ACTIVE_OPTIONS)
27
16
 
28
- css_class = "#{link_options.delete(:class)} #{active_link_to_class(url, active_options)}"
17
+ css_class = "#{link_options[:class]} #{active_link_to_class(url, active_options)}"
29
18
  css_class.strip!
30
19
  link_options[:class] = css_class if css_class != ''
31
20
 
@@ -81,8 +70,8 @@ module SimpleActiveLinkTo
81
70
  when Regexp
82
71
  path.match?(condition)
83
72
  when Array
84
- controllers = [*condition[0]]
85
- actions = [*condition[1]]
73
+ controllers = Array(condition[0])
74
+ actions = Array(condition[1])
86
75
  (controllers.blank? || controllers.member?(params[:controller])) &&
87
76
  (actions.blank? || actions.member?(params[:action])) ||
88
77
  controllers.any? do |controller, action|
@@ -1,3 +1,3 @@
1
1
  module SimpleActiveLinkTo
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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.1
4
+ version: 1.0.2
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-19 00:00:00.000000000 Z
11
+ date: 2020-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -47,6 +47,7 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
+ - ".github/workflows/gem.yml"
50
51
  - ".gitignore"
51
52
  - ".travis.yml"
52
53
  - Gemfile
@@ -56,7 +57,6 @@ files:
56
57
  - lib/simple_active_link_to.rb
57
58
  - lib/simple_active_link_to/simple_active_link_to.rb
58
59
  - lib/simple_active_link_to/version.rb
59
- - simple_active_link_to-1.0.0.gem
60
60
  - simple_active_link_to.gemspec
61
61
  - test/gemfiles/5.0.gemfile
62
62
  - test/gemfiles/5.1.gemfile