Skip to content

Commit

Permalink
Replace component specific System::EOL constants with top level `EO…
Browse files Browse the repository at this point in the history
…L` const (#347)

* Require Crystal `~> 1.11`
  • Loading branch information
Blacksmoke16 authored Feb 4, 2024
1 parent 80b7e77 commit 36cf53f
Show file tree
Hide file tree
Showing 29 changed files with 131 additions and 153 deletions.
2 changes: 1 addition & 1 deletion src/components/console/shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: athena-console

version: 0.3.4

crystal: ~> 1.8
crystal: ~> 1.11

license: MIT

Expand Down
10 changes: 5 additions & 5 deletions src/components/console/spec/application_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct ApplicationTest < ASPEC::TestCase

protected def assert_file_equals_string(filepath : String, string : String, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil
normalized_path = File.join __DIR__, "fixtures", filepath
string.should match(Regex.new(File.read(normalized_path).gsub ACON::System::EOL, "\n")), file: file, line: line
string.should match(Regex.new(File.read(normalized_path).gsub EOL, "\n")), file: file, line: line
end

protected def ensure_static_command_help(application : ACON::Application) : Nil
Expand Down Expand Up @@ -792,10 +792,10 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "foo:bar", "--no-interaction": true, decorated: false
tester.display.should eq "execute called#{ACON::System::EOL}"
tester.display.should eq "execute called#{EOL}"

tester.run command: "foo:bar", "-n": true, decorated: false
tester.display.should eq "execute called#{ACON::System::EOL}"
tester.display.should eq "execute called#{EOL}"
end

def test_run_global_option_and_no_command : Nil
Expand Down Expand Up @@ -974,7 +974,7 @@ struct ApplicationTest < ASPEC::TestCase

tester = ACON::Spec::ApplicationTester.new app
tester.run interactive: false
tester.display.should eq "execute called#{ACON::System::EOL}"
tester.display.should eq "execute called#{EOL}"

# TODO: Test custom application default.
end
Expand All @@ -987,7 +987,7 @@ struct ApplicationTest < ASPEC::TestCase

tester = ACON::Spec::ApplicationTester.new app
tester.run "--fooopt": "opt", interactive: false
tester.display.should eq "execute called#{ACON::System::EOL}opt#{ACON::System::EOL}"
tester.display.should eq "execute called#{EOL}opt#{EOL}"
end

def test_run_custom_single_default_command : Nil
Expand Down
4 changes: 2 additions & 2 deletions src/components/console/spec/application_tester_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ struct ApplicationTesterTest < ASPEC::TestCase
end

def test_output : Nil
@tester.output.to_s.should eq "foo#{ACON::System::EOL}"
@tester.output.to_s.should eq "foo#{EOL}"
end

def test_display : Nil
@tester.display.to_s.should eq "foo#{ACON::System::EOL}"
@tester.display.to_s.should eq "foo#{EOL}"
end

def test_status : Nil
Expand Down
4 changes: 2 additions & 2 deletions src/components/console/spec/command_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ describe ACON::Command do
it "interactive" do
tester = ACON::Spec::CommandTester.new TestCommand.new
tester.execute interactive: true
tester.display.should eq "interact called#{ACON::System::EOL}execute called#{ACON::System::EOL}"
tester.display.should eq "interact called#{EOL}execute called#{EOL}"
end

it "non-interactive" do
tester = ACON::Spec::CommandTester.new TestCommand.new
tester.execute interactive: false
tester.display.should eq "execute called#{ACON::System::EOL}"
tester.display.should eq "execute called#{EOL}"
end

it "invalid option" do
Expand Down
4 changes: 2 additions & 2 deletions src/components/console/spec/command_tester_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct CommandTesterTest < ASPEC::TestCase
end

def test_output : Nil
@tester.output.to_s.should eq "foo#{ACON::System::EOL}"
@tester.output.to_s.should eq "foo#{EOL}"
end

def test_display : Nil
@tester.display.to_s.should eq "foo#{ACON::System::EOL}"
@tester.display.to_s.should eq "foo#{EOL}"
end

def test_display_before_calling_execute : Nil
Expand Down
6 changes: 3 additions & 3 deletions src/components/console/spec/commands/complete_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct CompleteCommandTest < ASPEC::TestCase
})

self.execute({"--current" => "0", "--input" => [] of String})
@tester.display.should eq "#{["help", "list", "completion", "hello", "ahoy", "foo:bar1", "afoobar1"].join("\n")}#{ACON::System::EOL}"
@tester.display.should eq "#{["help", "list", "completion", "hello", "ahoy", "foo:bar1", "afoobar1"].join("\n")}#{EOL}"
end

def test_additional_shell_support : Nil
Expand Down Expand Up @@ -96,7 +96,7 @@ struct CompleteCommandTest < ASPEC::TestCase
@[DataProvider("provide_complete_command_name_inputs")]
def test_completion_command_name(input : Array(String), suggestions : Array(String)) : Nil
self.execute({"--current" => "0", "--input" => input})
@tester.display.should eq "#{suggestions.join("\n")}#{ACON::System::EOL}"
@tester.display.should eq "#{suggestions.join("\n")}#{EOL}"
end

def provide_complete_command_name_inputs : Hash
Expand All @@ -111,7 +111,7 @@ struct CompleteCommandTest < ASPEC::TestCase
@[DataProvider("provide_input_definition_inputs")]
def test_completion_command_input_definitions(input : Array(String), suggestions : Array(String)) : Nil
self.execute({"--current" => "1", "--input" => input})
@tester.display.should eq "#{suggestions.join("\n")}#{ACON::System::EOL}"
@tester.display.should eq "#{suggestions.join("\n")}#{EOL}"
end

def provide_input_definition_inputs : Hash
Expand Down
2 changes: 1 addition & 1 deletion src/components/console/spec/commands/list_spec.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "../spec_helper"

private def normalize(input : String) : String
input.gsub ACON::System::EOL, "\n"
input.gsub EOL, "\n"
end

struct ListCommandTest < ASPEC::TestCase
Expand Down
4 changes: 2 additions & 2 deletions src/components/console/spec/completion/output/bash_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ struct BashTest < CompletionOutputTestCase
end

def expected_options_output : String
"--option1\n--negatable\n--no-negatable#{ACON::System::EOL}"
"--option1\n--negatable\n--no-negatable#{EOL}"
end

def expected_values_output : String
"Green\nRed\nYellow#{ACON::System::EOL}"
"Green\nRed\nYellow#{EOL}"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ abstract struct AbstractDescriptorTestCase < ASPEC::TestCase
end

private def normalize_output(output : String) : String
output.gsub(ACON::System::EOL, "\n").strip
output.gsub(EOL, "\n").strip
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract struct AbstractQuestionHelperTest < ASPEC::TestCase
output = stream.to_s

if normalize
output = output.gsub ACON::System::EOL, "\n"
output = output.gsub EOL, "\n"
end

output.should contain string
Expand Down
2 changes: 1 addition & 1 deletion src/components/console/spec/helper/formatter_spec.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "../spec_helper"

private def normalize(input : String) : String
input.gsub ACON::System::EOL, "\n"
input.gsub EOL, "\n"
end

describe ACON::Helper::Formatter do
Expand Down
70 changes: 35 additions & 35 deletions src/components/console/spec/helper/progress_bar_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ struct ProgressBarTest < ASPEC::TestCase

self.assert_output(
output,
" 0/50 [>---------------------------] 0%#{ACON::System::EOL}",
"\e[1A\e[0J 1/50 [>---------------------------] 2%#{ACON::System::EOL}",
"\e[1A\e[0J 2/50 [=>--------------------------] 4%#{ACON::System::EOL}",
" 0/50 [>---------------------------] 0%#{EOL}",
"\e[1A\e[0J 1/50 [>---------------------------] 2%#{EOL}",
"\e[1A\e[0J 2/50 [=>--------------------------] 4%#{EOL}",
)
end

Expand All @@ -353,9 +353,9 @@ struct ProgressBarTest < ASPEC::TestCase

self.assert_output(
output,
" \033[44;37m 0/50\033[0m [>---------------------------] 0%#{ACON::System::EOL}",
"\e[1A\e[0J \033[44;37m 1/50\033[0m [>---------------------------] 2%#{ACON::System::EOL}",
"\e[1A\e[0J \033[44;37m 2/50\033[0m [=>--------------------------] 4%#{ACON::System::EOL}",
" \033[44;37m 0/50\033[0m [>---------------------------] 0%#{EOL}",
"\e[1A\e[0J \033[44;37m 1/50\033[0m [>---------------------------] 2%#{EOL}",
"\e[1A\e[0J \033[44;37m 2/50\033[0m [=>--------------------------] 4%#{EOL}",
)
end

Expand All @@ -377,12 +377,12 @@ struct ProgressBarTest < ASPEC::TestCase

self.assert_output(
acon_output,
" 0/50 [>---------------------------] 0%#{ACON::System::EOL}",
" 0/50 [>---------------------------] 0%#{ACON::System::EOL}",
"\e[1A\e[0J 1/50 [>---------------------------] 2%#{ACON::System::EOL}",
"\e[2A\e[0J 1/50 [>---------------------------] 2%#{ACON::System::EOL}",
"\e[1A\e[0J 1/50 [>---------------------------] 2%#{ACON::System::EOL}",
" 1/50 [>---------------------------] 2%#{ACON::System::EOL}",
" 0/50 [>---------------------------] 0%#{EOL}",
" 0/50 [>---------------------------] 0%#{EOL}",
"\e[1A\e[0J 1/50 [>---------------------------] 2%#{EOL}",
"\e[2A\e[0J 1/50 [>---------------------------] 2%#{EOL}",
"\e[1A\e[0J 1/50 [>---------------------------] 2%#{EOL}",
" 1/50 [>---------------------------] 2%#{EOL}",
)
end

Expand Down Expand Up @@ -424,9 +424,9 @@ struct ProgressBarTest < ASPEC::TestCase

self.assert_output(
output,
" 0/50 [>---------------------------] 0% %message% EXISTING TEXT.#{ACON::System::EOL}",
"\e[1A\e[0J 1/50 [>---------------------------] 2% MESSAGE\nTEXT! EXISTING TEXT.#{ACON::System::EOL}",
"\e[2A\e[0J 2/50 [=>--------------------------] 4% OTHER\nTEXT! EXISTING TEXT.#{ACON::System::EOL}",
" 0/50 [>---------------------------] 0% %message% EXISTING TEXT.#{EOL}",
"\e[1A\e[0J 1/50 [>---------------------------] 2% MESSAGE\nTEXT! EXISTING TEXT.#{EOL}",
"\e[2A\e[0J 2/50 [=>--------------------------] 4% OTHER\nTEXT! EXISTING TEXT.#{EOL}",
)
end

Expand All @@ -451,12 +451,12 @@ struct ProgressBarTest < ASPEC::TestCase

self.assert_output(
acon_output,
" 0/50 [>---------------------------] 0%#{ACON::System::EOL}",
" 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.#{ACON::System::EOL}",
"\e[4A\e[0J 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.#{ACON::System::EOL}",
"\e[3A\e[0J 1/50 [>---------------------------] 2%#{ACON::System::EOL}",
" 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.#{ACON::System::EOL}",
"\e[3A\e[0J 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.#{ACON::System::EOL}",
" 0/50 [>---------------------------] 0%#{EOL}",
" 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.#{EOL}",
"\e[4A\e[0J 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.#{EOL}",
"\e[3A\e[0J 1/50 [>---------------------------] 2%#{EOL}",
" 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.#{EOL}",
"\e[3A\e[0J 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.#{EOL}",
)
end

Expand Down Expand Up @@ -594,16 +594,16 @@ struct ProgressBarTest < ASPEC::TestCase

self.assert_output(
output,
" 0/200 [>---------------------------] 0%#{ACON::System::EOL}",
" 20/200 [==>-------------------------] 10%#{ACON::System::EOL}",
" 40/200 [=====>----------------------] 20%#{ACON::System::EOL}",
" 60/200 [========>-------------------] 30%#{ACON::System::EOL}",
" 80/200 [===========>----------------] 40%#{ACON::System::EOL}",
" 100/200 [==============>-------------] 50%#{ACON::System::EOL}",
" 120/200 [================>-----------] 60%#{ACON::System::EOL}",
" 140/200 [===================>--------] 70%#{ACON::System::EOL}",
" 160/200 [======================>-----] 80%#{ACON::System::EOL}",
" 180/200 [=========================>--] 90%#{ACON::System::EOL}",
" 0/200 [>---------------------------] 0%#{EOL}",
" 20/200 [==>-------------------------] 10%#{EOL}",
" 40/200 [=====>----------------------] 20%#{EOL}",
" 60/200 [========>-------------------] 30%#{EOL}",
" 80/200 [===========>----------------] 40%#{EOL}",
" 100/200 [==============>-------------] 50%#{EOL}",
" 120/200 [================>-----------] 60%#{EOL}",
" 140/200 [===================>--------] 70%#{EOL}",
" 160/200 [======================>-----] 80%#{EOL}",
" 180/200 [=========================>--] 90%#{EOL}",
" 200/200 [============================] 100%",
)
end
Expand All @@ -618,8 +618,8 @@ struct ProgressBarTest < ASPEC::TestCase

self.assert_output(
output,
" 0/50 [>---------------------------] 0%#{ACON::System::EOL}",
" 25/50 [==============>-------------] 50%#{ACON::System::EOL}",
" 0/50 [>---------------------------] 0%#{EOL}",
" 25/50 [==============>-------------] 50%#{EOL}",
" 50/50 [============================] 100%",
)
end
Expand All @@ -631,7 +631,7 @@ struct ProgressBarTest < ASPEC::TestCase

self.assert_output(
output,
" 0 [>---------------------------]#{ACON::System::EOL}",
" 0 [>---------------------------]#{EOL}",
" 1 [->--------------------------]",
)
end
Expand Down Expand Up @@ -1109,7 +1109,7 @@ struct ProgressBarTest < ASPEC::TestCase
"Processing \"foobar\"...",
"\x1B[1G\x1B[2K\x1B[1A",
self.generate_output(""),
"Foo!#{ACON::System::EOL}",
"Foo!#{EOL}",
self.generate_output("[--->------------------------]"),
"\nProcessing \"foobar\"...",
self.generate_output("[----->----------------------]\nProcessing \"foobar\"..."),
Expand Down
10 changes: 5 additions & 5 deletions src/components/console/spec/helper/progress_indicator_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ struct ProgressIndicatorTest < ASPEC::TestCase
self.generate_output(" \\ Advancing..."),
self.generate_output(" | Advancing..."),
self.generate_output(" | Done..."),
ACON::System::EOL,
EOL,
self.generate_output(" - Starting Again..."),
self.generate_output(" \\ Starting Again..."),
self.generate_output(" \\ Done Again..."),
ACON::System::EOL,
EOL,
)
end

Expand All @@ -62,9 +62,9 @@ struct ProgressIndicatorTest < ASPEC::TestCase

self.assert_output(
output,
" Starting...#{ACON::System::EOL}",
" Midway...#{ACON::System::EOL}",
" Done...#{ACON::System::EOL}#{ACON::System::EOL}",
" Starting...#{EOL}",
" Midway...#{EOL}",
" Done...#{EOL}#{EOL}",
)
end

Expand Down
12 changes: 6 additions & 6 deletions src/components/console/spec/helper/table_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ struct TableSpec < ASPEC::TestCase
@output : IO

protected def get_table_contents(table_name : String) : String
File.read(File.join __DIR__, "..", "fixtures", "helper", "table", "#{table_name}.txt") # .gsub(ACON::System::EOL, "\n")
File.read(File.join __DIR__, "..", "fixtures", "helper", "table", "#{table_name}.txt") # .gsub(EOL, "\n")
end

def initialize
Expand Down Expand Up @@ -51,7 +51,7 @@ struct TableSpec < ASPEC::TestCase
.style(style)
.render

self.output_content(output).should eq expected.gsub ACON::System::EOL, "\n"
self.output_content(output).should eq expected.gsub EOL, "\n"
end

def render_provider : Hash
Expand Down Expand Up @@ -970,7 +970,7 @@ struct TableSpec < ASPEC::TestCase
.style(style)
.render

self.output_content(output).should eq expected.gsub ACON::System::EOL, "\n"
self.output_content(output).should eq expected.gsub EOL, "\n"
end

def title_provider : Tuple
Expand Down Expand Up @@ -1098,7 +1098,7 @@ struct TableSpec < ASPEC::TestCase
.horizontal
.render

self.output_content(output).should eq expected.gsub ACON::System::EOL, "\n"
self.output_content(output).should eq expected.gsub EOL, "\n"
end

def horizontal_provider : Tuple
Expand Down Expand Up @@ -1163,7 +1163,7 @@ struct TableSpec < ASPEC::TestCase
.vertical
.render

self.output_content(output).should eq expected.gsub ACON::System::EOL, "\n"
self.output_content(output).should eq expected.gsub EOL, "\n"
end

def vertical_provider : Hash
Expand Down Expand Up @@ -1493,6 +1493,6 @@ struct TableSpec < ASPEC::TestCase
end

private def normalize(input : String) : String
input.gsub ACON::System::EOL, "\n"
input.gsub EOL, "\n"
end
end
Loading

0 comments on commit 36cf53f

Please sign in to comment.