File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -53,18 +53,24 @@ def source
53
53
end
54
54
end
55
55
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
+
58
64
def handler
59
65
HANDLERS [ ".rb" ]
60
66
end
61
67
62
68
def filepath
63
- :stdin
69
+ FILEPATH
64
70
end
65
71
66
72
def source
67
- $stdin . read
73
+ @source
68
74
end
69
75
end
70
76
@@ -191,7 +197,7 @@ def run(item)
191
197
192
198
source = item . source
193
199
formatted = item . handler . format ( source , options . print_width )
194
- File . write ( filepath , formatted ) if filepath != :stdin
200
+ File . write ( filepath , formatted ) if FileItem === item
195
201
196
202
color = source == formatted ? Color . gray ( filepath ) : filepath
197
203
delta = ( ( Time . now - start ) * 1000 ) . round
@@ -380,7 +386,7 @@ def run(argv)
380
386
end
381
387
end
382
388
else
383
- queue << STDINItem . new
389
+ queue << ScriptItem . new ( $stdin . read )
384
390
end
385
391
386
392
# At the end, we're going to return whether or not this worker ever
You can’t perform that action at this time.
0 commit comments