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
|
# File 'lib/yjncopycat/specfileparser.rb', line 8
def self.run
puts "Reading from #{YJNCopycat::SPEC_FILE_NAME} in current directory...".yellow
unless File.file?("./#{YJNCopycat::SPEC_FILE_NAME}")
puts "ERROR: Unable to locate #{YJNCopycat::SPEC_FILE_NAME}!".red
exit 0
end
contents = File.open("./#{YJNCopycat::SPEC_FILE_NAME}").read
lines = contents.split("\n")
for line in lines
if line =~ /name (.*)/
name = line.gsub(' ', '').sub('name', '')
end
if line =~ /url (.*)/
url = line.gsub(' ', '').sub('url', '')
end
end
if name.nil?
puts "#{PARSER_ERROR_MESSAGE} Missing 'name' parameter.".red
exit 0
end
if name.length < 3
puts "#{PARSER_ERROR_MESSAGE} Make sure 'name' is at least 3 characters.".red
exit 0
end
unless name =~ /\w/
puts "#{PARSER_ERROR_MESSAGE} Make sure there's no whitespace in 'name' parameter.".red
exit 0
end
if url.nil?
puts "#{PARSER_ERROR_MESSAGE} Missing 'url' parameter.".red
exit 0
end
unless url =~ URI::regexp
puts "#{PARSER_ERROR_MESSAGE} Incorrect value for 'url' parameter. \nMake sure it is a valid git repo for your iOS project.".red
exit 0
end
{ :name => name, :url => url}
end
|