Module: Juli::Command
- Defined in:
- lib/juli/command.rb,
lib/juli/command/tag.rb,
lib/juli/command/sitemap.rb,
lib/juli/command/file_entry.rb,
lib/juli/command/recent_update.rb
Overview
This is a top level module for juli(1) command execution. Each juli(1) command corresponds to each method here.
Defined Under Namespace
Classes: Error, FileEntry, RecentUpdate, Sitemap, Tag
Constant Summary collapse
- OUTPUT_TOP_COMMENT =
"# Juli-repo config file.\n#\n# This is YAML format.\n#\n# Starting '#' at each line means just comment.\n# You can delete these comments.\n#\n# The commented-out settings shown in this file represent the default values.\n\n\n# Locale(default = en)\n#\n#locale: en\n\n# show_indent_toggle_button (default = true) to show/hide the toggle button\n# for indented scope of the text. NOTE: toggle action still works even\n# though button is hidden.\n#\n#show_indent_toggle_button: true\n\n# When set to '1st-only' (default), wikiname auto-link is applied at ONLY 1st\n# occurence in a text, otherwise is applied at every occurence:\n#\n#link_wikiname_on: 1st-only\n\n# Specify output top directory (default = ../html).\n\n"- TEMPLATE_COMMENT =
"\n# Specify html template when generating (default = 'default.html', which \n# means that RUBY_LIB/juli/template/default.html is used).\n#\n# Current available templates are under RUBY_LIB/juli/template/, where\n# RUBY_LIB is the directory which juli library is installed\n# (e.g. /usr/local/lib/ruby/site_ruby/1.9/).\n#\n# You can put your customized template under JULI_REPO/.juli/\n# rather than ruby standard library directory. For example,\n# if you want to use your customized template 'blue_ocean.html',\n# create it under JULI_REPO/ and specify it at config as follows:\n#\n# $ cp RUBY_LIB/juli/template/default.html JULI_REPO/.juli/blue_ocean.html\n# (edit JULI_REPO/.juli/blue_ocean.html as you like)\n# (edit JULI_REPO/.juli/config as follows:\n#\n# template: blue_ocean.html\n#\n# File extention (e.g. .html) is required in this config.\n# -t option at 'juli gen' command line execution can be also supported.\n# \n\n"- EXT_COMMENT =
"\n# Generated file's extention (default = .shtml).\n# The reason why '.shtml' is because to use SSI (server side include)\n# for recent_update. Of course, it depends on web-server configuration and\n# you may not use SSI. In such a case, you can change to '.html'.\n\n"
Instance Method Summary collapse
-
#gen(opts) ⇒ Object
generate command.
-
#init(opts) ⇒ Object
init does:.
-
#run(command_str, opts = {}) ⇒ Object
top level command execution.
Instance Method Details
#gen(opts) ⇒ Object
generate command
OPTIONS
- -g generator
-
specify generator
- -f
-
force update
- -t template
-
specify template
- -o output_path
-
specify output file path (only non-bulk-mode)
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/juli/command.rb', line 136 def gen(opts) o = opts.dup o.delete(:g) # executes each generator's init here: v = visitor(opts[:g]).new(o) if ARGV.empty? print "bulk mode\n" if opts[:o] STDERR.print "ERROR: -o #{opts[:o]} is specified in bulk-mode\n" else v.run_bulk end else for file in ARGV do Juli::Parser.new.parse(file, v) end end end |
#init(opts) ⇒ Object
init does:
-
create juli-repository at the current directory, if not yet.
-
create config file under the juli-repo, if not yet. This stores juli-repo dependent information.
-
if parameters are specified, store it in config file under juli-repo.
OPTIONS
-o output_top -t template -e ext
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/juli/command.rb', line 105 def init(opts) if !File.directory?(Juli::REPO) FileUtils.mkdir(Juli::REPO) else STDERR.print "WARN: juli-repo is already created\n" end config_file = File.join(Juli::REPO, 'config') if !File.exist?(config_file) File.open(config_file, 'w') do |f| f.print OUTPUT_TOP_COMMENT write_config(f, 'output_top', opts[:o]) f.print TEMPLATE_COMMENT write_config(f, 'template', opts[:t]) f.print EXT_COMMENT write_config(f, 'ext', opts[:e]) write_macro_conf(f) write_helper_conf(f) end else STDERR.print "WARN: config file is already created\n" end end |
#run(command_str, opts = {}) ⇒ Object
top level command execution. command_str will be checked and dispatched to each method.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/juli/command.rb', line 15 def run(command_str, opts = {}) if command_str == 'init' init(opts) else Juli::Util::JuliI18n.new(conf, juli_repo) case command_str when 'gen'; gen(opts) when 'sitemap'; Juli::Command::Sitemap.new.run(opts) when 'recent_update'; Juli::Command::RecentUpdate.new.run(opts) when 'tag'; Juli::Command::Tag.new.run(opts) else STDERR.print "Unknown juli command: '#{command_str}'\n\n", usage, "\n" raise Error end end end |