gollum_rails 1.5.8 → 1.5.9

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: 2f50bda67c1494f2a78ba4b911358604be522e49
4
- data.tar.gz: ed0b30bf49b6471b1c76f61d941e43dadb6ecefe
3
+ metadata.gz: 0f5c86a6b0816f75daf382d0731715df5d7274a9
4
+ data.tar.gz: 99cd7e69fdf571ebbf48c98b7a2eff01b71d3e62
5
5
  SHA512:
6
- metadata.gz: 4c73c57f7bbae447b6c8515535e99ecbc664dbbe9d7ac34b76deec4363762804f559f622e2dff5f7b80a0bf74266d6f1c412a9a4b1e2f9ee845215c97e19aa49
7
- data.tar.gz: a10fa13ceed5c82695fce2815fda8d77c27eb16a4c87d259cac630bb3d77529ea82e9f91a8a1e95cfca216858850694e0fb0d2b73e13870db15fac5f8f44fd15
6
+ metadata.gz: eee8f381165c7de6ce549301dec98dcb31d2d4d2cdb38622e16d7a4bb5eafc5b8cf5bfee8bae7ff08a1a9758e2371594f0fc01f0dacc656cb8a27a3ad25d1e71
7
+ data.tar.gz: 2ee5cbf8c04839498b6483094a7b34e3fe3a3a435e9f8f34c7b0dbb03d93ce98b6853e1633827f91d57307e8ec71ba380504f23e81a74fd311f94ce8c12fd891
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gollum_rails (1.5.8)
4
+ gollum_rails (1.5.9)
5
5
  activemodel (>= 3.2.11)
6
6
  activesupport (>= 3.2.11)
7
7
  gollum-lib (~> 2.0.0)
@@ -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.8'
7
+ s.version = '1.5.9'
8
8
 
9
9
  s.summary = 'Combines Gollum and Rails'
10
10
  s.description= 'include Gollum into Rails with ease'
@@ -44,9 +44,6 @@ Gem::Specification.new do |s|
44
44
  lib/generators/gollum_rails/model/model_generator.rb
45
45
  lib/generators/gollum_rails/model/templates/model_template.erb
46
46
  lib/gollum_rails.rb
47
- lib/gollum_rails/adapters/gollum.rb
48
- lib/gollum_rails/adapters/gollum/.gitkeep
49
- lib/gollum_rails/adapters/gollum/page.rb
50
47
  lib/gollum_rails/callbacks.rb
51
48
  lib/gollum_rails/core.rb
52
49
  lib/gollum_rails/error.rb
@@ -56,10 +53,10 @@ Gem::Specification.new do |s|
56
53
  lib/gollum_rails/page.rb
57
54
  lib/gollum_rails/persistance.rb
58
55
  lib/gollum_rails/setup.rb
56
+ lib/gollum_rails/setup/error.rb
57
+ lib/gollum_rails/setup/options.rb
59
58
  lib/gollum_rails/store.rb
60
59
  lib/gollum_rails/validation.rb
61
- spec/gollum_rails/adapters/gollum/connector_spec.rb
62
- spec/gollum_rails/adapters/gollum/page_spec.rb
63
60
  spec/gollum_rails/page_spec.rb
64
61
  spec/gollum_rails/respository_spec.rb
65
62
  spec/gollum_rails/setup_spec.rb
@@ -24,10 +24,6 @@ require 'active_support'
24
24
  # GollumRails is a RubyGem for extending Rails and the Gollum wiki powered by github
25
25
  # It has the ability to combine the benefits from a git powered wiki with Rails.
26
26
  #
27
- # Example solutions:
28
- # * Gollum Wiki pages - Devise authentication - GollumRails connector - Haml layouting
29
- # * Gollum Wiki pages - Ember.js - Handlebars layout - Rails REST API
30
- # * ...
31
27
  #
32
28
  module GollumRails
33
29
  extend ActiveSupport::Autoload
@@ -45,8 +41,7 @@ module GollumRails
45
41
  autoload :Meta
46
42
 
47
43
  # GollumRails version string
48
- VERSION = '1.5.8'
44
+ VERSION = '1.5.9'
49
45
 
50
46
  end
51
47
 
52
- require 'gollum_rails/adapters/gollum'
@@ -31,9 +31,9 @@ module GollumRails
31
31
 
32
32
  private
33
33
 
34
- # def create_or_update #:nodoc:
35
- # run_callbacks(:save) { super }
36
- # end
34
+ def create_or_update #:nodoc:
35
+ run_callbacks(:save) { super }
36
+ end
37
37
 
38
38
  def create_record #:nodoc:
39
39
  run_callbacks(:create) { super }
@@ -44,4 +44,4 @@ module GollumRails
44
44
  end
45
45
 
46
46
  end
47
- end
47
+ end
@@ -22,11 +22,13 @@ module GollumRails
22
22
  def set_folder(options)
23
23
  if options.is_a? Hash
24
24
  return if options.empty?
25
+ base = options[:base]
25
26
  options = options[:folder]
26
27
  end
27
28
  Setup.wiki_options ||= {}
28
29
  Setup.wiki_options[:page_file_dir] = options
29
- Setup.wiki_options[:base_path] = options
30
+
31
+ Setup.wiki_options[:base_path] = (base || options) || ''
30
32
  end
31
33
  alias_method :folder=, :set_folder
32
34
  end
@@ -37,33 +39,53 @@ module GollumRails
37
39
  #
38
40
  # commit must be given to perform any page action!
39
41
  def initialize(attrs = {})
40
- run_callbacks :initialize do
41
- if wiki
42
- attrs.each{|k,v| self.public_send("#{k}=",v)} if attrs
43
- update_attrs if attrs[:gollum_page]
44
- end
42
+ assign_attributes(attrs)
43
+ _update_page_attributes if attrs[:gollum_page]
44
+ yield self if block_given?
45
+ run_callbacks :initialize unless _initialize_callbacks.empty?
46
+ end
47
+
48
+
49
+ # Allows you to set all the attributes by passing in a hash of attributes with
50
+ # keys matching the attribute name
51
+ #
52
+ # new_attributes - Hash - Hash of arguments
53
+ def assign_attributes(new_attributes)
54
+ if !new_attributes.respond_to?(:stringify_keys)
55
+ raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."
56
+ end
57
+ return if new_attributes.blank?
58
+
59
+ attributes = new_attributes.stringify_keys
60
+ attributes.each do |k, v|
61
+ _assign_attribute(k, v)
45
62
  end
46
63
  end
47
64
 
48
65
 
49
- # Gets the pathname for current file
50
- def path_name
66
+
67
+ def url_path #:nodoc:
68
+ File.split(url)
69
+ end
70
+
71
+ def path_name #:nodoc:
51
72
  f = full_path.first
52
73
  return '/' if f == '.'
53
74
  f
54
75
  end
55
76
 
56
- def full_path
77
+ def full_path #:nodoc:
57
78
  File.split(name)
58
79
  end
59
80
 
60
- def file_name
81
+ def file_name #:nodoc:
61
82
  full_path.last
62
83
  end
63
84
 
64
- def cname
85
+ def cname #:nodoc:
65
86
  Gollum::Page.cname(self.name)
66
87
  end
88
+
67
89
  # Gets a canonicalized filename of the page
68
90
  def canonicalized_filename
69
91
  Gollum::Page.canonicalize_filename(name)
@@ -90,7 +112,9 @@ module GollumRails
90
112
  #
91
113
  # Returns a String
92
114
  def url
93
- gollum_page.url_path
115
+ if gollum_page
116
+ gollum_page.url_path
117
+ end
94
118
  end
95
119
 
96
120
  # == Gets the title for current Gollum::Page
@@ -175,10 +199,18 @@ module GollumRails
175
199
  com = commit_local if !commit_local.nil?
176
200
  return com
177
201
  end
202
+
203
+ def _assign_attribute(key, value)
204
+ public_send("#{key}=", value)
205
+ rescue NoMethodEr3ror
206
+ if respond_to?("#{key}=")
207
+ raise
208
+ end
209
+ end
178
210
 
179
211
  # == Updates local attributes from gollum_page class
180
212
  #
181
- def update_attrs
213
+ def _update_page_attributes
182
214
  @name = gollum_page.name
183
215
  @content= gollum_page.raw_data
184
216
  @format = gollum_page.format
@@ -11,7 +11,7 @@ module GollumRails
11
11
  #
12
12
  # Returns an instance of Gollum::Page or false
13
13
  def create(data)
14
- page = Page.new(data)
14
+ page = self.new(data)
15
15
  page.save
16
16
  end
17
17
 
@@ -24,7 +24,7 @@ module GollumRails
24
24
  #
25
25
  # Returns an instance of Gollum::Page
26
26
  def create!(data)
27
- page = Page.new(data)
27
+ page = self.new(data)
28
28
  page.save!
29
29
  end
30
30
 
@@ -58,12 +58,11 @@ module GollumRails
58
58
  return nil unless valid?
59
59
  begin
60
60
  create_or_update
61
- rescue ::Gollum::DuplicatePageError => e
62
- #false
63
- end
64
- @gollum_page = Adapters::Gollum::Page.find_page(name, wiki)
65
-
66
- self
61
+ rescue ::Gollum::DuplicatePageError => e
62
+ end
63
+ self.gollum_page = wiki.paged(file_name, path_name, true, wiki.ref)
64
+ _update_page_attributes
65
+ self
67
66
  end
68
67
 
69
68
  # == Save without exception handling
@@ -101,42 +100,34 @@ module GollumRails
101
100
  #
102
101
  # returns a Commit id
103
102
  def update_record
103
+ wiki.update_page(self.gollum_page,
104
+ self.name,
105
+ self.format,
106
+ self.content,
107
+ self.commit)
104
108
  end
105
109
 
106
110
 
107
111
 
108
112
  # == Updates an existing page (or created)
109
113
  #
110
- # args - Argument chain
114
+ # attributes - Hash of arguments
111
115
  #
112
116
  # Returns an instance of GollumRails::Page
113
- def update_attributes(*args)
114
- run_callbacks :update do
115
- return update_deprecated(*args) if args.length > 1
116
- #content=nil,name=nil,format=:markdown, commit=nil
117
- args = args.first
118
- @gollum_page = page.update_page(gollum_page, wiki,
119
- args[:content],
120
- get_right_commit(args[:commit]),
121
- args[:name],
122
- args[:format]||:markdown)
123
- end
117
+ def update_attributes(attributes)
118
+ assign_attributes(attributes)
119
+ save
124
120
  end
125
121
 
126
- # == DEPRECATED: Updates an existing page (or created)
127
- #
128
- # content - optional. If given the content of the gollum_page will be updated
129
- # name - optional. If given the name of gollum_page will be updated
130
- # format - optional. Updates the format. Uses markdown as default
131
- # commit - optional. If given this commit will be used instead of that one, used
132
- # to initialize the instance
133
- #
134
- #
135
- # Returns an instance of GollumRails::Page
136
- def update_deprecated(content=nil,name=nil,format=:markdown, commit=nil)
137
- @gollum_page = page.update_page(gollum_page, wiki, content, get_right_commit(commit), name, format)
138
-
122
+ def seperate_path(path)
123
+ path = File.split(name)
124
+ if path.first == '/' || path.first == '.'
125
+ folder = nil
126
+ else
127
+ folder = path.first
128
+ end
139
129
  end
130
+
140
131
 
141
132
  # == Deletes current page
142
133
  #
@@ -179,4 +170,4 @@ module GollumRails
179
170
 
180
171
 
181
172
  end
182
- end
173
+ end
@@ -1,3 +1,4 @@
1
+ require 'gollum_rails/setup/error'
1
2
  module GollumRails
2
3
 
3
4
  # Setup functionality for Rails initializer
@@ -13,59 +14,45 @@ module GollumRails
13
14
  # end
14
15
  #
15
16
  #
16
- class Setup
17
+ module Setup
18
+ autoload :Options, 'gollum_rails/setup/options'
19
+ include Options
20
+
17
21
  class << self
18
-
19
- attr_accessor :wiki_path
20
-
21
- attr_writer :wiki_options
22
22
 
23
- attr_accessor :repository
24
-
25
- attr_accessor :startup
26
-
27
- # Gets / Sets the init options
28
- attr_accessor :options
29
-
30
-
31
- def wiki_options
32
- return {} unless @wiki_options.kind_of? Hash
33
- @wiki_options ||= {}
34
- end
35
- # Wiki startup options
36
- def options=(options)
37
- @options = options
38
- end
39
-
40
23
  # defines block builder for Rails initializer.
41
24
  # executes public methods inside own class
42
25
  #
43
- def build(&block)
44
- block.call self
45
- if @repository == :application
26
+ def build(new_attributes = nil, &block)
27
+ if block_given?
28
+ yield self
29
+ else
30
+ if !new_attributes.respond_to?(:stringify_keys)
31
+ raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."
32
+ end
33
+ attributes = new_attributes.stringify_keys
34
+ attributes.each do |k, v|
35
+ begin
36
+ public_send("#{k}=", v)
37
+ rescue NoMethodError
38
+ end
39
+ end
40
+
41
+ end
42
+ if self.repository == :application
46
43
  raise GollumRailsSetupError, "Rails configuration is not defined.
47
44
  Are you in a Rails app?" if Rails.application.nil?
48
45
 
49
46
  initialize_wiki Rails.application.config.wiki_repository
50
47
  else
51
48
  raise GollumRailsSetupError, "Git repository does not exist.
52
- Was the specified pathname correct?" unless Pathname.new(@repository).exist?
53
- initialize_wiki @repository
49
+ Was the specified pathname correct?" unless Pathname.new(self.repository).exist?
50
+ initialize_wiki self.repository
54
51
  end
55
52
  end
56
53
 
57
- #######
58
54
  private
59
- #######
60
-
61
- # Checks if provided path is present and valid
62
- #
63
- # Example
64
- # path_valid? '/'
65
- # # =>true
66
- #
67
- # path_valid? nil
68
- # # =>false
55
+
69
56
  def path_valid?(path)
70
57
  return path.exist? if path.is_a?(Pathname)
71
58
  return !(path.nil? || path.empty? || ! path.is_a?(String))
@@ -73,16 +60,15 @@ module GollumRails
73
60
 
74
61
  def initialize_wiki(path)
75
62
  if path_valid? path
76
- @wiki_path = path.to_s
77
- @wiki_options = options
63
+ self.wiki_path = path.to_s
64
+ self.wiki_options = options
78
65
  true
79
66
  else
80
- raise GollumRailsSetupError, 'Repistory path is empty or invalid!'
67
+ raise GollumRailsSetupError, 'Path to repository is empty or invalid!'
81
68
  end
82
69
 
83
70
  end
84
71
 
85
72
  end
86
73
  end
87
- class GollumRailsSetupError < ArgumentError; end
88
74
  end
@@ -0,0 +1,5 @@
1
+ module GollumRails
2
+ module Setup
3
+ class GollumRailsSetupError < ArgumentError; end
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ module GollumRails
2
+ module Setup
3
+ module Options
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+ attr_accessor :wiki_options
8
+ attr_accessor :repository
9
+ attr_accessor :startup
10
+ attr_accessor :options
11
+ attr_accessor :wiki_path
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -44,10 +44,6 @@ module GollumRails
44
44
  @content ||= (@gollum_page.content || "")
45
45
  end
46
46
 
47
- # Gets the page class
48
- def page
49
- Adapters::Gollum::Page.new
50
- end
51
47
 
52
48
  private
53
49
  # == To static
@@ -58,4 +54,4 @@ module GollumRails
58
54
 
59
55
 
60
56
  end
61
- end
57
+ end
@@ -101,11 +101,22 @@ describe "Gollum Page" do
101
101
  end
102
102
 
103
103
  it "updates properly without all arguments, content+commit" do
104
- @rr.update_attributes({:name => "google", :format => :wiki}).should be_a Gollum::Page
104
+ @rr.update_attributes({:name => "google", :format => :wiki}).should be_a GollumRails::Page
105
+ @rr.delete(@commit)
106
+ end
107
+ it "sets the format as created" do
108
+ @rr.update_attributes(name: "omg", format: :textile)
109
+ expect(@rr.format).to eq :textile
110
+ @rr.delete(@commit)
111
+ end
112
+
113
+ it "sets the name as created" do
114
+ @rr.update_attributes(name: "omg", format: :textile)
115
+ expect(@rr.name).to eq "omg"
105
116
  @rr.delete(@commit)
106
117
  end
107
118
  it "updates properly without all arguments, name, format" do
108
- @rr.update_attributes({:content => "test"}).should be_a Gollum::Page
119
+ @rr.update_attributes({:content => "test"}).should be_a GollumRails::Page
109
120
  expect(@rr.name).to match "Goole"
110
121
  expect(@rr.format.to_s).to match "markdown"
111
122
  @rr.delete(@commit)
@@ -295,16 +306,6 @@ describe "Gollum Page" do
295
306
  test.save
296
307
  end
297
308
  end
298
- describe "rails extension" do
299
-
300
- it "should test fetch_all" do
301
- GollumRails::Page.all.length.should == 1
302
- end
303
- it "should test all" do
304
- GollumRails::Page.find_all.length.should == 1
305
- end
306
-
307
- end
308
309
  describe "testing validation" do
309
310
 
310
311
 
@@ -369,7 +370,6 @@ describe "Gollum Page" do
369
370
 
370
371
  res = CommitDiff.new call
371
372
  res.save
372
- res.update_attributes("content",nil,:markdown, @commit)
373
373
  diff = res.compare_commits(res.history.first)
374
374
  expect(diff).to be_a String
375
375
  expect(diff).to match(/---/)
@@ -513,7 +513,7 @@ describe "Gollum Page" do
513
513
  it "should create a nested page under /test" do
514
514
  res = Fns.new @call.merge(name: 'test/my_page')
515
515
  res.save
516
- expect(res.path_name).to match 'test'
516
+ expect(res.url_path).to include 'test'
517
517
  res.destroy(@commit)
518
518
  end
519
519
  it "should find a nested file" do
@@ -35,7 +35,7 @@ describe GollumRails::Setup do
35
35
  config.repository = :application
36
36
 
37
37
  end
38
- }.to raise_error GollumRails::GollumRailsSetupError
38
+ }.to raise_error GollumRails::Setup::GollumRailsSetupError
39
39
 
40
40
  end
41
41
  it "should throw an error if a pathname was supplied that does not exist" do
@@ -43,7 +43,12 @@ describe GollumRails::Setup do
43
43
  GollumRails::Setup.build do |setup|
44
44
  setup.repository = Pathname.new('/nonexistingdirectoryshouldbenonexisting')
45
45
  end
46
- }.to raise_error GollumRails::GollumRailsSetupError
46
+ }.to raise_error GollumRails::Setup::GollumRailsSetupError
47
+ end
48
+ it "should also initialize without a block given" do
49
+ expect{
50
+ GollumRails::Setup.build(repository: '.')
51
+ }.not_to raise_error
47
52
  end
48
53
 
49
54
 
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.8
4
+ version: 1.5.9
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-26 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -156,9 +156,6 @@ files:
156
156
  - lib/generators/gollum_rails/model/model_generator.rb
157
157
  - lib/generators/gollum_rails/model/templates/model_template.erb
158
158
  - lib/gollum_rails.rb
159
- - lib/gollum_rails/adapters/gollum.rb
160
- - lib/gollum_rails/adapters/gollum/.gitkeep
161
- - lib/gollum_rails/adapters/gollum/page.rb
162
159
  - lib/gollum_rails/callbacks.rb
163
160
  - lib/gollum_rails/core.rb
164
161
  - lib/gollum_rails/error.rb
@@ -168,10 +165,10 @@ files:
168
165
  - lib/gollum_rails/page.rb
169
166
  - lib/gollum_rails/persistance.rb
170
167
  - lib/gollum_rails/setup.rb
168
+ - lib/gollum_rails/setup/error.rb
169
+ - lib/gollum_rails/setup/options.rb
171
170
  - lib/gollum_rails/store.rb
172
171
  - lib/gollum_rails/validation.rb
173
- - spec/gollum_rails/adapters/gollum/connector_spec.rb
174
- - spec/gollum_rails/adapters/gollum/page_spec.rb
175
172
  - spec/gollum_rails/page_spec.rb
176
173
  - spec/gollum_rails/respository_spec.rb
177
174
  - spec/gollum_rails/setup_spec.rb
@@ -200,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
197
  version: '0'
201
198
  requirements: []
202
199
  rubyforge_project: gollum_rails
203
- rubygems_version: 2.1.11
200
+ rubygems_version: 2.2.2
204
201
  signing_key:
205
202
  specification_version: 4
206
203
  summary: Combines Gollum and Rails
@@ -1,53 +0,0 @@
1
- # ~*~ encoding: utf-8 ~*~
2
- module GollumRails
3
- module Adapters
4
- # Gollum Wiki connector classes
5
- #
6
- #
7
- module Gollum
8
- autoload :Wiki, 'gollum_rails/adapters/gollum/wiki'
9
- autoload :Page, 'gollum_rails/adapters/gollum/page'
10
-
11
- # connector version
12
- VERSION="2.0.0"
13
-
14
- # Gollum connector class, keeping defaults!
15
- #
16
- class Connector
17
- class << self
18
- # Sets the page class used by all instances
19
- attr_writer :page_class
20
-
21
- # Sets the wiki class used by all instances
22
- attr_writer :wiki_path
23
-
24
- # Sets the wiki options
25
- attr_writer :wiki_options
26
-
27
-
28
- # Gets the Globally used Page class or use a new one if not defined
29
- #
30
- #
31
- # Returns the internal page class or a fresh ::Gollum::Page
32
- def page_class
33
- @page_class || Page
34
- end
35
-
36
- # Gets the wiki options
37
- def wiki_options
38
- @wiki_options || {}
39
- end
40
-
41
- # Gets the Globally used Page class or use a new one if not defined
42
- #
43
- #
44
- # Returns the internal page class or a fresh ::Gollum::Page
45
- def wiki_path
46
- @wiki_path || ""
47
- end
48
-
49
- end
50
- end
51
- end
52
- end
53
- end
File without changes
@@ -1,90 +0,0 @@
1
- module GollumRails
2
- module Adapters
3
- module Gollum
4
-
5
- # Main page class for the Gollum connector.
6
- #
7
- # It provides some awesome features for connecting gollum to gollum_rails such as:
8
- # * new_page
9
- # * find_page
10
- # * delete_page
11
- # * rename_page
12
- # * move_page
13
- # * first_page_commit
14
- # * page_creation time
15
- # * ...
16
- #
17
- class Page
18
-
19
- Connector.page_class = self
20
-
21
- class << self
22
-
23
- # == Parses a given filepath e.g. '/test/page'
24
- # Name is page
25
- # path is /test
26
- #
27
- # Returns a Hash
28
- def parse_path(name)
29
- path = '/'
30
- name = name.to_s
31
- if name.include?('/')
32
- name = name[1..-1] if name[0] == "/"
33
- content = name.split('/')
34
- name = content.pop
35
- path = '/'+content.join('/')
36
- end
37
- { path: path, name: name }
38
- end
39
-
40
- # finds all versions of a page
41
- #
42
- # name - the pagename to search
43
- # wiki - instance of Gollum::Wiki
44
- # version - optional - The pages version
45
- #
46
- # Returns the Gollum::Page class
47
- def find_page(name, wiki, version=nil)
48
- wiki.clear_cache
49
- path_data = parse_path(name)
50
- wiki.paged(path_data[:name], path_data[:path], exact = true, version)
51
- end
52
- end
53
-
54
-
55
- # == Updates an existing page
56
- #
57
- # page - An instance of Gollum::Page
58
- # wiki - An instance of Gollum::Wiki
59
- # content - New content
60
- # commit - Commit Hash
61
- # name - A new String (optional)
62
- # format - A filetype as symbol (optional)
63
- #
64
- # Returns the page
65
- def update_page( page, wiki, content=nil, commit={}, name=nil, format=nil)
66
- wiki.clear_cache
67
- return page if page.nil?
68
- name ||= page.name
69
- format = (format || page.format).to_sym
70
- content ||= page.raw_data
71
-
72
- wiki.update_page(page,name,format,content.to_s,commit) unless ((!content||page.raw_data == content) && page.format == format)
73
-
74
- self.class.find_page( mixin(page.url_path, name), wiki )
75
- end
76
-
77
- private
78
-
79
- # replaces old filename with new
80
- def mixin(old_url, new_name)
81
- url = old_url.split("/")
82
- url.pop
83
- url << new_name
84
- url.join("/")
85
- end
86
-
87
- end
88
- end
89
- end
90
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GollumRails::Adapters::Gollum::Connector do
4
- before(:each) do
5
- @class = GollumRails::Adapters::Gollum::Connector
6
- end
7
-
8
- it "should test the Wiki path connector" do
9
- @class.wiki_path.should be_a String
10
- end
11
- it "should test the Wiki options connector" do
12
- @class.wiki_options.should be_a Hash
13
- end
14
- it "should test the Wiki options content" do
15
- @class.wiki_options.should == {}
16
- end
17
- it "should test the Page class connector" do
18
- @class.page_class.should == GollumRails::Adapters::Gollum::Page
19
- end
20
-
21
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
- describe GollumRails::Adapters::Gollum::Page do
3
- before(:each) do
4
- @commit = {
5
- :message => 'page action',
6
- :name => 'The Mosny',
7
- :email => 'mosny@zyg.li'
8
- }
9
- end
10
- describe "Connector stuff" do
11
- it "should have updated the page_class on initialize" do
12
- adapter = GollumRails::Adapters::Gollum::Page.new
13
- GollumRails::Adapters::Gollum::Connector.page_class.should == GollumRails::Adapters::Gollum::Page
14
- end
15
- end
16
- describe "statically methods" do
17
- it "is a hash" do
18
- GollumRails::Adapters::Gollum::Page.parse_path('google/de').should be_a Hash
19
- end
20
- it "should equal" do
21
- path1 = GollumRails::Adapters::Gollum::Page.parse_path('google/de')
22
- path2 = GollumRails::Adapters::Gollum::Page.parse_path('/google/de')
23
- path1.should == path2
24
- end
25
- it "adds a leading slash" do
26
- GollumRails::Adapters::Gollum::Page.parse_path('google/de')[:path][0].should == '/'
27
- end
28
- end
29
- end