summaryrefslogtreecommitdiffstats
path: root/indenters/example.rb
blob: 6117e5a4045dcc6a8624f58fb46a7fc971638af4 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env ruby 
#odd assignments
BEGIN {
	puts "a block i have never seen used"
}
entry = Post.update(params["id"],{:title => params["title"],:post => params['post'],:context => params["context"],:creator => session[:creator]})
definition = "moo"
puts moo
moo = case 3
when 2
	"unless proceeding to 3"
when 3
	"right"
when 4
	"one to many"
when 5
	"three sir"
end

puts moo
def pointless_call
	if false
		"Sdf"
	elsif true
		"df"
	end
end
puts pointless_call

if true
	puts "moo"
end
i = 5
def title
	doc = load_page
	title = doc.search("h1").first.inner_html
	clean_html_tags(title)
	clean_9_0(title)
	title
end
if i
	if true
		puts "moo"
	elsif i < 3 * 23
		"sdf"
	else
		"df"
	end
end
class Tested
	def sadf
		"asdf"
	end
end

module Moo
	def t434t
		"352"
	end#comments at the end
end #comments again debug_if

=begin
block comments
    should have no formatting done
ever
=end

#java formatter test parts

ping(argument) {|block|

}

if (moo)
	cow;
else
	dog;
end

x = 5
x = 5
x = 5
x  =  5
IN_OUTS_RX = /^(def|class|module|begin|case|if|unless|loop|while|until|for)/

#end java formatter test parts

here_doc = <<-EOX
This should not
loose its formatting
EOX
dsfffffffff=[2, 3, 4, 5]
print <<-STRING1, <<-STRING2
Concat
STRING1
enate
STRING2

unless false
	"4"
else
	"5"
end
x = 2
while x > 0
	x -= 1
	if x == 1
		"p"
	else
		"3"
	end
end
x = 2
until x < 0
	x -= 1
end
a = 3
a *= 2 while a < 100
a -= 10 until a < 100
print "Hello\n" while false
print "Goodbye\n" while false
3.times do
	print "Ho! "
end
0.upto(9) do | x|
	print x, " "
end
0.step(12, 3) {|x | print x, " " }
x = 0
loop {
	if x == 5
		break
	end
	x += 1
}
(1..4).each {|x|
	puts x
}
(1..4).each do | x|
	puts x
end
for i in (1..4)
	puts i
end
i = 0
loop do
	i += 1
	next if i < 3
	print i
	break if i > 4
end
string = "x+1"
begin
	eval string
rescue SyntaxError, NameError => boom
	print "String doesn't compile: " + boom
rescue StandardError => bang
	print "Error running script: " + bang
ensure
	print "thank you pick axe"
end
a = "Fats ' ' \\\" do Waller"
a =~ /\/a/
if true then print "a" end
x = 3
unless  true then print "a" end
x = 3
begin raise "cow"
rescue Exception => e
end
x = 3
puts i += 1 while i < 3 # ruby
x = 3
klass = Fixnum
#its like a do while loop
begin
	print klass
	klass = klass.superclass
	print " < " if klass
end while klass
puts
p Fixnum.ancestors
boom = %q / this is a spinal tap/
boom = %q - string-
boom =%q(a (nested) string)
x = "done with string"

puts "In parent,term = #{ENV['TERM']}"
cow = if true
	"moot"
else
	"woot"
end

fork do
	puts "Start of child 1,term=#{ENV['TERM']}"
	ENV['TERM'] = "ansi"
	fork do
		puts "Start of child 2, term=#{ENV['TERM']}"
		begin
			if moo < 3
				p "asdf4"
			elsif 9 * 0
				p "asde"
			else
				puts cow
			end
		end	while x > 3
	end
	Process.wait
	puts "End of child 1, term=#{ENV['TERM']}"
end
Process.wait
puts "Back in parent, term=#{ENV['TERM']}"

OPENOFFICE = true  # do Openoffice - Spreadsheet Tests?
EXCEL      = true  # do Excel Tests?
GOOGLE     = true # do Google - Spreadsheet Tests?

OPENOFFICEWRITE = false # experimental:

END{
	puts "another block i have never seen"
}