solder 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: caab8b73cfc913261226022ae6e2e0d67fd6643164fa5d2b9058d7a8eb298cb1
4
+ data.tar.gz: a03a6323c422e4ee59cc89ccbc3b6431b3b82f755378ca7057d5868fde4e181a
5
+ SHA512:
6
+ metadata.gz: 1dc4b63179b081c60def903eae5ee336209a8c90eebe8136c43f2f5f3dd1f932a9b1b2745c672cf3c80f421243433f1228f6db36acc29bd838f0fba11b63c62e
7
+ data.tar.gz: 2d02e8e58009e38c21568c5d8aaa3dc97bfa6f42682865b4d2c13dba549dc76c4913670460dcf4a4ea0ac1c1cedb14138baf97133fcc13d349405a229671f5ee
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # 🧑‍🏭 Solder
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ### Persistence
8
+
9
+ Uses the active Rails cache store, possibly more adapters to come
10
+
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem "solder"
16
+ ```
17
+
18
+ And then execute:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+ ```bash
25
+ $ gem install solder
26
+ ```
27
+
28
+ ## Dependencies
29
+
30
+ ### Ruby
31
+ - Rails
32
+
33
+ ### Javascript
34
+
35
+ - Stimulus
36
+ - @rails/request.js
37
+ - Turbo
38
+
39
+ ## Contributing
40
+ Contribution directions go here.
41
+
42
+ ## License
43
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/solder .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module Solder
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,25 @@
1
+ module Solder
2
+ class UiStateController < ApplicationController
3
+ before_action :set_ui_state, only: :show
4
+
5
+ def show
6
+ render json: @ui_state.to_json
7
+ end
8
+
9
+ def update
10
+ Rails.cache.write "solder/#{params[:key]}", JSON.parse(params[:attributes])
11
+
12
+ head :ok
13
+ end
14
+
15
+ private
16
+
17
+ def ui_state_params
18
+ params.permit(:attributes, :key)
19
+ end
20
+
21
+ def set_ui_state
22
+ @ui_state = Rails.cache.read "solder/#{params[:key]}"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Solder
2
+ class UiStateController < ApplicationController
3
+ before_action :set_ui_state
4
+
5
+ def show
6
+ render json: @ui_state.value
7
+ end
8
+
9
+ def update
10
+ @ui_state.value = JSON.parse(params[:attributes])
11
+
12
+ head :ok
13
+ end
14
+
15
+ private
16
+
17
+ def ui_state_params
18
+ params.permit(:attributes, :key)
19
+ end
20
+
21
+ def set_ui_state
22
+ @ui_state = Kredis.json params[:key]
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module Solder
2
+ module ApplicationHelper
3
+ def solder_key(name)
4
+ key = cache_fragment_name(name, skip_digest: true)
5
+ .flatten
6
+ .compact
7
+ .map(&:cache_key)
8
+ .join(":")
9
+
10
+ key += ":#{caller(1..1).first}"
11
+
12
+ ActiveSupport::Digest.hexdigest(key)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Solder
2
+ module ApplicationHelper
3
+ def solder_key(name)
4
+ key = cache_fragment_name(name, skip_digest: true)
5
+ .flatten
6
+ .compact
7
+ .map(&:cache_key)
8
+ .join(":")
9
+ key += ":#{caller(1..1).first}"
10
+
11
+ ActiveSupport::Digest.hexdigest(key)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ module Solder
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Solder
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Solder
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Solder</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "solder/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Solder::Engine.routes.draw do
2
+ patch "ui_state/update"
3
+ get "ui_state/show"
4
+ end
data/config/routes.rb~ ADDED
@@ -0,0 +1,4 @@
1
+ Solder::Engine.routes.draw do
2
+ get 'ui_state/update'
3
+ get 'ui_state/show'
4
+ end
@@ -0,0 +1,22 @@
1
+ module Solder
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Solder
4
+
5
+ initializer "solder.check_caching" do |app|
6
+ unless app.config.action_controller.perform_caching && app.config.cache_store != :null_store
7
+ puts <<~WARN
8
+ 🧑‍🏭 Solder uses the Rails cache store to provide UI state persistence. Therefore, please make sure caching is enabled in your environment.
9
+
10
+ To enable caching in development, run:
11
+ rails dev:cache
12
+ WARN
13
+
14
+ exit false
15
+ end
16
+ end
17
+
18
+ config.after_initialize do
19
+ ::ApplicationHelper.include helpers
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ module Solder
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Solder
4
+
5
+ initializer "solder.check_caching" do
6
+ unless Rails.application.config.action_controller.perform_caching && Rails.application.config.cache_store != :null_store
7
+ puts <<~WARN
8
+ Solder uses the Rails cache store to provide UI state persistence. Therefore, please make sure caching is enabled in your environment.Engine
9
+
10
+ To enable caching in development, run:
11
+ rails dev:cache
12
+ WARN
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Solder
2
+ VERSION = "0.1.0"
3
+ end
data/lib/solder.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "solder/version"
2
+ require "solder/engine"
3
+
4
+ module Solder
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :solder do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Julian Rubisch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-12-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 7.0.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 7.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: stimulus-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: turbo-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: solargraph-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: standard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Simplistic UI State Management for Rails Apps using Hotwire and Caching
98
+ email:
99
+ - julian@julianrubisch.at
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - README.md
105
+ - Rakefile
106
+ - app/assets/config/solder_manifest.js
107
+ - app/assets/stylesheets/solder/application.css
108
+ - app/controllers/solder/application_controller.rb
109
+ - app/controllers/solder/ui_state_controller.rb
110
+ - app/controllers/solder/ui_state_controller.rb~
111
+ - app/helpers/solder/application_helper.rb
112
+ - app/helpers/solder/application_helper.rb~
113
+ - app/jobs/solder/application_job.rb
114
+ - app/mailers/solder/application_mailer.rb
115
+ - app/models/solder/application_record.rb
116
+ - app/views/layouts/solder/application.html.erb
117
+ - config/routes.rb
118
+ - config/routes.rb~
119
+ - lib/solder.rb
120
+ - lib/solder/engine.rb
121
+ - lib/solder/engine.rb~
122
+ - lib/solder/version.rb
123
+ - lib/tasks/solder_tasks.rake
124
+ homepage: https://github.com/julianrubisch/solder
125
+ licenses: []
126
+ metadata:
127
+ homepage_uri: https://github.com/julianrubisch/solder
128
+ source_code_uri: https://github.com/julianrubisch/solder
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubygems_version: 3.3.26
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Simplistic UI State Management for Rails Apps using Hotwire and Caching
148
+ test_files: []