-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the Linter::Result class into its own file.
Clears up a bit of the clutter inside of linter.rb and makes it clearly it's own entity within the linter.
- Loading branch information
1 parent
88f665e
commit 6b3de00
Showing
4 changed files
with
72 additions
and
71 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module Pod | ||
class Specification | ||
class Linter | ||
class Result | ||
|
||
# @return [Symbol] the type of result. | ||
# | ||
attr_reader :type | ||
|
||
# @return [String] the message associated with result. | ||
# | ||
attr_reader :message | ||
|
||
# @param [Symbol] type @see type | ||
# @param [String] message @see message | ||
# | ||
def initialize(type, message) | ||
@type = type | ||
@message = message | ||
@platforms = [] | ||
end | ||
|
||
# @return [Array<Platform>] the platforms where this result was | ||
# generated. | ||
# | ||
attr_reader :platforms | ||
|
||
# @return [String] a string representation suitable for UI output. | ||
# | ||
def to_s | ||
r = "[#{type.to_s.upcase}] #{message}" | ||
if platforms != Specification::PLATFORMS | ||
platforms_names = platforms.uniq.map do |p| | ||
Platform.string_name(p) | ||
end | ||
r << " [#{platforms_names * ' - '}]" unless platforms.empty? | ||
end | ||
r | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
module Pod | ||
describe Specification::Linter::Result do | ||
before do | ||
@result = Specification::Linter::Result.new(:error, 'This is a sample error.') | ||
end | ||
|
||
it "returns the type" do | ||
@result.type.should == :error | ||
end | ||
|
||
it "returns the message" do | ||
@result.message.should == 'This is a sample error.' | ||
end | ||
|
||
it "can store the platforms that generated the result" do | ||
@result.platforms << :ios | ||
@result.platforms.should == [:ios] | ||
end | ||
|
||
it "returns a string representation suitable for UI" do | ||
@result.to_s.should == '[ERROR] This is a sample error.' | ||
@result.platforms << :ios | ||
@result.to_s.should == '[ERROR] This is a sample error. [iOS]' | ||
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
6b3de00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍