nanoc-toolbox 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,4 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'simplecov', :require => false, :group => :test
7
- gem 'guard-rspec', :require => false, :group => :development
7
+ gem 'guard-rspec', :require => false, :group => :development
8
+ gem 'coveralls', :require => false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanoc-toolbox (0.1.2)
4
+ nanoc-toolbox (0.1.3)
5
5
  jsmin (~> 1.0)
6
6
  nanoc (~> 3.6)
7
7
  nokogiri (~> 1.6)
@@ -11,6 +11,13 @@ GEM
11
11
  specs:
12
12
  coderay (1.0.9)
13
13
  colored (1.2)
14
+ colorize (0.5.8)
15
+ coveralls (0.6.7)
16
+ colorize
17
+ multi_json (~> 1.3)
18
+ rest-client
19
+ simplecov (>= 0.7)
20
+ thor
14
21
  cri (2.3.0)
15
22
  colored (>= 1.2)
16
23
  diff-lcs (1.2.4)
@@ -32,6 +39,7 @@ GEM
32
39
  rb-kqueue (>= 0.2)
33
40
  lumberjack (1.0.3)
34
41
  method_source (0.8.1)
42
+ mime-types (1.23)
35
43
  mini_portile (0.5.0)
36
44
  multi_json (1.7.7)
37
45
  nanoc (3.6.4)
@@ -42,12 +50,14 @@ GEM
42
50
  coderay (~> 1.0.5)
43
51
  method_source (~> 0.8)
44
52
  slop (~> 3.4)
45
- rake (0.9.6)
53
+ rake (10.1.0)
46
54
  rb-fsevent (0.9.3)
47
55
  rb-inotify (0.9.0)
48
56
  ffi (>= 0.5.0)
49
57
  rb-kqueue (0.2.0)
50
58
  ffi (>= 0.5.0)
59
+ rest-client (1.6.7)
60
+ mime-types (>= 1.16)
51
61
  rspec (2.13.0)
52
62
  rspec-core (~> 2.13.0)
53
63
  rspec-expectations (~> 2.13.0)
@@ -68,8 +78,9 @@ PLATFORMS
68
78
 
69
79
  DEPENDENCIES
70
80
  bundler (~> 1.3)
81
+ coveralls
71
82
  guard-rspec
72
83
  nanoc-toolbox!
73
- rake (~> 0.9)
84
+ rake (~> 10.1)
74
85
  rspec (~> 2.13)
75
86
  simplecov
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # nanoc-toolbox
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/aadlani/nanoc-toolbox.png)](http://travis-ci.org/aadlani/nanoc-toolbox)
3
+ [![Build Status](https://travis-ci.org/aadlani/nanoc-toolbox.png)](http://travis-ci.org/aadlani/nanoc-toolbox)
4
4
  [![Dependency Status](https://gemnasium.com/aadlani/nanoc-toolbox.png)](https://gemnasium.com/aadlani/nanoc-toolbox)
5
5
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/aadlani/nanoc-toolbox)
6
+ [![Coverage Status](https://coveralls.io/repos/aadlani/nanoc-toolbox/badge.png)](https://coveralls.io/r/aadlani/nanoc-toolbox)
7
+
6
8
 
7
9
  ## Presentation
8
10
 
@@ -114,6 +114,7 @@ module Nanoc::Toolbox::Helpers
114
114
  # @option options [String] :item_tag ('li') tag englobing item
115
115
  # @option options [String] :title_tag ('h2') tag englobing the title
116
116
  # @option options [String] :title ('') Title of the menu, if nil will not display title
117
+ # @option options [String] :separator ('') Menu item separator
117
118
  #
118
119
  # @return [String] The output ready to be displayed by the caller
119
120
  def render_menu(items, options={})
@@ -123,6 +124,8 @@ module Nanoc::Toolbox::Helpers
123
124
  options[:item_tag] ||= 'li'
124
125
  options[:title_tag] ||= 'h2'
125
126
  options[:title] ||= nil
127
+ options[:separator] ||= ''
128
+
126
129
 
127
130
  # Parse the title and remove it from the options
128
131
  title = options[:title] ? content_tag(options[:title_tag], options[:title]) : ''
@@ -139,7 +142,7 @@ module Nanoc::Toolbox::Helpers
139
142
  options[:depth] += 1 # Increase the depth level after the call of navigation_for
140
143
  end
141
144
  output ||= ""
142
- content_tag(options[:item_tag], link_to_unless_current(item[:title], item[:link]) + output)
145
+ content_tag(options[:item_tag], link_to_unless_current(item[:title], item[:link]) + options[:separator] + output)
143
146
 
144
147
  end.join()
145
148
 
@@ -190,11 +193,14 @@ module Nanoc::Toolbox::Helpers
190
193
  end
191
194
 
192
195
  def find_breadcrumbs_trail(root)
193
- sections = breadcrumbs_trail.(root).map do |child|
196
+ trail = ["/"]
197
+ root.split('/').each { |s| trail << trail.last + "#{s}/" unless s.empty? }
198
+ trail.map do |child_identifier|
199
+ child = @items[child_identifier]
194
200
  { :title => (child[:short_title] || child[:title] || child.identifier),
195
201
  :link => relative_path_to(child),
196
- :subsections => nil }
197
- end
202
+ :subsections => nil } if child
203
+ end.compact
198
204
  end
199
205
  end
200
206
  end
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Version
5
5
  MAJOR = 0
6
6
  MINOR = 1
7
- PATCH = 2
7
+ PATCH = 3
8
8
  BUILD = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_development_dependency "bundler", "~> 1.3"
23
23
  s.add_development_dependency "rspec", "~> 2.13"
24
- s.add_development_dependency "rake", "~> 0.9"
24
+ s.add_development_dependency "rake", "~> 10.1"
25
25
 
26
26
  s.files = `git ls-files`.split("\n")
27
27
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
@@ -95,40 +95,34 @@ describe Nanoc::Toolbox::Helpers::Navigation do
95
95
  </body>
96
96
  </html>
97
97
  EOS
98
+
99
+ @item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
100
+ @item_rep.instance_variable_set :@content, {:pre => @content}
98
101
  end
99
102
 
100
103
  it "should return a toc for a page" do
101
- item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
102
- item_rep.instance_variable_set :@content, {:pre => @content}
103
-
104
- subject.toc_for(item_rep).should include "#title1"
105
- subject.toc_for(item_rep).should include "#title21"
106
- subject.toc_for(item_rep).should include "#title22"
107
- subject.toc_for(item_rep).should include "#title23"
104
+ subject.toc_for(@item_rep).should include "#title1"
105
+ subject.toc_for(@item_rep).should include "#title21"
106
+ subject.toc_for(@item_rep).should include "#title22"
107
+ subject.toc_for(@item_rep).should include "#title23"
108
108
 
109
- subject.toc_for(item_rep).should include "Title 1"
110
- subject.toc_for(item_rep).should include "Title 2"
109
+ subject.toc_for(@item_rep).should include "Title 1"
110
+ subject.toc_for(@item_rep).should include "Title 2"
111
111
  end
112
112
 
113
113
  it "calls find_to_sections and render_menu for the formating" do
114
- item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
115
- item_rep.instance_variable_set :@content, {:pre => @content}
116
-
117
114
  subject.should_receive(:find_toc_sections).once
118
115
  subject.should_receive(:render_menu).once
119
- subject.toc_for(item_rep)
116
+ subject.toc_for(@item_rep)
120
117
  end
121
118
 
122
119
  it "returns an empty string when the main content is empty" do
123
- item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
124
- item_rep.instance_variable_set :@content, {:pre => ""}
125
- subject.toc_for(item_rep).should eq ""
120
+ @item_rep.instance_variable_set :@content, {:pre => ""}
121
+ subject.toc_for(@item_rep).should eq ""
126
122
  end
127
123
 
128
124
  it "returns an empty string when the provided css path returns nothing" do
129
- item_rep = Nanoc::ItemRep.new(Nanoc::Item.new("", {:title => ""}, "/yetAnotherItem/"), "")
130
- item_rep.instance_variable_set :@content, {:pre => @content}
131
- subject.toc_for(item_rep, {:path => "section"}).should eq ""
125
+ subject.toc_for(@item_rep, {:path => "section"}).should eq ""
132
126
  end
133
127
  end
134
128
 
@@ -137,6 +131,28 @@ describe Nanoc::Toolbox::Helpers::Navigation do
137
131
  end
138
132
 
139
133
  describe ".breadcrumb_for" do
140
- it "should return a breadcrumb for an item"
134
+ before(:all) do
135
+ @items = {
136
+ "/" => Nanoc::Item.new("", {:title => "Home"}, "/"),
137
+ "/yetAnotherItem/" => Nanoc::Item.new("", {:title => "Sub1"}, "/yetAnotherItem/"),
138
+ "/yetAnotherItem/last/edit/" => Nanoc::Item.new("", {:title => "Sub2"}, "/yetAnotherItem/last/edit/")
139
+ }
140
+ subject.instance_variable_set :@items, @items
141
+ end
142
+
143
+ it "should return a breadcrumb for an item" do
144
+ subject.should_receive(:relative_path_to).exactly(2).times { "./" }
145
+ breadcrumb = subject.breadcrumb_for('/yetAnotherItem/')
146
+ breadcrumb.should include "Home"
147
+ breadcrumb.should_not include "Sub2"
148
+ end
149
+
150
+ it "should return a breadcrumb even if an empty element" do
151
+ subject.should_receive(:relative_path_to).exactly(3).times { "./" }
152
+ breadcrumb = subject.breadcrumb_for('/yetAnotherItem/last/edit')
153
+ breadcrumb.should include "Home"
154
+ breadcrumb.should include "Sub1"
155
+ breadcrumb.should include "Sub2"
156
+ end
141
157
  end
142
158
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'simplecov'
2
- SimpleCov.start
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
3
 
4
4
  require "rspec/core"
5
5
  require 'rspec/mocks'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-20 00:00:00.000000000 Z
12
+ date: 2013-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nanoc
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: '0.9'
101
+ version: '10.1'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: '0.9'
109
+ version: '10.1'
110
110
  description: The nanoc-toolbox is a collection of filters and helpers for the static
111
111
  site generator tool nanoc
112
112
  email: