simple-navigation 3.3.1 → 3.3.2
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.
- data/CHANGELOG +4 -0
- data/Rakefile +2 -5
- data/VERSION +1 -1
- data/lib/simple_navigation/adapters/sinatra.rb +14 -14
- data/spec/lib/simple_navigation/adapters/sinatra_spec.rb +8 -7
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rspec/core/rake_task'
|
3
|
-
require '
|
3
|
+
require 'rdoc/task'
|
4
4
|
|
5
5
|
desc 'Default: run specs.'
|
6
6
|
task :default => :spec
|
@@ -20,7 +20,7 @@ namespace :spec do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
desc 'Generate documentation for the simple_navigation plugin.'
|
23
|
-
|
23
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
24
24
|
rdoc.rdoc_dir = 'rdoc'
|
25
25
|
rdoc.title = 'SimpleNavigation'
|
26
26
|
rdoc.options << '--line-numbers' << '--inline-source'
|
@@ -44,9 +44,6 @@ begin
|
|
44
44
|
gemspec.rubyforge_project = 'andi'
|
45
45
|
end
|
46
46
|
Jeweler::GemcutterTasks.new
|
47
|
-
Jeweler::RubyforgeTasks.new do |rubyforge|
|
48
|
-
rubyforge.doc_task = "rdoc"
|
49
|
-
end
|
50
47
|
rescue LoadError => e
|
51
48
|
puts "Jeweler not available (#{e}). Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
52
49
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.3.
|
1
|
+
3.3.2
|
@@ -3,12 +3,12 @@ require 'cgi'
|
|
3
3
|
module SimpleNavigation
|
4
4
|
module Adapters
|
5
5
|
class Sinatra < Base
|
6
|
-
|
6
|
+
|
7
7
|
def self.register
|
8
8
|
SimpleNavigation.set_env(sinatra_root, sinatra_environment)
|
9
9
|
::Sinatra::Application.send(:helpers, SimpleNavigation::Helpers)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def initialize(context)
|
13
13
|
@context = context
|
14
14
|
@request = context.request
|
@@ -18,15 +18,15 @@ module SimpleNavigation
|
|
18
18
|
raise 'no context set for evaluation the config file' unless context
|
19
19
|
context
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def request_uri
|
23
23
|
request.fullpath
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def request_path
|
27
27
|
request.path
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def current_page?(url)
|
31
31
|
url_string = CGI.unescape(url)
|
32
32
|
if url_string.index("?")
|
@@ -35,34 +35,34 @@ module SimpleNavigation
|
|
35
35
|
uri = request_uri.split('?').first
|
36
36
|
end
|
37
37
|
if url_string =~ /^\w+:\/\//
|
38
|
-
url_string == "#{request.
|
38
|
+
url_string == "#{request.scheme}://#{request.host_with_port}#{uri}"
|
39
39
|
else
|
40
40
|
url_string == uri
|
41
|
-
end
|
41
|
+
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def link_to(name, url, options={})
|
45
45
|
"<a href='#{url}' #{to_attributes(options)}>#{name}</a>"
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def content_tag(type, content, options={})
|
49
49
|
"<#{type} #{to_attributes(options)}>#{content}</#{type}>"
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
protected
|
53
|
-
|
53
|
+
|
54
54
|
def self.sinatra_root
|
55
55
|
::Sinatra::Application.root
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def self.sinatra_environment
|
59
59
|
::Sinatra::Application.environment
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def to_attributes(options)
|
63
63
|
options.map {|k, v| "#{k}='#{v}'"}.join(' ')
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -22,18 +22,18 @@ describe SimpleNavigation::Adapters::Sinatra do
|
|
22
22
|
@adapter.context_for_eval.should == @context
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
describe 'request_uri' do
|
27
27
|
it {@adapter.request_uri.should == '/full?param=true'}
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
describe 'request_path' do
|
31
31
|
it {@adapter.request_path.should == '/full'}
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
describe 'current_page?' do
|
35
35
|
before(:each) do
|
36
|
-
@request.stub!(:
|
36
|
+
@request.stub!(:scheme => 'http', :host_with_port => 'my_host:5000')
|
37
37
|
end
|
38
38
|
it {@adapter.current_page?('/full?param=true').should be_true}
|
39
39
|
it {@adapter.current_page?('/full?param3=true').should be_false}
|
@@ -41,20 +41,21 @@ describe SimpleNavigation::Adapters::Sinatra do
|
|
41
41
|
it {@adapter.current_page?('http://my_host:5000/full?param=true').should be_true}
|
42
42
|
it {@adapter.current_page?('http://my_host:5000/full?param3=true').should be_false}
|
43
43
|
it {@adapter.current_page?('http://my_host:5000/full').should be_true}
|
44
|
+
it {@adapter.current_page?('https://my_host:5000/full').should be_false}
|
44
45
|
it {@adapter.current_page?('http://my_host:6000/full').should be_false}
|
45
46
|
it {@adapter.current_page?('http://my_other_host:5000/full').should be_false}
|
46
47
|
end
|
47
|
-
|
48
|
+
|
48
49
|
describe 'link_to' do
|
49
50
|
it "should return a link" do
|
50
51
|
@adapter.link_to('link', 'url', :class => 'clazz', :id => 'id').should == "<a href='url' class='clazz' id='id'>link</a>"
|
51
52
|
end
|
52
53
|
end
|
53
|
-
|
54
|
+
|
54
55
|
describe 'content_tag' do
|
55
56
|
it "should return a tag" do
|
56
57
|
@adapter.content_tag(:div, 'content', :class => 'clazz', :id => 'id').should == "<div class='clazz' id='id'>content</div>"
|
57
58
|
end
|
58
59
|
end
|
59
|
-
|
60
|
+
|
60
61
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: simple-navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.3.
|
5
|
+
version: 3.3.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andi Schacke
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-20 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|