vulture/add_post.rb

24 lines
576 B
Ruby

#!/usr/bin/env ruby
require 'sequel'
require 'sqlite3'
require_relative 'lib/config.rb'
# Load the Sequel timestamps plugin
Sequel::Model.plugin :timestamps
# Load configuration
conf = Config.new(File.join(__dir__, 'data/defaults.yaml'))
# Initialize Sequel gem for database actions
DB = Sequel.connect(adapter: conf.get('database.adapter'), database: conf.get('database.database'))
# Load models
require_relative 'lib/models/post.rb'
# Create new time object, three minutes in the future
t = Time.now + (3 * 60)
# Insert post
Post.create(text: ARGV[0], publish_at: t)