flyer 1.0.0 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0beb30f7cd48acf09067ba968ee6c437c554794
4
- data.tar.gz: a66326cd122f1deedfcc9284e76c968bc0b7d9e1
3
+ metadata.gz: 1a7568cd9041ad77ced29000063f89ef9c815b0b
4
+ data.tar.gz: 24e968c8a2f0739f595476775ac26e1b5540e915
5
5
  SHA512:
6
- metadata.gz: 0d4115bffda8d7e1291e0bf28612d1e7daaa6c278233d0f1eee132254626564487fb18f0d4efe50d642bff70eb77b71ae1179f1a641fa8ff1472be3528fe0e09
7
- data.tar.gz: 06d7c279e20ac755338c396c1ae0abc007425ee54a1f5ecf7263bf5c8d901c97a89ed4da8bf926f3bfb52dfe98988f38f797fe00b6bf2ab30981229f120cdcb7
6
+ metadata.gz: bd8a855af7c0f95eecdfc2e061eecee65a8cf3dedfb93c93ed5fc364289cc0ba7bd0066940776d107191446817facf65c5d7fdc4107ea7e765b1b57cff61962c
7
+ data.tar.gz: 154b49afab88694817a2ae3ff154f310fd77209a30d1f59c16130582dac91bde41c42ed1d731391b8d925b0a465f8d0ab6640ac7c638f2262941f30fc3ece028
data/README.md CHANGED
@@ -10,15 +10,16 @@ Display user notifications in Rails programmatically.
10
10
 
11
11
  ``` ruby
12
12
  # config/initializers/flyer.rb
13
+ # Use one init block for each notification
13
14
  Flyer::Notification.init do |config|
14
15
  # Unique id. Used to uniquely identify a notification.
15
16
  config.id = "new-user"
16
17
 
17
18
  # Message to be passed to view. Is evaluated in the view context.
18
- config.message { "Your nickname is #{current_user.nickname}" + icon "flash" }
19
+ config.message { "Your nickname is #{current_user.nickname}" + icon("flash") }
19
20
 
20
21
  # Optional. Path to be pssed to view. Is evaluated in the controller context.
21
- config.path { challenge_path }
22
+ config.path { root_path }
22
23
 
23
24
  # Optional. Only display notification if this blocks evaluates to true
24
25
  # The block is evaluated in the controller context.
@@ -34,6 +35,12 @@ Flyer::Notification.init do |config|
34
35
  # Optional. Arbitrary data to be passed to view.
35
36
  config.params = { timeout: 10 }
36
37
  end
38
+
39
+ # Global configuration
40
+ Flyer.configure do |config|
41
+ # Only display one notification at the time
42
+ config.max_notifications = 1
43
+ end
37
44
  ```
38
45
 
39
46
  ``` erb
@@ -1,6 +1,7 @@
1
1
  module Flyer
2
2
  end
3
3
 
4
+ require "flyer/configure"
4
5
  require "flyer/errors"
5
6
  require "flyer/controller_additions"
6
7
  require "flyer/notification"
@@ -0,0 +1,12 @@
1
+ module Flyer
2
+ def self.configure(&block)
3
+ block.call(settings)
4
+ end
5
+
6
+ def self.settings
7
+ @_settings ||= Configure.new
8
+ end
9
+
10
+ class Configure < Struct.new(:max_notifications)
11
+ end
12
+ end
@@ -20,6 +20,11 @@ module Flyer::ControllerAdditions
20
20
  raise Flyer::FoundNonUniqueIds.new
21
21
  end
22
22
 
23
+ #
24
+ if limit = Flyer.settings.max_notifications
25
+ found_notifications = found_notifications.take(limit)
26
+ end
27
+
23
28
  found_notifications
24
29
  end
25
30
  end
@@ -1,3 +1,3 @@
1
1
  module Flyer
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flyer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-08 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +91,7 @@ files:
91
91
  - README.md
92
92
  - Rakefile
93
93
  - lib/flyer.rb
94
+ - lib/flyer/configure.rb
94
95
  - lib/flyer/controller_additions.rb
95
96
  - lib/flyer/errors.rb
96
97
  - lib/flyer/notification.rb