active_link_to 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/active_link_to.gemspec +7 -6
- data/lib/active_link_to.rb +3 -3
- data/test/active_link_to_test.rb +11 -11
- data/test/test_helper.rb +1 -1
- metadata +13 -6
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
gem.summary = 'Marks currently active links'
|
9
9
|
gem.description = 'Extremely helpful when you need to add some logic that figures out if the link (or more often navigation item) is selected based on the current page or other arbitrary condition'
|
10
10
|
gem.email = "oleg@theworkinggroup.ca"
|
11
|
-
gem.homepage = "http://github.com/
|
11
|
+
gem.homepage = "http://github.com/theworkinggroup/active_link_to"
|
12
12
|
gem.authors = ["Oleg Khabarov"]
|
13
13
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
14
|
gem.rubyforge_project = 'active-link-to'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/active_link_to.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{active_link_to}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oleg Khabarov"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-07-01}
|
13
13
|
s.description = %q{Extremely helpful when you need to add some logic that figures out if the link (or more often navigation item) is selected based on the current page or other arbitrary condition}
|
14
14
|
s.email = %q{oleg@theworkinggroup.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,11 +28,11 @@ Gem::Specification.new do |s|
|
|
28
28
|
"test/active_link_to_test.rb",
|
29
29
|
"test/test_helper.rb"
|
30
30
|
]
|
31
|
-
s.homepage = %q{http://github.com/
|
31
|
+
s.homepage = %q{http://github.com/theworkinggroup/active_link_to}
|
32
32
|
s.rdoc_options = ["--charset=UTF-8"]
|
33
33
|
s.require_paths = ["lib"]
|
34
34
|
s.rubyforge_project = %q{active-link-to}
|
35
|
-
s.rubygems_version = %q{1.3.
|
35
|
+
s.rubygems_version = %q{1.3.6}
|
36
36
|
s.summary = %q{Marks currently active links}
|
37
37
|
s.test_files = [
|
38
38
|
"test/active_link_to_test.rb",
|
@@ -49,3 +49,4 @@ Gem::Specification.new do |s|
|
|
49
49
|
else
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
data/lib/active_link_to.rb
CHANGED
@@ -142,11 +142,11 @@ module ActiveLinkTo
|
|
142
142
|
def is_active_link?(url, options = {})
|
143
143
|
case options[:when]
|
144
144
|
when :self, nil
|
145
|
-
!request.
|
145
|
+
!request.fullpath.match(/^#{Regexp.escape(url)}(\/?.*)?$/).blank?
|
146
146
|
when :self_only
|
147
|
-
!request.
|
147
|
+
!request.fullpath.match(/^#{Regexp.escape(url)}\/?(\?.*)?$/).blank?
|
148
148
|
when Regexp
|
149
|
-
!request.
|
149
|
+
!request.fullpath.match(options[:when]).blank?
|
150
150
|
when Array
|
151
151
|
controllers = options[:when][0]
|
152
152
|
actions = options[:when][1]
|
data/test/active_link_to_test.rb
CHANGED
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
class ActiveLinkToTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def test_matching_self
|
6
|
-
request.
|
6
|
+
request.fullpath = '/test'
|
7
7
|
out = active_link_to 'name', '/test'
|
8
8
|
assert_equal '<a href="/test" class="active">name</a>', out
|
9
9
|
out = active_link_to 'name', '/test', :active => { :when => :self }
|
@@ -13,13 +13,13 @@ class ActiveLinkToTest < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_matching_self_with_extra_parameters
|
16
|
-
request.
|
16
|
+
request.fullpath = '/test?status=what'
|
17
17
|
out = active_link_to 'name', '/test'
|
18
18
|
assert_equal '<a href="/test" class="active">name</a>', out
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_matching_self_only
|
22
|
-
request.
|
22
|
+
request.fullpath = '/test/fail'
|
23
23
|
out = active_link_to 'name', '/test/fail', :active => { :when => :self_only }
|
24
24
|
assert_equal '<a href="/test/fail" class="active">name</a>', out
|
25
25
|
out = active_link_to 'name', '/test', :active => { :when => :self_only }
|
@@ -27,13 +27,13 @@ class ActiveLinkToTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_matching_self_only_with_extra_parameters
|
30
|
-
request.
|
30
|
+
request.fullpath = '/test/fail?why=because'
|
31
31
|
out = active_link_to 'name', '/test/fail', :active => { :when => :self_only }
|
32
32
|
assert_equal '<a href="/test/fail" class="active">name</a>', out
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_matching_custom_regex
|
36
|
-
request.
|
36
|
+
request.fullpath = '/test/something_else'
|
37
37
|
out = active_link_to 'name', '/test', :active => { :when => /^\/te/}
|
38
38
|
assert_equal '<a href="/test" class="active">name</a>', out
|
39
39
|
out = active_link_to 'name', '/test', :active => { :when => /^\/no/}
|
@@ -41,7 +41,7 @@ class ActiveLinkToTest < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_matching_controller_action_touples
|
44
|
-
request.
|
44
|
+
request.fullpath = '/test/23'
|
45
45
|
params[:controller], params[:action] = 'tests', 'show'
|
46
46
|
out = active_link_to 'name', '/test/23', :active => { :when => [['tests'], ['show', 'edit']]}
|
47
47
|
assert_equal '<a href="/test/23" class="active">name</a>', out
|
@@ -54,7 +54,7 @@ class ActiveLinkToTest < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_matching_booleans
|
57
|
-
request.
|
57
|
+
request.fullpath = 'doesnotmatter'
|
58
58
|
out = active_link_to 'name', '/test', :active => { :when => true }
|
59
59
|
assert_equal '<a href="/test" class="active">name</a>', out
|
60
60
|
out = active_link_to 'name', '/test', :active => { :when => false }
|
@@ -62,25 +62,25 @@ class ActiveLinkToTest < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_setting_active_class
|
65
|
-
request.
|
65
|
+
request.fullpath = '/test'
|
66
66
|
out = active_link_to 'name', '/test', :active => { :active_class => 'new_active'}
|
67
67
|
assert_equal '<a href="/test" class="new_active">name</a>', out
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_setting_inactive_class
|
71
|
-
request.
|
71
|
+
request.fullpath = '/test'
|
72
72
|
out = active_link_to 'name', '/not-test', :active => { :inactive_class => 'new_inactive'}
|
73
73
|
assert_equal '<a href="/not-test" class="new_inactive">name</a>', out
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_transforming_to_span
|
77
|
-
request.
|
77
|
+
request.fullpath = '/test'
|
78
78
|
out = active_link_to 'name', '/test', :active => { :disable_link => true }
|
79
79
|
assert_equal '<span class="active">name</span>', out
|
80
80
|
end
|
81
81
|
|
82
82
|
def test_should_not_modify_passed_params
|
83
|
-
request.
|
83
|
+
request.fullpath = '/test'
|
84
84
|
params = {:class => 'testing'}
|
85
85
|
out = active_link_to 'name', '/test', params
|
86
86
|
assert_equal '<a href="/test" class="testing active">name</a>', out
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_link_to
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Oleg Khabarov
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-07-01 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -34,7 +39,7 @@ files:
|
|
34
39
|
- test/active_link_to_test.rb
|
35
40
|
- test/test_helper.rb
|
36
41
|
has_rdoc: true
|
37
|
-
homepage: http://github.com/
|
42
|
+
homepage: http://github.com/theworkinggroup/active_link_to
|
38
43
|
licenses: []
|
39
44
|
|
40
45
|
post_install_message:
|
@@ -46,18 +51,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
51
|
requirements:
|
47
52
|
- - ">="
|
48
53
|
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
49
56
|
version: "0"
|
50
|
-
version:
|
51
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
58
|
requirements:
|
53
59
|
- - ">="
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
segments:
|
62
|
+
- 0
|
55
63
|
version: "0"
|
56
|
-
version:
|
57
64
|
requirements: []
|
58
65
|
|
59
66
|
rubyforge_project: active-link-to
|
60
|
-
rubygems_version: 1.3.
|
67
|
+
rubygems_version: 1.3.6
|
61
68
|
signing_key:
|
62
69
|
specification_version: 3
|
63
70
|
summary: Marks currently active links
|