File: highlight.rb

package info (click to toggle)
libsyntax-highlight-engine-kate-perl 0.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 3,848 kB
  • sloc: perl: 84,065; ruby: 176; asm: 166; cpp: 144; jsp: 128; haskell: 116; sh: 111; f90: 99; python: 98; ml: 75; xml: 43; yacc: 37; ansic: 32; tcl: 29; lisp: 24; makefile: 14; awk: 13; php: 5
file content (262 lines) | stat: -rw-r--r-- 5,431 bytes parent folder | download | duplicates (5)
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# This file is a testcase for the highlighting of Ruby code
# It's not executable code, but a collection of code snippets
#

require 'Config'
require 'DO/Clients'
require 'DO/DBClients'

  def CGI::escapeElement(string, *elements)
    elements = elements[0] if elements[0].kind_of?(Array)
    unless elements.empty?
      string.gsub(/<\/?(?:#{elements.join("|")})(?!\w)(?:.|\n)*?>/ni) do
        CGI::escapeHTML($&)
      end
    else
      string
    end
  end

case inputLine
  when "debug"
    dumpDebugInfo
    dumpSymbols
  when /p\s+(\w+)/
    dumpVariable($1)
  when "quit", "exit"
    exit
  else
    print "Illegal command: #{inputLine}"
end


kind = case year #hi there
         when 1850..1889 then "Blues"
         when 1940..1950 then "Bebop"
         else                 "Jazz"
       end

  # URL-encode a string.
  #   url_encoded_string = CGI::escape("'Stop!' said Fred")
  #      # => "%27Stop%21%27+said+Fred"
  def CGI::escape(string)
    string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
      '%' + $1.unpack('H2' * $1.size).join('%').upcase
    end.tr(' ', '+')
  end


# Class ClientManager
#
# definition : Import, store and export the various data used by the application.
# This class is the sole interface between the application and the underlying database.

mon, day, year = $1, $2, $3 if /(\d\d)-(\d\d)-(\d\d)/
puts "a = #{a}" if fDebug
print total unless total == 0

while gets
  next if /^#/            # Skip comments
  parseLine unless /^$/   # Don't parse empty lines
end

if artist == "John Coltrane" #hi there
  artist = "'Trane" #hi there
end unless nicknames == "no" #hi there

handle = if aSong.artist == "Gillespie" then #hi there
           "Dizzy"
         elsif aSong.artist == "Parker" then
           "Bird"
         else #hi there
           "unknown"
         end

if aSong.artist == "Gillespie" then  handle = "Dizzy"
elsif aSong.artist == "Parker" then  handle = "Bird"
else  handle = "unknown"
end #hi there


 case line
  when /title=(.*)/
    puts "Title is #$1"
  when /track=(.*)/
    puts "Track is #$1"
  when /artist=(.*)/
    puts "Artist is #$1"
end

case shape
  when Square, Rectangle
    # ...
  when Circle
    # ...
  when Triangle
    # ...
  else
    # ...
end 


until playList.duration > 60 #hi there
  playList.add(songList.pop)
end

3.times do
  print "Ho! "
end

loop {
  # block ...
}

songList.each do |aSong|
  aSong.play
end


i = 0
doUntil(i > 3) {
  print i, " "
  i += 1
}

def system_call
	# ... code which throws SystemCallError
rescue SystemCallError
	$stderr.print "IO failed: " + $!
	opFile.close
	File.delete(opName)
	raise
end

class ClientManager
	
	# constructor
	def initialize(dbase)
		@dbClient = DBClient.new(dbase)
		@clients = Clients.new
	end
	
	def prout(a, b, xy="jj") 24 end 
	###############################################################
	#
	# CLIENTS SECTION
	#
	###############################################################
	
	# update the clients object by retrieving the related data from the database
	# returns the number of clients
	def refreshClients
		@clients.clean
		unless @sqlQuery.nil? then
			@sqlQuery.selectClient.each do |row|
				@clients.addClient(row[0],row[1],row[2],row[3],row[4],row[5], row[6], row[7], row[8])
			end
		else
			puts "SqlQuery wasn't created : cannot read data from database"
		end
		return @clients.length
	end
	
end

  # Mixin module for HTML version 3 generation methods.
  module Html3 # :nodoc:

    # The DOCTYPE declaration for this version of HTML
    def doctype
      %|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">|
    end

    # Initialise the HTML generation methods for this version.
    def element_init
      extend TagMaker
      methods = ""
      # - -
      for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION tr
          th td ]
        methods += <<-BEGIN + nO_element_def(element) + <<-END
          def #{element.downcase}(attributes = {})
        BEGIN
          end
        END
      end
      eval(methods)
    end

  end

# following snippet from Webrick's log.rb

# test cases for general delimited input
# quoted strings
%Q|this is a string|
%Q{this is a string}
%Q(this is a string)
%Q<this is a string>
%Q[this is a string]

%|also a string|
%{also a string}
%(also a string)
%<also a string>
%[also a string]

# apostrophed strings
%q|apostrophed|
%q{apostrophed}
%q(apostrophed)
%q<apostrophed>
%q[apostrophed]

# regular expressions
%r{expression}
%r(expression)
%r<expression>
%r[expression]
%r|expression|

# shell commands
%x{ls -l}
%x(ls -l)
%x<ls -l>
%x[ls -l]

# sometimes it's useful to have the command on multiple lines
%x{ls -l |
grep test }

# token array
%w{one two three}
%w(one two three)
%w<one two three>
%w[one two three]

# snippet from Net::IMAP
# I object to putting String, Integer and Array into kernel methods.
# While these classes are builtin in Ruby, this is an implementation detail
# that should not be exposed to the user.
# If we want to handle all std-lib classes, fine. But then they should be in their
# own std-lib keyword category.

def send_data(data)
      case data
      when nil
        put_string("NIL")
      when String
        send_string_data(data)
      when Integer
        send_number_data(data)
      when Array
        send_list_data(data)
      when Time
        send_time_data(data)
      when Symbol
        send_symbol_data(data)
      else
        data.send_data(self)
      end
end