gollum-descendant_tree 0.0.1 → 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 011a69d0b24bc3d9070a5730df90e4f497472d82
4
+ data.tar.gz: 9ff25b636b2f48f602fa2217aaa30f28ae3be760
5
+ SHA512:
6
+ metadata.gz: a238b3f368852651c6f6556540973a1c46495c0b14d6fff1327ff775ea1e57c82b72bfdc4bb62674c92cc855a98edf6fd956a6bbcf020f6e8f5f7c9587ab33a8
7
+ data.tar.gz: 663a8044f4de0356a6e0afa31241aa585ce8586cc07718179fe525b9801c8a208e6c9f313b409ae0bd4bae2ec55a526846182aabdfc8f07926ccdeaeff728750
data/README.md CHANGED
@@ -4,7 +4,7 @@ DescendantTree adds a helper function, similar to Gollum's Table of Contents (TO
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Add this line to your Gollum application's Gemfile:
8
8
 
9
9
  gem 'gollum-descendant_tree'
10
10
 
@@ -11,15 +11,14 @@ module Gollum
11
11
  def tree
12
12
  current_page_name = get_current_page_name
13
13
  page_descendants = []
14
- previous_page = ''
15
14
  @wiki.pages.each do |page|
15
+ set_current_nest_index(page) if page.filename == @name
16
16
  if (page.url_path.include?(current_page_name))
17
17
  page_descendants << {
18
18
  title: page.title,
19
19
  url_path: page.url_path,
20
- nest_index: get_current_index(page, previous_page)
20
+ nest_index: get_current_index(page)
21
21
  }
22
- previous_page = page
23
22
  end
24
23
 
25
24
  end
@@ -28,16 +27,12 @@ module Gollum
28
27
 
29
28
  private
30
29
 
31
- def get_current_index(current, previous)
32
- return 0 if previous == ''
33
- current_path_array = get_path_array(current)
34
- previous_path_array = get_path_array(previous)
35
- i = -1
36
- previous_path_array.reverse_each do |node|
37
- next if current_path_array.include?(node)
38
- i += 1
39
- end
40
- @current_nest_index -= i
30
+ def set_current_nest_index(page)
31
+ @current_nest_index = get_path_array(page).length
32
+ end
33
+
34
+ def get_current_index(page)
35
+ get_path_array(page).length - @current_nest_index
41
36
  end
42
37
 
43
38
  def get_current_page_name
@@ -1,5 +1,5 @@
1
1
  module Gollum
2
2
  module DescendantTree
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gollum::DescendantTree::TreeBuilder do
4
+
5
+ it "returns the correct tree" do
6
+ wiki = double
7
+ wiki.stub(:pages).and_return(pages)
8
+ tree_builder = Gollum::DescendantTree::TreeBuilder.new(wiki, 'current_page.md')
9
+ expect(tree_builder.tree).to eq(tree_with_correct_nesting)
10
+ end
11
+
12
+ def pages
13
+ build_mock_pages
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gollum::DescendantTree::TreeRenderer do
4
+
5
+ it "correctly renders a tree with indexes" do
6
+ tree_renderer = Gollum::DescendantTree::TreeRenderer.new
7
+ expect(tree_renderer.render(tree_with_correct_nesting)).to eq(correct_output)
8
+ end
9
+
10
+ def correct_output
11
+ "<ul class='tree'>\n<li><a href='/home/current_page'>Current Page</a><ul>\n<li><a href='/home/current_page/child'>Child</a><ul>\n<li><a href='/home/current_page/child/grandchild'>Grandchild</a><ul>\n<li><a href='/home/current_page/child/grandchild/greatgrandchild'>GreatGrandchild</a></li></ul>\n</li></ul>\n<li><a href='/home/current_page/child_sibling'>Child Sibling</a></ul></li>\n</ul>\n"
12
+ end
13
+ end
@@ -4,11 +4,12 @@ module Gollum
4
4
  module PageMockFactory
5
5
  def build_mock_pages
6
6
  pages_info = [
7
- ['current_page', 'current_page.md', 'Current Page'],
8
- ['current_page/child','child.md','Child'],
9
- ['current_page/child/grandchild','grandchild.md','Grandchild'],
10
- ['current_page/child/grandchild/greatgrandchild','greatgrandchild.md','GreatGrandchild'],
11
- ['current_page/child_sibling', 'childsibling.md', 'Child Sibling']
7
+ ['home', 'home.md', 'Home'],
8
+ ['home/current_page', 'current_page.md', 'Current Page'],
9
+ ['home/current_page/child','child.md','Child'],
10
+ ['home/current_page/child/grandchild','grandchild.md','Grandchild'],
11
+ ['home/current_page/child/grandchild/greatgrandchild','greatgrandchild.md','GreatGrandchild'],
12
+ ['home/current_page/child_sibling', 'childsibling.md', 'Child Sibling']
12
13
  ]
13
14
  pages = []
14
15
  pages_info.each do |page|
@@ -24,6 +25,16 @@ module Gollum
24
25
  page.stub(:title).and_return(page_config[2])
25
26
  page
26
27
  end
28
+
29
+ def tree_with_correct_nesting
30
+ [
31
+ {:title=>"Current Page", :url_path=>"home/current_page", :nest_index=>0},
32
+ {:title=>"Child", :url_path=>"home/current_page/child", :nest_index=>1},
33
+ {:title=>"Grandchild", :url_path=>"home/current_page/child/grandchild", :nest_index=>2},
34
+ {:title=>"GreatGrandchild",:url_path=>"home/current_page/child/grandchild/greatgrandchild", :nest_index=>3},
35
+ {:title=>"Child Sibling", :url_path=>"home/current_page/child_sibling", :nest_index=>1}
36
+ ]
37
+ end
27
38
  end
28
39
  end
29
40
  end
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum-descendant_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Aaron Froehlich
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-05 00:00:00.000000000 Z
11
+ date: 2013-07-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
- requirement: &70271551146020 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *70271551146020
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rake
27
- requirement: &70271551144980 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ! '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *70271551144980
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rspec
38
- requirement: &70271551141900 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
47
  version: '2.13'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *70271551141900
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.13'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: gollum
49
- requirement: &70271551140480 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: 2.4.0
55
62
  type: :runtime
56
63
  prerelease: false
57
- version_requirements: *70271551140480
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.4.0
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: titleize
60
- requirement: &70271551139500 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
73
  - - ~>
64
74
  - !ruby/object:Gem::Version
65
75
  version: '1.3'
66
76
  type: :runtime
67
77
  prerelease: false
68
- version_requirements: *70271551139500
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
69
83
  description: Provides a tag that can be used in gollum to output descedants of the
70
84
  current page
71
85
  email:
@@ -86,41 +100,40 @@ files:
86
100
  - lib/gollum/descendant_tree/tree_renderer.rb
87
101
  - lib/gollum/descendant_tree/version.rb
88
102
  - lib/gollum/markup.rb
89
- - spec/gollum/descendant_tree/markup_spec.rb
90
- - spec/gollum/descendant_tree/tree_builder_spec.rb
91
- - spec/gollum/descendant_tree/tree_renderer_spec.rb
103
+ - spec/lib/gollum/descendant_tree/markup_spec.rb
104
+ - spec/lib/gollum/descendant_tree/tree_builder_spec.rb
105
+ - spec/lib/gollum/descendant_tree/tree_renderer_spec.rb
92
106
  - spec/spec_helper.rb
93
107
  - spec/support/test_helpers.rb
94
108
  homepage: https://github.com/singlebrook/gollum-descendant_tree
95
109
  licenses:
96
110
  - MIT
111
+ metadata: {}
97
112
  post_install_message:
98
113
  rdoc_options: []
99
114
  require_paths:
100
115
  - lib
101
116
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
117
  requirements:
104
118
  - - ! '>='
105
119
  - !ruby/object:Gem::Version
106
120
  version: '0'
107
121
  required_rubygems_version: !ruby/object:Gem::Requirement
108
- none: false
109
122
  requirements:
110
123
  - - ! '>='
111
124
  - !ruby/object:Gem::Version
112
125
  version: '0'
113
126
  requirements: []
114
127
  rubyforge_project:
115
- rubygems_version: 1.8.15
128
+ rubygems_version: 2.0.3
116
129
  signing_key:
117
- specification_version: 3
130
+ specification_version: 4
118
131
  summary: Descendant Tree is similar to Gollum's _TOC_ tag, except that it outputs
119
132
  an unordered list of all descendants of the current page, as determined by the page
120
133
  paths.
121
134
  test_files:
122
- - spec/gollum/descendant_tree/markup_spec.rb
123
- - spec/gollum/descendant_tree/tree_builder_spec.rb
124
- - spec/gollum/descendant_tree/tree_renderer_spec.rb
135
+ - spec/lib/gollum/descendant_tree/markup_spec.rb
136
+ - spec/lib/gollum/descendant_tree/tree_builder_spec.rb
137
+ - spec/lib/gollum/descendant_tree/tree_renderer_spec.rb
125
138
  - spec/spec_helper.rb
126
139
  - spec/support/test_helpers.rb
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gollum::DescendantTree::TreeBuilder do
4
-
5
- it "returns the correct tree" do
6
- wiki = double
7
- wiki.stub(:pages).and_return(pages)
8
- tree_builder = Gollum::DescendantTree::TreeBuilder.new(wiki, 'current_page.md')
9
- expect(tree_builder.tree).to eq(tree_with_correct_nesting)
10
- end
11
-
12
- def pages
13
- build_mock_pages
14
- end
15
-
16
- def tree_with_correct_nesting
17
- [{:title=>"Current Page", :url_path=>"current_page", :nest_index=>0},
18
- {:title=>"Child", :url_path=>"current_page/child", :nest_index=>1},
19
- {:title=>"Grandchild", :url_path=>"current_page/child/grandchild", :nest_index=>2},
20
- {:title=>"GreatGrandchild",:url_path=>"current_page/child/grandchild/greatgrandchild", :nest_index=>3},
21
- {:title=>"Child Sibling", :url_path=>"current_page/child_sibling", :nest_index=>1}]
22
- end
23
-
24
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gollum::DescendantTree::TreeRenderer do
4
-
5
- it "correctly renders a tree with indexes" do
6
- wiki = double
7
- wiki.stub(:pages).and_return(pages)
8
- tree_renderer = Gollum::DescendantTree::TreeRenderer.new
9
- expect(tree_renderer.render(tree_with_nesting)).to eq(correct_output)
10
- end
11
-
12
- def pages
13
- build_mock_pages
14
- end
15
-
16
- def correct_output
17
- "<ul class='tree'>\n<li><a href='/current_page'>Current Page</a><ul>\n<li><a href='/current_page/child'>Child</a><ul>\n<li><a href='/current_page/child/grandchild'>Grandchild</a><ul>\n<li><a href='/current_page/child/grandchild/greatgrandchild'>GreatGrandchild</a></li></ul>\n</li></ul>\n<li><a href='/current_page/child_sibling'>Child Sibling</a></ul></li>\n</ul>\n"
18
- end
19
-
20
- def tree_with_nesting
21
- [{:title=>"Current Page", :url_path=>"current_page", :nest_index=>0},
22
- {:title=>"Child", :url_path=>"current_page/child", :nest_index=>1},
23
- {:title=>"Grandchild", :url_path=>"current_page/child/grandchild", :nest_index=>2},
24
- {:title=>"GreatGrandchild",:url_path=>"current_page/child/grandchild/greatgrandchild", :nest_index=>3},
25
- {:title=>"Child Sibling", :url_path=>"current_page/child_sibling", :nest_index=>1}]
26
- end
27
- end