jap_mag 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +34 -0
- data/docker-compose.yml +9 -0
- data/jap_mag.gemspec +3 -1
- data/lib/jap_mag/version.rb +1 -1
- data/lib/jap_mag.rb +11 -8
- data/spec/jap_mag.rb +4 -0
- data/spec/lib_spec.rb +85 -0
- data/spec/rails_app.rb +9 -0
- data/spec/rails_engine.rb +4 -0
- data/spec/spec_helper.rb +10 -0
- metadata +29 -5
- data/.gitignore +0 -18
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f935d63a9bee80b8fb48337976b552478f1ba382c95e825a544880b1b38d9b29
|
4
|
+
data.tar.gz: 5605139d72747e7a967d4e75bf98355f3d47952c9492b739f34e1218e6183dbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5bafdff72acdb6d593a1633cd18314d6bb54f6433c87566c974c1289d70a345d5b601aebb9adeda136d2f799d3bf0ebe1f644847e41c2691a10f53c48b5f504
|
7
|
+
data.tar.gz: 0c308548e44afa4a64347d2014fb06c9b7cf4b71af31d42b5ffd3aa31c7630e7794c792f79b346a10b0947f874b69dd7d04845b37e72f48313d00348a1916c7f
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jap_mag (1.4.1)
|
5
|
+
will_paginate
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
rspec (3.11.0)
|
12
|
+
rspec-core (~> 3.11.0)
|
13
|
+
rspec-expectations (~> 3.11.0)
|
14
|
+
rspec-mocks (~> 3.11.0)
|
15
|
+
rspec-core (3.11.0)
|
16
|
+
rspec-support (~> 3.11.0)
|
17
|
+
rspec-expectations (3.11.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.11.0)
|
20
|
+
rspec-mocks (3.11.1)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.11.0)
|
23
|
+
rspec-support (3.11.0)
|
24
|
+
will_paginate (3.3.1)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
aarch64-linux-musl
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
jap_mag!
|
31
|
+
rspec
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.3.7
|
data/docker-compose.yml
ADDED
data/jap_mag.gemspec
CHANGED
@@ -8,7 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.summary = "jap_mag-#{gem.version}"
|
9
9
|
gem.homepage = "https://github.com/felixding/JapMag"
|
10
10
|
|
11
|
-
gem.files = `git ls-files`.split($\)
|
11
|
+
#gem.files = `git ls-files`.split($\)
|
12
|
+
gem.files = Dir['**/*'].keep_if { |file| File.file?(file) }
|
12
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
15
|
gem.name = "jap_mag"
|
@@ -16,4 +17,5 @@ Gem::Specification.new do |gem|
|
|
16
17
|
gem.version = JapMag::VERSION
|
17
18
|
|
18
19
|
gem.add_runtime_dependency :will_paginate
|
20
|
+
gem.add_development_dependency "rspec"
|
19
21
|
end
|
data/lib/jap_mag/version.rb
CHANGED
data/lib/jap_mag.rb
CHANGED
@@ -38,23 +38,26 @@ module JapMag
|
|
38
38
|
#
|
39
39
|
# the args can be one of the following:
|
40
40
|
#
|
41
|
-
# String: "page#index"
|
41
|
+
# String: "page#index page#intro"
|
42
42
|
# Array: %w(page#index page#intro)
|
43
43
|
# multiple arguments: "page#index", "page#intro"
|
44
44
|
#
|
45
45
|
def current_controller_action_in?(*args)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
if args.size == 1
|
47
|
+
case args.first.class.to_s
|
48
|
+
when 'Array'
|
49
|
+
args = args.first
|
50
|
+
when 'String'
|
51
|
+
args = args.first.split(' ')
|
52
|
+
end
|
53
|
+
end
|
51
54
|
|
52
55
|
args.each do |element|
|
53
56
|
if element.to_s.include?("#")
|
54
57
|
c, a = element.split('#')
|
55
|
-
return true if controller == c && action == a
|
58
|
+
return true if params[:controller] == c && params[:action] == a
|
56
59
|
else
|
57
|
-
return true if controller == element
|
60
|
+
return true if params[:controller] == element
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
data/spec/jap_mag.rb
ADDED
data/spec/lib_spec.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe JapMag do
|
4
|
+
#let(:rails_app) { Class.new { include JapMag } }
|
5
|
+
|
6
|
+
describe 'current_controller_action_in?' do
|
7
|
+
let(:rails_app) { RailsApp.new(controller: 'page', action: 'index') }
|
8
|
+
|
9
|
+
context 'string' do
|
10
|
+
it 'returns true when controller matches' do
|
11
|
+
s = 'page'
|
12
|
+
|
13
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns true when more than one controlers matches' do
|
17
|
+
s = 'page users'
|
18
|
+
|
19
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns true when controller#action matches' do
|
23
|
+
s = 'page#index'
|
24
|
+
|
25
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns true when more than one controler#action matches' do
|
29
|
+
s = 'page#index users#new users#create'
|
30
|
+
|
31
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns true when it is a mix of controller and controler#action' do
|
35
|
+
s = 'page users users#new users#create'
|
36
|
+
|
37
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns false when controller doesnot match' do
|
41
|
+
s = 'page1'
|
42
|
+
|
43
|
+
expect(rails_app.current_controller_action_in?(s)).to be(false)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'splat' do
|
48
|
+
it 'returns true when controller matches' do
|
49
|
+
s = *%w(page)
|
50
|
+
|
51
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns true when more than one controlers matches' do
|
55
|
+
s = *%w(page users)
|
56
|
+
|
57
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'returns true when controller#action matches' do
|
61
|
+
s = *%w(page#index)
|
62
|
+
|
63
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns true when more than one controler#action matches' do
|
67
|
+
s = *%w(page#index users#new users#create)
|
68
|
+
|
69
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns true when it is a mix of controller and controler#action' do
|
73
|
+
s = *%w(page users users#new users#create)
|
74
|
+
|
75
|
+
expect(rails_app.current_controller_action_in?(s)).to be(true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'returns false when controller doesnot match' do
|
79
|
+
s = *%w(page1)
|
80
|
+
|
81
|
+
expect(rails_app.current_controller_action_in?(s)).to be(false)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/spec/rails_app.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jap_mag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DING Yu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: will_paginate
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
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'
|
27
41
|
description: JapMag is a collection of frequently-used Rails controller methods and
|
28
42
|
helpers.
|
29
43
|
email:
|
@@ -32,9 +46,8 @@ executables: []
|
|
32
46
|
extensions: []
|
33
47
|
extra_rdoc_files: []
|
34
48
|
files:
|
35
|
-
- ".gitignore"
|
36
|
-
- ".ruby-version"
|
37
49
|
- Gemfile
|
50
|
+
- Gemfile.lock
|
38
51
|
- README.md
|
39
52
|
- Rakefile
|
40
53
|
- app/assets/javascripts/jap_mag.js
|
@@ -52,9 +65,15 @@ files:
|
|
52
65
|
- app/views/layouts/_tracking.erb
|
53
66
|
- app/views/layouts/application.haml
|
54
67
|
- config/locales/en.yml
|
68
|
+
- docker-compose.yml
|
55
69
|
- jap_mag.gemspec
|
56
70
|
- lib/jap_mag.rb
|
57
71
|
- lib/jap_mag/version.rb
|
72
|
+
- spec/jap_mag.rb
|
73
|
+
- spec/lib_spec.rb
|
74
|
+
- spec/rails_app.rb
|
75
|
+
- spec/rails_engine.rb
|
76
|
+
- spec/spec_helper.rb
|
58
77
|
homepage: https://github.com/felixding/JapMag
|
59
78
|
licenses: []
|
60
79
|
metadata: {}
|
@@ -77,4 +96,9 @@ rubygems_version: 3.3.5
|
|
77
96
|
signing_key:
|
78
97
|
specification_version: 4
|
79
98
|
summary: jap_mag-
|
80
|
-
test_files:
|
99
|
+
test_files:
|
100
|
+
- spec/jap_mag.rb
|
101
|
+
- spec/lib_spec.rb
|
102
|
+
- spec/rails_app.rb
|
103
|
+
- spec/rails_engine.rb
|
104
|
+
- spec/spec_helper.rb
|
data/.gitignore
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby-3.1.2
|