paper_boy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +5 -4
- data/lib/generators/paper_boy/install/templates/application_subscriber.rb.tt +1 -1
- data/lib/generators/rails/subscriber/templates/subscriber.rb.tt +1 -1
- data/lib/paper_boy.rb +10 -19
- data/lib/paper_boy/railtie.rb +20 -0
- data/lib/paper_boy/subscriber.rb +13 -0
- data/lib/paper_boy/version.rb +1 -1
- metadata +2 -2
- data/Gemfile.lock +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 322f3a888b5ba1d4ed7720523a4e76fc9594a029c0a8b4f3b2c621764398b911
|
4
|
+
data.tar.gz: 1ccec0f8a25f2ff682fc00576a5983ff2ea6ac87b3972e3dd57313c159420332
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc94274907490e08b575cbd24cc330126011605d6636584c87fb185961cec5e14712d60cf30ff28e8ab5d634b02060f432c413bb16a39dcc4d081aed85e293d3
|
7
|
+
data.tar.gz: 78798241e5dc8fd247ec1229b9f74b3f3470eed16bbf7910cde2e263f3233b48ea6424100e3b5694226a7803dde43df509f76ed4889f54f5090adfca626315c2
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# PaperBoy
|
2
2
|
|
3
|
-
Automatically deliver notifications to subscribers from controllers
|
3
|
+
Automatically deliver notifications to subscribers from controllers (lightweight mixin using `ActiveSupport::Notifications`)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
At first, execute install command:
|
24
24
|
|
25
|
-
$ bin/rails
|
25
|
+
$ bin/rails g paper_boy:install
|
26
26
|
|
27
27
|
Include `PaperBoy` in `ApplicationController`:
|
28
28
|
|
@@ -36,7 +36,7 @@ And you generate subscriber class with generator command:
|
|
36
36
|
|
37
37
|
$ bin/rails g paper_boy:subscriber
|
38
38
|
|
39
|
-
Then you implement
|
39
|
+
Then you implement `app/subscribers/users_subscriber.rb`:
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
class UsersSubscriber < ApplicationSubscriber
|
@@ -46,7 +46,8 @@ class UsersSubscriber < ApplicationSubscriber
|
|
46
46
|
# All instance variables are set from controller class.
|
47
47
|
user = payload[:current_user]
|
48
48
|
|
49
|
-
# implement something (mailer,
|
49
|
+
# implement something (mailer, notifier, logger ...etc)
|
50
|
+
logger.info user
|
50
51
|
end
|
51
52
|
|
52
53
|
attach_to :"users"
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class ApplicationSubscriber <
|
1
|
+
class ApplicationSubscriber < PaperBoy::Subscriber::Base
|
2
2
|
end
|
data/lib/paper_boy.rb
CHANGED
@@ -2,29 +2,12 @@
|
|
2
2
|
|
3
3
|
require "active_support/concern"
|
4
4
|
require "paper_boy/railtie" if defined?(Rails)
|
5
|
+
require "paper_boy/subscriber"
|
5
6
|
require "paper_boy/version"
|
6
7
|
|
7
8
|
module PaperBoy
|
8
9
|
extend ActiveSupport::Concern
|
9
10
|
|
10
|
-
IGNORE_IVARS = %w[
|
11
|
-
@_action_has_layout
|
12
|
-
@_routes
|
13
|
-
@_request
|
14
|
-
@_response
|
15
|
-
@_lookup_context
|
16
|
-
@_action_name
|
17
|
-
@_response_body
|
18
|
-
@marked_for_same_origin_verification
|
19
|
-
@_config
|
20
|
-
@_db_runtime
|
21
|
-
@_view_context_class
|
22
|
-
@_view_renderer
|
23
|
-
@_url_options
|
24
|
-
@_view_runtime
|
25
|
-
@_params
|
26
|
-
]
|
27
|
-
|
28
11
|
included do
|
29
12
|
after_action :paper_boy_deliver!
|
30
13
|
end
|
@@ -41,8 +24,16 @@ module PaperBoy
|
|
41
24
|
|
42
25
|
def paper_boy_context
|
43
26
|
instance_variable_names.each_with_object({}) do |name, payload|
|
44
|
-
next if
|
27
|
+
next if ignore_ivars.include?(name)
|
45
28
|
payload[name.sub(/\A@_?/, "")] = instance_variable_get(name)
|
46
29
|
end.compact
|
47
30
|
end
|
31
|
+
|
32
|
+
def ignore_ivars
|
33
|
+
Rails.application.config.paper_boy.ignore_ivars - skip_ignore_ivars
|
34
|
+
end
|
35
|
+
|
36
|
+
def skip_ignore_ivars
|
37
|
+
Rails.application.config.paper_boy.skip_ignore_ivars
|
38
|
+
end
|
48
39
|
end
|
data/lib/paper_boy/railtie.rb
CHANGED
@@ -13,6 +13,26 @@ end
|
|
13
13
|
|
14
14
|
module PaperBoy
|
15
15
|
class Railtie < Rails::Railtie
|
16
|
+
config.paper_boy = ActiveSupport::OrderedOptions.new
|
17
|
+
config.paper_boy.ignore_ivars = %w[
|
18
|
+
@_action_has_layout
|
19
|
+
@_routes
|
20
|
+
@_request
|
21
|
+
@_response
|
22
|
+
@_lookup_context
|
23
|
+
@_action_name
|
24
|
+
@_response_body
|
25
|
+
@marked_for_same_origin_verification
|
26
|
+
@_config
|
27
|
+
@_db_runtime
|
28
|
+
@_view_context_class
|
29
|
+
@_view_renderer
|
30
|
+
@_url_options
|
31
|
+
@_view_runtime
|
32
|
+
@_params
|
33
|
+
]
|
34
|
+
config.paper_boy.skip_ignore_ivars = []
|
35
|
+
|
16
36
|
config.after_initialize do |app|
|
17
37
|
app.config.paths.add 'app/subscribers', eager_load: true, glob: "**/*_subscriber.rb"
|
18
38
|
end
|
data/lib/paper_boy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paper_boy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiyuki Hirano
|
@@ -21,7 +21,6 @@ files:
|
|
21
21
|
- ".rspec"
|
22
22
|
- ".travis.yml"
|
23
23
|
- Gemfile
|
24
|
-
- Gemfile.lock
|
25
24
|
- LICENSE.txt
|
26
25
|
- README.md
|
27
26
|
- Rakefile
|
@@ -40,6 +39,7 @@ files:
|
|
40
39
|
- lib/generators/test_unit/templates/subscriber_test.rb.tt
|
41
40
|
- lib/paper_boy.rb
|
42
41
|
- lib/paper_boy/railtie.rb
|
42
|
+
- lib/paper_boy/subscriber.rb
|
43
43
|
- lib/paper_boy/version.rb
|
44
44
|
- paper_boy.gemspec
|
45
45
|
homepage: https://github.com/yhirano55/paper_boy
|
data/Gemfile.lock
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
paper_boy (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.3)
|
10
|
-
rake (10.5.0)
|
11
|
-
rspec (3.7.0)
|
12
|
-
rspec-core (~> 3.7.0)
|
13
|
-
rspec-expectations (~> 3.7.0)
|
14
|
-
rspec-mocks (~> 3.7.0)
|
15
|
-
rspec-core (3.7.1)
|
16
|
-
rspec-support (~> 3.7.0)
|
17
|
-
rspec-expectations (3.7.0)
|
18
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.7.0)
|
20
|
-
rspec-mocks (3.7.0)
|
21
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.7.0)
|
23
|
-
rspec-support (3.7.1)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
paper_boy!
|
30
|
-
rake (~> 10.0)
|
31
|
-
rspec (~> 3.0)
|
32
|
-
|
33
|
-
BUNDLED WITH
|
34
|
-
1.16.1
|