Module: Wikiscript
- Defined in:
- 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
Defined Under Namespace
Classes: Client, Page, PageReader, TableReader
Constant Summary collapse
- 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.2.0'
Class Method Summary collapse
- .banner ⇒ Object
- .lang ⇒ Object
-
.lang=(value) ⇒ Object
for now make lang a global - change why? why not??.
-
.parse_link(value) ⇒ Object
todo/change: find a better name - use match_link/etc.
- .root ⇒ Object
- .unlink(value) ⇒ Object
Class Method Details
.banner ⇒ Object
5 6 7 |
# File 'lib/wikiscript/version.rb', line 5 def self. "wikiscript/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]" end |
.lang ⇒ Object
34 35 36 37 |
# File 'lib/wikiscript.rb', line 34 def self.lang # note: for now always returns a string e.g. 'en', 'de' etc. not a symbol @@lang ||= 'en' end |
.lang=(value) ⇒ Object
for now make lang a global - change why? why not??
30 31 32 |
# File 'lib/wikiscript.rb', line 30 def self.lang=(value) @@lang = value.to_s # use to_s - lets you pass ing :en, :de etc. end |
.parse_link(value) ⇒ Object
todo/change: find a better name - use match_link/etc. - why? why not?
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/wikiscript.rb', line 73 def self.parse_link( value ) ## todo/change: find a better name - use match_link/etc. - why? why not? ## find first matching link ## return [nil,nil] if nothing found if (m = LINK_PATTERN.match( value )) link = m[:link] title = m[:title] link = link.strip ## remove leading and trailing spaces title = title.strip if title [link,title] else [nil,nil] end 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(value) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/wikiscript.rb', line 54 def self.unlink( value ) ## replace ALL wiki links with title (or link) ## e.g. [[Santiago]] ([[La Florida, Chile|La Florida]]) ## => Santiago (La Florida) value = value.gsub( LINK_PATTERN ) do |_| link = $~[:link] title = $~[:title] if title title else link end end value.strip end |