aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/hub.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-04-19 21:33:45 -0400
committerRalph Amissah <ralph@amissah.com>2011-04-19 21:33:45 -0400
commit17d1555cfcfbbcd1b0a83ace1e264152c71ebd2f (patch)
treee15ecdb72c6bf23effeaf4ea31941d6694e5ae8f /lib/sisu/v3/hub.rb
parentv3: urls, minor fixes (diff)
v3: options, hub, introduce opt.act booleans, more setting in options
* opt.act booleans more flexible than opt.cmd (start to favor use of opt.act over opt.cmd) * move option setting from hub to options where possible * separate out a few methods
Diffstat (limited to 'lib/sisu/v3/hub.rb')
-rw-r--r--lib/sisu/v3/hub.rb156
1 files changed, 71 insertions, 85 deletions
diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb
index 7794c08c..e20b4293 100644
--- a/lib/sisu/v3/hub.rb
+++ b/lib/sisu/v3/hub.rb
@@ -287,58 +287,28 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
if @opt.cmd =~/E/ # re-assign character
require 'profile'
end
- if @opt.mod.inspect =~/--harvest/
+ if @opt.act[:harvest]
require_relative 'harvest' # harvest.rb
- end
- if @opt.mod.inspect =~/--convert|--to|--from/
+ elsif @opt.mod.inspect =~/--convert|--to|--from/
require_relative 'sst_convert_markup' # sst_convert_markup.rb
- end
- if @opt.cmd =~/([AabCcDdeFfGgHhIiJjkLMmNnOoPpQqRrSsTtUuVvwWXxYyZ_0-9])/ \
+ elsif @opt.cmd =~/([AabCcDdeFfGgHhIiJjkLMmNnOoPpQqRrSsTtUuVvwWXxYyZ_0-9])/ \
and @opt.cmd =~/^-/ \
and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \
or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/
@@tell=SiSU_Screen::Ansi.new(@opt.cmd)
@cX=SiSU_Screen::Ansi.new(@opt.cmd).cX
flag=SiSU_Env::Info_processing_flag.new
- extra=''
- if @opt.cmd !~/[mn]/
- extra+=if @opt.cmd =~/[abegHhIiNOoPpTtwXxyz]/ \
- and @opt.cmd !~/[mn]/
- 'm' #% add dal
- elsif ((@opt.cmd =~/[Dd]/ \
- or (@opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \
- and @opt.mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \
- and @opt.cmd !~/[mn]/
- 'm' #% add dal
- else ''
- end
- end
- if @opt.cmd !~/y/
- extra+=if @opt.cmd =~/[abeHhIiNopsSstwXxz]/ \
- and @opt.cmd !~/y/
- 'ym' #% add manifest
- elsif (@opt.cmd =~/[Dd]/ \
- or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \
- and @opt.files[0] !~/^remove$/ \
- and @opt.cmd !~/y/
- 'ym' #% add manifest
- else ''
- end
- end
- @opt.cmd=@opt.cmd + extra
- opt=@opt.cmd.scan(/CC|\S/)
- @opt.cmd=opt.uniq.join
- if @opt.cmd =~/[vVM]/ #% version information
+ if @opt.cmd =~/[vVM]/ #% version information
if @opt.cmd =~/V/ \
- and @opt.files.empty? #% environment
+ and @opt.files.empty? #% environment
SiSU_Help::Help.new('env',@opt).environment
else SiSU_Help::Help.new('env',@opt).sisu_version
end
end
- if @opt.cmd =~/^-L$/ #% version information
+ if @opt.act[:license] #% license information
SiSU_Help::Help.new('license',@opt).help_request
end
- if @opt.cmd =~/m/i #% -m for -C
+ if @opt.act[:dal] or @opt.act[:maintenance] #% --maintenance, -m for -C
path={}
path[:css]=@@env.path.output + '/_sisu/css'
path[:xml]=@@env.path.output + '/_sisu/xml'
@@ -356,7 +326,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
end
end
end
- if @opt.cmd =~/C/ #% -C initialize/configure
+ if @opt.act[:site_init] #% --init-site, -C initialize/configure
op('conf','configure site')
if @opt.cmd =~/R/
if @opt.mod.inspect =~/--init(?:ialize)?=site/ \
@@ -372,19 +342,19 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
end
end
end
- if @opt.cmd =~/F/ #% -F cgi sample search form
+ if @opt.act[:sample_search_form] #% --sample-search-form, -F cgi sample search form
Operations.new(@opt).cgi
end
- if @opt.cmd =~/W/ #% -W webrick #@argv==port
+ if @opt.act[:webrick] #% --webrick, -W webrick
Operations.new(@opt).webrick
end
- if @opt.cmd =~/Z/ #% -Z wipe previous output clean
+ if @opt.cmd =~/Z/ #% -Z wipe previous output clean
op('zap','Zap, deletions')
end
- if @opt.cmd =~/s/ #% -s sisu source
+ if @opt.act[:share_source]
op('share_src','SiSU markup source')
end
- if @opt.cmd =~/m/ #% -m is remote url requested? (download if)
+ if @opt.act[:dal]
@retry_count= -1
begin
path_image='./_sisu/processing/external_document/image'
@@ -400,12 +370,12 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
@get_p << re_p.match(fns)[1] if re_p
end
end
- if @get_s.length > 0 #% remote markup file .sst
+ if @get_s.length > 0 #% remote markup file .sst
require_relative 'remote' # remote.rb
SiSU_Remote::Get.new(@opt,@get_s).fns
Operations.new.counter
end
- if @get_p.length > 0 #% remote sisupod
+ if @get_p.length > 0 #% remote sisupod
require_relative 'remote' # remote.rb
SiSU_Remote::Get.new(@opt,@get_p).sisupod
end
@@ -417,48 +387,57 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
end
@opt.files=@opt.files.collect {|x| x=x.gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst') }
end
- if @opt.cmd=~/m/ #% -m dal
+ if @opt.act[:dal] #%--dal, -m
op('dal','dal')
end
@opt.files=@opt.files.collect {|x| x=x.gsub(/\.ssm$/,'.ssm.sst') }
- if @opt.cmd =~/S/
- op('sisupod_make','sisupod (zip)') #% -S make sisupod
+ if @opt.act[:sisupod] #% --sisupod, -S make sisupod
+ op('sisupod_make','sisupod (zip)')
if @opt.fns=~/\.kdi._sst/
- op('share_src_kdissert','kdissert (kdi)') #% -S share kdissert source
+ op('share_src_kdissert','kdissert (kdi)') #% -S share kdissert source
end
end
- if @opt.cmd =~/N/; op('digests','digests') #% -N digest tree
+ if @opt.act[:hash_digests] #% --hash-digests, -N digest tree
+ op('digests','digests')
end
- if @opt.cmd =~/[hHz]/; op('html','html') #% -h -H -z html css
+ if @opt.act[:html] #% --html, -h
+ op('html','html')
end
- if @opt.cmd =~/[at]/; op('plaintext','plaintext') #% -t -a #-A -f -e -E plaintext -a creates ms-dos type; -A creates unix type, plaintext file
+ if @opt.act[:txt] #% --txt, -t -a
+ #-A -f -e -E plaintext -a creates ms-dos type; -A creates unix type, plaintext file
+ op('plaintext','plaintext')
end
- #if @opt.cmd =~/g/; op('git','git') #% -g git
- #end
- #if @opt.cmd =~/g/; op('wikispeak','wikispeak') #% -g wiki
- #end
- if @opt.cmd =~/e/; op('epub','ePub') #% -e epub
+ if @opt.act[:epub] #% --epub, -e
+ op('epub','ePub')
end
- if @opt.cmd =~/o/; op('odf','OpenDocument') #% -o opendocument
+ if @opt.act[:odt] #% --odt, -o opendocument
+ op('odf','OpenDocument')
end
- if @opt.cmd =~/x/; op('xml','xml sax') #% -x xml sax type
+ if @opt.act[:xml_sax] #% --xml-sax, -x xml sax type
+ op('xml','xml sax')
end
- if @opt.cmd =~/X/; op('xml_dom','xml dom') #% -X xml dom type
+ if @opt.act[:xml_dom] #% --xml-dom, -x xml dom type
+ op('xml_dom','xml dom')
end
- if @opt.cmd =~/f/; op('xml_fictionbook','xml fictionbook') #% -f xml fictionbook
+ if @opt.act[:fictionbook] #% --fictionbook, -f fictionbook xml
+ op('xml_fictionbook','xml fictionbook')
end
- if @opt.cmd =~/b/; op('xhtml','xhtml sax') #% -b xhtml sax type
+ if @opt.act[:xhtml] #% --xhtml, -b xhtml
+ op('xhtml','xhtml sax')
end
- if @opt.cmd =~/w/; op('concordance','Concordance') #% -w concordance
+ if @opt.act[:concordance] #% --concordance, -w
+ op('concordance','Concordance')
end
- if @opt.cmd =~/O/; op('xml_md_oai_pmh_dc','OAI PMH') #% -O open archive initiative, metadata harvesting
+ if @opt.cmd =~/O/ #% -O open archive initiative, metadata harvesting
+ op('xml_md_oai_pmh_dc','OAI PMH')
end
- if @opt.cmd =~/P/; op('po4a','po4a') #% -P
+ if @opt.act[:po4a] #% --po4a, -P
+ op('po4a','po4a')
end
- if @opt.cmd =~/g/ #% -g sisu git
+ if @opt.act[:git] #% --git, -g sisu git
op('git','SiSU Git')
end
- if @opt.cmd =~/T/ #% -T termsheet/standard form
+ if @opt.cmd =~/T/ #% -T termsheet/standard form
SiSU_Help::Help.new('termsheet').help_request
@opt.files.each do |fns|
if FileTest.file?(fns)
@@ -472,32 +451,39 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
end
Operations.new.counter
end
- if @opt.cmd =~/k/; op('xml_scaffold','XML scaffold') #% -T temporary tests
+ if @opt.cmd =~/k/ #% -T temporary tests
+ op('xml_scaffold','XML scaffold')
end
- if @opt.cmd =~/p/; op('texpdf','LaTeX pdf') #% -p latex/ texpdf
+ if @opt.act[:pdf] #% --pdf, -p latex/ texpdf
+ op('texpdf','LaTeX pdf')
end
- if @opt.cmd =~/i/; op('manpage','manpage') #% -i manpage
+ if @opt.act[:manpage] #% --manpage, -i
+ op('manpage','manpage')
end
- if @opt.cmd =~/I/; op('texinfo','TeX Info') #% -I texinfo (i taken by db import)
+ if @opt.act[:texinfo] #% --texinfo, -I
+ op('texinfo','TeX Info')
end
- if @opt.cmd =~/D/ \
- or @opt.mod.inspect =~/--pgsql/; op('dbi','postgresql') #% -D DB postgresql
+ if @opt.act[:psql] #% --pg, -D DB postgresql
+ op('dbi','postgresql')
end
- if @opt.cmd =~/d/ \
- or @opt.mod.inspect =~/--sqlite/; op('dbi','sqlite') #% -d DB sqlite
+ if @opt.act[:sqlite] #% --sqlite, -d DB sqlite
+ op('dbi','sqlite')
end
- #if @opt.cmd =~/G/; Operations.new(@opt).cgi #% -G cgi - used to make dbi intecface
- #end
- if @opt.cmd=~/m/; op('embedded','Embedded Content') #% -m embedded content
+ if @opt.act[:dal] #% --dal, -m embedded content
+ op('embedded','Embedded Content')
end
- if @opt.cmd =~/y/; op('manifest','Manifest') #% -y manifest
+ if @opt.act[:manifest] #% --manifest, -y
+ op('manifest','Manifest')
end
- if @opt.cmd =~/Y/; op('sitemaps','Sitemap') #% -Y sitemap
+ if @opt.act[:sitemap] #% --sitemap, -Y
+ op('sitemaps','Sitemap')
end
if @opt.mod.inspect !~/--harvest/
- if @opt.cmd =~/r/; op('remote','scp') #% -r copy to remote server
+ if @opt.act[:scp] #% -r copy to remote server
+ op('remote','scp')
end
- if @opt.cmd =~/R/; op('remote','rsync') #% -R copy to remote server
+ if @opt.act[:rsync] #% -R copy to remote server
+ op('remote','rsync')
end
else
end
@@ -517,20 +503,20 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
elsif @opt.mod.inspect =~/--identify/
require_relative 'sst_identify_markup' # sst_identify_markup.rb
markup_version=SiSU_Markup::Markup_identify.new(@opt).markup_version?
- elsif @opt.mod.inspect =~/--about/ #% help instructions
+ elsif @opt.mod.inspect =~/--about/ #% help instructions
if @opt.mod.inspect =~/--about/ \
and not @opt.what.empty?
SiSU_Help::Help.new(@opt.what,'color_off').help_request
else SiSU_Help::Help.new('list','color_off').help_request
end
- elsif @opt.mod.inspect =~/--sitemaps/ #% sitemaps
+ elsif @opt.mod.inspect =~/--sitemaps/ #% sitemaps
require_relative 'sitemaps' # sitemaps.rb
SiSU_Sitemaps::Source.new(@opt).read
if @opt.cmd =~/R/
require_relative 'remote' # remote.rb
SiSU_Remote::Put.new(@opt).rsync_sitemaps
end
- else #% help instructions
+ else #% help instructions
unless @opt.mod.inspect =~/--convert|--to|--from|--harvest/
if @opt.mod.inspect =~/--help/ \
and not @opt.what.empty?