lazy_value 0.0.2 → 0.0.3
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff43403a1c22e54f42ccc10e23553ca1185da22aa520bd19239863da25be47fe
|
4
|
+
data.tar.gz: 38e5f11b43ff1b07d08df7f4e1530ce86f967d5ec51c6af7601414f0d3d41c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64c8b7a444814282cfaf80acb512405f2194b7f18dd388104e4ff3fcff601eb1dfd891d82d296571fd33b3121f8ab58f4322583bf741089f1d282747b2e5cb3a
|
7
|
+
data.tar.gz: 3d90984bba75aced80822d571450179b59580a4f3bf8764973a966de332a590062f0501a13a610d596e4e6b808d0b8dad838817d337f6750b85dfd9d74676f5d
|
data/README.md
CHANGED
@@ -25,6 +25,17 @@ Functioning similarly to lazy Turbo frames, this value loader has no reliance on
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
+
It's strongly suggested to configure initializer (can be generated with `rails g lazy_value initializer`). You can put your credentials/secrets/env variable. It's needed to use the same encryption key between deploys or server instances.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
LazyValue.setup do |config|
|
32
|
+
config.salt = ENV["LAZY_VALUE_SALT"].presence || SecureRandom.random_bytes(ActiveSupport::MessageEncryptor.key_len)
|
33
|
+
config.key = ENV["LAZY_VALUE_KEY"].presence || SecureRandom.hex(32)
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
And now you can use `lazy_value_tag` helper in your views:
|
38
|
+
|
28
39
|
```erb
|
29
40
|
<div class="column is-one-quarter">
|
30
41
|
<div class="box has-text-centered">
|
@@ -99,6 +110,13 @@ And that is it. Start using it.
|
|
99
110
|
|
100
111
|
`bin/rails test:system`.
|
101
112
|
|
113
|
+
## TODO
|
114
|
+
|
115
|
+
- websockets options vs http
|
116
|
+
- pass variables
|
117
|
+
- change to modern JS?
|
118
|
+
- use POST? (if payload might be too big)
|
119
|
+
|
102
120
|
## Contributing
|
103
121
|
|
104
122
|
You are welcome to contribute.
|
@@ -109,4 +127,3 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
109
127
|
|
110
128
|
[<img src="https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/more_gems.png?raw=true"
|
111
129
|
/>](https://www.railsjazz.com/?utm_source=github&utm_medium=bottom&utm_campaign=rails_live_reload)
|
112
|
-
|
data/lib/lazy_value/version.rb
CHANGED
data/lib/lazy_value.rb
CHANGED
@@ -3,13 +3,28 @@ require "lazy_value/routes"
|
|
3
3
|
require "lazy_value/engine"
|
4
4
|
|
5
5
|
module LazyValue
|
6
|
-
mattr_accessor :
|
6
|
+
mattr_accessor :key
|
7
|
+
@@key = ENV["LAZY_VALUE_KEY"].presence || SecureRandom.hex(32)
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
mattr_accessor :salt
|
10
|
+
@@salt = ENV["LAZY_VALUE_SALT"].presence || SecureRandom.hex(8)
|
11
|
+
|
12
|
+
def self.setup
|
13
|
+
yield(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.cryptography
|
17
|
+
@cryptography ||= begin
|
18
|
+
ActiveSupport::MessageEncryptor.new(derived_key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.derived_key
|
23
|
+
key_generator.generate_key(salt, 32)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.key_generator
|
27
|
+
ActiveSupport::KeyGenerator.new(key, iterations: 1000)
|
13
28
|
end
|
14
29
|
|
15
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy_value
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-04-
|
12
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -137,6 +137,9 @@ files:
|
|
137
137
|
- app/controllers/lazy_value/application_controller.rb
|
138
138
|
- app/helpers/lazy_value/application_helper.rb
|
139
139
|
- config/routes.rb
|
140
|
+
- lib/generators/lazy_value/USAGE
|
141
|
+
- lib/generators/lazy_value/lazy_value_generator.rb
|
142
|
+
- lib/generators/lazy_value/templates/template.rb
|
140
143
|
- lib/lazy_value.rb
|
141
144
|
- lib/lazy_value/engine.rb
|
142
145
|
- lib/lazy_value/railtie.rb
|