pretty 0.2 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/pretty +50 -53
- metadata +3 -2
data/bin/pretty
CHANGED
@@ -5,58 +5,55 @@
|
|
5
5
|
|
6
6
|
#checking for filename(s)
|
7
7
|
if ARGV.empty?
|
8
|
-
|
8
|
+
STDERR.puts "Usage: pretty [-language] filename(-s)\nIf not language specified rules for Ruby will be used.\nExample pretty hello.rb"
|
9
9
|
else
|
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
|
-
errors.each {|err| p err; file << (err+"\n")}
|
60
|
-
p "Report file: #{name}"
|
61
|
-
file.close
|
10
|
+
#declaring variables
|
11
|
+
errors = []
|
12
|
+
ln_cnt = 1
|
13
|
+
err_cnt = 0
|
14
|
+
rules = []
|
15
|
+
|
16
|
+
#checking for language of file(-s)
|
17
|
+
if ARGV[0] =~ /-/
|
18
|
+
language = ARGV.shift[1..-1]
|
19
|
+
end
|
20
|
+
|
21
|
+
if !language : language = "ruby" end
|
22
|
+
File.open("./rules/#{language}.txt","r").read.each {|line| rules << line.split("!!!")}
|
23
|
+
|
24
|
+
ARGV.each do |filename| #parsing file(-s)
|
25
|
+
|
26
|
+
file = File.open(filename)
|
27
|
+
|
28
|
+
#check for shebang
|
29
|
+
if file.readline[0..1] != "#!"
|
30
|
+
errors[err_cnt] = "#{filename}:#{ln_cnt}: No shebang found but it's not end of world ;-)"
|
31
|
+
err_cnt+=1
|
32
|
+
end
|
33
|
+
|
34
|
+
#now checking for rest errors
|
35
|
+
file.rewind
|
36
|
+
file.each_line do |line|
|
37
|
+
ln_cnt+=1
|
38
|
+
rules.each do |rule|
|
39
|
+
if eval(rule[0])
|
40
|
+
errors[err_cnt] = "#{filename}:#{ln_cnt}: #{rule[1]}"
|
41
|
+
err_cnt+=1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
file.close
|
47
|
+
ln_cnt = 1
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
#shows and save report
|
52
|
+
name = "report#{Time.now.to_i}.txt"
|
53
|
+
file = File.open(name,"w")
|
54
|
+
puts "Found #{err_cnt} errors in #{ARGV.size} files"
|
55
|
+
if err_cnt == 0 : puts "This is propably the best program in the world!" end
|
56
|
+
errors.each {|err| puts err; file << (err+"\n")}
|
57
|
+
puts "Report file: #{name}"
|
58
|
+
file.close
|
62
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz 'WujcioL' Tybura
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-19 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -24,6 +24,7 @@ extra_rdoc_files: []
|
|
24
24
|
files:
|
25
25
|
- ./bin/pretty
|
26
26
|
- ./bin/pretty.bat
|
27
|
+
- ./bin/rules
|
27
28
|
has_rdoc: false
|
28
29
|
homepage: http://wujciol.yoyo.pl
|
29
30
|
post_install_message:
|