appygram-rails 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -24,4 +24,20 @@ exception reports via Appygram.
24
24
 
25
25
  using a valid API key for your app provided by Appygram
26
26
 
27
+ ## Limiting messages
28
+
29
+ This client will limit the number of exact duplicate messages it sends
30
+ to Appygram per day. The default limit is 25 duplicates. You can adjust
31
+ this in the initializer:
32
+
33
+ ```
34
+ Appygram.set_duplicate_limit 1
35
+ ```
36
+
37
+ Setting a limit of 0 will disable the duplicate check entirely.
38
+
39
+ In addition to this coarse daily client-side limit, you can
40
+ configure the number of alerts forwarded to each recipient, per
41
+ hour, in the Appygram web console.
42
+
27
43
  Copyright © 2012 Anything Labs.
@@ -1,4 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
2
4
  require 'appygram-rails/version'
3
5
 
4
6
  Gem::Specification.new do |gem|
@@ -14,7 +14,11 @@ module Appygram
14
14
 
15
15
  def error(exception_data)
16
16
  url = "/api/exceptions?api_key=#{::Appygram::Config.api_key}"
17
- call_remote(url, exception_data.to_json)
17
+ if Appygram.restrict_duplicates exception_data.uniqueness_hash
18
+ Appygram.logger.debug "Duplicate notification suppressed."
19
+ else
20
+ call_remote(url, exception_data.to_json)
21
+ end
18
22
  end
19
23
 
20
24
  def call_remote(url, data)
@@ -1,3 +1,3 @@
1
1
  module Appygram
2
- VERSION = '0.9.4'
2
+ VERSION = '0.9.5'
3
3
  end
@@ -21,6 +21,32 @@ module Appygram
21
21
  CLIENT_NAME = 'appygram-rails'
22
22
  ENVIRONMENT_FILTER = []
23
23
 
24
+ @@limit = 25
25
+
26
+ def self.restrict_duplicates(hash)
27
+ return false unless @@limit > 0
28
+
29
+ @@throttle ||= Hash.new
30
+ @@last_used ||= Date.today
31
+ if Date.today.yday != @@last_used.yday
32
+ @@last_used = Date.today
33
+ @@throttle = Hash.new
34
+ end
35
+ if @@throttle[hash]
36
+ @@throttle[hash] = @@throttle[hash] + 1
37
+ else
38
+ @@throttle[hash] = 1
39
+ end
40
+ if @@throttle[hash] > @@limit
41
+ return true
42
+ end
43
+ return false
44
+ end
45
+
46
+ def self.set_duplicate_limit(limit)
47
+ @@limit = limit
48
+ end
49
+
24
50
  def self.logger
25
51
  ::Appygram::LogFactory.logger
26
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appygram-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-13 00:00:00.000000000 Z
12
+ date: 2012-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70297162099240 !ruby/object:Gem::Requirement
16
+ requirement: &7408640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70297162099240
24
+ version_requirements: *7408640
25
25
  description: appygram-rails sends exceptions and feedback to the hosted messaging
26
26
  service at http://www.appygram.com
27
27
  email:
@@ -74,9 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 1.8.17
77
+ rubygems_version: 1.8.15
78
78
  signing_key:
79
79
  specification_version: 3
80
80
  summary: appygram is a hosted service for sending messages from mobile/web apps
81
81
  test_files: []
82
- has_rdoc: