Initial ruby project structure

This commit is contained in:
Gregory Ballantine 2022-12-07 15:39:48 -05:00
parent f69b5d587a
commit ae443a5ba3
4 changed files with 44 additions and 1 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) <year> <owner> 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: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

2
data/defaults.yaml Normal file
View File

@ -0,0 +1,2 @@
vulture:
run_interval: 1

20
lib/config.rb Normal file
View File

@ -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

21
vulture.rb Normal file
View File

@ -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