class CircleCI::CLI::Networking::CircleCIPusherClient
Public Instance Methods
bind(channel, event, &block)
click to toggle source
# File lib/circleci/cli/networking/pusher_client.rb, line 14 def bind(channel, event, &block) socket.subscribe(channel) socket[channel].bind(event, &block) end
bind_event_json(channel, event, &block)
click to toggle source
# File lib/circleci/cli/networking/pusher_client.rb, line 19 def bind_event_json(channel, event, &block) bind(channel, event) { |data| JSON.parse(data).each(&block) } end
connect()
click to toggle source
# File lib/circleci/cli/networking/pusher_client.rb, line 9 def connect PusherClient.logger.level = Logger::ERROR socket.connect(true) end
unsubscribe(channel)
click to toggle source
# File lib/circleci/cli/networking/pusher_client.rb, line 23 def unsubscribe(channel) socket.unsubscribe(channel) end
Private Instance Methods
auth(socket_id, channel)
click to toggle source
# File lib/circleci/cli/networking/pusher_client.rb, line 38 def auth(socket_id, channel) token = ENV['CIRCLE_CI_TOKEN'] || ask('Circle CI token ? :') res = connection.post( "/auth/pusher?circle-token=#{token}", { socket_id: socket_id, channel_name: channel.name } ) JSON.parse(res.body)['auth'] end
connection()
click to toggle source
# File lib/circleci/cli/networking/pusher_client.rb, line 47 def connection Faraday.new(url: 'https://circleci.com') do |f| f.request :url_encoded f.adapter Faraday.default_adapter end end
socket()
click to toggle source
# File lib/circleci/cli/networking/pusher_client.rb, line 29 def socket @socket ||= PusherClient::Socket.new( '1cf6e0e755e419d2ac9a', secure: true, auth_method: proc { |a, b| auth(a, b) }, logger: Logger.new('/dev/null') ) end