-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For example: ``` cat test/fixtures/merge.yml | flatito ```
- Loading branch information
Showing
9 changed files
with
135 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Flatito | ||
module Config | ||
@stdout = $stdout | ||
@stderr = $stderr | ||
@stdin = $stdin | ||
|
||
class << self | ||
attr_accessor :renderer, :stdout, :stder, :stdin | ||
|
||
def prepare_with_options(options) | ||
self.renderer = Renderer.build(options) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Flatito | ||
class PrintItems | ||
def self.call(search, items, pathname = nil) | ||
items = filter_by_search(items) if search | ||
return unless items.any? | ||
|
||
renderer.print_pathname(pathname) if pathname | ||
renderer.print_items(items) | ||
end | ||
|
||
def self.renderer | ||
Config.renderer | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class Flatito::ConfigTest < Minitest::Test | ||
class DummyTTY < StringIO | ||
def tty? | ||
true | ||
end | ||
end | ||
|
||
class DummyNotTTY < StringIO | ||
def tty? | ||
false | ||
end | ||
end | ||
|
||
test "when stdout is tty set renderer as tty" do | ||
Flatito::Config.stdout = DummyTTY.new | ||
Flatito::Config.prepare_with_options({}) | ||
|
||
assert_kind_of Flatito::Renderer::TTY, Flatito::Config.renderer | ||
end | ||
|
||
test "when stdout is not tty set renderer as plain" do | ||
Flatito::Config.stdout = DummyNotTTY.new | ||
Flatito::Config.prepare_with_options({}) | ||
|
||
assert_kind_of Flatito::Renderer::Plain, Flatito::Config.renderer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters