Skip to content

Commit d728d25

Browse files
committed
Rename STDINItem to ScriptItem
1 parent 8ff9ab0 commit d728d25

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/syntax_tree/cli.rb

+12-6
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,24 @@ def source
5353
end
5454
end
5555

56-
# An item of work that corresponds to the stdin content.
57-
class STDINItem
56+
# An item of work that corresponds to a script content passed via the command line.
57+
class ScriptItem
58+
FILEPATH = :script
59+
60+
def initialize(source)
61+
@source = source
62+
end
63+
5864
def handler
5965
HANDLERS[".rb"]
6066
end
6167

6268
def filepath
63-
:stdin
69+
FILEPATH
6470
end
6571

6672
def source
67-
$stdin.read
73+
@source
6874
end
6975
end
7076

@@ -191,7 +197,7 @@ def run(item)
191197

192198
source = item.source
193199
formatted = item.handler.format(source, options.print_width)
194-
File.write(filepath, formatted) if filepath != :stdin
200+
File.write(filepath, formatted) if FileItem === item
195201

196202
color = source == formatted ? Color.gray(filepath) : filepath
197203
delta = ((Time.now - start) * 1000).round
@@ -380,7 +386,7 @@ def run(argv)
380386
end
381387
end
382388
else
383-
queue << STDINItem.new
389+
queue << ScriptItem.new($stdin.read)
384390
end
385391

386392
# At the end, we're going to return whether or not this worker ever

0 commit comments

Comments
 (0)