cobplexity 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cobplexity/line.rb +13 -10
- metadata +1 -1
data/lib/cobplexity/line.rb
CHANGED
@@ -2,7 +2,7 @@ module Cobplexity
|
|
2
2
|
|
3
3
|
class Line
|
4
4
|
def initialize line
|
5
|
-
@line = line.
|
5
|
+
@line = line.rstrip
|
6
6
|
end
|
7
7
|
def code?
|
8
8
|
!self.blank? && !self.comment? && !self.continuation? && !self.paragraph? && !self.procedure_division?
|
@@ -10,6 +10,9 @@ module Cobplexity
|
|
10
10
|
def blank?
|
11
11
|
self.statement.empty?
|
12
12
|
end
|
13
|
+
def paragraph?
|
14
|
+
!self.comment? && !self.continuation? && !self.area_a.empty? && !self.copy_statement?
|
15
|
+
end
|
13
16
|
def comment?
|
14
17
|
self.control == '*'
|
15
18
|
end
|
@@ -18,26 +21,26 @@ module Cobplexity
|
|
18
21
|
end
|
19
22
|
def branches
|
20
23
|
self.statement.split.count do |item|
|
21
|
-
['IF', 'ELSE', 'WHEN', 'WHILE', 'UNTIL'].include? item.upcase
|
24
|
+
['IF', 'ELSE', 'WHEN', 'WHILE', 'UNTIL', 'AND', 'OR'].include? item.upcase
|
22
25
|
end
|
23
26
|
end
|
24
|
-
def paragraph?
|
25
|
-
!self.statement.match(/COPY /i) && !self.area_a.strip.empty?
|
26
|
-
end
|
27
27
|
def paragraph_name
|
28
28
|
self.statement.strip.delete '.'
|
29
29
|
end
|
30
|
+
def copy_statement?
|
31
|
+
self.statement.match /COPY /i
|
32
|
+
end
|
33
|
+
def procedure_division?
|
34
|
+
self.statement.match /PROCEDURE DIVISION\./i
|
35
|
+
end
|
30
36
|
def area_a
|
31
|
-
self.statement[0..3]
|
37
|
+
self.statement[0..3].strip
|
32
38
|
end
|
33
39
|
def control
|
34
40
|
@line.length > 6 ? @line[6] : ' '
|
35
41
|
end
|
36
42
|
def statement
|
37
|
-
@line.length > 7 ? @line[7
|
38
|
-
end
|
39
|
-
def procedure_division?
|
40
|
-
@line.match /PROCEDURE DIVISION/i
|
43
|
+
@line.length > 7 ? @line[7..71] : ''
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|