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
|
||||
|
||||
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')
|
||||
|
||||
# sidekiq worker to send pastes to es
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
# 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
|
||||
module Pastebinner
|
||||
class Configuration
|
||||
attr_accessor :api_key, :api_username, :api_password, :elasticsearch_url, :redis_url
|
||||
|
||||
def initialize
|
||||
@api_key = nil
|
||||
@api_username = nil
|
||||
@api_password = nil
|
||||
@elasticsearch_url = nil
|
||||
@redis_url = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# change this to a config module soon:
|
||||
require '../config/configuration'
|
||||
require '../config/initializers/sidekiq'
|
||||
require 'rest-client'
|
||||
require 'json'
|
||||
|
@ -11,6 +12,21 @@ require 'pastebinner/helpers/elastic_search_helper'
|
|||
require 'pastebinner/workers/paste_to_es'
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue