nasl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -72,6 +72,10 @@ module Nasl
72
72
  # end of the line that the inner region finishes on.
73
73
  outer = bol(inner.begin)..eol(inner.end) if outer.nil?
74
74
 
75
+ # If the outer region argument was provided, but wasn't a Range, access
76
+ # its region member.
77
+ outer = outer.region unless outer.is_a? Range
78
+
75
79
  ctx = ""
76
80
  point = inner.begin
77
81
 
@@ -81,18 +85,18 @@ module Nasl
81
85
  # Create the text to the left of the region. The only case where there is
82
86
  # no text to the left is at the start of the program.
83
87
  if outer.begin != inner.begin
84
- line = @code[outer.begin..inner.begin - 1]
88
+ line = @code[outer.begin...inner.begin]
85
89
  line = line.color(:green) if color
86
90
  ctx << line
87
91
  end
88
92
 
89
93
  # Create the text in the region.
90
- line = @code[inner.begin..inner.end - 1]
94
+ line = @code[inner.begin...inner.end]
91
95
  line = line.color(:red) if color
92
96
  ctx << line
93
97
 
94
98
  # Create the text to the right of the region.
95
- line = @code[inner.end..outer.end].chomp
99
+ line = @code[inner.end...outer.end].chomp
96
100
  line = line.color(:green) if color
97
101
  ctx << line
98
102
 
@@ -40,6 +40,14 @@ module Nasl
40
40
  @tokens = tokens
41
41
  end
42
42
 
43
+ def context(*args)
44
+ @tokens.first.context(args.shift, region, *args)
45
+ end
46
+
47
+ def region
48
+ @tokens.first.region.begin..@tokens.last.region.end
49
+ end
50
+
43
51
  def to_xml(xml)
44
52
  # Mangle the class name into something more appropriate for XML.
45
53
  name = self.class.name.split('::').last
@@ -1,3 +1,3 @@
1
1
  module Nasl
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nasl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &17198404300 !ruby/object:Gem::Requirement
16
+ requirement: &17197461360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *17198404300
24
+ version_requirements: *17197461360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: builder
27
- requirement: &17198403880 !ruby/object:Gem::Requirement
27
+ requirement: &17197460940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *17198403880
35
+ version_requirements: *17197460940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: racc
38
- requirement: &17198403460 !ruby/object:Gem::Requirement
38
+ requirement: &17197460520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *17198403460
46
+ version_requirements: *17197460520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rainbow
49
- requirement: &17198403040 !ruby/object:Gem::Requirement
49
+ requirement: &17197460100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *17198403040
57
+ version_requirements: *17197460100
58
58
  description:
59
59
  email:
60
60
  - mak@kolybabi.com