redis_snippets 0.0.10 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +4 -2
- data/.rspec +2 -0
- data/.travis.yml +19 -0
- data/Gemfile +12 -0
- data/README.md +84 -18
- data/Rakefile +5 -0
- data/app/controllers/redis_snippets/snippets_controller.rb +5 -6
- data/app/helpers/redis_snippets/snippets_helper.rb +5 -23
- data/app/presenters/snippet_presenter.rb +67 -0
- data/app/{models/redis_snippets/snippets.rb → services/snippet_store_service.rb} +9 -1
- data/app/views/redis_snippets/snippets/show.html.erb +11 -15
- data/config/routes.rb +1 -1
- data/lib/redis_snippets/engine.rb +3 -1
- data/lib/redis_snippets/redis.rb +10 -5
- data/lib/redis_snippets/{help.rb → util.rb} +2 -2
- data/lib/redis_snippets/version.rb +1 -1
- data/lib/redis_snippets.rb +4 -2
- data/redis_snippets.gemspec +5 -4
- data/spec/app/helpers/redis_snippets/snippets_helper_spec.rb +38 -0
- data/spec/app/presenters/snippet_presenter_spec.rb +53 -0
- data/spec/app/presenters/snippet_presenter_transform_spec.rb +45 -0
- data/spec/app/services/snippet_store_service_spec.rb +44 -0
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +62 -0
- data/spec/dummy/config/environments/test.rb +48 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/tmp/.keep +0 -0
- data/spec/dummy/tmp/development_secret.txt +1 -0
- data/spec/rails_helper.rb +54 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/simplecov_setup.rb +5 -0
- metadata +105 -11
@@ -0,0 +1,12 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path.
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in the app/assets
|
11
|
+
# folder are already added.
|
12
|
+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Define an application-wide content security policy
|
4
|
+
# For further information see the following documentation
|
5
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
6
|
+
|
7
|
+
# Rails.application.config.content_security_policy do |policy|
|
8
|
+
# policy.default_src :self, :https
|
9
|
+
# policy.font_src :self, :https, :data
|
10
|
+
# policy.img_src :self, :https, :data
|
11
|
+
# policy.object_src :none
|
12
|
+
# policy.script_src :self, :https
|
13
|
+
# policy.style_src :self, :https
|
14
|
+
|
15
|
+
# # Specify URI for violation reports
|
16
|
+
# # policy.report_uri "/csp-violation-report-endpoint"
|
17
|
+
# end
|
18
|
+
|
19
|
+
# If you are using UJS then enable automatic nonce generation
|
20
|
+
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
|
21
|
+
|
22
|
+
# Set the nonce only to specific directives
|
23
|
+
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
|
24
|
+
|
25
|
+
# Report CSP violations to a specified URI
|
26
|
+
# For further information see the following documentation:
|
27
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
28
|
+
# Rails.application.config.content_security_policy_report_only = true
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
3
|
+
# Any libraries that use thread pools should be configured to match
|
4
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
+
# and maximum; this matches the default thread size of Active Record.
|
6
|
+
#
|
7
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
9
|
+
threads min_threads_count, max_threads_count
|
10
|
+
|
11
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
12
|
+
#
|
13
|
+
port ENV.fetch("PORT") { 3000 }
|
14
|
+
|
15
|
+
# Specifies the `environment` that Puma will run in.
|
16
|
+
#
|
17
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
18
|
+
|
19
|
+
# Specifies the `pidfile` that Puma will use.
|
20
|
+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
21
|
+
|
22
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
23
|
+
# Workers are forked web server processes. If using threads and workers together
|
24
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
25
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
26
|
+
# processes).
|
27
|
+
#
|
28
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
29
|
+
|
30
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
31
|
+
# This directive tells Puma to first boot the application and load code
|
32
|
+
# before forking the application. This takes advantage of Copy On Write
|
33
|
+
# process behavior so workers use less memory.
|
34
|
+
#
|
35
|
+
# preload_app!
|
36
|
+
|
37
|
+
# Allow puma to be restarted by `rails restart` command.
|
38
|
+
plugin :tmp_restart
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
25c7ba3ff5498aead660dbc8bf38be3833df9479ffc2fc76fd8306308d7d365a455654be62905c9594caa61d0c85e7349056c1cd49d027995ac34dae86cd3dd7
|
@@ -0,0 +1,54 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
|
3
|
+
require 'support/simplecov_setup'
|
4
|
+
|
5
|
+
require File.expand_path('dummy/config/environment', __dir__)
|
6
|
+
require 'rspec/rails'
|
7
|
+
require 'redis_snippets'
|
8
|
+
|
9
|
+
include RedisSnippets::SnippetsHelper
|
10
|
+
|
11
|
+
Rails.application.config.redis_snippets = {
|
12
|
+
connection: MockRedis.new,
|
13
|
+
keys: [
|
14
|
+
:advert_header,
|
15
|
+
:advert_footer
|
16
|
+
],
|
17
|
+
transform: -> { ENV['TRANSFORM'] ? "Transformer" : nil }
|
18
|
+
}
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
22
|
+
# based on their file location, for example enabling you to call `get` and
|
23
|
+
# `post` in specs under `spec/controllers`.
|
24
|
+
#
|
25
|
+
# You can disable this behaviour by removing the line below, and instead
|
26
|
+
# explicitly tag your specs with their type, e.g.:
|
27
|
+
#
|
28
|
+
# RSpec.describe UsersController, :type => :controller do
|
29
|
+
# # ...
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# The different available types are documented in the features, such as in
|
33
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
34
|
+
config.infer_spec_type_from_file_location!
|
35
|
+
|
36
|
+
# Filter lines from Rails gems in backtraces.
|
37
|
+
config.filter_rails_from_backtrace!
|
38
|
+
# arbitrary gems may also be filtered via:
|
39
|
+
# config.filter_gems_from_backtrace("gem name")
|
40
|
+
|
41
|
+
def clean_keys!
|
42
|
+
RedisSnippets::Engine.config.redis_snippets[:keys].each do |key|
|
43
|
+
SnippetStoreService.del(key)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
config.before(:each) do
|
48
|
+
clean_keys!
|
49
|
+
end
|
50
|
+
|
51
|
+
config.after(:each) do
|
52
|
+
clean_keys!
|
53
|
+
end
|
54
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
|
3
|
+
require 'support/simplecov_setup'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.expect_with :rspec do |expectations|
|
7
|
+
expectations.syntax = :expect
|
8
|
+
end
|
9
|
+
|
10
|
+
config.mock_with :rspec do |mocks|
|
11
|
+
mocks.syntax = :expect
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_snippets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Moen Wulffeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: redis
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,28 +80,71 @@ dependencies:
|
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 1.2.1
|
69
|
-
description:
|
83
|
+
description: A Ruby on Rails gem that facilitates fast retrieval of snippets of code
|
84
|
+
or information for views.
|
70
85
|
email:
|
71
|
-
-
|
86
|
+
- wulffeld@gmail.com
|
72
87
|
executables: []
|
73
88
|
extensions: []
|
74
89
|
extra_rdoc_files: []
|
75
90
|
files:
|
76
91
|
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
77
95
|
- README.md
|
78
96
|
- Rakefile
|
79
97
|
- app/controllers/redis_snippets/snippets_controller.rb
|
80
98
|
- app/helpers/redis_snippets/snippets_helper.rb
|
81
|
-
- app/
|
99
|
+
- app/presenters/snippet_presenter.rb
|
100
|
+
- app/services/snippet_store_service.rb
|
82
101
|
- app/views/redis_snippets/snippets/show.html.erb
|
83
102
|
- config/routes.rb
|
84
103
|
- lib/redis_snippets.rb
|
85
104
|
- lib/redis_snippets/engine.rb
|
86
|
-
- lib/redis_snippets/help.rb
|
87
105
|
- lib/redis_snippets/redis.rb
|
106
|
+
- lib/redis_snippets/util.rb
|
88
107
|
- lib/redis_snippets/version.rb
|
89
108
|
- redis_snippets.gemspec
|
90
|
-
|
109
|
+
- spec/app/helpers/redis_snippets/snippets_helper_spec.rb
|
110
|
+
- spec/app/presenters/snippet_presenter_spec.rb
|
111
|
+
- spec/app/presenters/snippet_presenter_transform_spec.rb
|
112
|
+
- spec/app/services/snippet_store_service_spec.rb
|
113
|
+
- spec/dummy/.ruby-version
|
114
|
+
- spec/dummy/Rakefile
|
115
|
+
- spec/dummy/app/assets/config/manifest.js
|
116
|
+
- spec/dummy/app/assets/images/.keep
|
117
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
118
|
+
- spec/dummy/app/controllers/application_controller.rb
|
119
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
120
|
+
- spec/dummy/bin/rails
|
121
|
+
- spec/dummy/bin/rake
|
122
|
+
- spec/dummy/bin/setup
|
123
|
+
- spec/dummy/config.ru
|
124
|
+
- spec/dummy/config/application.rb
|
125
|
+
- spec/dummy/config/boot.rb
|
126
|
+
- spec/dummy/config/environment.rb
|
127
|
+
- spec/dummy/config/environments/development.rb
|
128
|
+
- spec/dummy/config/environments/test.rb
|
129
|
+
- spec/dummy/config/initializers/application_controller_renderer.rb
|
130
|
+
- spec/dummy/config/initializers/assets.rb
|
131
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
132
|
+
- spec/dummy/config/initializers/content_security_policy.rb
|
133
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
134
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
135
|
+
- spec/dummy/config/initializers/inflections.rb
|
136
|
+
- spec/dummy/config/initializers/mime_types.rb
|
137
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
138
|
+
- spec/dummy/config/puma.rb
|
139
|
+
- spec/dummy/config/routes.rb
|
140
|
+
- spec/dummy/lib/assets/.keep
|
141
|
+
- spec/dummy/log/.keep
|
142
|
+
- spec/dummy/tmp/.keep
|
143
|
+
- spec/dummy/tmp/development_secret.txt
|
144
|
+
- spec/rails_helper.rb
|
145
|
+
- spec/spec_helper.rb
|
146
|
+
- spec/support/simplecov_setup.rb
|
147
|
+
homepage: https://github.com/wulffeld/redis_snippets
|
91
148
|
licenses:
|
92
149
|
- MIT
|
93
150
|
metadata: {}
|
@@ -106,9 +163,46 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
163
|
- !ruby/object:Gem::Version
|
107
164
|
version: '0'
|
108
165
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.4.8
|
166
|
+
rubygems_version: 3.1.2
|
111
167
|
signing_key:
|
112
168
|
specification_version: 4
|
113
|
-
summary: Storing snippets of
|
114
|
-
test_files:
|
169
|
+
summary: Storing snippets of HTML, text, etc. in Redis for use in views.
|
170
|
+
test_files:
|
171
|
+
- spec/app/helpers/redis_snippets/snippets_helper_spec.rb
|
172
|
+
- spec/app/presenters/snippet_presenter_spec.rb
|
173
|
+
- spec/app/presenters/snippet_presenter_transform_spec.rb
|
174
|
+
- spec/app/services/snippet_store_service_spec.rb
|
175
|
+
- spec/dummy/.ruby-version
|
176
|
+
- spec/dummy/Rakefile
|
177
|
+
- spec/dummy/app/assets/config/manifest.js
|
178
|
+
- spec/dummy/app/assets/images/.keep
|
179
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
180
|
+
- spec/dummy/app/controllers/application_controller.rb
|
181
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
182
|
+
- spec/dummy/bin/rails
|
183
|
+
- spec/dummy/bin/rake
|
184
|
+
- spec/dummy/bin/setup
|
185
|
+
- spec/dummy/config.ru
|
186
|
+
- spec/dummy/config/application.rb
|
187
|
+
- spec/dummy/config/boot.rb
|
188
|
+
- spec/dummy/config/environment.rb
|
189
|
+
- spec/dummy/config/environments/development.rb
|
190
|
+
- spec/dummy/config/environments/test.rb
|
191
|
+
- spec/dummy/config/initializers/application_controller_renderer.rb
|
192
|
+
- spec/dummy/config/initializers/assets.rb
|
193
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
194
|
+
- spec/dummy/config/initializers/content_security_policy.rb
|
195
|
+
- spec/dummy/config/initializers/cookies_serializer.rb
|
196
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
197
|
+
- spec/dummy/config/initializers/inflections.rb
|
198
|
+
- spec/dummy/config/initializers/mime_types.rb
|
199
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
200
|
+
- spec/dummy/config/puma.rb
|
201
|
+
- spec/dummy/config/routes.rb
|
202
|
+
- spec/dummy/lib/assets/.keep
|
203
|
+
- spec/dummy/log/.keep
|
204
|
+
- spec/dummy/tmp/.keep
|
205
|
+
- spec/dummy/tmp/development_secret.txt
|
206
|
+
- spec/rails_helper.rb
|
207
|
+
- spec/spec_helper.rb
|
208
|
+
- spec/support/simplecov_setup.rb
|