wirb 2.2.2 → 3.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bb7682a36323e7f6091949c181a0d0dba6749959d8fe8722786c78f68b4b965
4
- data.tar.gz: b09786d2784b0bfffa33a2106537a756ae442b79495accfe5038e42ca6e0573d
3
+ metadata.gz: 3bad0568e8c6cdae110f6c5c0bb966199fcb8e0b07a70661798f70b935eb2aa9
4
+ data.tar.gz: b18ff8d1e52c62b9b98bc4dd6711c04854ffa0035623ca1fd97edb61ddd3cd99
5
5
  SHA512:
6
- metadata.gz: cde9e32b55bdcb44d9f8b39211198aa426ef7c23b0e95bea38dddf0cbd6ea2a13531a07687f753a32201dd91f6eeed5d18ded3dd9e9df27892e5530fc92a38f9
7
- data.tar.gz: 387112604206f5727d2df2689efc2077e642eefc467242523f1b7caa12d6d3f1bfd7683b88acc90de6eb4716c4453c3770593d4cd7200c3fc8783da740b302f5
6
+ metadata.gz: 280a3023dbcc80524f36a56099518697cbba22c7f004b038610e506ed0ad19798992eb063f1c71952124d9b35be9fdeec9b6ed17a00f891361615c53312739e2
7
+ data.tar.gz: 70a538972df7321bd79d88366217e48f9ba4175b35e70fef45d8fb65ba2f116b018991449038d920cca026add3039a4deaa5098ed27da040594f68b9ed3cd3a8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # Change Log
2
+
3
+ ## 3.0.0
4
+ * Require Ruby 3
5
+ * Relax Ruby version requirement to allow Ruby 4.0
6
+ * Support Ruby 3.4 hash inspects
7
+ * Support Ruby 4.0 concise set syntax
8
+
1
9
  ## 2.2.2
2
10
  * Relax Ruby version requirement to allow 3.0
3
11
 
@@ -95,7 +103,7 @@
95
103
  * Fix stupid rescue bug (no more wirb crashes)
96
104
 
97
105
  ## 0.2.3 / 0.2.4
98
- * Support for rubygems-test <gem-testers.org>
106
+ * Support for rubygems-test
99
107
 
100
108
  ## 0.2.2
101
109
  * Always return inspected string (even when errors happen) and endless-loop
data/COPYING.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2011-2020 Jan Lelis <https://janlelis.com>
1
+ Copyright (C) 2011-2025 Jan Lelis <https://janlelis.com>
2
2
  Copyright (C) 2006-2009 Paul Duncan <pabs@pablotron.org>
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a
data/README.md CHANGED
@@ -1,19 +1,16 @@
1
1
  ## WIRB Interactive Ruby [![version](https://badge.fury.io/rb/wirb.svg)](https://badge.fury.io/rb/wirb) [<img src="https://github.com/janlelis/wirb/workflows/Test/badge.svg" />](https://github.com/janlelis/wirb/actions?query=workflow%3ATest)
2
2
 
3
- The **WIRB** gem syntax highlights Ruby objects. Works best as your default REPL inspector (see usage section below), but does not require IRB.
3
+ The **WIRB** gem adds syntax highlighting to inspected Ruby objects. It covers core Ruby classes/modules and most of standard library. Works best as your default REPL inspector, but also works without IRB.
4
4
 
5
- Supported Rubies: 3.0, 2.7, 2.6, 2.5
5
+ Supports Ruby 3.x and 4.0.
6
6
 
7
- Older Rubies, should work: 2.4, 2.3, 2.2, 2.1, 2.0, rubinius
8
-
9
- Ancient Rubies (1.9, 1.8): Please use [WIRB 1.0](https://github.com/janlelis/wirb/tree/1.0.3)
7
+ Please note that WIRB also works well for Ruby 1 and Ruby 2 - just install the latest WIRB version possible to install.
10
8
 
11
9
  ## Features
12
10
 
13
11
  * Syntax highlighting for inspected Ruby objects
14
- * No monkey patches anywhere
15
12
  * Support for generic objects, especially enumerators, and nested generic objects
16
- * Supports common standard library objects, like `Set`
13
+ * Supports common standard library objects
17
14
  * Color schemas customizable via YAML
18
15
 
19
16
  ## Install
@@ -37,15 +34,17 @@ To activate WIRB permanently, you can add this to the `~/.irbrc` file:
37
34
  require 'wirb'
38
35
  Wirb.start
39
36
 
40
- Another way would be to use [Irbtools](https://irb.tools), which activate WIRB automatically.
37
+ Another way would be to use [Irbtools](https://github.com/janlelis/irbtools), which activates WIRB automatically.
41
38
 
42
39
  ## `Kernel#wp`
43
40
 
44
- WIRB comes with a pretty printing utility (similar to awesome_print):
41
+ WIRB comes with a pretty printing utility:
45
42
 
46
43
  require 'wirb/wp'
47
44
  wp some_object
48
45
 
46
+ Other than similar tools like *pp* or *awesome_print*, it will not change the format the highlighted objects by adding whitespace, but only adds colors.
47
+
49
48
  ### Bundled Schemas
50
49
 
51
50
  These are the bundled color schemas. You can load one with `Wirb.load_schema(:name)`
@@ -54,20 +53,15 @@ These are the bundled color schemas. You can load one with `Wirb.load_schema(:na
54
53
  * `:colorless` (only uses :bright, :underline and :inverse effect)
55
54
  * `:ultra` (by @venantius, matches the colorscheme from [Ultra](https://github.com/venantius/ultra) over in Clojure-land)
56
55
 
57
- ### Usage with Rails
58
-
59
- If you run into problems using WIRB with Rails, try [the solution in this issue](https://github.com/janlelis/wirb/issues/12#issuecomment-249492524).
60
56
 
61
57
  ## Also See
62
58
 
63
- * Gem that allows you to configure views for specific objects:
64
- [hirb](https://github.com/cldwalker/hirb)
65
59
  * WIRB is part of: [Irbtools](https://github.com/janlelis/irbtools)
66
60
  * More about terminal colors: [Paint](https://github.com/janlelis/paint)
67
61
 
68
62
  ## Credits
69
63
 
70
- Copyright (c) 2011-2020 Jan Lelis <https://janlelis.com> see COPYING for details.
64
+ Copyright (c) 2011-2025 Jan Lelis <https://janlelis.com> see COPYING for details.
71
65
 
72
66
  First tokenizer version was based on the [wirble](https://rubygems.org/gems/wirble) gem:
73
67
  Copyright (C) 2006-2009 Paul Duncan <pabs@pablotron.org>
data/Rakefile CHANGED
@@ -35,3 +35,11 @@ task :gemspec do
35
35
  gemspec.validate
36
36
  end
37
37
 
38
+
39
+ # # #
40
+ # Start an IRB session using WIRB as inspector
41
+
42
+ desc "#{gemspec.name} | wIRB"
43
+ task :irb do
44
+ sh "irb -f -I ./lib -r #{gemspec.name.gsub '-','/'} --inspect wirb"
45
+ end
@@ -9,12 +9,12 @@ module Wirb
9
9
 
10
10
  schema = normalize_schema(schema_yaml)
11
11
  schema[:name] = schema_name.to_sym
12
- schema
12
+ schema.freeze
13
13
  end
14
14
 
15
15
  def self.resolve_schema_yaml(yaml_path)
16
16
  if yaml_path.is_a? Symbol # bundled themes
17
- datadir = Gem.loaded_specs['wirb'].datadir
17
+ datadir = File.expand_path(File.dirname(__FILE__) + "/../../data/wirb/").freeze
18
18
  [yaml_path.to_s, YAML.load_file(File.join(datadir, "#{yaml_path}.yml"))]
19
19
  else
20
20
  [File.basename(yaml_path).gsub(/\.yml$/, ''), YAML.load_file(yaml_path)]
@@ -58,14 +58,29 @@ module Wirb
58
58
  case @state[-1]
59
59
  when nil, :hash, :array, :enumerator, :set, :variable # default state
60
60
  case c
61
- when '"' then push_state[:string]
62
- when '/' then push_state[:regexp]
63
- when '#' then push_state[:object]
64
- when /[A-Z]/ then push_state[:class, :repeat]
65
- when /[a-z]/ then push_state[:word, :repeat]
66
- when /[0-9-]/ then push_state[:number, :repeat]
67
- when '.' then push_state[:range, :repeat]
68
- when /\=/ then push_state[:equal, :repeat]
61
+ when '"'
62
+ push_state[:string]
63
+
64
+ when '/'
65
+ push_state[:regexp]
66
+
67
+ when '#'
68
+ push_state[:object]
69
+
70
+ when /[A-Z]/
71
+ push_state[:class, :repeat]
72
+
73
+ when /[a-z]/
74
+ push_state[:word, :repeat]
75
+
76
+ when /[0-9-]/
77
+ then push_state[:number, :repeat]
78
+
79
+ when '.'
80
+ push_state[:range, :repeat]
81
+
82
+ when /\=/
83
+ push_state[:equal, :repeat]
69
84
 
70
85
  when /\s/
71
86
  if get_state[:variable]
@@ -91,6 +106,7 @@ module Wirb
91
106
 
92
107
  when '>'
93
108
  pop_state[:repeat]
109
+
94
110
  when '('
95
111
  peek = chars[i+1..-1].join
96
112
  if peek =~ /^-?(?:Infinity|NaN|[0-9.e]+)[+-](?:Infinity|NaN|[0-9.e]+)\*?i\)/
@@ -144,18 +160,18 @@ module Wirb
144
160
  end
145
161
 
146
162
  when :class
147
- case c
148
- when /[a-z0-9_]/i
163
+ if c =~ /[a-z0-9_]/i
149
164
  @token << c
150
- else
151
- if @token =~ /^(Infinity|NaN)$/
152
- set_state[:special_number, :repeat]
153
- elsif c ==':' && nc == ':'
154
- pass_state[]
155
- pass[:class_separator, '::']
156
- elsif !(c == ':' && lc == ':')
157
- pass_state[:remove, :repeat]
158
- end
165
+ elsif c == ":" && get_previous_state[:hash]
166
+ pass_custom_state[:symbol, :remove, :repeat]
167
+ @refers_seen[-1] = true
168
+ elsif @token =~ /^(Infinity|NaN)$/
169
+ set_state[:special_number, :repeat]
170
+ elsif c ==':' && nc == ':'
171
+ pass_state[]
172
+ pass[:class_separator, '::']
173
+ elsif !(c == ':' && lc == ':')
174
+ pass_state[:remove, :repeat]
159
175
  end
160
176
 
161
177
  when :symbol
@@ -192,10 +208,15 @@ module Wirb
192
208
  end
193
209
 
194
210
  when :string
195
- if c == '"' && ( !( @token =~ /\\+$/; $& ) || $&.size % 2 == 0 ) # allow escaping of " and
196
- pass[:open_string, '"'] # work around \\
197
- pass_state[:remove]
198
- pass[:close_string, '"']
211
+ if c == '"' && ( !( @token =~ /\\+$/; $& ) || $&.size % 2 == 0 ) # allow escaping of " and work around \\
212
+ if nc == ':' && get_previous_state[:hash]
213
+ set_state[:symbol_string, :repeat]
214
+ @refers_seen[-1] = true
215
+ else
216
+ pass[:open_string, '"']
217
+ pass_state[:remove]
218
+ pass[:close_string, '"']
219
+ end
199
220
  else
200
221
  @token << c
201
222
  end
@@ -221,6 +242,9 @@ module Wirb
221
242
  if c =~ /[a-z0-9_]/i
222
243
  @token << c
223
244
  pass_custom_state[@token.to_sym, :remove] if %w[nil false true].include?(@token)
245
+ elsif c == ":"
246
+ pass_custom_state[:symbol, :remove, :repeat]
247
+ @refers_seen[-1] = true
224
248
  else
225
249
  pass_state[:remove, :repeat]
226
250
  end
@@ -337,7 +361,7 @@ module Wirb
337
361
  set_state[@token.to_sym]
338
362
  else
339
363
  set_state[:object_description]
340
- if @token == "enumerator" && RUBY_ENGINE != "rbx"
364
+ if @token == "enumerator"
341
365
  push_state[:enumerator]
342
366
  end
343
367
  end
data/lib/wirb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wirb
4
- VERSION = '2.2.2'
4
+ VERSION = '3.0.0'
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,12 @@ require 'wirb'
2
2
  require 'wirb/wp'
3
3
  require 'ruby_engine'
4
4
 
5
+ # CONFIG
6
+
7
+ RSpec.configure do |config|
8
+ config.expect_with(:rspec) { |c| c.syntax = :should }
9
+ end
10
+
5
11
  # TOKENIZER
6
12
 
7
13
  def tokenizer(filename)
@@ -80,3 +86,15 @@ end
80
86
  OBJECT_ID = /0x[0-9a-f]+/
81
87
 
82
88
  def ws(obj) puts Wirb::Tokenizer.run(obj.inspect).map{|*x| x.inspect + ','}*$/ end
89
+
90
+ def spaced_hashes?
91
+ RUBY_VERSION >= "3.4.0"
92
+ end
93
+
94
+ def symbol_hash_keys?
95
+ RUBY_VERSION >= "3.4.0"
96
+ end
97
+
98
+ def concise_set?
99
+ RUBY_VERSION >= "4.0.0"
100
+ end