Skip to content

Commit

Permalink
Merge pull request #17 from Sage/issue_16-prevent_parsing_errors_caus…
Browse files Browse the repository at this point in the history
…ed_by_leading_bom_character

Fixes #16: Prevent parsing errors caused by leading BOM character
  • Loading branch information
wteuber authored Jun 1, 2017
2 parents 1b6df70 + 44e0974 commit 0cfa3bf
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added

### Changed

### Removed


## [0.2.1] - 2017-06-01
### Added
- CHANGELOG.md

### Changed
- Fix handling of UTF-8-encoded files using byte order mark


## [0.2.0] - 2017-05-10
### Added
- Add file configuration to rake task
- Add YAML check service, including rake task
- Add ci_task helper methods
- Add more documentation and improve wording

### Changed
- Enable RSpec's verify_partial_doubles and disable_monkey_patching
- Change License to Apache-2.0
- Move CI helper methods to separate file
- Make printed file paths relative
- Disable output while running specs
- Update section Usage in README
- Make "rake ci" the default rake task

### Removed
- Remove flay
- Remove cane
- Remove Ruby refinements


## [0.1.0] - 2017-04-07
### Added
- Minimal initial version of "YAML Normalizer", fmi see README.md
2 changes: 1 addition & 1 deletion lib/yaml_normalizer/services/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def call

def normalized?(file)
file = Pathname.new(file).relative_path_from(Pathname.new(Dir.pwd))
input = File.read(file)
input = File.read(file, mode: 'r:bom|utf-8')
norm = normalize_yaml(input)

if input.eql?(norm)
Expand Down
3 changes: 2 additions & 1 deletion lib/yaml_normalizer/services/normalize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def call

def normalize!(file)
file = Pathname.new(file).relative_path_from(Pathname.new(Dir.pwd))
if stable?(input = File.read(file), norm = normalize_yaml(input))
if stable?(input = File.read(file, mode: 'r:bom|utf-8'),
norm = normalize_yaml(input))
File.open(file, 'w') { |f| f.write(norm) }
$stderr.puts "[NORMALIZED] #{file}"
else
Expand Down
2 changes: 1 addition & 1 deletion lib/yaml_normalizer/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module YamlNormalizer
# The current Yaml Normalizer version
VERSION = '0.2.0'
VERSION = '0.2.1'
end
2 changes: 1 addition & 1 deletion spec/data/valid2.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
this: is
a:
- valid
Expand Down
2 changes: 1 addition & 1 deletion spec/data/valid2_normalized.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
a:
- valid
- yaml
Expand Down

0 comments on commit 0cfa3bf

Please sign in to comment.