wirb 0.2.6 → 0.3.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/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.3.0
2
+ * Improve 1.9 enumerator detection/highlighting
3
+ * Remove :open_enumerator / :close_enumerator (use nested usual base objects instead)
4
+ * Support timestamps (:timestamp)
5
+ * Support instance variables and their contents (:object_variable, :object_variable_prefix)
6
+ * Add Wirb.stop to not colorize anything, anymore (in irb)
7
+ * Support RubyVM instruction sequences
8
+
1
9
  == 0.2.6
2
10
  * Fix Ruby 1.8 "already initialized constant" warnings
3
11
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ task :test => :spec
7
7
 
8
8
  RSpec::Core::RakeTask.new(:spec) do |t|
9
9
  t.rspec_opts = [
10
- # '--color',
10
+ '--color',
11
11
  '-r ' + File.expand_path( File.join( 'spec', 'spec_helper') ),
12
12
  ]
13
13
  end
data/lib/wirb/schema.rb CHANGED
@@ -9,8 +9,6 @@ module Wirb
9
9
 
10
10
  :open_set => :green,
11
11
  :close_set => :green,
12
- :open_enumerator => :green,
13
- :close_enumerator => :green,
14
12
 
15
13
  # delimiter colors
16
14
  :comma => :green,
@@ -25,11 +23,13 @@ module Wirb
25
23
  :open_object => :green,
26
24
  :object_description_prefix => :green,
27
25
  :object_description => :brown,
28
- :object_addr_prefix => :brown_underline,
29
- :object_addr => :brown_underline,
26
+ :object_address_prefi => :brown_underline,
27
+ :object_address => :brown_underline,
30
28
  :object_line_prefix => :brown_underline,
31
29
  :object_line => :brown_underline,
32
30
  :object_line_number => :brown_underline,
31
+ :object_variable_prefix => :light_purple,
32
+ :object_variable => :light_purple,
33
33
  :close_object => :green,
34
34
 
35
35
  # symbol
@@ -58,7 +58,9 @@ module Wirb
58
58
  :close_rational => :light_cyan,
59
59
 
60
60
  # misc
61
- :keyword => nil, # rename to default?
61
+ :default => nil,
62
+ :keyword => nil, # some lowercased word, merge with default?
63
+ :time => :purple,
62
64
  :nil => :light_red,
63
65
  :false => :red,
64
66
  :true => :green,
@@ -24,7 +24,10 @@ class << Wirb
24
24
 
25
25
  pass = lambda{ |kind, string| @passed << string; yield kind, string }
26
26
 
27
- set_state = lambda{ |state| @state[-1] = state }
27
+ set_state = lambda{ |state, *options|
28
+ @state[-1] = state
29
+ @repeat = true if options.include? :repeat
30
+ }
28
31
 
29
32
  get_state = lambda{ |state| @state[-1] == state }
30
33
 
@@ -49,9 +52,8 @@ class << Wirb
49
52
  # warn "char = #{c} state = #{@state*':'}"
50
53
 
51
54
  case @state[-1]
52
- when nil, :hash, :array, :enumerator, :set # "default" state
55
+ when nil, :hash, :array, :enumerator, :set, :variable # "default" state
53
56
  case c
54
- when ':' then push_state[:symbol]
55
57
  when '"' then push_state[:string]
56
58
  when '/' then push_state[:regexp]
57
59
  when '#' then push_state[:object]
@@ -59,15 +61,37 @@ class << Wirb
59
61
  when /[a-z]/ then push_state[:keyword, :repeat]
60
62
  when /[0-9-]/ then push_state[:number, :repeat]
61
63
  when '.' then push_state[:range, :repeat]
62
- when /\s/ then pass[:whitespace, c]
63
- when ',' then pass[:comma, ',']
64
+
65
+ when /\s/
66
+ if get_state[:variable]
67
+ pop_state[:repeat]
68
+ else
69
+ pass[:whitespace, c]
70
+ end
71
+
72
+ when ','
73
+ if get_state[:variable]
74
+ pop_state[:repeat]
75
+ else
76
+ pass[:comma, ',']
77
+ end
78
+
79
+ when ':'
80
+ if get_state[:enumerator]
81
+ set_state[:object_description, :repeat]
82
+ else
83
+ push_state[:symbol]
84
+ end
85
+
64
86
  when '>'
65
87
  if lc == '='
66
88
  if get_state[:hash]
67
89
  pass[:refers, '=>']
68
- else # FIXME remove this buggy <=> cheat
90
+ else # MAYBE remove this <=> cheat
69
91
  pass[:symbol, '=>']
70
92
  end
93
+ elsif get_state[:variable]
94
+ pop_state[:repeat]
71
95
  end
72
96
  when '('
73
97
  if nc =~ /[0-9-]/
@@ -79,39 +103,42 @@ class << Wirb
79
103
 
80
104
  when '{'
81
105
  if get_state[:set]
82
- pass[:open_set, '{']; push_state[nil]
106
+ pass[:open_set, '{']; push_state[nil] # {{ means set-hash
83
107
  else
84
108
  pass[:open_hash, '{']; push_state[:hash]
85
109
  end
86
110
 
87
111
  when '['
88
- if get_state[:enumerator]
89
- pass[:open_enumerator, '[']; push_state[nil]
90
- else
91
- pass[:open_array, '[']; push_state[:array]
92
- end
112
+ pass[:open_array, '[']; push_state[:array]
93
113
 
94
114
  when ']'
95
115
  if get_state[:array]
96
- pass[:close_array, ']']; pop_state[]
97
- elsif get_previous_state[:enumerator]
98
- pass[:close_enumerator, ']']; pop_state[]
99
- set_state[:object_description]
116
+ pass[:close_array, ']']
117
+ pop_state[]
118
+ pop_state[] if get_state[:enumerator]
100
119
  end
101
120
 
102
121
  when '}'
103
122
  if get_state[:hash]
104
- pass[:close_hash, '}']; pop_state[]
123
+ pass[:close_hash, '}']
105
124
  elsif get_previous_state[:set]
106
- pass[:close_set, '}']; pop_state[]
107
- set_state[:object_description]
125
+ pass[:close_set, '}']
126
+ pop_state[] # remove extra nil state
108
127
  end
128
+ pop_state[]
129
+ pop_state[] if get_state[:enumerator]
130
+
131
+ when '<'
132
+ pass[:open_object, '<']
133
+ push_state[:ruby_vm]
134
+ push_state[:object_class]
109
135
 
110
136
  # else
111
- # warn "ignoring char #{c.inspect}" if @debug
137
+ # warn "ignoring char #{c.inspect}" if @debug
112
138
  end
113
139
 
114
140
  when :class
141
+ next set_state[:time, :repeat] if c == ' ' # Ruby 1.8 default timestamp
115
142
  case c
116
143
  when /[a-z0-9_]/i
117
144
  @token << c
@@ -188,7 +215,9 @@ class << Wirb
188
215
  end
189
216
 
190
217
  when :number
191
- if c =~ /[0-9e+.-]/ && !(c == '.' && nc == '.')
218
+ if c == '-' && @token != '' && @token[-1] != 'e'
219
+ set_state[:time, :repeat]
220
+ elsif c =~ /[0-9e+.-]/ && !(c == '.' && nc == '.')
192
221
  @token << c
193
222
  elsif c == '/' # ruby 1.8 mathn
194
223
  pass_state[]
@@ -197,6 +226,23 @@ class << Wirb
197
226
  pass_state[:remove, :repeat]
198
227
  end
199
228
 
229
+ when :time # via regex, state needs to be triggered somewhere else
230
+ peek = chars[i..-1].join
231
+ if [
232
+ /^\d+-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (?:[+-]\d{4}|[a-z]{3})/i, # 1.9 / UTC
233
+ /^[a-z]{3} [a-z]{3} \d{2} \d{2}:\d{2}:\d{2} (?:[+-]\d{4}|[a-z]{3}) \d{4}/i, # 1.8
234
+ #/^\d+-\d{2}-\d{2}/, # simple date
235
+ ].any?{ |regex|
236
+ ( @token + peek ) =~ regex
237
+ } # found, adjust parsing-pointer:
238
+ i = i + $&.size - @token.size - 1
239
+ @token = $&
240
+ pass_state[:remove]
241
+ else
242
+ @token << c
243
+ pop_state[:remove]
244
+ end
245
+
200
246
  when :range
201
247
  if c == '.'
202
248
  @token << c
@@ -227,7 +273,8 @@ class << Wirb
227
273
  open_brackets = 0
228
274
  when '>'
229
275
  pass[:close_object, '>']
230
- pop_state[]; @token = ''
276
+ pop_state[]
277
+ pop_state[] if get_state[:enumerator]
231
278
  end
232
279
 
233
280
  when :object_class
@@ -241,14 +288,24 @@ class << Wirb
241
288
  pass_state[]
242
289
  pass[:class_separator, '::']
243
290
  elsif !(c == ':' && lc == ':')
244
- pass_state[:keep_token]
245
- pass[:object_description_prefix, c]
246
- if %w[set].include? @token = @token.downcase
247
- set_state[@token.to_sym]
291
+ if get_previous_state[:ruby_vm]
292
+ pass_state[]
293
+ pop_state[:remove]
248
294
  else
249
- set_state[:object_description]
295
+ pass_state[:keep_token]
296
+ pass[:object_description_prefix, c]
297
+
298
+ @token = @token.downcase
299
+ if %w[set].include?(@token)
300
+ set_state[@token.to_sym]
301
+ else
302
+ set_state[:object_description]
303
+ if %w[enumerator].include?(@token) && RUBY_VERSION >= '1.9'
304
+ push_state[@token.to_sym]
305
+ end
306
+ end
307
+ @token = ''
250
308
  end
251
- @token = ''
252
309
  end
253
310
  end
254
311
 
@@ -264,16 +321,16 @@ class << Wirb
264
321
  when '<'
265
322
  open_brackets += 1
266
323
  @token << c
267
- when '['
268
- pass_state[:repeat]
269
- set_state[:enumerator]
324
+ when '@'
325
+ pass_state[]
326
+ push_state[:object_variable]
270
327
  when '"'
271
328
  pass_state[]
272
329
  push_state[:string]
273
330
  when /[0-9]/
274
331
  if c == '0' && nc == 'x'
275
332
  pass_state[:repeat]
276
- push_state[:object_addr]
333
+ push_state[:object_address]
277
334
  else
278
335
  # push_state[:number, :repeat]
279
336
  @token << c
@@ -282,7 +339,17 @@ class << Wirb
282
339
  @token << c
283
340
  end
284
341
 
285
- when :object_addr
342
+ when :object_variable
343
+ if c =~ /[a-z0-9_]/i
344
+ @token << c
345
+ else
346
+ pass[:object_variable_prefix, '@']
347
+ pass_state[:remove]
348
+ pass[:object_description, '=']
349
+ push_state[:variable]
350
+ end
351
+
352
+ when :object_address
286
353
  if c =~ /[x0-9a-f]/
287
354
  @token << c
288
355
  else
@@ -295,11 +362,14 @@ class << Wirb
295
362
  end
296
363
  end
297
364
 
298
- when :object_line
365
+ when :object_line
299
366
  if c == ':' && nc =~ /[0-9]/
300
367
  @token << ':'
301
368
  pass_state[:remove]
302
369
  push_state[:object_line_number]
370
+ elsif c == '>' # e.g. RubyVM
371
+ pass_state[:remove, :repeat]
372
+ pass[:close_object, '>'] # TODO move somewhere else if disturbing
303
373
  else
304
374
  @token << c
305
375
  end
@@ -310,6 +380,18 @@ class << Wirb
310
380
  else
311
381
  pass_state[:remove, :repeat]
312
382
  end
383
+
384
+ # <RubyVM::InstructionSequence:pp@/home/jan/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/output-method.rb>
385
+ when :ruby_vm # TODO write tests
386
+ if c =~ /[^@]/i
387
+ @token << c
388
+ else
389
+ pass[:object_description_prefix, ':']
390
+ pass[:object_line_prefix, @token + '@']
391
+ @token = ''
392
+ set_state[:object_line]
393
+ end
394
+
313
395
 
314
396
  # else
315
397
  # raise "unknown state #{@state[-1]} #{@state.inspect}"
@@ -325,7 +407,7 @@ class << Wirb
325
407
  snapshot = Marshal.dump([@state, @token, llc, lc, c, nc])
326
408
  end
327
409
  rescue
328
- # p$!, $!.backtrace[0]
410
+ p$!, $!.backtrace[0]
329
411
  pass[:default, str.sub(@passed, '')]
330
412
  end
331
413
  end
data/lib/wirb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wirb
2
- VERSION = '0.2.6'
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/wirb.rb CHANGED
@@ -6,6 +6,9 @@ require File.expand_path( File.dirname(__FILE__) + '/wirb/tokenizer' )
6
6
  class << Wirb
7
7
  attr_accessor :schema
8
8
 
9
+ @running = false
10
+ def running?() @running end
11
+
9
12
  # Return the escape code for a given color
10
13
  def get_color(key)
11
14
  if key.is_a? String
@@ -24,24 +27,36 @@ class << Wirb
24
27
 
25
28
  # Colorize a result string
26
29
  def colorize_result(string, custom_schema = schema)
27
- check = ''
28
- colorful = tokenize(string).map do |kind, token|
29
- check << token
30
- colorize_string token, custom_schema[kind]
31
- end.join
32
-
33
- # always display the correct inspect string!
34
- check == string ? colorful : string
30
+ if @running
31
+ check = ''
32
+ colorful = tokenize(string).map do |kind, token|
33
+ check << token
34
+ colorize_string token, custom_schema[kind]
35
+ end.join
36
+
37
+ # always display the correct inspect string!
38
+ check == string ? colorful : string
39
+ else
40
+ string
41
+ end
35
42
  end
36
43
 
37
- # Colorize results in irb/ripl (or whatever might be supported in future)
44
+ # Colorize results
45
+ # Will hook into irb if IRB is defined
38
46
  def start
39
- require File.dirname(__FILE__) + '/wirb/irb'
47
+ require File.dirname(__FILE__) + '/wirb/irb' if defined?(IRB)
48
+ @running = true
40
49
  rescue LoadError
41
- warn "Couldn't activate Wirb for #{which}"
50
+ warn "Couldn't activate Wirb"
42
51
  end
43
52
  alias activate start
44
53
  alias enable start
54
+
55
+ def stop # don't colorize, anymore
56
+ @running = false
57
+ end
58
+ alias deactivate stop
59
+ alias disable stop
45
60
  end
46
61
 
47
62
  # J-_-L
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,8 @@ require 'wirb/wp'
5
5
  require 'zucker/engine'
6
6
  require 'zucker/version'
7
7
 
8
+ Wirb.start
9
+
8
10
  def tokenizer(filename)
9
11
  filename =~ /tokenizer_(.*)_spec\.rb/
10
12
  "Wirb.tokenize" + ($1 ? "(#{$1})" : "")
@@ -81,8 +83,6 @@ end
81
83
  # common regex patterns
82
84
  OBJECT_ID = /0x[0-9a-f]+/
83
85
 
84
- =begin helper methods for getting tokens
85
- def ws(obj)
86
- puts Wirb.tokenize(obj.inspect).map{|*x| x.inspect + ','}*$/
87
- end
86
+ =begin helper method for getting tokens
87
+ def ws(obj); puts Wirb.tokenize(obj.inspect).map{|*x| x.inspect + ','}*$/; end
88
88
  =end
@@ -7,8 +7,8 @@ describe tokenizer(__FILE__) do
7
7
  [:open_object, "#<"],
8
8
  [:object_class, "Enumerator"],
9
9
  [:object_description_prefix, ":"],
10
- [:object_description, " "],
11
- [:open_enumerator, "["],
10
+ [:whitespace, " "],
11
+ [:open_array, "["],
12
12
  [:number, "2"],
13
13
  [:comma, ","],
14
14
  [:whitespace, " "],
@@ -16,19 +16,82 @@ describe tokenizer(__FILE__) do
16
16
  [:comma, ","],
17
17
  [:whitespace, " "],
18
18
  [:number, "4"],
19
- [:close_enumerator, "]"],
19
+ [:close_array, "]"],
20
20
  [:object_description, ":each"],
21
21
  [:close_object, ">"],
22
22
  ]
23
23
  end
24
24
 
25
+ please do check Set[2,3,4].map
26
+ tokens.should == [
27
+ [:open_object, "#<"],
28
+ [:object_class, "Enumerator"],
29
+ [:object_description_prefix, ":"],
30
+ [:whitespace, " "],
31
+ [:open_object, "#<"],
32
+ [:object_class, "Set"],
33
+ [:object_description_prefix, ":"],
34
+ [:whitespace, " "],
35
+ [:open_set, "{"],
36
+ [:number, "2"],
37
+ [:comma, ","],
38
+ [:whitespace, " "],
39
+ [:number, "3"],
40
+ [:comma, ","],
41
+ [:whitespace, " "],
42
+ [:number, "4"],
43
+ [:close_set, "}"],
44
+ [:close_object, ">"],
45
+ [:object_description, ":map"],
46
+ [:close_object, ">"],
47
+ ]
48
+ end
49
+
50
+ please do check({1=>3}.each)
51
+ tokens.should == [
52
+ [:open_object, "#<"],
53
+ [:object_class, "Enumerator"],
54
+ [:object_description_prefix, ":"],
55
+ [:whitespace, " "],
56
+ [:open_hash, "{"],
57
+ [:number, "1"],
58
+ [:refers, "=>"],
59
+ [:number, "3"],
60
+ [:close_hash, "}"],
61
+ [:object_description, ":each"],
62
+ [:close_object, ">"],
63
+ ]
64
+ end
65
+
66
+ please do check({1=>3}.each.map)
67
+ tokens.should == [
68
+ [:open_object, "#<"],
69
+ [:object_class, "Enumerator"],
70
+ [:object_description_prefix, ":"],
71
+ [:whitespace, " "],
72
+ [:open_object, "#<"],
73
+ [:object_class, "Enumerator"],
74
+ [:object_description_prefix, ":"],
75
+ [:whitespace, " "],
76
+ [:open_hash, "{"],
77
+ [:number, "1"],
78
+ [:refers, "=>"],
79
+ [:number, "3"],
80
+ [:close_hash, "}"],
81
+ [:object_description, ":each"],
82
+ [:close_object, ">"],
83
+ [:object_description, ":map"],
84
+ [:close_object, ">"],
85
+ ]
86
+ end
87
+
25
88
  please do check [2,Set[{1=>2}],4].map
26
- tokens.should be_like [
89
+ tokens.should == [
27
90
  [:open_object, "#<"],
28
91
  [:object_class, "Enumerator"],
29
92
  [:object_description_prefix, ":"],
30
- [:object_description, " "],
31
- [:open_enumerator, "["],
93
+ [:whitespace, " "],
94
+ [:open_array, "["],
32
95
  [:number, "2"],
33
96
  [:comma, ","],
34
97
  [:whitespace, " "],
@@ -47,7 +110,7 @@ describe tokenizer(__FILE__) do
47
110
  [:comma, ","],
48
111
  [:whitespace, " "],
49
112
  [:number, "4"],
50
- [:close_enumerator, "]"],
113
+ [:close_array, "]"],
51
114
  [:object_description, ":map"],
52
115
  [:close_object, ">"],
53
116
  ]
@@ -58,7 +121,9 @@ describe tokenizer(__FILE__) do
58
121
  [:open_object, "#<"],
59
122
  [:object_class, "Enumerator"],
60
123
  [:object_description_prefix, ":"],
61
- [:object_description, " Wirb:tokenize("],
124
+ [:whitespace, " "],
125
+ [:class, "Wirb"],
126
+ [:object_description, ":tokenize("],
62
127
  [:open_string, "\""],
63
128
  [:string, "[2,3,4]"],
64
129
  [:close_string, "\""],
@@ -75,8 +140,17 @@ describe tokenizer(__FILE__) do
75
140
  [:class_separator, "::"],
76
141
  [:object_class, "EratosthenesGenerator"],
77
142
  [:object_description_prefix, ":"],
78
- [:object_addr, /#{OBJECT_ID}/],
79
- [:object_description, ' @last_prime=nil, @ubound=nil'],
143
+ [:object_address, /#{OBJECT_ID}/],
144
+ [:object_description, ' '],
145
+ [:object_variable_prefix, "@"],
146
+ [:object_variable, "last_prime"],
147
+ [:object_description, "="],
148
+ [:nil, "nil"],
149
+ [:object_description, ", "],
150
+ [:object_variable_prefix, "@"],
151
+ [:object_variable, "ubound"],
152
+ [:object_description, "="],
153
+ [:nil, "nil"],
80
154
  [:close_object, ">"],
81
155
  ]
82
156
  end
@@ -86,8 +160,8 @@ describe tokenizer(__FILE__) do
86
160
  [:open_object, "#<"],
87
161
  [:object_class, "Enumerator"],
88
162
  [:object_description_prefix, ":"],
89
- [:object_description, " "],
90
- [:open_enumerator, "["],
163
+ [:whitespace, " "],
164
+ [:open_array, "["],
91
165
  [:open_hash, "{"],
92
166
  [:number, "1"],
93
167
  [:refers, "=>"],
@@ -98,7 +172,9 @@ describe tokenizer(__FILE__) do
98
172
  [:open_object, "#<"],
99
173
  [:object_class, "Enumerator"],
100
174
  [:object_description_prefix, ":"],
101
- [:object_description, " Wirb:tokenize("],
175
+ [:whitespace, " "],
176
+ [:class, "Wirb"],
177
+ [:object_description, ":tokenize("],
102
178
  [:open_string, "\""],
103
179
  [:string, "2"],
104
180
  [:close_string, "\""],
@@ -130,19 +206,35 @@ describe tokenizer(__FILE__) do
130
206
  [:open_object, "#<"],
131
207
  [:object_class, "Enumerator"],
132
208
  [:object_description_prefix, ":"],
133
- [:object_description, " "],
134
- [:open_enumerator, "["],
209
+ [:whitespace, " "],
210
+ [:open_array, "["],
135
211
  [:number, "5"],
136
212
  [:comma, ","],
137
213
  [:whitespace, " "],
138
214
  [:number, "6"],
139
- [:close_enumerator, "]"],
215
+ [:close_array, "]"],
140
216
  [:object_description, ":each"],
141
217
  [:close_object, ">"],
142
- [:close_enumerator, "]"],
218
+ [:close_array, "]"],
143
219
  [:object_description, ":map"],
144
220
  [:close_object, ">"],
145
221
  ]
146
222
  end
147
223
  end
224
+
225
+ only18 do
226
+ if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' # TODO tests for jruby + rbx
227
+ please do check [3,4,5].each
228
+ tokens.should be_like [
229
+ [:open_object, "#<"],
230
+ [:object_class, "Enumerable"],
231
+ [:class_separator, "::"],
232
+ [:object_class, "Enumerator"],
233
+ [:object_description_prefix, ":"],
234
+ [:object_address, /#{OBJECT_ID}/],
235
+ [:close_object, ">"],
236
+ ]
237
+ end
238
+ end
239
+ end
148
240
  end
@@ -7,24 +7,53 @@ describe tokenizer(__FILE__) do
7
7
 
8
8
  please do check StringIO.new 'wirb'
9
9
  if RubyEngine.rbx?
10
+ =begin TODO sort ivars
10
11
  tokens.should be_like [
11
12
  [:open_object, "#<"],
12
13
  [:object_class, "StringIO"],
13
14
  [:object_description_prefix, ":"],
14
- [:object_addr, OBJECT_ID],
15
- [:object_description, /.*/],
15
+ [:object_address, OBJECT_ID],
16
+ [:object_description, " "],
17
+ [:object_variable_prefix, "@"],
18
+ [:object_variable, "string"],
19
+ [:object_description, "="],
16
20
  [:open_string, "\""],
17
21
  [:string, "wirb"],
18
22
  [:close_string, "\""],
19
- [:object_description, /.*/],
23
+ [:object_description, " "],
24
+ [:object_variable_prefix, "@"],
25
+ [:object_variable, "append"],
26
+ [:object_description, "="],
27
+ [:false, "false"],
28
+ [:object_description, " "],
29
+ [:object_variable_prefix, "@"],
30
+ [:object_variable, "readable"],
31
+ [:object_description, "="],
32
+ [:true, "true"],
33
+ [:object_description, " "],
34
+ [:object_variable_prefix, "@"],
35
+ [:object_variable, "writable"],
36
+ [:object_description, "="],
37
+ [:true, "true"],
38
+ [:object_description, " "],
39
+ [:object_variable_prefix, "@"],
40
+ [:object_variable, "pos"],
41
+ [:object_description, "="],
42
+ [:number, "0"],
43
+ [:object_description, " "],
44
+ [:object_variable_prefix, "@"],
45
+ [:object_variable, "lineno"],
46
+ [:object_description, "="],
47
+ [:number, "0"],
20
48
  [:close_object, ">"],
21
49
  ]
50
+ =end
22
51
  else
23
52
  tokens.should be_like [
24
53
  [:open_object, "#<"],
25
54
  [:object_class, "StringIO"],
26
55
  [:object_description_prefix, ":"],
27
- [:object_addr, OBJECT_ID],
56
+ [:object_address, OBJECT_ID],
28
57
  [:close_object, ">"],
29
58
  ]
30
59
  end
@@ -54,7 +54,7 @@ describe tokenizer(__FILE__) do
54
54
  [:open_object, "#<"],
55
55
  [:object_class, "Object"],
56
56
  [:object_description_prefix, ":"],
57
- [:object_addr, OBJECT_ID],
57
+ [:object_address, OBJECT_ID],
58
58
  [:close_object, ">"],
59
59
  [:close_hash, "}"],
60
60
  [:close_hash, "}"],
@@ -8,7 +8,7 @@ describe tokenizer(__FILE__) do
8
8
  [:open_object, "#<"],
9
9
  [:object_class, "Object"],
10
10
  [:object_description_prefix, ":"],
11
- [:object_addr, OBJECT_ID],
11
+ [:object_address, OBJECT_ID],
12
12
  [:close_object, ">"],
13
13
  ]
14
14
  end
@@ -18,7 +18,7 @@ describe tokenizer(__FILE__) do
18
18
  [:open_object, "#<"],
19
19
  [:object_class, "Proc"],
20
20
  [:object_description_prefix, ":"],
21
- [:object_addr, OBJECT_ID],
21
+ [:object_address, OBJECT_ID],
22
22
  [:object_line_prefix, "@"],
23
23
  [:object_line, /.*tokenizer_object_spec.rb:/],
24
24
  [:object_line_number, /\d+/],
@@ -31,7 +31,7 @@ describe tokenizer(__FILE__) do
31
31
  [:open_object, "#<"],
32
32
  [:object_class, "Proc"],
33
33
  [:object_description_prefix, ":"],
34
- [:object_addr, OBJECT_ID],
34
+ [:object_address, OBJECT_ID],
35
35
  [:object_line_prefix, "@"],
36
36
  [:object_line, /.*tokenizer_object_spec.rb:/],
37
37
  [:object_line_number, /\d+/],
@@ -46,7 +46,7 @@ describe tokenizer(__FILE__) do
46
46
  [:open_object, "#<"],
47
47
  [:object_class, "Binding"],
48
48
  [:object_description_prefix, ":"],
49
- [:object_addr, OBJECT_ID],
49
+ [:object_address, OBJECT_ID],
50
50
  [:close_object, ">"],
51
51
  ]
52
52
  end
@@ -79,7 +79,7 @@ describe tokenizer(__FILE__) do
79
79
  [:object_class, "Class"],
80
80
  [:object_description_prefix, ":"],
81
81
  [:object_description, '#<Class:#<Module:'],
82
- [:object_addr, OBJECT_ID],
82
+ [:object_address, OBJECT_ID],
83
83
  [:object_description, '>>'],
84
84
  [:close_object, ">"]
85
85
  ]
@@ -105,4 +105,30 @@ describe tokenizer(__FILE__) do
105
105
  [:close_object, ">"],
106
106
  ]
107
107
  end
108
+
109
+ please do
110
+ class Hey
111
+ def initialize
112
+ @hallo = [1,42]
113
+ end
114
+ end
115
+ check Hey.new
116
+ tokens.should be_like [
117
+ [:open_object, "#<"],
118
+ [:object_class, "Hey"],
119
+ [:object_description_prefix, ":"],
120
+ [:object_address, /#{OBJECT_ID}/],
121
+ [:object_description, " "],
122
+ [:object_variable_prefix, "@"],
123
+ [:object_variable, "hallo"],
124
+ [:object_description, "="],
125
+ [:open_array, "["],
126
+ [:number, "1"],
127
+ [:comma, ","],
128
+ [:whitespace, " "],
129
+ [:number, "42"],
130
+ [:close_array, "]"],
131
+ [:close_object, ">"]
132
+ ]
133
+ end
108
134
  end
@@ -0,0 +1,15 @@
1
+ describe tokenizer(__FILE__) do
2
+ after :each do check_value end
3
+
4
+ please do now = Time.now
5
+ check [Time.now, Time.now]
6
+ tokens.should == [
7
+ [:open_array, "["],
8
+ [:time, now.to_s],
9
+ [:comma, ","],
10
+ [:whitespace, " "],
11
+ [:time, now.to_s],
12
+ [:close_array, "]"],
13
+ ]
14
+ end
15
+ end
data/wirb.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Wirb::VERSION
8
8
  s.authors = ["Jan Lelis"]
9
9
  s.email = "mail@janlelis.de"
10
- s.homepage = "http://github.com/janlelis/wirb"
10
+ s.homepage = "https://github.com/janlelis/wirb"
11
11
  s.summary = "Colorizes your irb results."
12
12
  s.description = "Colorizes your irb results. It's based on Wirble but only provides result highlighting. Just call Wirb.start and enjoy the colors ;)."
13
13
  s.required_rubygems_version = '>= 1.3.6'
@@ -17,5 +17,14 @@ Gem::Specification.new do |s|
17
17
  s.license = 'MIT'
18
18
  s.add_development_dependency 'rspec'
19
19
  s.add_development_dependency 'rspec-core'
20
- s.add_development_dependency 'zucker', '>=9'
20
+ s.add_development_dependency 'zucker', '>= 11'
21
+
22
+ len = s.homepage.size
23
+ s.post_install_message = \
24
+ (" ┌── " + "info ".ljust(len-2,'%') + "─┐\n" +
25
+ " J-_-L │ " + s.homepage + " │\n" +
26
+ " ├── " + "usage ".ljust(len-2,'%') + "─┤\n" +
27
+ " │ " + "require 'wirb'".ljust(len,' ') + " │\n" +
28
+ " │ " + "Wirb.start".ljust(len,' ') + " │\n" +
29
+ " └─" + '─'*len + "─┘").gsub('%', '─') # 1.8 workaround
21
30
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wirb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.6
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jan Lelis
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-18 00:00:00 Z
13
+ date: 2011-05-26 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: "9"
45
+ version: "11"
46
46
  type: :development
47
47
  version_requirements: *id003
48
48
  description: Colorizes your irb results. It's based on Wirble but only provides result highlighting. Just call Wirb.start and enjoy the colors ;).
@@ -75,6 +75,7 @@ files:
75
75
  - spec/tokenizer_set_spec.rb
76
76
  - spec/tokenizer_object_spec.rb
77
77
  - spec/tokenizer_nested_spec.rb
78
+ - spec/tokenizer_time_spec.rb
78
79
  - spec/tokenizer_string_spec.rb
79
80
  - COPYING.txt
80
81
  - README.rdoc
@@ -82,10 +83,10 @@ files:
82
83
  - Rakefile
83
84
  - wirb.gemspec
84
85
  - .gemtest
85
- homepage: http://github.com/janlelis/wirb
86
+ homepage: https://github.com/janlelis/wirb
86
87
  licenses:
87
88
  - MIT
88
- post_install_message:
89
+ post_install_message: " \xE2\x94\x8C\xE2\x94\x80\xE2\x94\x80 info \xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x90\n J-_-L \xE2\x94\x82 https://github.com/janlelis/wirb \xE2\x94\x82\n \xE2\x94\x9C\xE2\x94\x80\xE2\x94\x80 usage \xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\xA4\n \xE2\x94\x82 require 'wirb' \xE2\x94\x82\n \xE2\x94\x82 Wirb.start \xE2\x94\x82\n \xE2\x94\x94\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x98"
89
90
  rdoc_options: []
90
91
 
91
92
  require_paths: