pretty 0.1

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.
Files changed (3) hide show
  1. data/bin/pretty +54 -0
  2. data/bin/pretty.bat +6 -0
  3. metadata +54 -0
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby
2
+
3
+ #Autor: Mateusz "WujcioL" Tybura (mailto:wujciol@gmail.com)
4
+ #License: MIT
5
+
6
+ #checking for filename(s)
7
+ if ARGV.empty?
8
+ STDERR.puts "ERROR: Give filename(s) as argument(s)"
9
+ else
10
+ #declaring variables
11
+ errors = []
12
+ ln_cnt = 1
13
+ err_cnt = 0
14
+
15
+ #parsing each file
16
+ ARGV.each do |filename|
17
+
18
+ file = File.open(filename)
19
+
20
+ #check for shebang
21
+ if file.readline[0..1] != "#!"
22
+ errors[err_cnt] << "#{filename}:#{ln_cnt}: No shebang"
23
+ err_cnt+=1
24
+ end
25
+
26
+ #now checking rest of file
27
+ file.each_line do |line|
28
+ ln_cnt+=1
29
+ if line.size > 80 #short lines are better to read
30
+ errors[err_cnt] = "#{filename}:#{ln_cnt}: Too long line"
31
+ err_cnt+=1
32
+ end
33
+ if line =~ /^;/ #it's not good to add ; on end of line
34
+ errors[err_cnt] = "#{filename}:#{ln_cnt}: You don't need to use ; on line end"
35
+ err_cnt+=1
36
+ end
37
+ if line =~ /\t{4}/ #code with less tabulations is better to read
38
+ errors[err_cnt] = "#{filename}:#{ln_cnt}: Too many tabulations"
39
+ err_cnt+=1
40
+ end
41
+ end
42
+
43
+ file.close
44
+ ln_cnt = 1
45
+
46
+ end
47
+
48
+ #shows and save report
49
+ name = "report#{Time.now.to_i}.txt"
50
+ file = File.open(name,"w")
51
+ errors.each {|err| p err; file << (err+"\n")}
52
+ p "Report file: #{name}"
53
+ file.close
54
+ end
@@ -0,0 +1,6 @@
1
+ @ECHO OFF
2
+ IF NOT "%~f0" == "~f0" GOTO :WinNT
3
+ @"ruby.exe" "d:/ruby/bin/pretty" %1 %2 %3 %4 %5 %6 %7 %8 %9
4
+ GOTO :EOF
5
+ :WinNT
6
+ @"ruby.exe" "%~dpn0" %*
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pretty
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Mateusz 'WujcioL' Tybura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-09 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: This program is checking your code for few errors which makes it not pretty.
17
+ email: wujciol@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - ./bin/pretty
26
+ - ./bin/pretty.bat
27
+ has_rdoc: false
28
+ homepage: http://wujciol.yoyo.pl
29
+ post_install_message:
30
+ rdoc_options: []
31
+
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: "0"
39
+ version:
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ requirements: []
47
+
48
+ rubyforge_project: pretty
49
+ rubygems_version: 1.2.0
50
+ signing_key:
51
+ specification_version: 2
52
+ summary: Simple code checker
53
+ test_files: []
54
+