Class: SpecTag
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#description ⇒ Object
Returns the value of attribute description.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #escape(str) ⇒ Object
-
#initialize(string = nil) ⇒ SpecTag
constructor
A new instance of SpecTag.
- #parse(string) ⇒ Object
- #to_s ⇒ Object
- #unescape(str) ⇒ Object
Constructor Details
#initialize(string = nil) ⇒ SpecTag
Returns a new instance of SpecTag.
4 5 6 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 4 def initialize(string=nil) parse(string) if string end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
2 3 4 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 2 def comment @comment end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 2 def description @description end |
#tag ⇒ Object
Returns the value of attribute tag.
2 3 4 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 2 def tag @tag end |
Instance Method Details
#==(o) ⇒ Object
29 30 31 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 29 def ==(o) @tag == o.tag and @comment == o.comment and @description == o.description end |
#escape(str) ⇒ Object
20 21 22 23 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 20 def escape(str) str = %["#{str.gsub(/\n/, '\n')}"] if /\n/ =~ str str end |
#parse(string) ⇒ Object
8 9 10 11 12 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 8 def parse(string) m = /^([^()#:]+)(\(([^)]+)?\))?:(.*)$/.match string @tag, @comment, description = m.values_at(1, 3, 4) if m @description = unescape description end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 25 def to_s "#{@tag}#{ "(#{@comment})" if @comment }:#{escape @description}" end |
#unescape(str) ⇒ Object
14 15 16 17 18 |
# File 'lib/extensions/mspec/mspec/runner/tag.rb', line 14 def unescape(str) return unless str str = str[1..-2] if str[0] == ?" and str[-1] == ?" str.gsub(/\\n/, "\n") end |