trying to add in support for configure block. launching console giving me bug with pb object
This commit is contained in:
parent
332efbe9cb
commit
67bc00bb1d
3 changed files with 33 additions and 10 deletions
|
@ -15,7 +15,9 @@ def rest_client_toggle_log(default=false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pb = Pastebinner::ApiClient.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password'])
|
# not working yet
|
||||||
|
config = Pastebinner::Configuration.new
|
||||||
|
pb = Pastebinner::ApiClient.new(config.api_key, config.api_username, config.api_password)
|
||||||
es = Pastebinner::ElasticSearchHelper.new(ENV['elastic_search_url'], 'pastes')
|
es = Pastebinner::ElasticSearchHelper.new(ENV['elastic_search_url'], 'pastes')
|
||||||
|
|
||||||
# sidekiq worker to send pastes to es
|
# sidekiq worker to send pastes to es
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
# ideally i want to have a configuration block like this loaded
|
module Pastebinner
|
||||||
Pastebinner.configure do |config|
|
class Configuration
|
||||||
config.pastebin_username = pastebin_username
|
attr_accessor :api_key, :api_username, :api_password, :elasticsearch_url, :redis_url
|
||||||
config.pastebin_password = pastebin_password
|
|
||||||
config.pastebin_api_key = pastebin_api_key
|
def initialize
|
||||||
config.elastic_search_url = elastic_search_url
|
@api_key = nil
|
||||||
config.redis_url = redis_url
|
@api_username = nil
|
||||||
|
@api_password = nil
|
||||||
|
@elasticsearch_url = nil
|
||||||
|
@redis_url = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# change this to a config module soon:
|
# change this to a config module soon:
|
||||||
|
require '../config/configuration'
|
||||||
require '../config/initializers/sidekiq'
|
require '../config/initializers/sidekiq'
|
||||||
require 'rest-client'
|
require 'rest-client'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
@ -11,6 +12,21 @@ require 'pastebinner/helpers/elastic_search_helper'
|
||||||
require 'pastebinner/workers/paste_to_es'
|
require 'pastebinner/workers/paste_to_es'
|
||||||
|
|
||||||
module Pastebinner
|
module Pastebinner
|
||||||
class Error < StandardError; end
|
|
||||||
# your code goes here
|
class << self
|
||||||
|
attr_accessor :configuration
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.configuration
|
||||||
|
@configuration ||= Configuration.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.reset
|
||||||
|
@configuration = Configuration.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.configure
|
||||||
|
yield(configuration)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue