-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
12 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module HamlLint | ||
# Wrapper class representing a single target for HamlLint::Runner to run against, comprised of an IO object | ||
# containing haml code, as well as a file path. | ||
# Wrapper class representing a single target for HamlLint::Runner to run against, comprised of a file path to | ||
# eventually read from, and an optional IO argument to override with. | ||
class Source | ||
# @return [String] File path associated with the given IO object. | ||
attr_reader :path | ||
|
||
# Wraps an IO object and file path to a source object. | ||
# Wraps an optional IO object and file path to a source object. | ||
# | ||
# @param [IO] io | ||
# @param [String] path | ||
def initialize(io, path) | ||
@io = io | ||
# @param [IO] io | ||
def initialize(path: nil, io: nil) | ||
@path = path | ||
@io = io | ||
end | ||
|
||
# @return [String] Contents of the given IO object. | ||
def contents | ||
@contents ||= @io.read | ||
@contents ||= @io&.read || File.read(path) | ||
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