gollum-lib 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gollum-lib might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e62158d0795431631a6a845ac26a221535c8604
4
- data.tar.gz: 35c5ad577b84b262fd492dfc2e5b30f92d5f97ee
3
+ metadata.gz: d4dcf391053842849c400121f0f21c035094742f
4
+ data.tar.gz: 58367a8f8ded27b4ef7457e48fae7f6019a3141e
5
5
  SHA512:
6
- metadata.gz: 54dd123e3f0cc5c2dc7df860a289d1ca3a46edd360c4d8ecf0dabf3e9d6ee3b2e68383c4b21b3d87f82e1309df3cfd24515e07e7b219a518557e1043ea2dbaa2
7
- data.tar.gz: 5bd2a239672e66b8a0364acdee7806e1be851b821dfb5b471328d8ffeb8e8581bfea27ee5641363138898e4a6c51530fd5c0a948277190cfe779f11f558716af
6
+ metadata.gz: 42e1d2261b367bb8b65b1ced6497ad11597f4d07c8a7a69cf33856da53663e1ef984c632bc645bf4543f7e1a84819bb83a283e70eb2ca028344fd00673a9b4c7
7
+ data.tar.gz: 67c364841f195db1e110fa453ee35e5b2f22029204d10090638fed88560edd353de91fde9bc7fad8993342104ca31a53ea0009c3cfe72d6b834188fff555ff8b
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
data/Rakefile CHANGED
@@ -119,13 +119,16 @@ task :release => :build do
119
119
  exit!
120
120
  end
121
121
  sh "git commit --allow-empty -a -m 'Release #{version}'"
122
- sh "git pull"
122
+ sh "git pull --rebase origin master"
123
123
  sh "git tag v#{version}"
124
124
  sh "git push origin master"
125
125
  sh "git push origin v#{version}"
126
126
  sh "gem push pkg/#{name}-#{version}.gem"
127
127
  end
128
128
 
129
+ desc 'Publish to rubygems. Same as release'
130
+ task :publish => :release
131
+
129
132
  desc 'Build gem'
130
133
  task :build => :gemspec do
131
134
  sh "mkdir -p pkg"
data/gollum-lib.gemspec CHANGED
@@ -1,53 +1,54 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.specification_version = 2 if s.respond_to? :specification_version=
3
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
3
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
4
4
  s.rubygems_version = '0.0.1'
5
- s.required_ruby_version = ">= 1.9"
5
+ s.required_ruby_version = '>= 1.9'
6
6
 
7
7
  s.name = 'gollum-lib'
8
- s.version = '2.0.0'
9
- s.date = '2014-02-20'
8
+ s.version = '3.0.0'
9
+ s.date = '2014-04-05'
10
10
  s.rubyforge_project = 'gollum-lib'
11
11
  s.license = 'MIT'
12
12
 
13
- s.summary = "A simple, Git-powered wiki."
14
- s.description = "A simple, Git-powered wiki with a sweet API and local frontend."
13
+ s.summary = 'A simple, Git-powered wiki.'
14
+ s.description = 'A simple, Git-powered wiki with a sweet API and local frontend.'
15
15
 
16
- s.authors = ["Tom Preston-Werner", "Rick Olson"]
16
+ s.authors = ['Tom Preston-Werner', 'Rick Olson']
17
17
  s.email = 'tom@github.com'
18
18
  s.homepage = 'http://github.com/gollum/gollum-lib'
19
19
 
20
20
  s.require_paths = %w[lib]
21
21
 
22
- s.rdoc_options = ["--charset=UTF-8"]
22
+ s.rdoc_options = ['--charset=UTF-8']
23
23
  s.extra_rdoc_files = %w[README.md LICENSE]
24
24
 
25
- s.add_dependency('gitlab-grit', '2.6.0')
26
- s.add_dependency('github-markup', ['>= 0.7.5', '< 1.0.0'])
27
- s.add_dependency('rouge', '~> 1.3.1')
28
- s.add_dependency('sanitize', '~> 2.0.6')
29
- s.add_dependency('nokogiri', '~> 1.6.0')
30
- s.add_dependency('stringex', '~> 2.1.0')
25
+ s.add_dependency 'gitlab-grit', '~> 2.6.5'
26
+ s.add_dependency 'rouge', '~> 1.3.3'
27
+ s.add_dependency 'nokogiri', '~> 1.6.1'
28
+ s.add_dependency 'stringex', '~> 2.5.1'
29
+ s.add_dependency 'sanitize', '~> 2.1.0'
30
+ s.add_dependency 'github-markup', '~> 1.1.0'
31
31
 
32
- s.add_development_dependency('github-markdown', '~> 0.5.3')
33
- s.add_development_dependency('RedCloth', '~> 4.2.9')
34
- s.add_development_dependency('mocha', '~> 0.13.2')
35
- s.add_development_dependency('org-ruby', '~> 0.8.1')
36
- s.add_development_dependency('shoulda', '~> 3.4.0')
37
- s.add_development_dependency('wikicloth', '~> 0.8.0')
38
- s.add_development_dependency('rake', '~> 10.0.3')
39
- s.add_development_dependency('pry', '~> 0.9.12')
32
+ s.add_development_dependency 'org-ruby', '~> 0.9.3'
33
+ s.add_development_dependency 'github-markdown', '~> 0.6.5'
34
+ s.add_development_dependency 'RedCloth', '~> 4.2.9'
35
+ s.add_development_dependency 'mocha', '~> 1.0.0'
36
+ s.add_development_dependency 'shoulda', '~> 3.5.0'
37
+ s.add_development_dependency 'wikicloth', '~> 0.8.1'
38
+ s.add_development_dependency 'rake', '~> 10.2.2'
39
+ s.add_development_dependency 'pry', '~> 0.9.12'
40
40
  # required by pry
41
- s.add_development_dependency('rb-readline', '~> 0.4.2')
41
+ s.add_development_dependency 'rb-readline', '~> 0.5.1'
42
+ # updating minitest-reporters requires a new minitest which fails with gollum's tests.
42
43
  s.add_development_dependency 'minitest-reporters', '~> 0.14.16'
43
- s.add_development_dependency('nokogiri-diff', '~> 0.1.2')
44
+ s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
44
45
  # required by guard
45
- s.add_development_dependency('guard', '~> 1.8.0')
46
- s.add_development_dependency('guard-minitest', '~> 0.5.0')
47
- s.add_development_dependency('rb-inotify', '~> 0.9.0')
48
- s.add_development_dependency('rb-fsevent', '~> 0.9.3')
49
- s.add_development_dependency('rb-fchange', '~> 0.0.6')
50
-
46
+ s.add_development_dependency 'guard', '~> 2.6.0'
47
+ s.add_development_dependency 'guard-minitest', '~> 2.2.0'
48
+ s.add_development_dependency 'rb-inotify', '~> 0.9.3'
49
+ s.add_development_dependency 'rb-fsevent', '~> 0.9.4'
50
+ s.add_development_dependency 'rb-fchange', '~> 0.0.6'
51
+ s.add_development_dependency 'twitter_cldr', '~> 2.4.2'
51
52
  # = MANIFEST =
52
53
  s.files = %w[
53
54
  Gemfile
data/lib/gollum-lib.rb CHANGED
@@ -27,21 +27,21 @@ require File.expand_path('../gollum-lib/filter', __FILE__)
27
27
 
28
28
  # Set ruby to UTF-8 mode
29
29
  # This is required for Ruby 1.8.7 which gollum still supports.
30
- $KCODE = 'U' if RUBY_VERSION[0,3] == '1.8'
30
+ $KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8'
31
31
 
32
32
  module Gollum
33
33
  module Lib
34
- VERSION = '2.0.0'
34
+ VERSION = '3.0.0'
35
35
  end
36
36
 
37
37
  def self.assets_path
38
38
  ::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
39
39
  end
40
-
40
+
41
41
  def self.set_git_timeout(time)
42
42
  Grit::Git.git_timeout = time
43
43
  end
44
-
44
+
45
45
  def self.set_git_max_filesize(size)
46
46
  Grit::Git.git_max_size = size
47
47
  end
@@ -60,9 +60,9 @@ module Gollum
60
60
  super(message || "Cannot write #{@dir}/#{@attempted_path}, found #{@dir}/#{@existing_path}.")
61
61
  end
62
62
  end
63
-
64
- class InvalidGitRepositoryError < StandardError ; end
65
- class NoSuchPathError < StandardError ; end
66
-
63
+
64
+ class InvalidGitRepositoryError < StandardError; end
65
+ class NoSuchPathError < StandardError; end
66
+
67
67
  end
68
68
 
@@ -38,7 +38,7 @@ module Gollum
38
38
  # Returns an unbaked Grit::Blob instance.
39
39
  def blob(repo)
40
40
  @blob ||= Grit::Blob.create(repo,
41
- :id => @sha, :name => name, :size => @size, :mode => @mode)
41
+ :id => @sha, :name => name, :size => @size, :mode => @mode)
42
42
  end
43
43
 
44
44
  # Gets a Page instance for this blob.
@@ -47,8 +47,8 @@ module Gollum
47
47
  #
48
48
  # Returns a Gollum::Page instance.
49
49
  def page(wiki, commit)
50
- blob = self.blob(wiki.repo)
51
- page = wiki.page_class.new(wiki).populate(blob, self.dir)
50
+ blob = self.blob(wiki.repo)
51
+ page = wiki.page_class.new(wiki).populate(blob, self.dir)
52
52
  page.version = commit
53
53
  page
54
54
  end
@@ -59,8 +59,8 @@ module Gollum
59
59
  #
60
60
  # Returns a Gollum::File instance.
61
61
  def file(wiki, commit)
62
- blob = self.blob(wiki.repo)
63
- file = wiki.file_class.new(wiki).populate(blob, self.dir)
62
+ blob = self.blob(wiki.repo)
63
+ file = wiki.file_class.new(wiki).populate(blob, self.dir)
64
64
  file.version = commit
65
65
  file
66
66
  end
@@ -39,7 +39,7 @@ module Gollum
39
39
  def index
40
40
  @index ||= begin
41
41
  idx = @wiki.repo.index
42
- if tree = options[:tree]
42
+ if tree = options[:tree]
43
43
  idx.read_tree(tree)
44
44
  elsif parent = parents.first
45
45
  idx.read_tree(parent.tree.id)
@@ -53,7 +53,7 @@ module Gollum
53
53
  # Returns a Grit::Actor.
54
54
  def actor
55
55
  @actor ||= begin
56
- @options[:name] = @wiki.default_committer_name if @options[:name].to_s.empty?
56
+ @options[:name] = @wiki.default_committer_name if @options[:name].to_s.empty?
57
57
  @options[:email] = @wiki.default_committer_email if @options[:email].to_s.empty?
58
58
  Grit::Actor.new(@options[:name], @options[:email])
59
59
  end
@@ -92,7 +92,7 @@ module Gollum
92
92
 
93
93
  path = @wiki.page_file_name(name, format)
94
94
 
95
- dir = '/' if dir.strip.empty?
95
+ dir = '/' if dir.strip.empty?
96
96
 
97
97
  fullpath = ::File.join(*[@wiki.page_file_dir, dir, path].compact)
98
98
  fullpath = fullpath[1..-1] if fullpath =~ /^\//
@@ -107,7 +107,7 @@ module Gollum
107
107
  tree.blobs.each do |blob|
108
108
  next if page_path_scheduled_for_deletion?(index.tree, fullpath)
109
109
 
110
- existing_file = blob.name.downcase.sub(/\.\w+$/, '')
110
+ existing_file = blob.name.downcase.sub(/\.\w+$/, '')
111
111
  existing_file_ext = ::File.extname(blob.name).sub(/^\./, '')
112
112
 
113
113
  new_file_ext = ::File.extname(path).sub(/^\./, '')
@@ -145,17 +145,17 @@ module Gollum
145
145
  end
146
146
 
147
147
  path =
148
- if dir == ''
149
- @wiki.page_file_name(name, format)
150
- else
151
- ::File.join(dir, @wiki.page_file_name(name, format))
152
- end
148
+ if dir == ''
149
+ @wiki.page_file_name(name, format)
150
+ else
151
+ ::File.join(dir, @wiki.page_file_name(name, format))
152
+ end
153
153
 
154
154
  path = path.force_encoding('ascii-8bit') if path.respond_to?(:force_encoding)
155
155
 
156
156
  Dir.chdir(::File.join(@wiki.repo.path, '..')) do
157
157
  if file_path_scheduled_for_deletion?(index.tree, path)
158
- @wiki.repo.git.rm({'f' => true}, '--', path)
158
+ @wiki.repo.git.rm({ 'f' => true }, '--', path)
159
159
  else
160
160
  @wiki.repo.git.checkout({}, 'HEAD', '--', path)
161
161
  end
@@ -198,7 +198,7 @@ module Gollum
198
198
  parts = path.split('/')
199
199
  if parts.size == 1
200
200
  deletions = map.keys.select { |k| !map[k] }
201
- downfile = parts.first.downcase.sub(/\.\w+$/, '')
201
+ downfile = parts.first.downcase.sub(/\.\w+$/, '')
202
202
  deletions.any? { |d| d.downcase.sub(/\.\w+$/, '') == downfile }
203
203
  else
204
204
  part = parts.shift
@@ -11,10 +11,10 @@ module Gollum
11
11
  #
12
12
  # Returns a newly initialized Gollum::File.
13
13
  def initialize(wiki)
14
- @wiki = wiki
15
- @blob = nil
16
- @path = nil
17
- @on_disk = false
14
+ @wiki = wiki
15
+ @blob = nil
16
+ @path = nil
17
+ @on_disk = false
18
18
  @on_disk_path = nil
19
19
  end
20
20
 
@@ -31,7 +31,7 @@ module Gollum
31
31
  #
32
32
  # Returns the String url_path
33
33
  def escaped_url_path
34
- CGI.escape(self.url_path).gsub('%2F','/')
34
+ CGI.escape(self.url_path).gsub('%2F', '/')
35
35
  end
36
36
 
37
37
  # Public: The on-disk filename of the file.
@@ -41,6 +41,7 @@ module Gollum
41
41
  return @path if on_disk?
42
42
  @blob && @blob.name
43
43
  end
44
+
44
45
  alias filename name
45
46
 
46
47
  # Public: The raw contents of the page.
@@ -90,9 +91,9 @@ module Gollum
90
91
  #
91
92
  # Returns the populated Gollum::File.
92
93
  def populate(blob, path=nil)
93
- @blob = blob
94
- @path = "#{path}/#{blob.name}"[1..-1]
95
- @on_disk = false
94
+ @blob = blob
95
+ @path = "#{path}/#{blob.name}"[1..-1]
96
+ @on_disk = false
96
97
  @on_disk_path = nil
97
98
  self
98
99
  end
@@ -115,7 +116,7 @@ module Gollum
115
116
  # This will try to resolve symbolic links, as well
116
117
  pathname = Pathname.new(::File.expand_path(::File.join(@wiki.repo.path, '..', name)))
117
118
  if pathname.symlink?
118
- source = ::File.readlink(pathname.to_path)
119
+ source = ::File.readlink(pathname.to_path)
119
120
  realpath = ::File.join(::File.dirname(pathname.to_path), source)
120
121
  return false unless realpath && ::File.exist?(realpath)
121
122
  @on_disk_path = realpath.to_s
@@ -10,9 +10,9 @@ module Gollum
10
10
  # set pages to wiki.pages and show_all to false
11
11
  # set pages to wiki.pages + wiki.files and show_all to true
12
12
  def initialize pages, options = {}
13
- @pages = pages
13
+ @pages = pages
14
14
  @show_all = options[:show_all] || false
15
- @checked = options[:collapse_tree] ? '' : "checked"
15
+ @checked = options[:collapse_tree] ? '' : "checked"
16
16
  end
17
17
 
18
18
  def enclose_tree string
@@ -52,18 +52,18 @@ module Gollum
52
52
  else
53
53
  url = ::File.join(::File.dirname(page.path), page.filename_stripped)
54
54
  end
55
- url = url[2..-1] if url[0,2] == './'
55
+ url = url[2..-1] if url[0, 2] == './'
56
56
  url
57
57
  end
58
58
 
59
59
  def render_files
60
- html = ''
61
- count = @pages.size
60
+ html = ''
61
+ count = @pages.size
62
62
  folder_start = -1
63
63
 
64
64
  # Process all pages until folders start
65
- count.times do | index |
66
- page = @pages[ index ]
65
+ count.times do |index|
66
+ page = @pages[index]
67
67
  path = page.path
68
68
 
69
69
  unless path.include? '/'
@@ -81,7 +81,7 @@ module Gollum
81
81
 
82
82
  # Handle special case of only one folder.
83
83
  if (count - folder_start == 1)
84
- page = @pages[ folder_start ]
84
+ page = @pages[folder_start]
85
85
  html += <<-HTML
86
86
  <li>
87
87
  <label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
@@ -95,14 +95,14 @@ module Gollum
95
95
  end
96
96
 
97
97
  sorted_folders = []
98
- (folder_start).upto count - 1 do | index |
99
- sorted_folders += [[ @pages[ index ].path, index ]]
98
+ (folder_start).upto count - 1 do |index|
99
+ sorted_folders += [[@pages[index].path, index]]
100
100
  end
101
101
 
102
102
  # http://stackoverflow.com/questions/3482814/sorting-list-of-string-paths-in-vb-net
103
- sorted_folders.sort! do |first,second|
104
- a = first[0]
105
- b = second[0]
103
+ sorted_folders.sort! do |first, second|
104
+ a = first[0]
105
+ b = second[0]
106
106
 
107
107
  # use :: operator because gollum defines its own conflicting File class
108
108
  dir_compare = ::File.dirname(a) <=> ::File.dirname(b)
@@ -118,34 +118,34 @@ module Gollum
118
118
 
119
119
  # keep track of folder depth, 0 = at root.
120
120
  cwd_array = []
121
- changed = false
121
+ changed = false
122
122
 
123
123
  # process rest of folders
124
- (0...sorted_folders.size).each do | index |
125
- page = @pages[ sorted_folders[ index ][ 1 ] ]
126
- path = page.path
127
- folder = ::File.dirname path
124
+ (0...sorted_folders.size).each do |index|
125
+ page = @pages[sorted_folders[index][1]]
126
+ path = page.path
127
+ folder = ::File.dirname path
128
128
 
129
- tmp_array = folder.split '/'
129
+ tmp_array = folder.split '/'
130
130
 
131
- (0...tmp_array.size).each do | index |
132
- if cwd_array[ index ].nil? || changed
133
- html += new_sub_folder tmp_array[ index ]
134
- next
135
- end
131
+ (0...tmp_array.size).each do |index|
132
+ if cwd_array[index].nil? || changed
133
+ html += new_sub_folder tmp_array[index]
134
+ next
135
+ end
136
136
 
137
- if cwd_array[ index ] != tmp_array[ index ]
138
- changed = true
139
- (cwd_array.size - index).times do
140
- html += end_folder
141
- end
142
- html += new_sub_folder tmp_array[ index ]
137
+ if cwd_array[index] != tmp_array[index]
138
+ changed = true
139
+ (cwd_array.size - index).times do
140
+ html += end_folder
143
141
  end
142
+ html += new_sub_folder tmp_array[index]
144
143
  end
144
+ end
145
145
 
146
- html += new_page page
147
- cwd_array = tmp_array
148
- changed = false
146
+ html += new_page page
147
+ cwd_array = tmp_array
148
+ changed = false
149
149
  end
150
150
 
151
151
  # return the completed html
@@ -46,7 +46,7 @@
46
46
  module Gollum
47
47
  class Filter
48
48
  include Gollum::Helpers
49
-
49
+
50
50
  # Setup the object. Sets `@markup` to be the instance of Gollum::Markup that
51
51
  # is running this filter chain, and sets `@map` to be an empty hash (for use
52
52
  # in your extract/process operations).
@@ -54,7 +54,7 @@ module Gollum
54
54
  @markup = markup
55
55
  @map = {}
56
56
  end
57
-
57
+
58
58
  def extract(_d)
59
59
  raise RuntimeError,
60
60
  "#{self.class} has not implemented ##extract!"
@@ -64,7 +64,7 @@ module Gollum
64
64
  raise RuntimeError,
65
65
  "#{self.class} has not implemented ##process!"
66
66
  end
67
-
67
+
68
68
  protected
69
69
  # Render a (presumably) non-fatal error as HTML
70
70
  #