From ae443a5ba3ea03197eb110d1006a745be09e99fe Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Wed, 7 Dec 2022 15:39:48 -0500 Subject: [PATCH] Initial ruby project structure --- LICENSE | 2 +- data/defaults.yaml | 2 ++ lib/config.rb | 20 ++++++++++++++++++++ vulture.rb | 21 +++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 data/defaults.yaml create mode 100644 lib/config.rb create mode 100644 vulture.rb diff --git a/LICENSE b/LICENSE index 5f662b3..f8df596 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) +Copyright (c) 2022 Metaunix.net Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/data/defaults.yaml b/data/defaults.yaml new file mode 100644 index 0000000..fda6a21 --- /dev/null +++ b/data/defaults.yaml @@ -0,0 +1,2 @@ +vulture: + run_interval: 1 diff --git a/lib/config.rb b/lib/config.rb new file mode 100644 index 0000000..fe21f39 --- /dev/null +++ b/lib/config.rb @@ -0,0 +1,20 @@ +require 'yaml' + +class Config + + def initialize(config_path) + @data = YAML::load_file(config_path) + end + + def get(key, depth = 0) + bits = key.split('.') + value = @data + + bits.each do |bit| + value = value[bit] + end + + return value + end + +end diff --git a/vulture.rb b/vulture.rb new file mode 100644 index 0000000..a2eaa41 --- /dev/null +++ b/vulture.rb @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +require 'logger' + +require_relative 'lib/config.rb' + +# Load configuration +conf = Config.new(File.join(__dir__, 'data/defaults.yaml')) + +# Initialize logging +logger = Logger.new(STDOUT) +logger.level = Logger::INFO + +# Main program loop +while true + # Let the user know something is going on + logger.info('Checking for new social media posts to make public...') + + # Wait for the specified wait period + sleep(conf.get('vulture.run_interval') * 60) +end