added the type of config block i want to have. not ready but setup a skeleton to use with it

This commit is contained in:
booboy 2019-02-05 00:30:50 -06:00
parent c3fe3a2bb7
commit 6c0b401d23
5 changed files with 27 additions and 19 deletions

1
.gitignore vendored
View file

@ -8,6 +8,7 @@
/tmp/
/data
Gemfile.lock
.config
# rspec failure tracking
.rspec_status

View file

@ -1,14 +1,19 @@
#!/usr/bin/env ruby
require 'sidekiq'
require 'sidekiq/api'
require 'pry'
require '../lib/pastebinner'
require '../lib/elastic_search_helper'
require '../lib/paste_to_es'
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
require 'pry'
# set restclient logging and setup a pb object
RestClient.log ='stdout'
pb = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password'])
es = ElasticSearchHelper.new(ENV['elastic_search_url'], 'pastes')
binding.pry

8
config/configuration.rb Normal file
View file

@ -0,0 +1,8 @@
# ideally i want to have a configuration block like this loaded
Pastebinner.configure do |config|
config.pastebin_username = pastebin_username
config.pastebin_password = pastebin_password
config.pastebin_api_key = pastebin_api_key
config.elastic_search_url = elastic_search_url
config.redis_url = redis_url
end

View file

@ -0,0 +1,9 @@
# server config
Sidekiq.configure_server do |config|
config.redis = { url: ENV["REDIS_SERVER_URL"] }
end
# client config
Sidekiq.configure_client do |config|
config.redis = { url: ENV["REDIS_SERVER_URL"] }
end

View file

@ -1,15 +0,0 @@
class Configuration
# this is going to be where i store config options like
# - database or directory. directory is built in, we just need to fine tune it a bit more
# - we will start doing just a standard sqlite file for raw pastes as a test
# we can use systemd service/timer files to generate a way to automate downloading raw pastes.
def generate_service_file(user=, working_directory=, exec_start=)
# this should maybe be a HERE document that will create the file with the
# or just open the base template file that we have and replace these specific lines.
end
def build_cron
# need to lookup what we have to put in PATH in the cron to inherit the environment variables for the api key,username,password
end
end