Skip to content

Commit

Permalink
Only show relevant files when pass in --full option
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanitoFatas committed Jun 8, 2019
1 parent fa91926 commit 16b69d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/gel/command/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

class Gel::Command::Env < Gel::Command
def run(command_line)
MarkdownFormatter.format(metadata)
option = { full: (command_line.shift == "--full") }
data = metadata(option)
MarkdownFormatter.format(data)
end

private

def metadata
{
def metadata(option)
metadata = {
"Gel" => gel_envs,
"User" => user_envs,
"Ruby" => ruby_envs,
"Relevant Files" => RELEVANT_FILES,
}
if option[:full]
metadata.merge!("Relevant Files" => RELEVANT_FILES)
end
metadata
end

module MarkdownFormatter
Expand Down
10 changes: 9 additions & 1 deletion test/command/env_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
require "test_helper"

class EnvTest < Minitest::Test
def test_help
def test_env
output = capture_stdout { Gel::Command::Env.run(["env"]) }

assert output =~ %r{## Gel}
assert output =~ %r{## User}
assert output =~ %r{## Ruby}
end

def test_env_with_full
output = capture_stdout { Gel::Command::Env.run(["env", "--full"]) }

assert output =~ %r{## Gel}
assert output =~ %r{## User}
assert output =~ %r{## Ruby}
Expand Down

0 comments on commit 16b69d0

Please sign in to comment.