Skip to content

Commit

Permalink
Merge pull request #14 from CocoaPods/seg-unquoted-string-all-valid-c…
Browse files Browse the repository at this point in the history
…hars

[Reader] Allow reading all valid characters in unquoted strings
  • Loading branch information
segiddins authored Nov 3, 2016
2 parents e4487db + 4faef3d commit b1e0382
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

##### Bug Fixes

* None.
* Fix reading all supported characters in unquoted strings.
[Samuel Giddins](https://github.com/segiddins)
[#13](https://github.com/CocoaPods/Nanaimo/issues/13)


## 0.2.0 (2016-11-02)
Expand Down
2 changes: 1 addition & 1 deletion lib/nanaimo/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def parse_object

def parse_string
eat_whitespace!
unless match = @scanner.scan(%r{[\w/.$]+})
unless match = @scanner.scan(%r{[\w_$/:.-]+}o)
raise_parser_error ParseError, "Invalid character #{current_character.inspect} in unquoted string"
end
Nanaimo::String.new(match, nil)
Expand Down
13 changes: 13 additions & 0 deletions spec/nanaimo/reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ module Nanaimo
expect(subject).to eq Nanaimo::Dictionary.new({ Nanaimo::String.new('key', '') => Nanaimo::String.new('$PROJECT_DIR/mogenerator/mogenerator', '') }, '')
end
end

describe 'that contain' do
valid_characters = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + %w(_ $ / : . -)
valid_characters << valid_characters.join('')
valid_characters.each do |c|
describe "the valid character `#{c}`" do
let(:unquoted_string) { c }
it 'is parsed correctly' do
expect(subject).to eq Nanaimo::Dictionary.new({ Nanaimo::String.new('key', '') => Nanaimo::String.new(c, '') }, '')
end
end
end
end
end

describe 'quoted strings' do
Expand Down

0 comments on commit b1e0382

Please sign in to comment.