Class: VimwikiMarkdown::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/vimwiki_markdown/options.rb

Constant Summary collapse

DEFAULTS =

force - 1/0

["1", #force - 1/0
"markdown",
"md",
"~/vimwiki/site_html/",
"~/vimwiki/index.md",
"~/vimwiki/site_html/style.css",
"~/vimwiki/templates/",
"default",
".tpl",
"-"].freeze
FORCE =
0
SYNTAX =
1
EXTENSION =
2
OUTPUT_DIR =
3
INPUT_FILE =
4
CSS_FILE =
5
TEMPLATE_PATH =
6
TEMPLATE_DEFAULT =
7
TEMPLATE_EXT =
8
ROOT_PATH =
9

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

syntax : the syntax chosen for this wiki

extension : the file extension for this wiki
output_dir : the full path of the output directory, i.e. 'path_html'
input_file : the full path of the wiki page
css_file : the full path of the css file for this wiki
template_path : the full path to the wiki's templates
template_default : the default template name
template_ext : the extension of template files
root_path : a count of ../ for pages buried in subdirs
            if you have wikilink [[dir1/dir2/dir3/my page in a subdir]]
            then e %root_path% is replaced by '../../../'.


45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vimwiki_markdown/options.rb', line 45

def initialize
  @force = arguments[FORCE] == "1" ? true : false
  @syntax = arguments[SYNTAX]
  @extension = ".#{arguments[EXTENSION]}"
  @output_dir = arguments[OUTPUT_DIR]
  @input_file = arguments[INPUT_FILE]
  @css_file = arguments[CSS_FILE]
  @template_path = arguments[TEMPLATE_PATH]
  @template_default = arguments[TEMPLATE_DEFAULT]
  @template_ext = arguments[TEMPLATE_EXT]
  @root_path = arguments[ROOT_PATH]
  @root_path = "./" if @root_path == "-"
  raise "Must be markdown" unless syntax == 'markdown'
end

Instance Attribute Details

#css_fileObject (readonly)

Returns the value of attribute css_file.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def css_file
  @css_file
end

#extensionObject (readonly)

Returns the value of attribute extension.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def extension
  @extension
end

#forceObject (readonly)

Returns the value of attribute force.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def force
  @force
end

#input_fileObject (readonly)

Returns the value of attribute input_file.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def input_file
  @input_file
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def output_dir
  @output_dir
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def root_path
  @root_path
end

#syntaxObject (readonly)

Returns the value of attribute syntax.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def syntax
  @syntax
end

#template_defaultObject (readonly)

Returns the value of attribute template_default.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def template_default
  @template_default
end

#template_extObject (readonly)

Returns the value of attribute template_ext.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def template_ext
  @template_ext
end

#template_pathObject (readonly)

Returns the value of attribute template_path.



27
28
29
# File 'lib/vimwiki_markdown/options.rb', line 27

def template_path
  @template_path
end

Class Method Details

.argumentsObject



64
65
66
# File 'lib/vimwiki_markdown/options.rb', line 64

def self.arguments
  ARGV.empty? ? DEFAULTS : ARGV
end

Instance Method Details

#output_fullpathObject



72
73
74
# File 'lib/vimwiki_markdown/options.rb', line 72

def output_fullpath
  "#{output_dir}#{title.parameterize}.html"
end

#template_filenameObject



60
61
62
# File 'lib/vimwiki_markdown/options.rb', line 60

def template_filename
  "#{template_path}#{template_default}#{template_ext}"
end

#titleObject



68
69
70
# File 'lib/vimwiki_markdown/options.rb', line 68

def title
  File.basename(input_file, "#{extension}").capitalize
end