Class: SlideShowGenerator
- Inherits:
-
Object
- Object
- SlideShowGenerator
- Extended by:
- Logging
- Includes:
- Singleton
- Defined in:
- lib/html2slideshow.rb
Overview
The SlideShowGenerator class provides the main routine to start
the slideshow-generation.
Alternatively a commandline parameter -g or --generic can be
used to write a generic configuration file, which can be used
to alter the program output in later runs of the generator.
See Argparser for details on commandline parameters.
Constant Summary collapse
- @@log =
self::init_logger()
Instance Method Summary collapse
-
#generate(args) ⇒ Object
The original console-version works with this method.
-
#initialize ⇒ SlideShowGenerator
constructor
A new instance of SlideShowGenerator.
-
#read_dir(options) ⇒ Object
read from DIR.
-
#read_html(options) ⇒ Object
read from html.
-
#run ⇒ Object
main routine.
Methods included from Logging
init_logger, log_level=, log_target=
Methods included from File_Checking
file_check, #file_check, last_mime_type, magic_check, mime_check
Constructor Details
#initialize ⇒ SlideShowGenerator
Returns a new instance of SlideShowGenerator.
48 49 50 |
# File 'lib/html2slideshow.rb', line 48 def initialize @log = @@log end |
Instance Method Details
#generate(args) ⇒ Object
The original console-version works with this method
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/html2slideshow.rb', line 53 def generate(args) = nil = ArgParser.parse(args) @log.level = Logger::INFO if !.debug @log.debug('Log-level is ' << @log.level.to_s) @log.debug("options are " + .to_s) unless .generic pwd = Dir.pwd() if(.source && !.source.empty?) = File_Checking.file_check(.source, [:exist?, :readable?, :writable?, :directory?]) if() = sprintf( trl("Source-directory") << ": %s" , ) else Dir.chdir(.source) if('files' == .source_type) read_dir() else read_html() end Dir.chdir(pwd) end else = trl('No source-directory given!') end else = Configurator.write_configuration(.generic) end if end |
#read_dir(options) ⇒ Object
read from DIR
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/html2slideshow.rb', line 86 def read_dir() @log.debug('reading files from souce-directory') if(!.formats || .formats.empty?) .formats = %w[jpg JPG jpeg JPEG webp] @log.debug("no image types chosen, looking for JPEGs and WebP") end @log.debug('working on directory ' + Dir.pwd) source = SourceFile.new(Dir.pwd, ) HtmlBuilder.new(source, ) end |
#read_html(options) ⇒ Object
read from html
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/html2slideshow.rb', line 98 def read_html() @log.debug('reading references from html') htmlfiles = Dir.glob("{*.htm,*.html}") if(htmlfiles && !htmlfiles.empty?) htmlfiles.each do |sf| @log.debug('working on file ' + sf) source = SourceFile.new(sf, ) HtmlBuilder.new(source, ) end else @log.error("NO source-files in %s! Check source-directory!" %.source) end end |
#run ⇒ Object
main routine.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/html2slideshow.rb', line 113 def run() = generate(ARGV) if @log.error @log.debug('returning nil') nil else msg = trl('DONE') puts "-" * msg.length << "\n" << msg @log.debug('returning true') true end end |