Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #29 from petems/fix_resources_with_variable_names
Browse files Browse the repository at this point in the history
Fixes resources with variable name
  • Loading branch information
Wliu authored and Wliu committed Mar 12, 2016
2 parents 3785bd3 + 52b9b43 commit 6879ea1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions grammars/puppet.cson
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@
'match': '^\\s*(\\w+)\\s*{\\s*([\'"].+[\'"]):'
'name': 'meta.definition.resource.puppet'
}
{
'match': '^\\s*(\\w+)\\s*{\\s*(\\$[a-zA-Z_]+)\\s*:'
'captures':
'1':
'name': 'storage.type.puppet'
'2':
'name': 'entity.name.section.puppet'
'name': 'meta.definition.resource.puppet'
}
{
'match': '\\b(case|if|else|elsif)(?!::)\\b'
'name': 'keyword.control.puppet'
Expand Down
10 changes: 10 additions & 0 deletions spec/puppet-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ describe "Puppet grammar", ->
it "tokenizes contain as an include function", ->
{tokens} = grammar.tokenizeLine('include foo')
expect(tokens[0]).toEqual value: 'include', scopes: ['source.puppet', 'meta.include.puppet', 'keyword.control.import.include.puppet']

it "tokenizes resource type and string title", ->
{tokens} = grammar.tokenizeLine("package {'foo':}")
expect(tokens[0]).toEqual value: 'package', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'storage.type.puppet']
expect(tokens[2]).toEqual value: "'foo'", scopes: ['source.puppet', 'meta.definition.resource.puppet', 'entity.name.section.puppet']

it "tokenizes resource type and variable title", ->
{tokens} = grammar.tokenizeLine("package {$foo:}")
expect(tokens[0]).toEqual value: 'package', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'storage.type.puppet']
expect(tokens[2]).toEqual value: '$foo', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'entity.name.section.puppet']

0 comments on commit 6879ea1

Please sign in to comment.