callforth 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3515d35e34fb8f1b0cce016eab83f67272decf35e79ceb595d2f9aaec378f4f1
4
- data.tar.gz: 3180709d77efa3e733286632ef58eeaf3656fcbf836e75a16b9d93d1c2b2eb32
3
+ metadata.gz: c149e039cab30348bbfe6294da588f644d57fbdffc1277761f0e44d66eddc761
4
+ data.tar.gz: 75c0fde6f0988988090c6b91149eb635b0e23e0045e245dfbe1b1178ca3d97ff
5
5
  SHA512:
6
- metadata.gz: 6bac94d199141a54b09b960bd88c477f434718e58a0c8b982a666ea60c87369ec8c5c2d600bdf51234d1663fed6a2aaa7e976e4e8b6d35ded42b1c70fa56d3de
7
- data.tar.gz: e8973752f20b3056014f46d623de78067775d3d9c2ffdbf00e381a984ffe2e1eff72108bd4012c38d455e75910f3836ed34b093ea0f613d6c5ea398dc862c02b
6
+ metadata.gz: aaeaa96d7f05f7e5995fdbf77453926f3eb27a8859e57f7901b944377ebd98dfec4b38816354c65983f462d696daef40525d05590a6b94f15e3fdc91c5c4f98a
7
+ data.tar.gz: '08ad737909628d29e761a41032202cfd89e02629e70a5835447e523f8b5c44cd3105211612c545e25358b64382566c5ef47a3dbb111729a4b52b80e9962c6944'
@@ -1,7 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support"
4
+ require "active_support/callbacks"
5
+
3
6
  require "callforth/version"
7
+ require "callforth/config_options"
8
+ require "callforth/setup"
4
9
 
5
10
  module Callforth
6
- # Your code goes here...
11
+ mattr_accessor :secret_key
7
12
  end
13
+
14
+ require "callforth/railtie" if defined?(Rails)
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Callforth
4
+ class ConfigOptions
5
+ class_attribute :enabled, default: true
6
+
7
+ class_attribute :secret_key, default: -> { Rails.application.credentials.secret_key_base }
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/railtie"
4
+
5
+ module Callforth
6
+ class Railtie < Rails::Railtie
7
+ config.callforth = Callforth::ConfigOptions
8
+
9
+ config.after_initialize do |application|
10
+ if application.config.callforth.enabled
11
+ Callforth::Setup.for(application)
12
+ else
13
+ Callforth::Setup.clear
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Callforth
4
+ class Setup
5
+ class << self
6
+ def for(application)
7
+ callforth_config = application.config.callforth
8
+
9
+ setup_secret_key(callforth_config)
10
+ end
11
+
12
+ def clear
13
+ clear_secret_key
14
+ end
15
+
16
+ private
17
+
18
+ def setup_secret_key(config)
19
+ Callforth.secret_key = config.secret_key.respond_to?(:call) ? config.secret_key.call : config.secret_key
20
+ end
21
+
22
+ def clear_secret_key
23
+ Callforth.secret_key = nil
24
+ end
25
+ end
26
+ end
27
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Callforth
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.7.3"
5
+ VERSION = "0.7.4"
6
6
  end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Generate the Callforth configuration initializer.
3
+
4
+ Example:
5
+ `rails generate callforth:initializer`
6
+
7
+ Generates:
8
+ Initializer: config/initializers/technologic.rb
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Callforth
4
+ module Generators
5
+ class InitializerGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ def create_initializer
9
+ template "initializer.rb.erb", File.join("config/initializers/callforth.rb")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # When disabled, the secret key is not setup, so nothing can be encoded or decoded.
5
+ # config.callforth.enabled = true
6
+
7
+ # Callforth requires a secret key as part of the encoding/decoding process to secure and authorize callers.
8
+ # config.callforth.secret_key = -> { Rails.application.credentials.secret_key_base }
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callforth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Garside
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-04 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Like a callback, except from an outside caller rather than a bound listener
14
14
  email:
@@ -20,7 +20,13 @@ files:
20
20
  - LICENSE.txt
21
21
  - README.md
22
22
  - lib/callforth.rb
23
+ - lib/callforth/config_options.rb
24
+ - lib/callforth/railtie.rb
25
+ - lib/callforth/setup.rb
23
26
  - lib/callforth/version.rb
27
+ - lib/generators/callforth/initializer/USAGE
28
+ - lib/generators/callforth/initializer/initializer_generator.rb
29
+ - lib/generators/callforth/initializer/templates/initializer.rb.erb
24
30
  homepage: https://www.freshly.com
25
31
  licenses:
26
32
  - MIT