Module: Wikiscript
- Defined in:
- lib/wikiscript.rb,
lib/wikiscript.rb,
lib/wikiscript/page.rb,
lib/wikiscript/client.rb,
lib/wikiscript/version.rb,
lib/wikiscript/page_reader.rb,
lib/wikiscript/table_reader.rb,
lib/wikiscript/outline_reader.rb
Defined Under Namespace
Classes: Client, OutlineReader, Page, PageReader, TableReader
Constant Summary
collapse
- Logging =
LogUtils::Logging
- LINK_PATTERN =
todo: fix? - strip spaces from link and title
spaces possible? strip in ruby later e.g. use strip - why? why not?
todo/change: find a better name - rename LINK_PATTERN to LINK_REGEX - why? why not?
%r{
\[\[
(?<link>[^|\]]+) # everything but pipe (|) or bracket (])
(?:
\|
(?<title>[^\]]+)
)? # optional wiki link title
\]\]
}x
- VERSION =
'0.4.0'
Class Method Summary
collapse
Class Method Details
.banner ⇒ Object
5
6
7
|
# File 'lib/wikiscript/version.rb', line 5
def self.banner
"wikiscript/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
end
|
.get(title, lang: Wikiscript.lang) ⇒ Object
Also known as:
fetch, download
95
|
# File 'lib/wikiscript.rb', line 95
def self.get( title, lang: Wikiscript.lang ) Page.get( title, lang: lang ); end
|
.lang ⇒ Object
33
34
35
36
|
# File 'lib/wikiscript.rb', line 33
def self.lang
@@lang ||= 'en'
end
|
.lang=(value) ⇒ Object
for now make lang a global - change why? why not??
29
30
31
|
# File 'lib/wikiscript.rb', line 29
def self.lang=(value)
@@lang = value.to_s end
|
.parse(text) ⇒ Object
more convenience shortcuts / helpers
91
|
# File 'lib/wikiscript.rb', line 91
def self.parse( text ) PageReader.parse( text ); end
|
.parse_link(text) ⇒ Object
todo/change: find a better name - use match_link/etc. - why? why not?
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/wikiscript.rb', line 74
def self.parse_link( text ) if (m = LINK_PATTERN.match( text ))
link = m[:link]
title = m[:title]
link = link.strip title = title.strip if title
[link,title]
else
[nil,nil]
end
end
|
.parse_table(text) ⇒ Object
.read(path) ⇒ Object
94
|
# File 'lib/wikiscript.rb', line 94
def self.read( path ) Page.read( path ); end
|
.root ⇒ Object
9
10
11
|
# File 'lib/wikiscript/version.rb', line 9
def self.root
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
end
|
.unlink(text) ⇒ Object
Also known as:
flatten_links
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/wikiscript.rb', line 53
def self.unlink( text )
text = text.gsub( LINK_PATTERN ) do |_|
link = $~[:link]
title = $~[:title]
if title
title
else
link
end
end
text.strip
end
|