xcfit 2.0.4 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -9
  3. data/Docs/InitialVersion.md +340 -0
  4. data/Package.swift +5 -0
  5. data/README.md +348 -145
  6. data/XCFit.gemspec +1 -1
  7. data/XCFit.podspec +17 -9
  8. data/XCFit/Classes/Cucumberish/Core/CCIBlockDefinitions.h +400 -0
  9. data/XCFit/Classes/Cucumberish/Core/Managers/CCIFeaturesManager.h +72 -0
  10. data/XCFit/Classes/Cucumberish/Core/Managers/CCIFeaturesManager.m +141 -0
  11. data/XCFit/Classes/Cucumberish/Core/Managers/CCIStepsManager.h +51 -0
  12. data/XCFit/Classes/Cucumberish/Core/Managers/CCIStepsManager.m +245 -0
  13. data/XCFit/Classes/Cucumberish/Core/Models/CCIArgument.h +62 -0
  14. data/XCFit/Classes/Cucumberish/Core/Models/CCIArgument.m +117 -0
  15. data/XCFit/Classes/Cucumberish/Core/Models/CCIAroundHock.h +37 -0
  16. data/XCFit/Classes/Cucumberish/Core/Models/CCIAroundHock.m +37 -0
  17. data/XCFit/Classes/Cucumberish/Core/Models/CCIBackground.h +46 -0
  18. data/XCFit/Classes/Cucumberish/Core/Models/CCIBackground.m +117 -0
  19. data/XCFit/Classes/Cucumberish/Core/Models/CCIExample.h +89 -0
  20. data/XCFit/Classes/Cucumberish/Core/Models/CCIExample.m +128 -0
  21. data/XCFit/Classes/Cucumberish/Core/Models/CCIFeature.h +49 -0
  22. data/XCFit/Classes/Cucumberish/Core/Models/CCIFeature.m +174 -0
  23. data/XCFit/Classes/Cucumberish/Core/Models/CCIHock.h +36 -0
  24. data/XCFit/Classes/Cucumberish/Core/Models/CCIHock.m +34 -0
  25. data/XCFit/Classes/Cucumberish/Core/Models/CCILocation.h +61 -0
  26. data/XCFit/Classes/Cucumberish/Core/Models/CCILocation.m +91 -0
  27. data/XCFit/Classes/Cucumberish/Core/Models/CCIScenarioDefinition.h +97 -0
  28. data/XCFit/Classes/Cucumberish/Core/Models/CCIScenarioDefinition.m +224 -0
  29. data/XCFit/Classes/Cucumberish/Core/Models/CCIStep.h +85 -0
  30. data/XCFit/Classes/Cucumberish/Core/Models/CCIStep.m +98 -0
  31. data/XCFit/Classes/Cucumberish/Core/Models/CCIStepDefinition.h +43 -0
  32. data/XCFit/Classes/Cucumberish/Core/Models/CCIStepDefinition.m +65 -0
  33. data/XCFit/Classes/Cucumberish/Cucumberish.h +133 -0
  34. data/XCFit/Classes/Cucumberish/Cucumberish.m +604 -0
  35. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHAstBuilder.h +15 -0
  36. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHAstBuilder.m +312 -0
  37. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHAstNode.h +20 -0
  38. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHAstNode.m +79 -0
  39. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHBackground.h +12 -0
  40. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHBackground.m +18 -0
  41. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHComment.h +11 -0
  42. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHComment.m +27 -0
  43. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHDataTable.h +14 -0
  44. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHDataTable.m +30 -0
  45. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHDocString.h +14 -0
  46. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHDocString.m +29 -0
  47. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHExamples.h +24 -0
  48. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHExamples.m +49 -0
  49. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHFeature.h +24 -0
  50. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHFeature.m +50 -0
  51. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinDialect.h +25 -0
  52. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinDialect.m +64 -0
  53. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinDialectProvider.h +9 -0
  54. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinDialectProvider.m +124 -0
  55. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinDialectProviderProtocol.h +10 -0
  56. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLanguageConstants.h +9 -0
  57. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLanguageConstants.m +10 -0
  58. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLanguageSetting.h +17 -0
  59. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLanguageSetting.m +18 -0
  60. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLine.h +12 -0
  61. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLine.m +179 -0
  62. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLineProtocol.h +64 -0
  63. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLineSpan.h +9 -0
  64. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHGherkinLineSpan.m +26 -0
  65. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHHasDescriptionProtocol.h +8 -0
  66. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHHasLocationProtocol.h +8 -0
  67. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHHasRowsProtocol.h +8 -0
  68. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHHasStepsProtocol.h +8 -0
  69. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHHasTagsProtocol.h +8 -0
  70. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHLocation.h +12 -0
  71. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHLocation.m +41 -0
  72. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHNode.h +4 -0
  73. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHNode.m +5 -0
  74. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHParser+Extensions.h +10 -0
  75. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHParser+Extensions.m +18 -0
  76. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHParser.h +132 -0
  77. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHParser.m +2735 -0
  78. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHParserException.h +55 -0
  79. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHParserException.m +192 -0
  80. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHScenario.h +14 -0
  81. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHScenario.m +18 -0
  82. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHScenarioDefinition.h +23 -0
  83. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHScenarioDefinition.m +41 -0
  84. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHScenarioDefinition_Private.h +6 -0
  85. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHScenarioOutline.h +15 -0
  86. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHScenarioOutline.m +26 -0
  87. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHStep.h +16 -0
  88. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHStep.m +35 -0
  89. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHStepArgument.h +4 -0
  90. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHStepArgument.m +5 -0
  91. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTableCell.h +13 -0
  92. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTableCell.m +28 -0
  93. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTableRow.h +13 -0
  94. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTableRow.m +29 -0
  95. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTag.h +13 -0
  96. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTag.m +28 -0
  97. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHToken.h +26 -0
  98. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHToken.m +50 -0
  99. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTokenMatcher.h +29 -0
  100. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTokenMatcher.m +283 -0
  101. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTokenScanner.h +12 -0
  102. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/GHTokenScanner.m +59 -0
  103. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/NSString+Trim.h +7 -0
  104. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/NSString+Trim.m +28 -0
  105. data/XCFit/Classes/Cucumberish/Dependencies/Gherkin/gherkin-languages.json +2969 -0
  106. data/XCFit/Classes/Cucumberish/Utils/NSArray+Hashes.h +24 -0
  107. data/XCFit/Classes/Cucumberish/Utils/NSArray+Hashes.m +44 -0
  108. data/XCFit/Classes/Cucumberish/Utils/NSObject+Dictionary.h +7 -0
  109. data/XCFit/Classes/Cucumberish/Utils/NSObject+Dictionary.m +83 -0
  110. data/XCFit/Classes/Cucumberish/Utils/NSString+Formatter.h +32 -0
  111. data/XCFit/Classes/Cucumberish/Utils/NSString+Formatter.m +70 -0
  112. data/Xcode7-Templates/XCFit/Cucumberish UI Test Bundle Base.xctemplate/TemplateInfo.plist +13 -0
  113. data/Xcode7-Templates/XCFit/iOS UI Cucumberish Testing Bundle.xctemplate/TemplateInfo.plist +11 -0
  114. data/lib/XCFit/version.rb +1 -1
  115. metadata +108 -38
  116. data/XCFit/Assets/.gitkeep +0 -0
  117. data/XCFit/Assets/Gherkin/Cucumber Feature.xctemplate/TemplateIcon.png +0 -0
  118. data/XCFit/Assets/Gherkin/Cucumber Feature.xctemplate/TemplateIcon@2x.png +0 -0
  119. data/XCFit/Assets/Gherkin/Cucumber Feature.xctemplate/TemplateInfo.plist +0 -22
  120. data/XCFit/Assets/Gherkin/Cucumber Feature.xctemplate/___FILEBASENAME___.feature +0 -20
  121. data/XCFit/Assets/XCFit/Base Acceptance Tests.xctemplate/AcceptanceTests-Bridging-Header.h +0 -1
  122. data/XCFit/Assets/XCFit/Base Acceptance Tests.xctemplate/FixtureExample.swift +0 -31
  123. data/XCFit/Assets/XCFit/Base Acceptance Tests.xctemplate/SlimTables.h +0 -28
  124. data/XCFit/Assets/XCFit/Base Acceptance Tests.xctemplate/TemplateIcon.png +0 -0
  125. data/XCFit/Assets/XCFit/Base Acceptance Tests.xctemplate/TemplateIcon@2x.png +0 -0
  126. data/XCFit/Assets/XCFit/Base Acceptance Tests.xctemplate/TemplateInfo.plist +0 -150
  127. data/XCFit/Assets/XCFit/Base Acceptance Tests.xctemplate/___PACKAGENAMEASIDENTIFIER___-Bridging-Header.h +0 -1
  128. data/XCFit/Assets/XCFit/Base Acceptance Tests.xctemplate/___PACKAGENAMEASIDENTIFIER___.m +0 -15
  129. data/XCFit/Assets/XCFit/Cucumberish API Test Bundle Base.xctemplate/TemplateIcon.png +0 -0
  130. data/XCFit/Assets/XCFit/Cucumberish API Test Bundle Base.xctemplate/TemplateIcon@2x.png +0 -0
  131. data/XCFit/Assets/XCFit/Cucumberish API Test Bundle Base.xctemplate/TemplateInfo.plist +0 -123
  132. data/XCFit/Assets/XCFit/Cucumberish API Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___-Bridging-Header.h +0 -7
  133. data/XCFit/Assets/XCFit/Cucumberish API Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___.feature +0 -11
  134. data/XCFit/Assets/XCFit/Cucumberish API Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___.h +0 -14
  135. data/XCFit/Assets/XCFit/Cucumberish API Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___.m +0 -17
  136. data/XCFit/Assets/XCFit/Cucumberish API Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___.swift +0 -23
  137. data/XCFit/Assets/XCFit/Cucumberish UI Test Bundle Base.xctemplate/TemplateIcon.png +0 -0
  138. data/XCFit/Assets/XCFit/Cucumberish UI Test Bundle Base.xctemplate/TemplateIcon@2x.png +0 -0
  139. data/XCFit/Assets/XCFit/Cucumberish UI Test Bundle Base.xctemplate/TemplateInfo.plist +0 -123
  140. data/XCFit/Assets/XCFit/Cucumberish UI Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___-Bridging-Header.h +0 -7
  141. data/XCFit/Assets/XCFit/Cucumberish UI Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___.feature +0 -11
  142. data/XCFit/Assets/XCFit/Cucumberish UI Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___.h +0 -14
  143. data/XCFit/Assets/XCFit/Cucumberish UI Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___.m +0 -17
  144. data/XCFit/Assets/XCFit/Cucumberish UI Test Bundle Base.xctemplate/___PACKAGENAMEASIDENTIFIER___.swift +0 -25
  145. data/XCFit/Assets/XCFit/Mac Acceptance Tests.xctemplate/Empty.xib +0 -12
  146. data/XCFit/Assets/XCFit/Mac Acceptance Tests.xctemplate/TemplateInfo.plist +0 -54
  147. data/XCFit/Assets/XCFit/MacOS API Cucumberish Testing Bundle.xctemplate/TemplateInfo.plist +0 -39
  148. data/XCFit/Assets/XCFit/MacOS UI Cucumberish Testing Bundle.xctemplate/TemplateInfo.plist +0 -39
  149. data/XCFit/Assets/XCFit/iOS API Cucumberish Testing Bundle.xctemplate/TemplateInfo.plist +0 -39
  150. data/XCFit/Assets/XCFit/iOS Acceptance Tests.xctemplate/TemplateInfo.plist +0 -52
  151. data/XCFit/Assets/XCFit/iOS UI Cucumberish Testing Bundle.xctemplate/TemplateInfo.plist +0 -39
@@ -0,0 +1,10 @@
1
+ #import <Foundation/Foundation.h>
2
+ @class GHGherkinDialect;
3
+ @class GHLocation;
4
+
5
+ @protocol GHGherkinDialectProviderProtocol <NSObject>
6
+
7
+ @property (nonatomic, readonly) GHGherkinDialect * defaultDialect;
8
+ - (GHGherkinDialect *)dialectWithLanguage:(NSString *)theLanguage location:(GHLocation *)theLocation;
9
+
10
+ @end
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+ extern NSString * const GHTagPrefix;
3
+ extern NSString * const GHCommentPrefix;
4
+ extern NSString * const GHTitleKeywordSeparator;
5
+ extern NSString * const GHTableCellSeparator;
6
+ extern NSString * const GHTableCellEscape;
7
+ extern NSString * const GHTableCellNewlineEscape;
8
+ extern NSString * const GHDocStringSeparator;
9
+ extern NSString * const GHDocStringAlternativeSeparator;
@@ -0,0 +1,10 @@
1
+ #import "GHGherkinLanguageConstants.h"
2
+
3
+ NSString * const GHTagPrefix = @"@";
4
+ NSString * const GHCommentPrefix = @"#";
5
+ NSString * const GHTitleKeywordSeparator = @":";
6
+ NSString * const GHTableCellSeparator = @"|";
7
+ NSString * const GHTableCellEscape = @"\\";
8
+ NSString * const GHTableCellNewlineEscape = @"n";
9
+ NSString * const GHDocStringSeparator = @"\"\"\"";
10
+ NSString * const GHDocStringAlternativeSeparator = @"```";
@@ -0,0 +1,17 @@
1
+ #import <Foundation/Foundation.h>
2
+ @interface GHGherkinLanguageSetting : NSObject
3
+
4
+ @property (nonatomic, strong) NSString * name;
5
+ @property (nonatomic, strong) NSString * native;
6
+ @property (nonatomic, strong) NSArray<NSString *> * feature;
7
+ @property (nonatomic, strong) NSArray<NSString *> * background;
8
+ @property (nonatomic, strong) NSArray<NSString *> * scenario;
9
+ @property (nonatomic, strong) NSArray<NSString *> * scenarioOutline;
10
+ @property (nonatomic, strong) NSArray<NSString *> * examples;
11
+ @property (nonatomic, strong) NSArray<NSString *> * given;
12
+ @property (nonatomic, strong) NSArray<NSString *> * when;
13
+ @property (nonatomic, strong) NSArray<NSString *> * then;
14
+ @property (nonatomic, strong) NSArray<NSString *> * and;
15
+ @property (nonatomic, strong) NSArray<NSString *> * but;
16
+
17
+ @end
@@ -0,0 +1,18 @@
1
+ #import "GHGherkinLanguageSetting.h"
2
+
3
+ @implementation GHGherkinLanguageSetting
4
+
5
+ @synthesize name;
6
+ @synthesize native;
7
+ @synthesize feature;
8
+ @synthesize background;
9
+ @synthesize scenario;
10
+ @synthesize scenarioOutline;
11
+ @synthesize examples;
12
+ @synthesize given;
13
+ @synthesize when;
14
+ @synthesize then;
15
+ @synthesize and;
16
+ @synthesize but;
17
+
18
+ @end
@@ -0,0 +1,12 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ #import "GHGherkinLineProtocol.h"
4
+
5
+ @interface GHGherkinLine : NSObject <GHGherkinLineProtocol>
6
+
7
+ @property (nonatomic, readonly) NSString * lineText;
8
+ @property (nonatomic, readonly) NSUInteger lineNumber;
9
+
10
+ - (id)initWithLine:(NSString *)theLine lineNumber:(NSUInteger)theLineNumber;
11
+
12
+ @end
@@ -0,0 +1,179 @@
1
+ #import "GHGherkinLine.h"
2
+
3
+ #import "GHGherkinLanguageConstants.h"
4
+ #import "GHGherkinLineSpan.h"
5
+
6
+ #import "NSString+Trim.h"
7
+
8
+ @interface GHGherkinLine ()
9
+
10
+ @property (nonatomic, strong) NSString * lineText;
11
+ @property (nonatomic, assign) NSUInteger lineNumber;
12
+
13
+ - (NSMutableArray<NSArray<NSObject *> *> *)splitCellsFromRow:(NSString *)theRow;
14
+ - (NSString *)trim:(NSString *)theString trimmedCharsCount:(NSUInteger *)theTrimmedCharsCount;
15
+ + (BOOL)startsWithFrom:(NSString *)theText index:(NSInteger)theTextIndex value:(NSString *)theValue;
16
+
17
+ @end
18
+
19
+ @implementation GHGherkinLine
20
+ {
21
+ NSString * trimmedLineText;
22
+ }
23
+
24
+ @synthesize lineText;
25
+ @synthesize lineNumber;
26
+
27
+ - (id)initWithLine:(NSString *)theLine lineNumber:(NSUInteger)theLineNumber
28
+ {
29
+ if (self = [super init])
30
+ {
31
+ lineNumber = theLineNumber;
32
+ lineText = theLine;
33
+ trimmedLineText = [theLine stringByTrimmingStartWithCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
34
+ }
35
+
36
+ return self;
37
+ }
38
+
39
+ - (void)detach
40
+ {
41
+ //nop
42
+ }
43
+
44
+ - (NSUInteger)indent
45
+ {
46
+ return [lineText length] - [trimmedLineText length];
47
+ }
48
+
49
+ - (BOOL)empty
50
+ {
51
+ return trimmedLineText && ![trimmedLineText length];
52
+ }
53
+
54
+ - (BOOL)hasPrefix:(NSString *)theText
55
+ {
56
+ return [trimmedLineText hasPrefix: theText];
57
+ }
58
+
59
+ - (BOOL)hasTitleKeywordPrefix:(NSString *)theText
60
+ {
61
+ NSUInteger textLength = [theText length];
62
+ return [trimmedLineText length] > textLength && [trimmedLineText hasPrefix: theText] &&
63
+ [GHGherkinLine startsWithFrom: trimmedLineText index: textLength value: GHTitleKeywordSeparator];
64
+ }
65
+
66
+ + (BOOL)startsWithFrom:(NSString *)theText index:(NSInteger)theTextIndex value:(NSString *)theValue
67
+ {
68
+ NSUInteger valueLength = [theValue length];
69
+ NSString * textSubstring = [theText substringWithRange: NSMakeRange(theTextIndex, valueLength)];
70
+ NSString * valueSubstring = [theValue substringWithRange: NSMakeRange(0, valueLength)];
71
+
72
+ return [textSubstring compare: valueSubstring options: NSLiteralSearch] == NSOrderedSame;
73
+ }
74
+
75
+ - (NSString *)lineTextByRemovingIndent:(NSInteger)theIndentToRemove
76
+ {
77
+ if (theIndentToRemove < 0 || theIndentToRemove > [self indent])
78
+ return trimmedLineText;
79
+
80
+ return [lineText substringFromIndex: theIndentToRemove];
81
+ }
82
+
83
+ - (NSString *)trimmedRest:(NSUInteger)theLength
84
+ {
85
+ return [[trimmedLineText substringFromIndex: theLength] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
86
+ }
87
+
88
+ - (NSArray<GHGherkinLineSpan *> *)tags
89
+ {
90
+ NSInteger position = [self indent];
91
+ NSMutableArray * tags = [[NSMutableArray alloc] init];
92
+
93
+ for (NSString * item in [trimmedLineText componentsSeparatedByCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]])
94
+ {
95
+ if ([item length])
96
+ {
97
+ [tags addObject: [[GHGherkinLineSpan alloc] initWithColumn: position + 1 text: item]];
98
+ position += [item length];
99
+ }
100
+ position++; // separator
101
+ }
102
+
103
+ return [[NSArray alloc] initWithArray: tags];
104
+ }
105
+
106
+ - (NSArray<GHGherkinLineSpan *> *)tableCells
107
+ {
108
+ NSMutableArray<NSArray<NSObject *> *> * items = [self splitCellsFromRow: trimmedLineText];
109
+ [items removeLastObject];
110
+
111
+ NSMutableArray * tableCells = [[NSMutableArray alloc] init];
112
+ BOOL isBeforeFirst = YES;
113
+ for (NSArray * item in items)
114
+ {
115
+ if (!isBeforeFirst)
116
+ {
117
+ NSUInteger trimmedStart = 0;
118
+ NSString * cellText = [self trim: [item firstObject] trimmedCharsCount: &trimmedStart];
119
+ NSUInteger cellPosition = [[item lastObject] integerValue] + trimmedStart;
120
+
121
+ if (![cellText length])
122
+ cellPosition = [[item lastObject] integerValue];
123
+
124
+ [tableCells addObject: [[GHGherkinLineSpan alloc] initWithColumn: [self indent] + cellPosition + 1 text: cellText]];
125
+ }
126
+
127
+ isBeforeFirst = NO;
128
+ }
129
+
130
+ return tableCells;
131
+ }
132
+
133
+ - (NSMutableArray<NSArray<NSObject *> *> *)splitCellsFromRow:(NSString *)theRow
134
+ {
135
+ NSMutableString * cell = [[NSMutableString alloc] init];
136
+ NSInteger startPos = 0;
137
+ NSMutableArray<NSArray<NSObject *> *> * items = [[NSMutableArray alloc] init];
138
+ NSUInteger rowLength = [theRow length];
139
+ for (NSUInteger i = 0; i < rowLength; i++)
140
+ {
141
+ NSString * stringCharacter = [theRow substringWithRange: NSMakeRange(i, 1)];
142
+ if ([stringCharacter isEqualToString: GHTableCellSeparator])
143
+ {
144
+ [items addObject: @[ cell, @(startPos)]];
145
+ cell = [[NSMutableString alloc] init];
146
+ startPos = i + 1;
147
+ }
148
+ else if ([stringCharacter isEqualToString: GHTableCellEscape])
149
+ {
150
+ stringCharacter = i + 1 < rowLength ? [theRow substringWithRange: NSMakeRange(++i, 1)] : nil;
151
+ if ([stringCharacter isEqualToString: GHTableCellNewlineEscape])
152
+ [cell appendString: @"\n"];
153
+ else
154
+ {
155
+ if (![stringCharacter isEqualToString: GHTableCellSeparator] && ![stringCharacter isEqualToString: GHTableCellEscape])
156
+ [cell appendString: GHTableCellEscape];
157
+ [cell appendString: stringCharacter];
158
+ }
159
+ }
160
+ else
161
+ [cell appendString: stringCharacter];
162
+ }
163
+ [items addObject: @[ cell, @(startPos)]];
164
+
165
+ return items;
166
+ }
167
+
168
+ - (NSString *)trim:(NSString *)theString trimmedCharsCount:(NSUInteger *)theTrimmedCharsCount
169
+ {
170
+ NSUInteger trimmedCharsCount = 0;
171
+ NSCharacterSet * whitespaceAndNewLineCharacterSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
172
+ while (trimmedCharsCount < [theString length] && [whitespaceAndNewLineCharacterSet characterIsMember: [theString characterAtIndex: trimmedCharsCount]])
173
+ trimmedCharsCount++;
174
+
175
+ *theTrimmedCharsCount = trimmedCharsCount;
176
+ return [theString stringByTrimmingCharactersInSet: whitespaceAndNewLineCharacterSet];
177
+ }
178
+
179
+ @end
@@ -0,0 +1,64 @@
1
+ #import <Foundation/Foundation.h>
2
+ @class GHGherkinLineSpan;
3
+
4
+ @protocol GHGherkinLineProtocol <NSObject>
5
+
6
+ @property (nonatomic, readonly) NSString * lineText;
7
+ @property (nonatomic, readonly) NSUInteger lineNumber;
8
+ @property (nonatomic, readonly) NSUInteger indent;
9
+
10
+ /// <summary>
11
+ /// Called by the parser to indicate non-streamed reading (e.g. during look-ahead).
12
+ /// </summary>
13
+ /// <remarks>
14
+ /// If the implementation depends on streamed reading behavior, with this method, it can clone itself, so that it will be detached.
15
+ /// </remarks>
16
+ - (void)detach;
17
+
18
+ /// <summary>
19
+ /// Gets if the line is empty or contains whitespaces only.
20
+ /// </summary>
21
+ /// <returns>YES, if empty or contains whitespaces only; otherwise, NO.</returns>
22
+ - (BOOL)empty;
23
+
24
+ /// <summary>
25
+ /// Determines whether the beginning of the line (wihtout whitespaces) matches a specified string.
26
+ /// </summary>
27
+ /// <param name="theText">The string to compare. </param>
28
+ /// <returns>YES if text matches the beginning of this line; otherwise, NO.</returns>
29
+ - (BOOL)hasPrefix:(NSString *)theText;
30
+
31
+ /// <summary>
32
+ /// Determines whether the beginning of the line (wihtout whitespaces) matches a specified title keyword (ie. a keyword followed by a ':' character).
33
+ /// </summary>
34
+ /// <param name="theKeyword">The keyword to compare. </param>
35
+ /// <returns>YES if keyword matches the beginning of this line and followed by a ':' character; otherwise, NO.</returns>
36
+ - (BOOL)hasTitleKeywordPrefix:(NSString *)theKeyword;
37
+
38
+ /// <summary>
39
+ /// Returns the line text
40
+ /// </summary>
41
+ /// <param name="theIndentToRemove">The maximum number of whitespace characters to remove. -1 removes all leading whitespaces.</param>
42
+ /// <returns>The line text.</returns>
43
+ - (NSString *)lineTextByRemovingIndent:(NSInteger)theIndentToRemove;
44
+
45
+ /// <summary>
46
+ /// Returns the remaining part of the line.
47
+ /// </summary>
48
+ /// <param name="theLength"></param>
49
+ /// <returns></returns>
50
+ - (NSString *)trimmedRest:(NSUInteger)theLength;
51
+
52
+ /// <summary>
53
+ /// Tries parsing the line as a tag list, and returns the tags wihtout the leading '@' characters.
54
+ /// </summary>
55
+ /// <returns>(position,text) pairs, position is 0-based index</returns>
56
+ - (NSArray<GHGherkinLineSpan *> *)tags;
57
+
58
+ /// <summary>
59
+ /// Tries parsing the line as table row and returns the trimmed cell values.
60
+ /// </summary>
61
+ /// <returns>(position,text) pairs, position is 0-based index</returns>
62
+ - (NSArray<GHGherkinLineSpan *> *)tableCells;
63
+
64
+ @end
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+ @interface GHGherkinLineSpan : NSObject
3
+
4
+ @property (nonatomic, readonly) NSUInteger column;
5
+ @property (nonatomic, readonly) NSString * text;
6
+
7
+ - (id)initWithColumn:(NSUInteger)theColumn text:(NSString *)theText;
8
+
9
+ @end
@@ -0,0 +1,26 @@
1
+ 
2
+ #import "GHGherkinLineSpan.h"
3
+
4
+ @interface GHGherkinLineSpan ()
5
+
6
+ @property (nonatomic, assign) NSUInteger column;
7
+ @property (nonatomic, strong) NSString * text;
8
+
9
+ @end
10
+
11
+ @implementation GHGherkinLineSpan
12
+
13
+ @synthesize column;
14
+ @synthesize text;
15
+
16
+ - (id)initWithColumn:(NSUInteger)theColumn text:(NSString *)theText
17
+ {
18
+ if (self = [super init])
19
+ {
20
+ column = theColumn;
21
+ text = theText;
22
+ }
23
+ return self;
24
+ }
25
+
26
+ @end
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ @protocol GHHasDescriptionProtocol <NSObject>
3
+
4
+ @property (nonatomic, readonly) NSString * keyword;
5
+ @property (nonatomic, readonly) NSString * name;
6
+ @property (nonatomic, readonly) NSString * desc;
7
+
8
+ @end
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ @class GHLocation;
3
+
4
+ @protocol GHHasLocationProtocol <NSObject>
5
+
6
+ @property (nonatomic, readonly) GHLocation * location;
7
+
8
+ @end
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ @class GHTableRow;
3
+
4
+ @protocol GHHasRowsProtocol <NSObject>
5
+
6
+ @property (nonatomic, readonly) NSArray<GHTableRow *> * rows;
7
+
8
+ @end
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ @class GHStep;
3
+
4
+ @protocol GHHasStepsProtocol <NSObject>
5
+
6
+ @property (nonatomic, readonly) NSArray<GHStep *> * steps;
7
+
8
+ @end
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ @class GHTag;
3
+
4
+ @protocol GHHasTagsProtocol <NSObject>
5
+
6
+ @property (nonatomic, readonly) NSArray<GHTag *> * tags;
7
+
8
+ @end
@@ -0,0 +1,12 @@
1
+ #import <Foundation/Foundation.h>
2
+ @interface GHLocation : NSObject
3
+
4
+ @property (nonatomic, readonly) NSUInteger line;
5
+ @property (nonatomic, readonly) NSUInteger column;
6
+
7
+ - (id)init;
8
+ - (id)initWithLine:(NSUInteger)theLine;
9
+ - (id)initWithColumn:(NSUInteger)theColumn;
10
+ - (id)initWithLine:(NSUInteger)theLine column:(NSUInteger)theColumn;
11
+
12
+ @end
@@ -0,0 +1,41 @@
1
+ #import "GHLocation.h"
2
+
3
+ @interface GHLocation ()
4
+
5
+ @property (nonatomic, assign) NSUInteger line;
6
+ @property (nonatomic, assign) NSUInteger column;
7
+
8
+ @end
9
+
10
+ @implementation GHLocation
11
+
12
+ @synthesize line;
13
+ @synthesize column;
14
+
15
+ - (id)init
16
+ {
17
+ return [self initWithLine: 0 column: 0];
18
+ }
19
+
20
+ - (id)initWithLine:(NSUInteger)theLine
21
+ {
22
+ return [self initWithLine: theLine column: 0];
23
+ }
24
+
25
+ - (id)initWithColumn:(NSUInteger)theColumn
26
+ {
27
+ return [self initWithLine: 0 column: theColumn];
28
+ }
29
+
30
+ - (id)initWithLine:(NSUInteger)theLine column:(NSUInteger)theColumn
31
+ {
32
+ if (self = [super init])
33
+ {
34
+ line = theLine;
35
+ column = theColumn;
36
+ }
37
+
38
+ return self;
39
+ }
40
+
41
+ @end