wedge 0.1.38 → 0.1.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wedge/middleware.rb +2 -1
- data/lib/wedge/plugins/current_user.rb +1 -1
- data/lib/wedge/railtie.rb +17 -0
- data/lib/wedge/store.rb +50 -0
- data/lib/wedge/version.rb +1 -1
- data/lib/wedge.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94ce92466e715398f4986ff8e0ea3566a5d702f8
|
4
|
+
data.tar.gz: b7ded8da8e6c96de01c412046d58b59a279a2faf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f1c9de0900362595f228002697f8cecddfd20b4940ac0502b8e0b9c3490d5845bf3c2492fdc7515d677b93677834cf551b8083fdd7905bcb2ec7b0412a07718
|
7
|
+
data.tar.gz: d83feebf9647b56f9252b1b052ffe287caa028190844783fd68b6938a67693255d92a0921eed17907ad28818f9c8b5957e17cfabb540c29ec68f2e6a1eeead27
|
data/lib/wedge/middleware.rb
CHANGED
@@ -35,6 +35,8 @@ class Wedge
|
|
35
35
|
def call(env)
|
36
36
|
responder = Responder.new(@app, @opal, @scope, @skip_call, env)
|
37
37
|
responder.respond
|
38
|
+
ensure
|
39
|
+
Wedge::Store.clear!
|
38
40
|
end
|
39
41
|
|
40
42
|
class << self
|
@@ -89,7 +91,6 @@ class Wedge
|
|
89
91
|
method_called = data.delete(:__wedge_method__)
|
90
92
|
method_args = data.delete(:__wedge_args__)
|
91
93
|
|
92
|
-
|
93
94
|
if wedge_path == 'wedge/list_assets'
|
94
95
|
res = {
|
95
96
|
urls: Wedge.get_asset_urls(data[:path_name]),
|
@@ -20,7 +20,7 @@ class Wedge
|
|
20
20
|
|
21
21
|
module InstanceMethods
|
22
22
|
def wedge_current_user
|
23
|
-
|
23
|
+
Store[:current_user] ||= Wedge[:current_user, wedge(:current_user_plugin).get_current_user]
|
24
24
|
end
|
25
25
|
alias_method :current_user, :wedge_current_user
|
26
26
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Wedge
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
initializer "request_store.insert_middleware" do |app|
|
4
|
+
if ActionDispatch.const_defined? :RequestId
|
5
|
+
app.config.middleware.insert_after ActionDispatch::RequestId, Wedge::Middleware
|
6
|
+
else
|
7
|
+
app.config.middleware.insert_after Rack::MethodOverride, Wedge::Middleware
|
8
|
+
end
|
9
|
+
|
10
|
+
if ActionDispatch.const_defined?(:Reloader) && ActionDispatch::Reloader.respond_to?(:to_cleanup)
|
11
|
+
ActionDispatch::Reloader.to_cleanup do
|
12
|
+
Wedge::Store.clear!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/wedge/store.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
class Wedge
|
2
|
+
module Store
|
3
|
+
include Methods
|
4
|
+
|
5
|
+
def self.store
|
6
|
+
if server?
|
7
|
+
Thread.current[:__wedge__] ||= {}
|
8
|
+
else
|
9
|
+
$__wedge_store__ ||= {}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.clear!
|
14
|
+
if server?
|
15
|
+
Thread.current[:__wedge__] = {}
|
16
|
+
else
|
17
|
+
$__wedge_store__ = {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.read(key)
|
22
|
+
store[key]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.[](key)
|
26
|
+
store[key]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.write(key, value)
|
30
|
+
store[key] = value
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.[]=(key, value)
|
34
|
+
store[key] = value
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.exist?(key)
|
38
|
+
store.key?(key)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.fetch(key, &block)
|
42
|
+
store[key] = yield unless exist?(key)
|
43
|
+
store[key]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.delete(key, &block)
|
47
|
+
store.delete(key, &block)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/wedge/version.rb
CHANGED
data/lib/wedge.rb
CHANGED
@@ -16,11 +16,13 @@ unless RUBY_ENGINE == 'opal'
|
|
16
16
|
require 'wedge/utilis/nokogiri'
|
17
17
|
require 'wedge/middleware'
|
18
18
|
end
|
19
|
+
require 'wedge/store'
|
19
20
|
require 'wedge/html'
|
20
21
|
require 'wedge/dom'
|
21
22
|
require 'wedge/events'
|
22
23
|
require 'wedge/config'
|
23
24
|
require 'wedge/component'
|
25
|
+
require 'wedge/railtie' if RUBY_ENGINE == 'RUBY' && defined?(Rails::Railtie)
|
24
26
|
|
25
27
|
class Wedge
|
26
28
|
include Methods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wedge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
@@ -170,7 +170,9 @@ files:
|
|
170
170
|
- lib/wedge/plugins/pjax.rb
|
171
171
|
- lib/wedge/plugins/render.rb
|
172
172
|
- lib/wedge/plugins/uploader.rb
|
173
|
+
- lib/wedge/railtie.rb
|
173
174
|
- lib/wedge/require.rb
|
175
|
+
- lib/wedge/store.rb
|
174
176
|
- lib/wedge/utilis/blank.rb
|
175
177
|
- lib/wedge/utilis/duplicable.rb
|
176
178
|
- lib/wedge/utilis/element.rb
|