gollum_rails 1.5.5 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31725c554d1fb9b5d052c746fa3e98f5c3c340c0
4
- data.tar.gz: 832779213e534adc377ea9778a79023c24cfb0f7
3
+ metadata.gz: 5997873b85103d1d0ed0f94b46693a365d0529db
4
+ data.tar.gz: 57fee5ae386f2c24af584d033d562b6dd9f7eddc
5
5
  SHA512:
6
- metadata.gz: dacfbd80c3b06a23164cd6cfe0ef1f593b9a0c2c0a3ebc8900f667d12250edfa4eaf0c674fae9a69f2b196733f1613f7caece461e10dd961621788dac0f250fb
7
- data.tar.gz: 7ad2e6e515cbe372d639b0eee3401624427f4da055bb6aa336621d80111f800a7bbfb88ad8cda70f97de666d509cdd2096df472d9de809bdef8ee92ec2c08a1f
6
+ metadata.gz: d7d17cd47c838ba9a212ab1f9bc8d8c551fc4a16c4ec35ab7706a4fe47f65ddce80ac9546f5ed60a830841c34a30c78a625870583c1e31d26e072b74fe12125c
7
+ data.tar.gz: 21f43bad70858c468995c3b6b2e5189cb0a7d330b8ed4dcbddedfa84004c6b0cc1e6772ec670850912f68bb5ea3b2a56c4a8fede411ba8b87afa73af46bd44d9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gollum_rails (1.5.5)
4
+ gollum_rails (1.5.6)
5
5
  activemodel (>= 3.2.11)
6
6
  activesupport (>= 3.2.11)
7
7
  gollum-lib (~> 2.0.0)
data/gollum_rails.gemspec CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
4
4
  s.name = 'gollum_rails'
5
5
  s.rubyforge_project = s.name
6
6
 
7
- s.version = '1.5.5'
7
+ s.version = '1.5.6'
8
8
 
9
9
  s.summary = 'Combines Gollum and Rails'
10
10
  s.description= 'include Gollum into Rails with ease'
data/lib/gollum_rails.rb CHANGED
@@ -45,7 +45,7 @@ module GollumRails
45
45
  autoload :Meta
46
46
 
47
47
  # GollumRails version string
48
- VERSION = '1.5.5'
48
+ VERSION = '1.5.6'
49
49
 
50
50
  end
51
51
 
@@ -13,14 +13,20 @@ module GollumRails
13
13
  Gollum::Markup.formats.include?(format.to_sym)
14
14
  end
15
15
 
16
+ # Resets the folder to /
17
+ def reset_folder
18
+ set_folder(nil)
19
+ end
20
+
21
+ # Sets the folder
16
22
  def set_folder(options)
17
- if options.kind_of? Hash
18
-
23
+ if options.is_a? Hash
19
24
  return if options.empty?
20
25
  options = options[:folder]
21
26
  end
22
27
  Setup.wiki_options ||= {}
23
28
  Setup.wiki_options[:page_file_dir] = options
29
+ Setup.wiki_options[:base_path] = options
24
30
  end
25
31
  alias_method :folder=, :set_folder
26
32
  end
@@ -40,14 +46,40 @@ module GollumRails
40
46
  end
41
47
 
42
48
 
43
-
49
+ # Gets the pathname for current file
44
50
  def path_name
45
- f = File.split(name).first
51
+ f = full_path.first
46
52
  return '/' if f == '.'
47
53
  f
48
54
  end
55
+
56
+ def full_path
57
+ File.split(name)
58
+ end
59
+
60
+ def file_name
61
+ full_path.last
62
+ end
63
+
64
+ # Gets the next subfolder for current pathname
65
+ def next_folder(previous)
66
+ path = path_name
67
+ previous = File.split(previous).join
68
+ path.gsub!(/#{previous}/i, '')
69
+ ngxpath = File.split(path).first #use path only cuz we want the next folder not file
70
+ new_path = ngxpath.split('/').reject { |c| c.empty? }
71
+ px = new_path.join
72
+ if px == '.' || px.empty?
73
+ return nil
74
+ end
75
+ px
76
+
77
+ end
49
78
 
50
-
79
+ def cname
80
+ Gollum::Page.cname(self.name)
81
+ end
82
+ # Gets a canonicalized filename of the page
51
83
  def canonicalized_filename
52
84
  Gollum::Page.canonicalize_filename(name)
53
85
  end
@@ -22,13 +22,13 @@ module GollumRails
22
22
  #
23
23
  # name - the name of the page
24
24
  # version - optional - The pages version
25
- # reset_folder - optional - resets the folder to / before performing the search
25
+ # folder_reset - optional - resets the folder to / before performing the search
26
26
  # exact - optional - perform an exact match
27
27
  #
28
28
  # Return an instance of Gollum::Page
29
- def find(name, version=nil, reset_folder=false, exact=true)
29
+ def find(name, version=nil, folder_reset=false, exact=true)
30
30
  name = name[:name] if name.kind_of?(Hash) && name.has_key?(:name)
31
- Page.set_folder(nil) if reset_folder
31
+ Page.reset_folder if folder_reset
32
32
  wiki.clear_cache
33
33
  path = File.split(name)
34
34
  if path.first == '/' || path.first == '.'
@@ -67,6 +67,43 @@ describe "Gollum Page" do
67
67
  expect(RailsModel.find('test-page')).not_to be_nil
68
68
  @rr.destroy
69
69
  end
70
+ it "has a cname" do
71
+ @rr.name = 'test page'
72
+ @rr.save
73
+ expect(@rr.cname).to match('test-page')
74
+ @rr.destroy
75
+ end
76
+ it "has a filename " do
77
+ @rr.name = '/home/page/test/page'
78
+ @rr.save
79
+ expect(@rr.file_name).to match 'page'
80
+ @rr.destroy
81
+ end
82
+ it "has a path name" do
83
+ @rr.name = '/home/page/test/page'
84
+ @rr.save
85
+
86
+ expect(@rr.path_name).to match 'home/page/test'
87
+ @rr.destroy
88
+ end
89
+ it "can get the next subfolder" do
90
+ @rr.name = '/home/page/test/page'
91
+ @rr.save
92
+ expect(@rr.next_folder('/home')).to match 'page'
93
+ @rr.destroy
94
+ end
95
+ it "can get the next subfolder again" do
96
+ @rr.name = '/home/page'
97
+ @rr.save
98
+ expect(@rr.next_folder("/home")).to be_nil
99
+ @rr.destroy
100
+ end
101
+ it "cannot get the next subfolder" do
102
+ @rr.name = 'page'
103
+ @rr.save
104
+ expect(@rr.next_folder("/")).to be_nil
105
+ @rr.destroy
106
+ end
70
107
  it "was last changed by me" do
71
108
  @rr.save
72
109
  @rr.last_changed_by.should == 'flo <mosny@zyg.li>'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Kasper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-21 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel