Initial ruby project structure
This commit is contained in:
parent
f69b5d587a
commit
ae443a5ba3
2
LICENSE
2
LICENSE
@ -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
2
data/defaults.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
vulture:
|
||||||
|
run_interval: 1
|
20
lib/config.rb
Normal file
20
lib/config.rb
Normal 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
21
vulture.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user