trap 2.1 → 2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +12 -0
- data/Gemfile +2 -0
- data/README.md +2 -3
- data/Rakefile +2 -1
- data/bin/console +4 -3
- data/lib/trap.rb +3 -1
- data/lib/trap/helpers/bootstrap_helper.rb +11 -6
- data/lib/trap/version.rb +3 -1
- data/trap.gemspec +6 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1ddfeac6f412bcc95002dd44fc9f5de6535412117a0da30fcfd02d88e2013de1
|
4
|
+
data.tar.gz: 3dd2db672921d36c84b5db1c0491df45dd4b706c024ab50fef81582562f08427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b53dffe6731661c66022de323fbe23d6a1534811db8e7ccf4a19c7a9d609d3075659156ef57324770b5e56fb55e90aba044f51a83c700bfa17cbe8e5727432b
|
7
|
+
data.tar.gz: 1d0491949ec8f825a57071b2cc191827da4980cc161537817f2141e63ca1802ba745bb801d2856c2725a0389540cdb2b74c30fcbcb4bccc2b841526d5fc91587
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Documentation:
|
2
|
+
Enabled: false
|
3
|
+
Metrics/LineLength:
|
4
|
+
Max: 120
|
5
|
+
Metrics/AbcSize:
|
6
|
+
Max: 18
|
7
|
+
Style/ClassAndModuleChildren:
|
8
|
+
EnforcedStyle: compact
|
9
|
+
Layout/ArgumentAlignment:
|
10
|
+
EnforcedStyle: with_fixed_indentation
|
11
|
+
AllCops:
|
12
|
+
TargetRubyVersion: 2.7
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Trap
|
2
2
|
|
3
|
-
Bootstrap helpers
|
4
|
-
Use `trap 1.x` for Bootstrap 3.x compatible.
|
3
|
+
Bootstrap helpers
|
5
4
|
|
6
5
|
## Installation
|
7
6
|
|
@@ -48,7 +47,7 @@ Using `menu_item` instead of
|
|
48
47
|
</li>
|
49
48
|
```
|
50
49
|
|
51
|
-
## For Bootstrap
|
50
|
+
## For Bootstrap
|
52
51
|
|
53
52
|
You should use `trap-1.x` versions to include Bootstrap 3. Contributing to `bootstrap-3` branch.
|
54
53
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'trap'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "trap"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
data/lib/trap.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module BootstrapHelper
|
2
4
|
def menu_item(name = nil, path = '#', *args, &block)
|
3
5
|
path = name || path if block_given?
|
4
6
|
options = args.extract_options!
|
5
7
|
options[:class] = [options[:class], 'nav-link'].join(' ')
|
6
8
|
content_tag :li, class: "nav-item #{is_active?(path, options)}" do
|
7
|
-
|
9
|
+
if block_given?
|
10
|
+
name = path
|
11
|
+
path = options
|
12
|
+
end
|
8
13
|
link_to name, path, options, &block
|
9
14
|
end
|
10
15
|
end
|
11
16
|
|
12
|
-
def model_menu_item(model:, route:, icon: nil, number: nil)
|
13
|
-
title = model.is_a?(Class) ? model.model_name.human.pluralize(:ru) : model
|
17
|
+
def model_menu_item(model:, route:, icon: nil, number: nil, pluralize: nil)
|
18
|
+
title = model.is_a?(Class) ? (pluralize || model.model_name.human.pluralize(:ru)) : model
|
14
19
|
if icon
|
15
20
|
menu_item route do
|
16
21
|
concat icon_element icon
|
@@ -29,7 +34,7 @@ module BootstrapHelper
|
|
29
34
|
private
|
30
35
|
|
31
36
|
def is_active?(path, options = {})
|
32
|
-
:active if uri_state(path, options).in? [
|
37
|
+
:active if uri_state(path, options).in? %i[active chosen]
|
33
38
|
end
|
34
39
|
|
35
40
|
def uri_state(uri, options = {})
|
@@ -40,12 +45,12 @@ module BootstrapHelper
|
|
40
45
|
else
|
41
46
|
request.path
|
42
47
|
end
|
43
|
-
if !options[:method].nil? || !options[
|
48
|
+
if !options[:method].nil? || !options['data-method'].nil?
|
44
49
|
:inactive
|
45
50
|
elsif uri == request_uri || (options[:root] && (request_uri == '/') || (request_uri == root_url))
|
46
51
|
:active
|
47
52
|
else
|
48
|
-
if request_uri.start_with?(uri)
|
53
|
+
if request_uri.start_with?(uri) && !root
|
49
54
|
:chosen
|
50
55
|
else
|
51
56
|
:inactive
|
data/lib/trap/version.rb
CHANGED
data/trap.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'trap/version'
|
5
6
|
|
@@ -9,15 +10,15 @@ Gem::Specification.new do |spec|
|
|
9
10
|
spec.authors = ['Pavel Kalashnikov']
|
10
11
|
spec.email = ['kalashnikovisme@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
13
|
+
spec.summary = 'Bootstrap helpers'
|
14
|
+
spec.description = 'Bootstrap helpers'
|
14
15
|
spec.homepage = 'https://github.com/kalashnikovisme/trap'
|
15
16
|
spec.license = 'MIT'
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
19
|
spec.bindir = 'exe'
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = %w[lib app]
|
21
22
|
|
22
23
|
spec.add_development_dependency 'bundler', '>= 1.8'
|
23
24
|
spec.add_development_dependency 'rake', '>= 10.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- ".rubocop.yml"
|
49
50
|
- ".travis.yml"
|
50
51
|
- CODE_OF_CONDUCT.md
|
51
52
|
- Gemfile
|
@@ -78,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
79
|
- !ruby/object:Gem::Version
|
79
80
|
version: '0'
|
80
81
|
requirements: []
|
81
|
-
|
82
|
-
rubygems_version: 2.6.11
|
82
|
+
rubygems_version: 3.0.3
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Bootstrap helpers
|