Module: Appygram
- Defined in:
- lib/appygram.rb,
lib/appygram/version.rb
Defined Under Namespace
Classes: Config
Constant Summary collapse
- VERSION =
"1.0.5"
Class Method Summary collapse
Class Method Details
.configure(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/appygram.rb', line 7 def self.configure(params) if params[:api_key] Appygram::Config.api_key = params[:api_key] end if params[:appygram_endpoint] appygram_endpoint = params[:appygram_endpoint] Appygram::Config.appygram_endpoint = URI appygram_endpoint end if params[:trace_endpoint] trace_endpoint = params[:trace_endpoint] Appygram::Config.trace_endpoint = URI trace_endpoint end # defaults if nothing is set Appygram::Config.appygram_endpoint ||= URI 'https://arecibo.appygram.com/appygrams' Appygram::Config.trace_endpoint ||= URI 'https://arecibo.appygram.com/traces' if params[:platform] Appygram::Config.platform = params[:platform] || 'web' end if params[:software] Appygram::Config.software = params[:software] || "appygram.rb #{Appygram::VERSION}" end # TODO: respect throttling per readme end |
.send(params) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/appygram.rb', line 31 def self.send(params) pc = params.clone pc[:api_key] = Appygram::Config.api_key pc[:platform] = Appygram::Config.platform unless pc[:platform] pc[:software] = Appygram::Config.software unless pc[:software] if pc[:app_json] pc[:app_json] = JSON pc[:app_json] end url = Appygram::Config.appygram_endpoint req = Net::HTTP::Post.new url.request_uri req.form_data = pc session = Net::HTTP.new(url.host, url.port) if url.scheme == 'https' session.use_ssl = true end session.start {|http| http.request(req) } end |
.trace(exception, params = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/appygram.rb', line 51 def self.trace(exception, params = {}) pc = params.clone pc[:api_key] = Appygram::Config.api_key pc[:platform] = Appygram::Config.platform unless pc[:platform] pc[:software] = Appygram::Config.software unless pc[:software] if pc[:app_json] pc[:app_json] = JSON pc[:app_json] end url = Appygram::Config.trace_endpoint req = Net::HTTP::Post.new url.request_uri trace = [] exception.backtrace.each do |line| trace << line.split(':') end pc[:trace] = JSON({ 'class' => exception.class.name, 'message' => exception., 'backtrace' => trace }) req.form_data = pc session = Net::HTTP.new(url.host, url.port) if url.scheme == 'https' session.use_ssl = true end session.start {|http| http.request(req) } end |