gollum-lib 4.0.3-java → 4.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTBlOGQ3ZDA1OTc3ZDRhNDQxYWEyZWFmMDQxN2Q3ODUzNTlmZjkzNw==
4
+ ZWYyYjYxMWEyZGU4NzQ3OGY5NmZiMzMwNjRhZmEzZDRmOGMxMzVhZA==
5
5
  data.tar.gz: !binary |-
6
- NmQzNTQ4YTg4YTI1NGZkNTI0NGQyY2FmN2FjMWRhNWE3N2U2MzI0YQ==
6
+ YjY4ZTA4ZmI3YTQxYTBkNDk3Mzg2OGRjYTI2ODU1OTZhNmRlNjgzMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjI0YjMxZDQ4NjQ2ZmVmODY0YjNiNmFiMWExZWI4ZDNkZGI5MjBhOTQyNGI2
10
- ODlmNGYwYjYxNzNkZjJiNDNkMDIwZTdjNWZhNzQxNTRmZWRiYjJlYWZlNTEw
11
- OTM2ZjEyZWY4YmQwN2Y2MjU0MjNjZTg3ZmU2MDJhZjljYTJiOTA=
9
+ ZDkyMGY4NGZkOGY2ZDZjZWEzYmNjYWMwYTg3ZTE1ZTRlODUzZDQ2Y2Y3NmJj
10
+ OGNhNjI0M2RjYmQwMjhmNWRiZTRkM2M5MTE2YTI4ZDJmNzE1NDcxZDc4OGU2
11
+ YjYyYTRhYjhjZmE2MTg4NWYzMzZhN2FiYmNjZWEwZDdkOTQzNGY=
12
12
  data.tar.gz: !binary |-
13
- ZTc4MTZkNDM3OGE4YmY5YzI3NzYxZDRkMWM1MTFiMTgzZTk4M2RlZGFkOGQz
14
- NjdhNTNkN2ViYTJhMjllOWRkNzg4ZGVjMjYyY2IxMzc3NWMyNTlkMWIwMjEz
15
- YzJlYzJhNDhhZDMxMjA3Njc2MzM5YmI4NTNmMTQ0ZmM0MWQ4YWE=
13
+ NTU0MDMzMjEzYWJiMzA3ZmExZTgzYmUxY2E5M2M5ZmFlYzdjZDhlNTJmNDQ1
14
+ ODM4YjY5Mzk5NzVmM2IzMDE5ZmEwYTdmMGFjZDc3OTYyZTVmMmI3ODEzZTcx
15
+ ZGRiNDYzMDMwOGM3Y2U3OTEwOThhZDIwNWI1MmE0MGM5NWZjYjQ=
data/README.md CHANGED
@@ -22,7 +22,7 @@ Gollum-lib follows the rules of [Semantic Versioning](http://semver.org/) and us
22
22
  - Python 2.5+ (2.7.3 recommended)
23
23
  - Ruby 1.9.3+ (1.9.3 recommended)
24
24
  - Unix like operating system (OS X, Ubuntu, Debian, and more)
25
- - Will not work on Windows (because of [grit](https://github.com/github/grit))
25
+ - Will not work on Windows with the default [grit](https://github.com/github/grit) adapter, but might work via JRuby (please let us know!)
26
26
 
27
27
  ## INSTALLATION
28
28
 
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ require 'date'
9
9
  #############################################################################
10
10
 
11
11
  def name
12
- @name ||= Dir['*.gemspec'].first.split('.').first
12
+ "gollum-lib"
13
13
  end
14
14
 
15
15
  def version
@@ -149,7 +149,7 @@ desc 'Update gemspec'
149
149
  task :gemspec => :validate do
150
150
  # read spec file and split out manifest section
151
151
  spec = File.read(gemspec_file)
152
- head, manifest, tail = spec.split(" # = MANIFEST =\n")
152
+ head, _manifest, tail = spec.split(" # = MANIFEST =\n")
153
153
 
154
154
  # replace name version and date
155
155
  replace_header(head, :name)
@@ -167,7 +167,7 @@ task :gemspec => :validate do
167
167
  join("\n")
168
168
 
169
169
  # piece file back together and write
170
- manifest = " s.files = %w[\n#{files}\n ]\n"
170
+ manifest = " s.files = %w(\n#{files}\n )\n"
171
171
  spec = [head, manifest, tail].join(" # = MANIFEST =\n")
172
172
  File.open(gemspec_file, 'w') { |io| io.write(spec) }
173
173
  puts "Updated #{gemspec_file}"
data/gemspec.rb CHANGED
@@ -8,7 +8,7 @@ def specification(version, default_adapter, platform = nil)
8
8
  s.name = 'gollum-lib'
9
9
  s.version = version
10
10
  s.platform = platform if platform
11
- s.date = '2015-04-10'
11
+ s.date = '2015-08-09'
12
12
  s.rubyforge_project = 'gollum-lib'
13
13
  s.license = 'MIT'
14
14
 
@@ -19,13 +19,13 @@ def specification(version, default_adapter, platform = nil)
19
19
  s.email = 'tom@github.com'
20
20
  s.homepage = 'http://github.com/gollum/gollum-lib'
21
21
 
22
- s.require_paths = %w[lib]
22
+ s.require_paths = %w(lib)
23
23
 
24
24
  s.rdoc_options = ['--charset=UTF-8']
25
- s.extra_rdoc_files = %w[README.md LICENSE]
25
+ s.extra_rdoc_files = %w(README.md LICENSE)
26
26
 
27
27
  s.add_dependency *default_adapter
28
- s.add_dependency 'rouge', '~> 1.7.4'
28
+ s.add_dependency 'rouge', '~> 1.9'
29
29
  s.add_dependency 'nokogiri', '~> 1.6.4'
30
30
  s.add_dependency 'stringex', '~> 2.5.1'
31
31
  s.add_dependency 'sanitize', '~> 2.1.0'
@@ -52,7 +52,7 @@ def specification(version, default_adapter, platform = nil)
52
52
  s.add_development_dependency 'rb-fchange', '~> 0.0.6'
53
53
  s.add_development_dependency 'twitter_cldr', '~> 3.1.0'
54
54
  # = MANIFEST =
55
- s.files = %w[
55
+ s.files = %w(
56
56
  Gemfile
57
57
  HISTORY.md
58
58
  LICENSE
@@ -72,6 +72,7 @@ def specification(version, default_adapter, platform = nil)
72
72
  lib/gollum-lib/filter/macro.rb
73
73
  lib/gollum-lib/filter/metadata.rb
74
74
  lib/gollum-lib/filter/plain_text.rb
75
+ lib/gollum-lib/filter/plantuml.rb
75
76
  lib/gollum-lib/filter/remote_code.rb
76
77
  lib/gollum-lib/filter/render.rb
77
78
  lib/gollum-lib/filter/sanitize.rb
@@ -84,6 +85,8 @@ def specification(version, default_adapter, platform = nil)
84
85
  lib/gollum-lib/hook.rb
85
86
  lib/gollum-lib/macro.rb
86
87
  lib/gollum-lib/macro/all_pages.rb
88
+ lib/gollum-lib/macro/global_toc.rb
89
+ lib/gollum-lib/macro/series.rb
87
90
  lib/gollum-lib/markup.rb
88
91
  lib/gollum-lib/markups.rb
89
92
  lib/gollum-lib/page.rb
@@ -92,7 +95,7 @@ def specification(version, default_adapter, platform = nil)
92
95
  lib/gollum-lib/version.rb
93
96
  lib/gollum-lib/wiki.rb
94
97
  licenses/licenses.txt
95
- ]
98
+ )
96
99
  # = MANIFEST =
97
100
 
98
101
  s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
@@ -87,6 +87,7 @@ module Gollum
87
87
  return '' if dir =~ /^.:\/$/
88
88
  if dir
89
89
  dir = ::File.expand_path(dir, '/')
90
+ dir = dir[2..-1] if dir =~ /^[a-zA-Z]:\// # expand_path may add d:/ on windows
90
91
  dir = '' if dir == '/'
91
92
  end
92
93
  dir
@@ -39,9 +39,9 @@ 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
- elsif parent = parents.first
44
+ elsif (parent = parents.first)
45
45
  idx.read_tree(parent.tree.id)
46
46
  end
47
47
  idx
@@ -97,7 +97,7 @@ module Gollum
97
97
  fullpath = ::File.join(*[@wiki.page_file_dir, dir, path].compact)
98
98
  fullpath = fullpath[1..-1] if fullpath =~ /^\//
99
99
 
100
- if index.current_tree && tree = index.current_tree / (@wiki.page_file_dir || '/')
100
+ if index.current_tree && (tree = index.current_tree / (@wiki.page_file_dir || '/'))
101
101
  tree = tree / dir unless tree.nil?
102
102
  end
103
103
 
@@ -202,7 +202,7 @@ module Gollum
202
202
  deletions.any? { |d| d.downcase.sub(/\.\w+$/, '') == downfile }
203
203
  else
204
204
  part = parts.shift
205
- if rest = map[part]
205
+ if (rest = map[part])
206
206
  page_path_scheduled_for_deletion?(rest, parts.join('/'))
207
207
  else
208
208
  false
@@ -226,7 +226,7 @@ module Gollum
226
226
  deletions.any? { |d| d == parts.first }
227
227
  else
228
228
  part = parts.shift
229
- if rest = map[part]
229
+ if (rest = map[part])
230
230
  file_path_scheduled_for_deletion?(rest, parts.join('/'))
231
231
  else
232
232
  false
@@ -63,14 +63,14 @@ module Gollum
63
63
  #
64
64
  # Returns true if this is a pointer to an on-disk file
65
65
  def on_disk?
66
- return @on_disk
66
+ @on_disk
67
67
  end
68
68
 
69
69
  # Public: The path to this file on disk
70
70
  #
71
71
  # Returns nil if on_disk? is false.
72
72
  def on_disk_path
73
- return @on_disk_path
73
+ @on_disk_path
74
74
  end
75
75
 
76
76
  # Public: The Gollum::Git::Commit version of the file.
@@ -90,7 +90,7 @@ module Gollum
90
90
  # path - The String directory path of the file.
91
91
  #
92
92
  # Returns the populated Gollum::File.
93
- def populate(blob, path=nil)
93
+ def populate(blob, path = nil)
94
94
  @blob = blob
95
95
  @path = "#{path}/#{blob.name}"[1..-1]
96
96
  @on_disk = false
@@ -123,7 +123,7 @@ module Gollum
123
123
  else
124
124
  @on_disk_path = pathname.to_path
125
125
  end
126
- return true
126
+ true
127
127
  end
128
128
 
129
129
  # Find a file in the given Gollum repo.
@@ -136,19 +136,19 @@ module Gollum
136
136
  # Returns a Gollum::File or nil if the file could not be found. Note
137
137
  # that if you specify try_on_disk=true, you may or may not get a file
138
138
  # for which on_disk? is actually true.
139
- def find(name, version, try_on_disk=false)
139
+ def find(name, version, try_on_disk = false)
140
140
  checked = name.downcase
141
141
  map = @wiki.tree_map_for(version)
142
142
  commit = version.is_a?(Gollum::Git::Commit) ? version : @wiki.commit_for(version)
143
143
 
144
- if entry = map.detect { |entry| entry.path.downcase == checked }
144
+ if (result = map.detect { |entry| entry.path.downcase == checked })
145
145
  @path = name
146
146
  @version = commit
147
147
 
148
148
  if try_on_disk && get_disk_reference(name, commit)
149
149
  @on_disk = true
150
150
  else
151
- @blob = entry.blob(@wiki.repo)
151
+ @blob = result.blob(@wiki.repo)
152
152
  end
153
153
 
154
154
  self
@@ -1,35 +1,34 @@
1
1
  # ~*~ encoding: utf-8 ~*~
2
2
  module Gollum
3
- =begin
4
- FileView requires that:
5
- - All files in root dir are processed first
6
- - Then all the folders are sorted and processed
7
- =end
3
+ # FileView requires that:
4
+ # - All files in root dir are processed first
5
+ # - Then all the folders are sorted and processed
6
+
8
7
  class FileView
9
8
  # common use cases:
10
9
  # set pages to wiki.pages and show_all to false
11
10
  # set pages to wiki.pages + wiki.files and show_all to true
12
- def initialize pages, options = {}
11
+ def initialize(pages, options = {})
13
12
  @pages = pages
14
13
  @show_all = options[:show_all] || false
15
14
  @checked = options[:collapse_tree] ? '' : "checked"
16
15
  end
17
16
 
18
- def enclose_tree string
17
+ def enclose_tree(string)
19
18
  %Q(<ol class="tree">\n) + string + %Q(</ol>)
20
19
  end
21
20
 
22
- def new_page page
21
+ def new_page(page)
23
22
  name = page.name
24
23
  url = url_for_page page
25
24
  %Q( <li class="file"><a href="#{url}"><span class="icon"></span>#{name}</a></li>)
26
25
  end
27
26
 
28
- def new_folder folder_path
27
+ def new_folder(folder_path)
29
28
  new_sub_folder folder_path
30
29
  end
31
30
 
32
- def new_sub_folder path
31
+ def new_sub_folder(path)
33
32
  <<-HTML
34
33
  <li>
35
34
  <label>#{path}</label> <input type="checkbox" #{@checked} />
@@ -41,7 +40,7 @@ module Gollum
41
40
  "</ol></li>\n"
42
41
  end
43
42
 
44
- def url_for_page page
43
+ def url_for_page(page)
45
44
  url = ''
46
45
  if @show_all
47
46
  # Remove ext for valid pages.
@@ -121,8 +120,8 @@ module Gollum
121
120
  changed = false
122
121
 
123
122
  # process rest of folders
124
- (0...sorted_folders.size).each do |index|
125
- page = @pages[sorted_folders[index][1]]
123
+ (0...sorted_folders.size).each do |i|
124
+ page = @pages[sorted_folders[i][1]]
126
125
  path = page.path
127
126
  folder = ::File.dirname path
128
127
 
@@ -143,9 +142,9 @@ module Gollum
143
142
  end
144
143
  end
145
144
 
146
- html += new_page page
145
+ html += new_page page
147
146
  cwd_array = tmp_array
148
- changed = false
147
+ changed = false
149
148
  end
150
149
 
151
150
  # return the completed html
@@ -6,28 +6,28 @@
6
6
  class Gollum::Filter::Code < Gollum::Filter
7
7
  def extract(data)
8
8
  case @markup.format
9
- when :txt
10
- return data
11
- when :asciidoc
12
- data.gsub!(/^(\[source,([^\r\n]*)\]\n)?----\n(.+?)\n----$/m) do
13
- cache_codeblock($2, $3)
14
- end
15
- when :org
16
- org_headers = %r{([ \t]*#\+HEADER[S]?:[^\r\n]*\n)*}
17
- org_name = %r{([ \t]*#\+NAME:[^\r\n]*\n)?}
18
- org_lang = %r{[ ]*([^\n \r]*)[ ]*[^\r\n]*}
19
- org_begin = %r{[ \t]*#\+BEGIN_SRC#{org_lang}\n}
20
- org_end = %r{\n[ \t]*#\+END_SRC[ \t]*}
21
- data.gsub!(/^#{org_headers}#{org_name}#{org_begin}(.+?)#{org_end}$/mi) do
22
- cache_codeblock($3, $4)
23
- end
9
+ when :txt
10
+ return data
11
+ when :asciidoc
12
+ data.gsub!(/^(\[source,([^\r\n]*)\]\n)?----\n(.+?)\n----$/m) do
13
+ cache_codeblock(Regexp.last_match[2], Regexp.last_match[3])
14
+ end
15
+ when :org
16
+ org_headers = %r{([ \t]*#\+HEADER[S]?:[^\r\n]*\n)*}
17
+ org_name = %r{([ \t]*#\+NAME:[^\r\n]*\n)?}
18
+ org_lang = %r{[ ]*([^\n \r]*)[ ]*[^\r\n]*}
19
+ org_begin = %r{[ \t]*#\+BEGIN_SRC#{org_lang}\n}
20
+ org_end = %r{\n[ \t]*#\+END_SRC[ \t]*}
21
+ data.gsub!(/^#{org_headers}#{org_name}#{org_begin}(.+?)#{org_end}$/mi) do
22
+ cache_codeblock(Regexp.last_match[3], Regexp.last_match[4])
23
+ end
24
24
  end
25
25
  data.gsub!(/^([ \t]*)(~~~+) ?([^\r\n]+)?\r?\n(.+?)\r?\n\1(~~~+)[ \t\r]*$/m) do
26
- m_indent = $1
27
- m_start = $2 # ~~~
28
- m_lang = $3
29
- m_code = $4
30
- m_end = $5 # ~~~
26
+ m_indent = Regexp.last_match[1]
27
+ m_start = Regexp.last_match[2] # ~~~
28
+ m_lang = Regexp.last_match[3]
29
+ m_code = Regexp.last_match[4]
30
+ m_end = Regexp.last_match[5] # ~~~
31
31
  # start and finish tilde fence must be the same length
32
32
  next '' if m_start.length != m_end.length
33
33
  lang = m_lang ? m_lang.strip : nil
@@ -39,7 +39,7 @@ class Gollum::Filter::Code < Gollum::Filter
39
39
  end
40
40
 
41
41
  data.gsub!(/^([ \t]*)``` ?([^\r\n]+)?\r?\n(.+?)\r?\n\1```[ \t]*\r?$/m) do
42
- "#{$1}#{cache_codeblock($2.to_s.strip, $3, $1)}" # print the SHA1 ID with the proper indentation
42
+ "#{Regexp.last_match[1]}#{cache_codeblock(Regexp.last_match[2].to_s.strip, Regexp.last_match[3], Regexp.last_match[1])}" # print the SHA1 ID with the proper indentation
43
43
  end
44
44
  data
45
45
  end
@@ -56,7 +56,7 @@ class Gollum::Filter::Code < Gollum::Filter
56
56
 
57
57
  blocks = []
58
58
 
59
- @map.each do |id, spec|
59
+ @map.each do |_id, spec|
60
60
  next if spec[:output] # cached
61
61
 
62
62
  code = spec[:code]
@@ -76,8 +76,11 @@ class Gollum::Filter::Code < Gollum::Filter
76
76
  if !lang || lang.downcase == 'bash'
77
77
  hl_code = "<pre>#{code}</pre>"
78
78
  else
79
+ # Set the default lexer to 'text' to prevent #153
80
+ lexer = Pygments::Lexer[(lang)] || Pygments::Lexer['text']
81
+
79
82
  # must set startinline to true for php to be highlighted without <?
80
- hl_code = Pygments.highlight(code, :lexer => lang, :options => { :encoding => encoding.to_s, :startinline => true })
83
+ hl_code = lexer.highlight(code, :options => { :encoding => encoding.to_s, :startinline => true })
81
84
  end
82
85
  else # Rouge
83
86
  begin
@@ -110,9 +113,7 @@ class Gollum::Filter::Code < Gollum::Filter
110
113
  end
111
114
  end
112
115
  # Removes paragraph tags surrounding <pre> blocks, see issue https://github.com/gollum/gollum-lib/issues/97
113
- data.gsub!(/(<p>#{id}<\/p>|#{id})/) do
114
- body
115
- end
116
+ data.gsub!(/(<p>#{id}<\/p>|#{id})/) { body }
116
117
  end
117
118
 
118
119
  data
@@ -127,9 +128,7 @@ class Gollum::Filter::Code < Gollum::Filter
127
128
  # regex - A regex to match whitespace
128
129
  def remove_leading_space(code, regex)
129
130
  if code.lines.all? { |line| line =~ /\A\r?\n\Z/ || line =~ regex }
130
- code.gsub!(regex) do
131
- ''
132
- end
131
+ code.gsub!(regex) { '' }
133
132
  end
134
133
  end
135
134
 
@@ -11,27 +11,27 @@ class Gollum::Filter::Macro < Gollum::Filter
11
11
  arg_list = %r{(\s*|#{arg}(?:\s*,\s*#{arg})*)}
12
12
 
13
13
  data.gsub(/('?)\<\<\s*([A-Z][A-Za-z0-9]*)\s*\(#{arg_list}\)\s*\>\>/) do
14
- next CGI.escape_html($&[1..-1]) unless $1.empty?
15
- id = Digest::SHA1.hexdigest($2 + $3)
16
- macro = $2
17
- argstr = $3
14
+ next CGI.escape_html($&[1..-1]) unless Regexp.last_match[1].empty?
15
+ id = Digest::SHA1.hexdigest(Regexp.last_match[2] + Regexp.last_match[3])
16
+ macro = Regexp.last_match[2]
17
+ argstr = Regexp.last_match[3]
18
18
  args = []
19
19
  opts = {}
20
20
 
21
- argstr.scan /,?\s*(#{arg})\s*/ do |arg|
21
+ argstr.scan(/,?\s*(#{arg})\s*/) do |arguments|
22
22
  # Stabstabstab
23
- arg = arg.first
23
+ argument = arguments.first
24
24
 
25
- if arg =~ /^([a-z0-9_]+)="(.*?)"/
26
- opts[$1] = $2
27
- elsif arg =~ /^"(.*)"$/
28
- args << $1
29
- else
30
- args << arg
31
- end
32
- end
33
-
34
- args << opts unless opts.empty?
25
+ if argument =~ /^([a-z0-9_]+)="(.*?)"/
26
+ opts[Regexp.last_match[1]] = Regexp.last_match[2]
27
+ elsif argument =~ /^"(.*)"$/
28
+ args << Regexp.last_match[1]
29
+ else
30
+ args << argument
31
+ end
32
+ end
33
+
34
+ args << opts unless opts.empty?
35
35
 
36
36
  @map[id] = { :macro => macro, :args => args }
37
37
  id
@@ -14,7 +14,7 @@ class Gollum::Filter::Metadata < Gollum::Filter
14
14
  @markup.metadata ||= {}
15
15
  # Split untrusted input on newlines, then remove bits that look like
16
16
  # HTML elements before parsing each line.
17
- $1.split("\n").each do |line|
17
+ Regexp.last_match[1].split("\n").each do |line|
18
18
  line.gsub!(/<[^>]*>/, '')
19
19
  k, v = line.split(':', 2)
20
20
  @markup.metadata[k.strip] = (v ? v.strip : '') if k
@@ -23,7 +23,7 @@ class Gollum::Filter::Metadata < Gollum::Filter
23
23
  end
24
24
  end
25
25
 
26
- def process(d)
27
- d
26
+ def process(data)
27
+ data
28
28
  end
29
29
  end