forked from xilinus/prototypeui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdistrib.rb
More file actions
41 lines (36 loc) · 1.02 KB
/
distrib.rb
File metadata and controls
41 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'protodoc'
require 'dependencies_resolver'
class Distrib
TemplateName = 'distrib.js.erb'
Resolver = DependenciesResolver.new(PUI_DEPENDENCIES)
def initialize(*components)
components = PUI_COMPONENTS if components.empty?
@components = components.collect { |c| c.to_sym }
end
def write(filename = PUI_DIST_FILE)
open(filename, 'w') do |f|
dependencies = Resolver.resolve(*@components)
dependencies.delete(:core)
dependencies.unshift(:core)
dependencies.each do |component|
f << preprocess(component) << "\n"
end
end
end
def preprocess(component)
component_path = File.join(PUI_SRC_DIR, component.to_s)
if File.directory?(component_path)
Dir.chdir(component_path) do
if File.exist?(TemplateName)
Protodoc::Preprocessor.new(TemplateName).to_s
else
File.read("#{component}.js")
end
end
elsif File.exist?(component_path)
File.read(component_path)
else
""
end
end
end