kode 0.1.0
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.tar.gz.sig +0 -0
- data/History.txt +4 -0
- data/Manifest.txt +9 -0
- data/README.txt +65 -0
- data/Rakefile +17 -0
- data/bin/ruby-code-indenter +16 -0
- data/bin/ruby-code-styler +1 -0
- data/lib/kode.rb +248 -0
- data/test/dirty.rb +231 -0
- data/test/test_kode.rb +0 -0
- metadata +94 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
= kode
|
2
|
+
|
3
|
+
* Based on: http://www.arachnoid.com/ruby/rubyBeautifier.html
|
4
|
+
* Gem's home: http://kode.rubyforge.org
|
5
|
+
* Git repo: http://gitorious.org/projects/kode
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
|
9
|
+
This module is fork (and rework) of "Ruby Script Beautifier" by P. Lutus.
|
10
|
+
|
11
|
+
* Autoindenting of ruby code (Kode::Indenter)
|
12
|
+
* Check code for coding conventions (Kode::Styler)
|
13
|
+
* ... sometime erb/yaml formatter?
|
14
|
+
|
15
|
+
== FEATURES/PROBLEMS:
|
16
|
+
|
17
|
+
* Autoindenter works pretty well if you use ruby coding conventions
|
18
|
+
* Conventions checker coming soon :)
|
19
|
+
* erb/yaml indenter sometime...
|
20
|
+
|
21
|
+
== SYNOPSIS:
|
22
|
+
|
23
|
+
require 'kode'
|
24
|
+
|
25
|
+
# rewrites original and creates backup copy
|
26
|
+
|
27
|
+
Kode::Indenter.process :file => "/path/to/file.rb"
|
28
|
+
|
29
|
+
Kode::Indenter.process :file => "/path/to/file.rb", :backup => false
|
30
|
+
|
31
|
+
Kode::Indenter.process :text => "ruby\ncode\nhere"
|
32
|
+
|
33
|
+
|
34
|
+
== REQUIREMENTS:
|
35
|
+
|
36
|
+
* You need Ruby, dude :)
|
37
|
+
|
38
|
+
== INSTALL:
|
39
|
+
|
40
|
+
* sudo gem install kode
|
41
|
+
|
42
|
+
Vim addicts have to add this snippet to your ~/.vimrc
|
43
|
+
|
44
|
+
nmap <leader>rci :%!ruby-code-indenter<cr>
|
45
|
+
|
46
|
+
Gedit addicts have to add new external tool
|
47
|
+
Edit -> Preferences -> Plugins -> External Tools
|
48
|
+
Put ruby-code-indenter as command
|
49
|
+
Take current file as input
|
50
|
+
And replace current file by output
|
51
|
+
|
52
|
+
TextMate addicts may found this useful:
|
53
|
+
http://blog.neontology.com/posts/2006/05/10/beautiful-ruby-in-textmate
|
54
|
+
|
55
|
+
Emacs addicts please drop me some lisp snipet
|
56
|
+
|
57
|
+
|
58
|
+
== LICENSE:
|
59
|
+
|
60
|
+
Copyright (C) 2006, Paul Lutus
|
61
|
+
|
62
|
+
Copyright (C) 2008, Antono Vasiljev <antono.vasiljev@gmail.com>
|
63
|
+
|
64
|
+
GPL 2+
|
65
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/kode.rb'
|
6
|
+
|
7
|
+
Hoe.new('kode', Kode::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'kode'
|
9
|
+
p.author = 'Antono Vasiljev'
|
10
|
+
p.email = 'antono.vasiljev@gmail.com'
|
11
|
+
p.summary = 'Code indenter and coding convention checker for Ruby'
|
12
|
+
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
13
|
+
p.url = "http://gitorious.org/projects/kode"
|
14
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/../lib/kode'
|
3
|
+
|
4
|
+
if ARGV.any?
|
5
|
+
ARGV.each do |path|
|
6
|
+
Kode::Indenter.process :file => path, :backup => true
|
7
|
+
end
|
8
|
+
elsif !(code = STDIN.read).empty?
|
9
|
+
puts Kode::Indenter.process(:text => code)
|
10
|
+
else
|
11
|
+
STDERR.puts "usage: ruby-code-indenter file.rb"
|
12
|
+
STDERR.puts "usage: cat file.rb | ruby-code-indenter"
|
13
|
+
exit 0
|
14
|
+
end
|
15
|
+
|
16
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
data/lib/kode.rb
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
=begin
|
2
|
+
/***************************************************************************
|
3
|
+
* Copyright (C) 2006, Paul Lutus *
|
4
|
+
* Copyright (C) 2008, Antono Vasiljev *
|
5
|
+
* *
|
6
|
+
* This program is free software; you can redistribute it and/or modify *
|
7
|
+
* it under the terms of the GNU General Public License as published by *
|
8
|
+
* the Free Software Foundation; either version 2 of the License, or *
|
9
|
+
* (at your option) any later version. *
|
10
|
+
* *
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
14
|
+
* GNU General Public License for more details. *
|
15
|
+
* *
|
16
|
+
* You should have received a copy of the GNU General Public License *
|
17
|
+
* along with this program; if not, write to the *
|
18
|
+
* Free Software Foundation, Inc., *
|
19
|
+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
20
|
+
***************************************************************************/
|
21
|
+
=end
|
22
|
+
module Kode
|
23
|
+
|
24
|
+
VERSION = '0.1.0'
|
25
|
+
|
26
|
+
class Indenter
|
27
|
+
|
28
|
+
# indent regexp
|
29
|
+
INDENT_EXP = [
|
30
|
+
/^def\b/,
|
31
|
+
/^if\b/,
|
32
|
+
/^else\b/,
|
33
|
+
/^elsif\b/,
|
34
|
+
/\bdo\b/,
|
35
|
+
/^class\b/,
|
36
|
+
/^module\b/,
|
37
|
+
/(=\s*|^)until\b/,
|
38
|
+
/(=\s*|^)for\b/,
|
39
|
+
/^unless\b/,
|
40
|
+
/(=\s*|^)while\b/,
|
41
|
+
/(=\s*|^)begin\b/,
|
42
|
+
/(^| )case\b/,
|
43
|
+
/\bthen\b/,
|
44
|
+
/^rescue\b/,
|
45
|
+
/^ensure\b/,
|
46
|
+
/\bwhen\b/,
|
47
|
+
/\{[^\}]*$/,
|
48
|
+
/\[[^\]]*$/
|
49
|
+
]
|
50
|
+
|
51
|
+
# outdent regexp
|
52
|
+
OUTDENT_EXP = [
|
53
|
+
/^end\b/,
|
54
|
+
/^else\b/,
|
55
|
+
/^elsif\b/,
|
56
|
+
/^rescue\b/,
|
57
|
+
/^ensure\b/,
|
58
|
+
/\bwhen\b/,
|
59
|
+
/^[^\{]*\}/,
|
60
|
+
/^[^\[]*\]/
|
61
|
+
]
|
62
|
+
|
63
|
+
# Creates cleaner. Takes hash of parametrs:
|
64
|
+
#
|
65
|
+
# :indent_char - indent symbol (default: space)
|
66
|
+
#
|
67
|
+
# :indent_size - quantity of indent symbols for single step (default: 2)
|
68
|
+
#
|
69
|
+
def initialize(params = {})
|
70
|
+
@indent_char = params[:indent_char] || " "
|
71
|
+
@indent_size = params[:indent_size] || 2
|
72
|
+
end
|
73
|
+
|
74
|
+
# Cleaning source. Takes hash of parametrs:
|
75
|
+
#
|
76
|
+
# :file - Source code as path to file
|
77
|
+
#
|
78
|
+
# :text - Source code as ruby string
|
79
|
+
#
|
80
|
+
# :backup - makes backup copy if true
|
81
|
+
#
|
82
|
+
# :indent_char - indent symbol (default: " ")
|
83
|
+
#
|
84
|
+
# :indent_size - quantity of indent symbols for single step
|
85
|
+
#
|
86
|
+
#
|
87
|
+
def self.process(params = {})
|
88
|
+
unless params[:file].nil?
|
89
|
+
params[:text] = File.read(params[:file])
|
90
|
+
@path = params[:file]
|
91
|
+
end
|
92
|
+
|
93
|
+
output = self.new(params).process(params[:text])
|
94
|
+
|
95
|
+
if params[:backup] && (source != dest) && params[:file]
|
96
|
+
File.open(params[:file] + ".ugly~","w") { |f| f.write(params[:text]) }
|
97
|
+
File.open(params[:file],"w") { |f| f.write(output) }
|
98
|
+
else
|
99
|
+
return output
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# Cleaning source. Takes source code as ruby string.
|
106
|
+
#
|
107
|
+
def process(source)
|
108
|
+
|
109
|
+
cursor_inside_comment_block = false
|
110
|
+
cursor_at_program_end = false
|
111
|
+
|
112
|
+
multiline_array = []
|
113
|
+
multiline_string = ""
|
114
|
+
|
115
|
+
indent_level = 0
|
116
|
+
dest = ""
|
117
|
+
|
118
|
+
source.each_line do |line|
|
119
|
+
|
120
|
+
unless cursor_at_program_end
|
121
|
+
|
122
|
+
# detect program end mark
|
123
|
+
if line =~ /^__END__$/
|
124
|
+
cursor_at_program_end = true
|
125
|
+
else
|
126
|
+
|
127
|
+
# combine continuing lines
|
128
|
+
if(!(line =~ /^\s*#/) && line =~ /[^\\]\\\s*$/)
|
129
|
+
multiline_array.push line
|
130
|
+
multiline_string += line.sub(/^(.*)\\\s*$/,"\\1")
|
131
|
+
next
|
132
|
+
end
|
133
|
+
|
134
|
+
# add final line
|
135
|
+
if (multiline_string.length > 0)
|
136
|
+
multiline_array.push line
|
137
|
+
multiline_string += line.sub(/^(.*)\\\s*$/,"\\1")
|
138
|
+
end
|
139
|
+
|
140
|
+
tline = ((multiline_string.length > 0) ? multiline_string : line).strip
|
141
|
+
|
142
|
+
cursor_inside_comment_block = true if tline.match(/^=begin/)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
if (cursor_inside_comment_block or cursor_at_program_end)
|
147
|
+
dest += line # add the line unchanged
|
148
|
+
else
|
149
|
+
|
150
|
+
cursor_at_comment_line = (tline =~ /^#/)
|
151
|
+
|
152
|
+
unless cursor_at_comment_line
|
153
|
+
# throw out sequences that will
|
154
|
+
# only sow confusion
|
155
|
+
# XXX WTF?
|
156
|
+
while tline.gsub!(/\{[^\{]*?\}/,"")
|
157
|
+
end
|
158
|
+
while tline.gsub!(/\[[^\[]*?\]/,"")
|
159
|
+
end
|
160
|
+
while tline.gsub!(/'.*?'/,"")
|
161
|
+
end
|
162
|
+
while tline.gsub!(/".*?"/,"")
|
163
|
+
end
|
164
|
+
while tline.gsub!(/\`.*?\`/,"")
|
165
|
+
end
|
166
|
+
while tline.gsub!(/\([^\(]*?\)/,"")
|
167
|
+
end
|
168
|
+
while tline.gsub!(/\/.*?\//,"")
|
169
|
+
end
|
170
|
+
while tline.gsub!(/%r(.).*?\1/,"")
|
171
|
+
end
|
172
|
+
|
173
|
+
# delete end-of-line comments
|
174
|
+
tline.sub!(/#[^\"]+$/,"")
|
175
|
+
# convert quotes
|
176
|
+
# WTF?
|
177
|
+
tline.gsub!(/\\\"/,"'")
|
178
|
+
OUTDENT_EXP.each do |re|
|
179
|
+
if (tline =~ re)
|
180
|
+
indent_level -= 1
|
181
|
+
break
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
unless multiline_array.empty?
|
187
|
+
multiline_array.each do |ml|
|
188
|
+
dest += add_line(ml,indent_level)
|
189
|
+
end
|
190
|
+
multiline_array.clear
|
191
|
+
multiline_string = ""
|
192
|
+
else
|
193
|
+
dest += add_line(line,indent_level)
|
194
|
+
end
|
195
|
+
|
196
|
+
unless cursor_at_comment_line
|
197
|
+
INDENT_EXP.each do |re|
|
198
|
+
if(tline =~ re && !(tline =~ /\s+end\s*$/))
|
199
|
+
indent_level += 1
|
200
|
+
break
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
cursor_inside_comment_block = false if tline =~ /^=end/
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
if (indent_level != 0)
|
212
|
+
STDERR.puts "#{@path}: Indentation error: #{indent_level}" if @path
|
213
|
+
end
|
214
|
+
|
215
|
+
return dest
|
216
|
+
end
|
217
|
+
|
218
|
+
private
|
219
|
+
|
220
|
+
def make_indent(indent_level)
|
221
|
+
return (indent_level < 0) ? "" : @indent_char * @indent_size * indent_level
|
222
|
+
end
|
223
|
+
|
224
|
+
def add_line(line,indent_level)
|
225
|
+
line.strip!
|
226
|
+
line = make_indent(indent_level)+line if line.length > 0
|
227
|
+
return line + "\n"
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
# Check code for Ruby coding conventions...
|
234
|
+
#
|
235
|
+
class Styler
|
236
|
+
|
237
|
+
METHOD = {
|
238
|
+
:match => /def\s+([\.\w]+)/,
|
239
|
+
:false => /[A-Z]+/,
|
240
|
+
:true => /[a-z_]+/
|
241
|
+
}
|
242
|
+
|
243
|
+
def self.process
|
244
|
+
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
data/test/dirty.rb
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
=begin
|
2
|
+
/***************************************************************************
|
3
|
+
* Copyright (C) 2006, Paul Lutus *
|
4
|
+
* *
|
5
|
+
* This program is free software; you can redistribute it and/or modify *
|
6
|
+
* it under the terms of the GNU General Public License as published by *
|
7
|
+
* the Free Software Foundation; either version 2 of the License, or *
|
8
|
+
* (at your option) any later version. *
|
9
|
+
* *
|
10
|
+
* This program is distributed in the hope that it will be useful, *
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
13
|
+
* GNU General Public License for more details. *
|
14
|
+
* *
|
15
|
+
* You should have received a copy of the GNU General Public License *
|
16
|
+
* along with this program; if not, write to the *
|
17
|
+
* Free Software Foundation, Inc., *
|
18
|
+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
19
|
+
***************************************************************************/
|
20
|
+
=end
|
21
|
+
|
22
|
+
module Code
|
23
|
+
|
24
|
+
class Indenter
|
25
|
+
|
26
|
+
# indent regexp
|
27
|
+
INDENT_EXP = [
|
28
|
+
/^def\b/,
|
29
|
+
/^if\b/,
|
30
|
+
/^else\b/,
|
31
|
+
/^elsif\b/,
|
32
|
+
/\bdo\b/,
|
33
|
+
/^class\b/,
|
34
|
+
/^module\b/,
|
35
|
+
/(=\s*|^)until\b/,
|
36
|
+
/(=\s*|^)for\b/,
|
37
|
+
/^unless\b/,
|
38
|
+
/(=\s*|^)while\b/,
|
39
|
+
/(=\s*|^)begin\b/,
|
40
|
+
/(^| )case\b/,
|
41
|
+
/\bthen\b/,
|
42
|
+
/^rescue\b/,
|
43
|
+
/^ensure\b/,
|
44
|
+
/\bwhen\b/,
|
45
|
+
/\{[^\}]*$/,
|
46
|
+
/\[[^\]]*$/
|
47
|
+
]
|
48
|
+
|
49
|
+
# outdent regexp
|
50
|
+
OUTDENT_EXP = [
|
51
|
+
/^end\b/,
|
52
|
+
/^else\b/,
|
53
|
+
/^elsif\b/,
|
54
|
+
/^rescue\b/,
|
55
|
+
/^ensure\b/,
|
56
|
+
/\bwhen\b/,
|
57
|
+
/^[^\{]*\}/,
|
58
|
+
/^[^\[]*\]/
|
59
|
+
]
|
60
|
+
|
61
|
+
# Creates cleaner. Takes hash of parametrs:
|
62
|
+
#
|
63
|
+
# :indent_char - indent symbol (default: " ")
|
64
|
+
# :indent_size - quantity of indent symbols for single step
|
65
|
+
#
|
66
|
+
def initialize(params = {})
|
67
|
+
@indent_char = params[:indent_char] || " "
|
68
|
+
@indent_size = params[:indent_size] || 2
|
69
|
+
end
|
70
|
+
|
71
|
+
# Cleaning file by given path. Takes full path to ruby source file and a hash of parameters:
|
72
|
+
#
|
73
|
+
# :backup - makes backup copy if true
|
74
|
+
#
|
75
|
+
# For more look at +CleanR.new+ documentation
|
76
|
+
#
|
77
|
+
def self.process_file(path, params = { :backup => true } )
|
78
|
+
|
79
|
+
source = File.read(path)
|
80
|
+
dest = self.clean(params.merge(:text => source))
|
81
|
+
|
82
|
+
if params[:backup] && (source != dest)
|
83
|
+
# make a backup copy
|
84
|
+
File.open(path + ".ugly~","w") { |f| f.write(source) }
|
85
|
+
# overwrite the original
|
86
|
+
File.open(path,"w") { |f| f.write(dest) }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Cleaning source. Takes hash of parametrs:
|
91
|
+
#
|
92
|
+
# :text - Source code as ruby string
|
93
|
+
#
|
94
|
+
# For more keys look at +CleanR.new+ documentation
|
95
|
+
#
|
96
|
+
def self.clean(params = {})
|
97
|
+
self.new(params).clean(params[:text])
|
98
|
+
end
|
99
|
+
|
100
|
+
def clean(source)
|
101
|
+
|
102
|
+
cursor_inside_comment_block = false
|
103
|
+
cursor_at_program_end = false
|
104
|
+
|
105
|
+
multiline_array = []
|
106
|
+
multiline_string = ""
|
107
|
+
|
108
|
+
indent_level = 0
|
109
|
+
dest = ""
|
110
|
+
|
111
|
+
source.each_line do |line|
|
112
|
+
|
113
|
+
unless cursor_at_program_end
|
114
|
+
|
115
|
+
# detect program end mark
|
116
|
+
if line =~ /^__END__$/
|
117
|
+
cursor_at_program_end = true
|
118
|
+
else
|
119
|
+
|
120
|
+
# combine continuing lines
|
121
|
+
if(!(line =~ /^\s*#/) && line =~ /[^\\]\\\s*$/)
|
122
|
+
multiline_array.push line
|
123
|
+
multiline_string += line.sub(/^(.*)\\\s*$/,"\\1")
|
124
|
+
next
|
125
|
+
end
|
126
|
+
|
127
|
+
# add final line
|
128
|
+
if (multiline_string.length > 0)
|
129
|
+
multiline_array.push line
|
130
|
+
multiline_string += line.sub(/^(.*)\\\s*$/,"\\1")
|
131
|
+
end
|
132
|
+
|
133
|
+
tline = ((multiline_string.length > 0) ? multiline_string : line).strip
|
134
|
+
|
135
|
+
cursor_inside_comment_block = true if tline.match(/^=begin/)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
if (cursor_inside_comment_block or cursor_at_program_end)
|
140
|
+
dest += line # add the line unchanged
|
141
|
+
else
|
142
|
+
|
143
|
+
cursor_at_comment_line = (tline =~ /^#/)
|
144
|
+
|
145
|
+
unless cursor_at_comment_line
|
146
|
+
# throw out sequences that will
|
147
|
+
# only sow confusion
|
148
|
+
# XXX WTF?
|
149
|
+
while tline.gsub!(/\{[^\{]*?\}/,"")
|
150
|
+
end
|
151
|
+
while tline.gsub!(/\[[^\[]*?\]/,"")
|
152
|
+
end
|
153
|
+
while tline.gsub!(/'.*?'/,"")
|
154
|
+
end
|
155
|
+
while tline.gsub!(/".*?"/,"")
|
156
|
+
end
|
157
|
+
while tline.gsub!(/\`.*?\`/,"")
|
158
|
+
end
|
159
|
+
while tline.gsub!(/\([^\(]*?\)/,"")
|
160
|
+
end
|
161
|
+
while tline.gsub!(/\/.*?\//,"")
|
162
|
+
end
|
163
|
+
while tline.gsub!(/%r(.).*?\1/,"")
|
164
|
+
end
|
165
|
+
|
166
|
+
# delete end-of-line comments
|
167
|
+
tline.sub!(/#[^\"]+$/,"")
|
168
|
+
# convert quotes
|
169
|
+
# WTF?
|
170
|
+
tline.gsub!(/\\\"/,"'")
|
171
|
+
OUTDENT_EXP.each do |re|
|
172
|
+
if (tline =~ re)
|
173
|
+
indent_level -= 1
|
174
|
+
break
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
unless multiline_array.empty?
|
180
|
+
multiline_array.each do |ml|
|
181
|
+
dest += add_line(ml,indent_level)
|
182
|
+
end
|
183
|
+
multiline_array.clear
|
184
|
+
multiline_string = ""
|
185
|
+
else
|
186
|
+
dest += add_line(line,indent_level)
|
187
|
+
end
|
188
|
+
|
189
|
+
unless cursor_at_comment_line
|
190
|
+
INDENT_EXP.each do |re|
|
191
|
+
if(tline =~ re && !(tline =~ /\s+end\s*$/))
|
192
|
+
indent_level += 1
|
193
|
+
break
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
cursor_inside_comment_block = false if tline =~ /^=end/
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
if (indent_level != 0)
|
205
|
+
STDERR.puts "#{path}: Indentation error: #{indent_level}"
|
206
|
+
end
|
207
|
+
|
208
|
+
return dest
|
209
|
+
end
|
210
|
+
|
211
|
+
private
|
212
|
+
|
213
|
+
def make_indent(indent_level)
|
214
|
+
return (indent_level < 0) ? "" : @indent_char * @indent_size * indent_level
|
215
|
+
end
|
216
|
+
|
217
|
+
def add_line(line,indent_level)
|
218
|
+
line.strip!
|
219
|
+
line = make_indent(indent_level)+line if line.length > 0
|
220
|
+
return line + "\n"
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
class Styler
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
|
data/test/test_kode.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kode
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Antono Vasiljev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDQDCCAiigAwIBAgIBADANBgkqhkiG9w0BAQUFADBGMRgwFgYDVQQDDA9hbnRv
|
14
|
+
bm8udmFzaWxqZXYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixk
|
15
|
+
ARkWA2NvbTAeFw0wODAyMjQxNzQyMzNaFw0wOTAyMjMxNzQyMzNaMEYxGDAWBgNV
|
16
|
+
BAMMD2FudG9uby52YXNpbGpldjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYK
|
17
|
+
CZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
|
18
|
+
tnBsZV7rCGSGhRfCfiTJ4Hu7vrAty73aF7nDJnXiBEn5nLDb2r4XAnz/WFjNCJty
|
19
|
+
f+9NuRLocUtx53mmC4GbOth1IROlYxTCcoSnaWYUK6k9X2/uQuZmGaTWm+l9cVfB
|
20
|
+
toNB2+NmxS5m3shtlu4eDD23OPXAN7whUSqM6atszzKcfAjcSX580b+6wtDy8vGa
|
21
|
+
9GxWYojzhbOLiKekkP6/XX0tattBfziLgWRNFgf0spwr0RbTpCo9x+mmo3YjmCXx
|
22
|
+
FCMstCdYmrMw21pAu2oJjnoqZ+XmMMefZ4xy5+A5+by+6MuiSHzzQASy5E56bFeL
|
23
|
+
uTqLtDDNOS6h/D3p0DvbrwIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
|
24
|
+
sDAdBgNVHQ4EFgQUpDAbiShgNHzfObH6wSF5vbw47WUwDQYJKoZIhvcNAQEFBQAD
|
25
|
+
ggEBAC86UZzjH6Tiua20Tv6zgiS45YjW/MYKztfXL3OyifrlT0dTLoSJ7edt+kBW
|
26
|
+
CMh1ykErLh0e+w2hGbs7igZI25dRbcI5UnfnTEqb67Ghm+gHqdMXeQYFWhXU2D4C
|
27
|
+
UDwmpMJU93SPb7dit2s44UaMT9dplQANwLNQFEECr70WJ5VG3avo4x10oxeRHlDa
|
28
|
+
jTpXj3vTnG3ZDpWPDhmoX+2WeJfuPwAznuL2Z1HBMk8iDlJ1GM+FGUbVfMofD4Ex
|
29
|
+
P5/ty+94oWvf4D4SOAXWib/x0LVZJIWIMaoFEjH/tvmxtMJaJXvL+oixnc9xE1U4
|
30
|
+
jPtJtRL1RfX37yQGoofqWl37iHY=
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
|
33
|
+
date: 2008-02-25 00:00:00 +02:00
|
34
|
+
default_executable:
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: hoe
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.5.0
|
44
|
+
version:
|
45
|
+
description: "== DESCRIPTION: This module is fork (and rework) of \"Ruby Script Beautifier\" by P. Lutus. * Autoindenting of ruby code (Kode::Indenter) * Check code for coding conventions (Kode::Styler) * ... sometime erb/yaml formatter? == FEATURES/PROBLEMS:"
|
46
|
+
email: antono.vasiljev@gmail.com
|
47
|
+
executables:
|
48
|
+
- ruby-code-indenter
|
49
|
+
- ruby-code-styler
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
- README.txt
|
56
|
+
files:
|
57
|
+
- History.txt
|
58
|
+
- Manifest.txt
|
59
|
+
- README.txt
|
60
|
+
- Rakefile
|
61
|
+
- bin/ruby-code-indenter
|
62
|
+
- bin/ruby-code-styler
|
63
|
+
- lib/kode.rb
|
64
|
+
- test/test_kode.rb
|
65
|
+
- test/dirty.rb
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://gitorious.org/projects/kode
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options:
|
70
|
+
- --main
|
71
|
+
- README.txt
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project: kode
|
89
|
+
rubygems_version: 1.0.1
|
90
|
+
signing_key:
|
91
|
+
specification_version: 2
|
92
|
+
summary: Code indenter and coding convention checker for Ruby
|
93
|
+
test_files:
|
94
|
+
- test/test_kode.rb
|
metadata.gz.sig
ADDED
Binary file
|