-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.rb
66 lines (51 loc) · 2.25 KB
/
init.rb
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require_relative 'empirical/empirical'
require 'find'
require 'fileutils'
begin
outputDir = ARGV[0]
if !outputDir.end_with?('/')
outputDir = outputDir + '/'
end
if !Dir.exist?(outputDir)
FileUtils::mkdir_p(outputDir) # if the nested dirs don't exists, FileUtils handles this case
end
sassFilesDirectory = ARGV[1]
if !sassFilesDirectory.end_with?('/')
sassFilesDirectory = sassFilesDirectory + '/'
end
main_file_paths = []
Find.find(sassFilesDirectory) do |path|
main_file_paths << path if path =~ /.*mainfiles.txt$/
end
header = true
main_file_paths.each do |main_file|
main_file_file_dirname = File.dirname(main_file)
website = File.basename(main_file_file_dirname)
files_to_consider = []
file = File.open(main_file)
file.each do |main_file_relative_path|
main_file_relative_path = main_file_relative_path.gsub(/[\r\n]/,'')
abs_path_to_main_sass_file = File.expand_path(main_file_relative_path, main_file_file_dirname)
files_to_consider << abs_path_to_main_sass_file
end
if files_to_consider.length > 0
extension = File.extname(files_to_consider[0]).to_s.gsub('.', '')
puts("We are doing #{main_file}, main files to consider: #{files_to_consider}")
empirical = EmpiricalStudy.new(website, files_to_consider)
empirical.write_selectors_info_to_file("#{outputDir}#{extension}-selectorsInfo.txt", header)
empirical.write_mixin_calls_info_to_file("#{outputDir}#{extension}-mixinCallsInfo.txt", header)
empirical.write_mixin_declarations_info_to_file("#{outputDir}#{extension}-mixinDeclarationInfo.txt", header)
empirical.write_extend_info_to_file("#{outputDir}#{extension}-extendInfo.txt", header)
empirical.write_file_size_info_to_file("#{outputDir}#{extension}-fileSizes.txt", header)
empirical.write_variable_declarations_to_file("#{outputDir}#{extension}-variableDeclarationsInfo.txt", header)
empirical.write_declared_script_functions_info("#{outputDir}#{extension}-declaredScriptFunctionsInfo.txt", header)
empirical.write_interpolations_info_to_file("#{outputDir}#{extension}-interpolationsInfo.txt", header)
if header
header = false
end
end
#rescue Sass::SyntaxError
#
#end
end
end