theme 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/theme/assets/middleware.rb +4 -3
- data/lib/theme/events.rb +30 -5
- data/lib/theme/version.rb +1 -1
- data/lib/theme.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0b89431f2a1082d7268129f5cd39b1e975b1aed
|
4
|
+
data.tar.gz: 69c7664de317304e7c5726763047d9c31423b55d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a2736c18cc0613c85280a5e8449474375dd89aab9265111688ac1c7501b67d1c371907a845e9a93ee0969bdc348cfddd2103f3d3661d6d8db922c00b22d2754
|
7
|
+
data.tar.gz: ea7293e18a2b953968af3ffc520e2332115c92f37eb2afc6b6709616ca4f8ee6f99c1c264be51b15e4c3cb0a8834f193d52dce090d0492f43cc7b0017c27bf9d
|
@@ -105,9 +105,10 @@ module Theme
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def render_all_files
|
108
|
-
content
|
109
|
-
files
|
110
|
-
|
108
|
+
content = ''
|
109
|
+
files = Theme.config.assets[ext]
|
110
|
+
type_folder = Theme.config.public_send "asset_#{type}_folder"
|
111
|
+
path = "#{Theme.config.asset_path}/#{type_folder}"
|
111
112
|
|
112
113
|
files.each do |file|
|
113
114
|
if file[/^http/]
|
data/lib/theme/events.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
module Theme
|
2
|
+
class ThreadUtility
|
3
|
+
def self.with_connection(&block)
|
4
|
+
begin
|
5
|
+
yield block
|
6
|
+
rescue Exception => e
|
7
|
+
raise e
|
8
|
+
ensure
|
9
|
+
# Check the connection back in to the connection pool
|
10
|
+
if defined?(ActiveRecord) && ActiveRecord::Base.connection
|
11
|
+
ActiveRecord::Base.connection.close
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
2
17
|
module Events
|
3
18
|
def self.included(other)
|
4
19
|
other.extend(Macros)
|
@@ -10,17 +25,27 @@ module Theme
|
|
10
25
|
|
11
26
|
def notify_listeners(event, *args)
|
12
27
|
id = self.class.instance_variable_get :@id
|
28
|
+
# threads = []
|
13
29
|
|
14
30
|
(@listeners || []).each do |listener|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
31
|
+
event_key = :"for_#{id}_#{event}"
|
32
|
+
event_keys = listener.class._event_blocks.keys
|
33
|
+
|
34
|
+
if id && event_keys.include?(event_key)
|
35
|
+
# threads << Thread.new do
|
36
|
+
# ThreadUtility.with_connection do
|
37
|
+
listener.trigger(event_key, *args)
|
38
|
+
# end
|
39
|
+
# end
|
19
40
|
end
|
20
41
|
end
|
42
|
+
#
|
43
|
+
# threads.map(&:join)
|
21
44
|
end
|
22
45
|
|
23
46
|
def trigger(name, options = {})
|
47
|
+
options = Hashr.new(options) if options.is_a? Hash
|
48
|
+
|
24
49
|
callback = false
|
25
50
|
|
26
51
|
if respond_to? name
|
@@ -50,7 +75,7 @@ module Theme
|
|
50
75
|
def on_event(name, options = {}, &block)
|
51
76
|
if id = options[:for]
|
52
77
|
(@_for_listeners ||= []) << id
|
53
|
-
name = :"#{id}_#{name}"
|
78
|
+
name = :"for_#{id}_#{name}"
|
54
79
|
end
|
55
80
|
|
56
81
|
@_event_blocks ||= {}
|
data/lib/theme/version.rb
CHANGED
data/lib/theme.rb
CHANGED
@@ -29,7 +29,9 @@ module Theme
|
|
29
29
|
load_component_files
|
30
30
|
app.settings[:render] ||= {}
|
31
31
|
app.plugin Assets
|
32
|
-
|
32
|
+
if Theme.config.use_component_middleware
|
33
|
+
app.use Middleware
|
34
|
+
end
|
33
35
|
else
|
34
36
|
yield config
|
35
37
|
end
|
@@ -48,6 +50,7 @@ module Theme
|
|
48
50
|
view_path: './views',
|
49
51
|
layout: 'app',
|
50
52
|
layout_path: './views/layouts',
|
53
|
+
use_component_middleware: true,
|
51
54
|
assets: OpenStruct.new({
|
52
55
|
js: {},
|
53
56
|
css: {}
|
@@ -130,9 +133,11 @@ module Theme
|
|
130
133
|
components = {}
|
131
134
|
|
132
135
|
Theme.config.components.each do |name, klass|
|
133
|
-
|
136
|
+
comp_klass = Object.const_get(klass)
|
137
|
+
component = comp_klass.new self
|
134
138
|
components[name] = component
|
135
|
-
component.instance_variable_set :@id, name
|
139
|
+
# component.instance_variable_set :@id, name
|
140
|
+
comp_klass.instance_variable_set :@id, name
|
136
141
|
end
|
137
142
|
|
138
143
|
components.each do |name, component|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|