Module: CertBot
- Defined in:
- lib/cert_bot.rb,
lib/cert_bot/io.rb,
lib/cert_bot/data.rb,
lib/cert_bot/parameter.rb,
lib/cert_bot/mail_agent.rb,
lib/cert_bot/rss_handler.rb,
lib/cert_bot/configuration.rb,
lib/cert_bot/data/severity.rb,
lib/cert_bot/advisory_parser.rb,
lib/cert_bot/io/csv_accessor.rb,
lib/cert_bot/help/help_output.rb,
lib/cert_bot/io/cache_cleaner.rb,
lib/cert_bot/data/update_status.rb,
lib/cert_bot/json/json_generator.rb,
lib/cert_bot/parameter/parameter_handler.rb,
lib/cert_bot/parameter/parameter_repository.rb
Overview
This module is the main entry point and will be called from the main forecast script
Defined Under Namespace
Modules: AdvisoryParser, CacheCleaner, Data, JsonGenerator, MailAgent, Parameter Classes: Configuration, CsvAccessor, HelpOutput, MetaData, RssHandler
Class Attribute Summary collapse
-
.parameter_handler ⇒ Parameter::ParameterHandler
readonly
The handler controlling the parameters.
Class Method Summary collapse
-
.contains_parameter?(symbol) ⇒ boolean
private
method the check if the given parameter has been set.
-
.initialize(arguments) ⇒ Object
main entry point and initialization.
-
.parse_rss ⇒ Object
main entry point that requires the parameter repository to be filled the method reads the required parameter and generates the mail.
-
.print_error(message) ⇒ Object
call for standard error output.
-
.print_help ⇒ Object
call to print the help text.
-
.print_version ⇒ Object
call to print version number and author.
Class Attribute Details
.parameter_handler ⇒ Parameter::ParameterHandler (readonly)
Returns the handler controlling the parameters.
13 14 15 |
# File 'lib/cert_bot.rb', line 13 def parameter_handler @parameter_handler end |
Class Method Details
.contains_parameter?(symbol) ⇒ boolean (private)
method the check if the given parameter has been set
28 29 30 |
# File 'lib/cert_bot.rb', line 28 def contains_parameter?(symbol) @parameter_handler != nil && @parameter_handler.repository.parameters[symbol] != nil end |
.initialize(arguments) ⇒ Object
main entry point and initialization
17 18 19 20 21 |
# File 'lib/cert_bot.rb', line 17 def initialize(arguments) @parameter_handler = Parameter::ParameterHandler.new(arguments) CertBot::Data::Severity.initialize CertBot::Data::UpdateStatus.initialize end |
.parse_rss ⇒ Object
main entry point that requires the parameter repository to be filled the method reads the required parameter and generates the mail
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cert_bot.rb', line 36 def self.parse_rss if (!contains_parameter?(:help) && !contains_parameter?(:version)) rss_feed = "https://wid.cert-bund.de/content/public/securityAdvisory/rss" config_file = @parameter_handler.repository.parameters[:file] severity = CertBot::Data::Severity. get_mapping_for(@parameter_handler.repository.parameters[:severity]) severity = :medium if (severity.nil?) severities = CertBot::Data::Severity.values[severity] rss_handler = CertBot::RssHandler.new(rss_feed, config_file) rss_handler.read_feed(severities, @parameter_handler.repository.parameters[:updated]) end end |
.print_error(message) ⇒ Object
call for standard error output
68 69 70 71 72 |
# File 'lib/cert_bot.rb', line 68 def self.print_error() puts "#{}".red puts "For help type: ruby <script> --help".green nil end |
.print_help ⇒ Object
call to print the help text
50 51 52 53 54 55 56 57 |
# File 'lib/cert_bot.rb', line 50 def self.print_help if (contains_parameter?(:help)) CertBot::HelpOutput.print_help_for(@parameter_handler.repository.parameters[:help]) else print_error("Error: Module not initialized. Run CertBot.new(ARGV)") end nil end |
.print_version ⇒ Object
call to print version number and author
60 61 62 63 64 |
# File 'lib/cert_bot.rb', line 60 def self.print_version puts "cert_bot version 0.4.1".yellow puts "Created by Benjamin Held (Juli 2022)".yellow nil end |