Skip to content

Commit

Permalink
Drop deprecated with_color top-level method (crystal-lang#9531)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian J. Cardiff authored Jun 23, 2020
1 parent 4482942 commit 19c0adb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 43 deletions.
2 changes: 1 addition & 1 deletion samples/2048.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Screen

def self.colorize_for(tile)
fg_color, bg_color = TILES[tile]
color = with_color(fg_color)
color = Colorize.with.fore(fg_color)
color = color.on(bg_color) if bg_color
color.surround do
yield
Expand Down
12 changes: 6 additions & 6 deletions samples/pretty_json.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ class PrettyPrinter
def read_any
case @pull.kind
when .null?
with_color.bold.surround(@output) do
Colorize.with.bold.surround(@output) do
@pull.read_null.to_json(@output)
end
when .bool?
with_color.light_blue.surround(@output) do
Colorize.with.light_blue.surround(@output) do
@pull.read_bool.to_json(@output)
end
when .int?
with_color.red.surround(@output) do
Colorize.with.red.surround(@output) do
@pull.read_int.to_json(@output)
end
when .float?
with_color.red.surround(@output) do
Colorize.with.red.surround(@output) do
@pull.read_float.to_json(@output)
end
when .string?
with_color.yellow.surround(@output) do
Colorize.with.yellow.surround(@output) do
@pull.read_string.to_json(@output)
end
when .begin_array?
Expand Down Expand Up @@ -80,7 +80,7 @@ class PrettyPrinter
print '\n' if @indent > 0
end
print_indent
with_color.cyan.surround(@output) do
Colorize.with.cyan.surround(@output) do
key.to_json(@output)
end
print ": "
Expand Down
26 changes: 0 additions & 26 deletions spec/std/colorize_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -129,32 +129,6 @@ describe "colorize" do
colorize("hello", :red).inspect.should eq("\e[31m\"hello\"\e[0m")
end

describe "with_color deprecated top-level method" do
it "without args" do
io = IO::Memory.new
with_color.red.toggle(true).surround(io) do
io << "hello"
with_color.green.toggle(true).surround(io) do
io << "world"
end
io << "bye"
end
io.to_s.should eq("\e[31mhello\e[0;32mworld\e[0;31mbye\e[0m")
end

it "with args" do
io = IO::Memory.new
with_color(:red).toggle(true).surround(io) do
io << "hello"
with_color(:green).toggle(true).surround(io) do
io << "world"
end
io << "bye"
end
io.to_s.should eq("\e[31mhello\e[0;32mworld\e[0;31mbye\e[0m")
end
end

it "colorizes with surround" do
io = IO::Memory.new
with_color_wrap.red.surround(io) do
Expand Down
10 changes: 0 additions & 10 deletions src/colorize.cr
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,6 @@ module Colorize
end
end

@[Deprecated("Use `Colorize.with`")]
def with_color
Colorize.with
end

@[Deprecated("Use `Colorize.with.fore(color)`")]
def with_color(color : Symbol)
Colorize.with.fore(color)
end

module Colorize::ObjectExtensions
def colorize
Colorize::Object.new(self)
Expand Down

0 comments on commit 19c0adb

Please sign in to comment.