Class: Perkins::Application
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
-
#github_client_id ⇒ Object
Returns the value of attribute github_client_id.
-
#github_client_secret ⇒ Object
Returns the value of attribute github_client_secret.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#redis ⇒ Object
Returns the value of attribute redis.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#sse_endpoint ⇒ Object
Returns the value of attribute sse_endpoint.
-
#working_dir ⇒ Object
Returns the value of attribute working_dir.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #init_github_client ⇒ Object
-
#initialize(opts = {}) ⇒ Application
constructor
A new instance of Application.
- #setup_sidekiq ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Application
Returns a new instance of Application.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/perkins/application.rb', line 11 def initialize(opts={}) @host = opts[:host] unless opts[:host].blank? @post = opts[:port] unless opts[:port].blank? @github_client_id = opts[:github_client_id] unless opts[:github_client_id].blank? @github_client_server = opts[:github_client_secret] unless opts[:github_client_secret].blank? working_dir = opts[:working_dir] unless opts[:working_dir].blank? self.class.instance = self self.init_github_client self end |
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
8 9 10 |
# File 'lib/perkins/application.rb', line 8 def instance @instance end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
3 4 5 |
# File 'lib/perkins/application.rb', line 3 def database @database end |
#github_client_id ⇒ Object
Returns the value of attribute github_client_id.
5 6 7 |
# File 'lib/perkins/application.rb', line 5 def github_client_id @github_client_id end |
#github_client_secret ⇒ Object
Returns the value of attribute github_client_secret.
5 6 7 |
# File 'lib/perkins/application.rb', line 5 def github_client_secret @github_client_secret end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/perkins/application.rb', line 3 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/perkins/application.rb', line 3 def port @port end |
#redis ⇒ Object
Returns the value of attribute redis.
3 4 5 |
# File 'lib/perkins/application.rb', line 3 def redis @redis end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
4 5 6 |
# File 'lib/perkins/application.rb', line 4 def server @server end |
#sse_endpoint ⇒ Object
Returns the value of attribute sse_endpoint.
3 4 5 |
# File 'lib/perkins/application.rb', line 3 def sse_endpoint @sse_endpoint end |
#working_dir ⇒ Object
Returns the value of attribute working_dir.
3 4 5 |
# File 'lib/perkins/application.rb', line 3 def working_dir @working_dir end |
Instance Method Details
#as_json(options = {}) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/perkins/application.rb', line 51 def as_json( = {}) data = {} fields = [:host, :port, :github_client_id, :github_client_secret, :working_dir] fields.each { |k| data[k] = send(k) } data end |
#init_github_client ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/perkins/application.rb', line 32 def init_github_client #$github_client = Octokit::Client.new \ # :client_id => @github_client_id, # :client_secret => @github_client_server #GLOBAL SERVER 2 SERVER GITHUB CLIENT $github_client ||= Octokit::Client.new( login: ENV['LOGIN'], access_token: ENV['ACCESS_TOKEN'] ) end |
#setup_sidekiq ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/perkins/application.rb', line 60 def setup_sidekiq # Sidekiq server is multi-threaded so our Redis connection pool size defaults to concurrency (-c) Sidekiq.configure_server do |config| config.redis = { :namespace => 'perkins-worker' } if defined?(ActiveRecord::Base) #ActiveRecord::Base.establish_connection #Perkins::Application.instance.database ActiveRecord::Base.establish_connection(@dbconfig[ENV['RACK_ENV']]) end end Sidekiq.configure_client do |config| config.redis = { :namespace => 'perkins-worker' } end end |