59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/distil/project.rb', line 59
def self.from_config(config, parent=nil)
if config.is_a?(String)
string= config
uri= URI.parse(string)
config= { "name" => File.basename(config, ".*") }
case
when ['.js', '.css'].include?(File.extname(uri.path))
config["href"]= uri.to_s
when uri.scheme
config["repository"]= uri.to_s
else
config["path"]= uri.to_s
full_path= File.expand_path(config["path"])
if File.exist?(full_path) && File.file?(full_path)
config["path"]= File.dirname(full_path)
else
config["path"]= full_path
end
end
end
if !config["name"]
case when config["repository"]
uri= URI.parse(config["repository"])
config["name"]= File.basename(uri.path, ".*")
when config["path"]
config["name"]= File.basename(config["path"], ".*")
else
raise ValidationError.new("External project has neither name, path nor repository")
end
end
if config["href"]
return RemoteProject.new(config, parent)
end
config["path"]||= "ext/#{config["name"]}"
if config["repository"] && !File.directory?(config["path"])
fetch_project_using_git(config)
end
config["mode"]||= parent.mode if parent
path= config["path"]
if !path
ErrorReporter.error "No path for project: #{config["name"]}"
return nil
end
if !File.directory?(path)
ErrorReporter.error "Path is not valid for project: #{config["name"]}"
return nil
end
basename= File.basename(path)
case
when exist?(path, "#{basename}.jsproj")
project_file= File.join(path, "#{basename}.jsproj")
project_info= YAML.load_file(project_file)
project_info.merge!(config)
project_info["path"]= path
project= ExternalProject.new(project_info, parent)
if parent
project.build_command ||= "distil --mode=#{parent.mode} --force=#{parent.force}"
else
project.build_command ||= "distil"
end
when exist?(path, "Makefile") || exist?(path, "makefile")
project= ExternalProject.new(config, parent)
project.build_command ||= "make"
when exist?(path, "Rakefile") || exist?(path, "rakefile")
project= ExternalProject.new(config, parent)
project.build_command ||= "rake"
when exist?(path, "Jakefile") || exist?(path, "jakefile")
project= ExternalProject.new(config, parent)
project.build_command ||= "jake"
else
ErrorReporter.error "Could not determine type for project: #{config["name"]}"
end
return project
end
|