coderay_bash 1.0.1 → 1.0.2

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/coderay_bash.gemspec CHANGED
@@ -13,7 +13,7 @@ spec = Gem::Specification.new do |s|
13
13
  s.email = "pejuko@gmail.com"
14
14
  s.authors = ["Petr Kovar"]
15
15
  s.name = 'coderay_bash'
16
- s.version = '1.0.1'
16
+ s.version = '1.0.2'
17
17
  s.date = Time.now.strftime("%Y-%m-%d")
18
18
  s.add_dependency('coderay', '>= 1.0')
19
19
  s.require_path = 'lib'
@@ -66,6 +66,8 @@ module CodeRay module Scanners
66
66
  @state = :initial
67
67
  @quote = nil
68
68
  @shell = false
69
+ @brace_shell = 0
70
+ @quote_brace_shell = 0
69
71
  end
70
72
 
71
73
  def scan_tokens encoder, options
@@ -106,12 +108,13 @@ module CodeRay module Scanners
106
108
  next
107
109
  elsif match = scan(/`/)
108
110
  if @shell
111
+ encoder.text_token(match, :delimiter)
109
112
  encoder.end_group :shell
110
113
  else
111
114
  encoder.begin_group :shell
115
+ encoder.text_token(match, :delimiter)
112
116
  end
113
117
  @shell = (not @shell)
114
- encoder.text_token(match, :delimiter)
115
118
  next
116
119
  elsif match = scan(/'[^']*'?/)
117
120
  kind = :string
@@ -137,8 +140,19 @@ module CodeRay module Scanners
137
140
  end
138
141
  kind = IDENT_KIND[var]
139
142
  kind = :instance_variable if kind == :ident
140
- elsif match = scan(/ \$\( [^\)]+ \) /ox)
141
- kind = :shell
143
+ #elsif match = scan(/ \$\( [^\)]+ \) /ox)
144
+ elsif match = scan(/ \$\( /ox)
145
+ @brace_shell += 1
146
+ encoder.begin_group :shell
147
+ encoder.text_token(match, :delimiter)
148
+ next
149
+ elsif match = scan(/ \) /ox)
150
+ if @brace_shell > 0
151
+ encoder.text_token(match, :delimiter)
152
+ encoder.end_group :shell
153
+ @brace_shell -= 1
154
+ next
155
+ end
142
156
  elsif match = scan(PRE_CONSTANTS)
143
157
  kind = :predefined_constant
144
158
  elsif match = scan(/[^\s'"]*[A-Za-z_][A-Za-z_0-9]*\+?=/)
@@ -202,6 +216,20 @@ module CodeRay module Scanners
202
216
  kind = :predefined_constant
203
217
  elsif match = scan(/ (?: \$\(\(.*?\)\) ) /x)
204
218
  kind = :global_variable
219
+ elsif match = scan(/ \$\( /ox)
220
+ encoder.begin_group :shell
221
+ encoder.text_token(match, :delimiter)
222
+ @quote_brace_shell += 1
223
+ next
224
+ elsif match = scan(/\)/)
225
+ if @quote_brace_shell > 0
226
+ encoder.text_token(match, :delimiter)
227
+ encoder.end_group :shell
228
+ @quote_brace_shell -= 1
229
+ next
230
+ else
231
+ kind = :content
232
+ end
205
233
  elsif match = scan(/ \$ (?: (?: \{ [^\}]* \}) | (?: [A-Za-z_0-9]+ ) ) /x)
206
234
  match =~ /(\$\{?)([^\}]*)(\}?)/
207
235
  pre=$1
@@ -215,7 +243,7 @@ module CodeRay module Scanners
215
243
  end
216
244
  kind = IDENT_KIND[match]
217
245
  kind = :instance_variable if kind == :ident
218
- elsif match = scan(/[^#{@quote}\\]+/)
246
+ elsif match = scan(/[^\)\$#{@quote}\\]+/)
219
247
  kind = :content
220
248
  else match = scan(/.+/)
221
249
  # this shouldn't be
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coderay_bash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-11 00:00:00.000000000Z
12
+ date: 2012-03-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coderay
16
- requirement: &14527500 !ruby/object:Gem::Requirement
16
+ requirement: &14542400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *14527500
24
+ version_requirements: *14542400
25
25
  description: ! 'Bash highlighting for coderay. This gem was tested with coderay 1.0
26
26
  and won''t work with coderay < 1.0.
27
27
 
@@ -34,9 +34,9 @@ files:
34
34
  - README.md
35
35
  - coderay_bash.gemspec
36
36
  - Rakefile
37
- - lib/coderay/scanners/erb_bash.rb
38
- - lib/coderay/scanners/bash.rb
39
37
  - lib/coderay_bash.rb
38
+ - lib/coderay/scanners/bash.rb
39
+ - lib/coderay/scanners/erb_bash.rb
40
40
  homepage: http://github.com/pejuko/coderay_bash
41
41
  licenses: []
42
42
  post_install_message: ! 'This gem was tested with coderay 1.0 and won''t work with
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project:
63
- rubygems_version: 1.8.15
63
+ rubygems_version: 1.8.10
64
64
  signing_key:
65
65
  specification_version: 3
66
66
  summary: Simple bash scanner for highlighting with coderay.