light_switch 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.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +209 -0
  4. data/Rakefile +7 -0
  5. data/app/assets/config/light_switch_manifest.js +2 -0
  6. data/app/assets/images/light_switch/light-switch.svg +1 -0
  7. data/app/assets/javascripts/light_switch/application.js +1 -0
  8. data/app/assets/stylesheets/light_switch/application.css +97 -0
  9. data/app/assets/stylesheets/light_switch/normalize.css +427 -0
  10. data/app/assets/stylesheets/light_switch/skeleton.css +418 -0
  11. data/app/controllers/light_switch/application_controller.rb +4 -0
  12. data/app/controllers/light_switch/switches_controller.rb +52 -0
  13. data/app/models/concerns/light_switch/switch/notifications_concern.rb +23 -0
  14. data/app/models/light_switch/application_record.rb +5 -0
  15. data/app/models/light_switch/switch.rb +29 -0
  16. data/app/views/layouts/light_switch/application.html.erb +30 -0
  17. data/app/views/light_switch/switches/_form.html.erb +6 -0
  18. data/app/views/light_switch/switches/_form_errors.html.erb +5 -0
  19. data/app/views/light_switch/switches/_switch.html.erb +23 -0
  20. data/app/views/light_switch/switches/index.html.erb +22 -0
  21. data/config/locales/light_switch.en.yml +13 -0
  22. data/config/routes.rb +5 -0
  23. data/db/migrate/20231116015256_create_light_switch_switches.rb +11 -0
  24. data/lib/light_switch/configuration.rb +5 -0
  25. data/lib/light_switch/engine.rb +27 -0
  26. data/lib/light_switch/null_cache.rb +10 -0
  27. data/lib/light_switch/version.rb +3 -0
  28. data/lib/light_switch.rb +41 -0
  29. data/lib/tasks/light_switch_tasks.rake +4 -0
  30. metadata +223 -0
@@ -0,0 +1,10 @@
1
+ module LightSwitch
2
+ class NullCache
3
+ def fetch(_key, **)
4
+ yield if block_given?
5
+ end
6
+
7
+ def delete(_key)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module LightSwitch
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,41 @@
1
+ require "light_switch/version"
2
+ require "light_switch/configuration"
3
+ require "light_switch/engine"
4
+ require "light_switch/null_cache"
5
+
6
+ module LightSwitch
7
+ module_function
8
+
9
+ def config
10
+ @config ||= Configuration.new
11
+ end
12
+
13
+ def configure
14
+ yield config
15
+ end
16
+
17
+ def configure_defaults
18
+ config.cache = NullCache.new
19
+
20
+ config.cache_fetch_options = {
21
+ expires_in: 86_400, # 1 day
22
+ race_condition_ttl: 300 # 5 minutes
23
+ }
24
+
25
+ config.switches = []
26
+ end
27
+
28
+ def [](switch_name)
29
+ config.cache.fetch("#{LightSwitch::Switch.name.underscore}/#{switch_name}", **config.cache_fetch_options) do
30
+ LightSwitch::Switch.find_or_initialize_by(name: switch_name.to_s)
31
+ end
32
+ end
33
+
34
+ def on?(switch_name)
35
+ self[switch_name].on?
36
+ end
37
+
38
+ def off?(switch_name)
39
+ self[switch_name].off?
40
+ end
41
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :light_switch do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: light_switch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Joel Lubrano
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: inline_svg
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.8'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.8'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rails
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.2.2
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '8.2'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 7.0.2.2
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: '8.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: turbo-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '1.5'
53
+ - - "<"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.1'
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '1.5'
63
+ - - "<"
64
+ - !ruby/object:Gem::Version
65
+ version: '2.1'
66
+ - !ruby/object:Gem::Dependency
67
+ name: abbrev
68
+ requirement: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ - !ruby/object:Gem::Dependency
81
+ name: appraisal
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: bundler-gem_version_tasks
96
+ requirement: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ - !ruby/object:Gem::Dependency
109
+ name: capybara
110
+ requirement: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ type: :development
116
+ prerelease: false
117
+ version_requirements: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ - !ruby/object:Gem::Dependency
123
+ name: gems-cli
124
+ requirement: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ type: :development
130
+ prerelease: false
131
+ version_requirements: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ - !ruby/object:Gem::Dependency
137
+ name: standard
138
+ requirement: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ - !ruby/object:Gem::Dependency
151
+ name: webrick
152
+ requirement: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ type: :development
158
+ prerelease: false
159
+ version_requirements: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ description: An implementation of the circuit breaker pattern using ActiveRecord
165
+ email:
166
+ - joel.lubrano@gmail.com
167
+ executables: []
168
+ extensions: []
169
+ extra_rdoc_files: []
170
+ files:
171
+ - LICENSE.txt
172
+ - README.md
173
+ - Rakefile
174
+ - app/assets/config/light_switch_manifest.js
175
+ - app/assets/images/light_switch/light-switch.svg
176
+ - app/assets/javascripts/light_switch/application.js
177
+ - app/assets/stylesheets/light_switch/application.css
178
+ - app/assets/stylesheets/light_switch/normalize.css
179
+ - app/assets/stylesheets/light_switch/skeleton.css
180
+ - app/controllers/light_switch/application_controller.rb
181
+ - app/controllers/light_switch/switches_controller.rb
182
+ - app/models/concerns/light_switch/switch/notifications_concern.rb
183
+ - app/models/light_switch/application_record.rb
184
+ - app/models/light_switch/switch.rb
185
+ - app/views/layouts/light_switch/application.html.erb
186
+ - app/views/light_switch/switches/_form.html.erb
187
+ - app/views/light_switch/switches/_form_errors.html.erb
188
+ - app/views/light_switch/switches/_switch.html.erb
189
+ - app/views/light_switch/switches/index.html.erb
190
+ - config/locales/light_switch.en.yml
191
+ - config/routes.rb
192
+ - db/migrate/20231116015256_create_light_switch_switches.rb
193
+ - lib/light_switch.rb
194
+ - lib/light_switch/configuration.rb
195
+ - lib/light_switch/engine.rb
196
+ - lib/light_switch/null_cache.rb
197
+ - lib/light_switch/version.rb
198
+ - lib/tasks/light_switch_tasks.rake
199
+ homepage: https://github.com/jdlubrano/light_switch_rb
200
+ licenses:
201
+ - MIT
202
+ metadata:
203
+ homepage_uri: https://github.com/jdlubrano/light_switch_rb
204
+ source_code_uri: https://github.com/jdlubrano/light_switch_rb
205
+ changelog_uri: https://github.com/jdlubrano/light_switch_rb/CHANGELOG.md
206
+ rdoc_options: []
207
+ require_paths:
208
+ - lib
209
+ required_ruby_version: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ required_rubygems_version: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: '0'
219
+ requirements: []
220
+ rubygems_version: 3.6.9
221
+ specification_version: 4
222
+ summary: Circuit breakers on Rails
223
+ test_files: []