impromptu 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/impromptu.gemspec +1 -1
- data/lib/impromptu/file.rb +15 -2
- data/lib/impromptu/folder.rb +3 -12
- data/lib/impromptu/resource.rb +3 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0
|
data/impromptu.gemspec
CHANGED
data/lib/impromptu/file.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Impromptu
|
2
2
|
class File
|
3
|
-
attr_reader :path, :folder, :resources, :related_resources, :related_files, :modified_time
|
3
|
+
attr_reader :path, :folder, :resources, :related_resources, :related_files, :modified_time, :preload
|
4
4
|
RELOADABLE_EXTENSIONS = %w{rb}
|
5
5
|
|
6
|
-
def initialize(path, folder, provides=[])
|
6
|
+
def initialize(path, folder, preload=false, provides=[])
|
7
7
|
@path = path
|
8
8
|
@folder = folder
|
9
9
|
@resources = OrderedSet.new
|
@@ -12,6 +12,7 @@ module Impromptu
|
|
12
12
|
@frozen = false
|
13
13
|
@modified_time = nil
|
14
14
|
@dirty = true
|
15
|
+
@preload = preload
|
15
16
|
@provides = [provides].compact.flatten
|
16
17
|
end
|
17
18
|
|
@@ -27,6 +28,17 @@ module Impromptu
|
|
27
28
|
@path.hash
|
28
29
|
end
|
29
30
|
|
31
|
+
# Indicate whether this file needs to be preloaded
|
32
|
+
def preload=(preload)
|
33
|
+
@preload = preload
|
34
|
+
end
|
35
|
+
|
36
|
+
# True if this file needs to be preloaded before other files
|
37
|
+
# are automatically loaded on demand
|
38
|
+
def preload?
|
39
|
+
@preload
|
40
|
+
end
|
41
|
+
|
30
42
|
# Traverse the file/resource graph to determine which total
|
31
43
|
# set of files and resources are related to this file. For
|
32
44
|
# instance, if a resource provided by this file is also
|
@@ -181,6 +193,7 @@ module Impromptu
|
|
181
193
|
@provides.each do |resource_name|
|
182
194
|
resource = Impromptu.root_resource.get_or_create_child(combine_symbol_with_namespace(resource_name))
|
183
195
|
resource.add_file(self)
|
196
|
+
resource.preload = preload?
|
184
197
|
@resources << resource
|
185
198
|
end
|
186
199
|
end
|
data/lib/impromptu/folder.rb
CHANGED
@@ -129,7 +129,8 @@ module Impromptu
|
|
129
129
|
# * provides (required): an array of symbols, or a symbol
|
130
130
|
# indicating the name of the resource(s) provided by the file
|
131
131
|
def file(name, options={})
|
132
|
-
|
132
|
+
file_preload = options[:preload] || preload?
|
133
|
+
file = Impromptu::File.new(@folder.join(*name).realpath, self, file_preload, options[:provides])
|
133
134
|
@files.push(file).add_resource_definition
|
134
135
|
end
|
135
136
|
|
@@ -158,7 +159,7 @@ module Impromptu
|
|
158
159
|
# find all source files and add unseen files to the files list
|
159
160
|
@folder.find do |path|
|
160
161
|
next unless source_file?(path)
|
161
|
-
file = Impromptu::File.new(path.realpath, self)
|
162
|
+
file = Impromptu::File.new(path.realpath, self, preload?)
|
162
163
|
new_file_set << file
|
163
164
|
unless @files.include?(file)
|
164
165
|
changes = true
|
@@ -178,16 +179,6 @@ module Impromptu
|
|
178
179
|
file.refreeze
|
179
180
|
end
|
180
181
|
end
|
181
|
-
|
182
|
-
# ensure all resources defined by this folder
|
183
|
-
# are marked to be preloaded if required
|
184
|
-
if preload?
|
185
|
-
@files.each do |file|
|
186
|
-
file.resources.each do |resource|
|
187
|
-
resource.preload = true
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
182
|
end
|
192
183
|
|
193
184
|
|
data/lib/impromptu/resource.rb
CHANGED
@@ -33,12 +33,13 @@ module Impromptu
|
|
33
33
|
@name.hash
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
36
|
+
# Indicate whether this resource needs to be preloaded
|
37
37
|
def preload=(preload)
|
38
38
|
@preload = preload
|
39
39
|
end
|
40
40
|
|
41
|
-
# True if this resource
|
41
|
+
# True if this resource needs to be preloaded before other files
|
42
|
+
# are automatically loaded on demand
|
42
43
|
def preload?
|
43
44
|
@preload
|
44
45
|
end
|