diff --git a/.gitignore b/.gitignore index 3ab247f..26ff689 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /tmp/ /data Gemfile.lock +.config # rspec failure tracking .rspec_status diff --git a/bin/console b/bin/console index fa30917..15a5cf9 100755 --- a/bin/console +++ b/bin/console @@ -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 diff --git a/config/configuration.rb b/config/configuration.rb new file mode 100644 index 0000000..8b2c72a --- /dev/null +++ b/config/configuration.rb @@ -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 diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb new file mode 100644 index 0000000..35d0e5f --- /dev/null +++ b/config/initializers/sidekiq.rb @@ -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 diff --git a/lib/configuration.rb b/lib/configuration.rb deleted file mode 100644 index f7f1bb0..0000000 --- a/lib/configuration.rb +++ /dev/null @@ -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