sugar_utils 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +11 -1
- data/lib/sugar_utils/file.rb +6 -2
- data/lib/sugar_utils/version.rb +1 -1
- data/spec/sugar_utils/file_spec.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b470d625c6383906e21070cde292ed14a90fd80e
|
4
|
+
data.tar.gz: 455983e1fc7a18e0d6a2eea4f9cef67ed25a2804
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cddd4ee3cabe8b6e76f93d4ac9c2be1be91d0a441d408f8234e07fddadd269d6a9ac257e527b8e9aba5203ae12d2157d40fa2107b15490968710010d413601f1
|
7
|
+
data.tar.gz: 01b451f98527ac178922e6c1f0f9bf6bc493fa6632cd3633d87f6a245f644e9b8a7ea577052e8b3db2942b2f8968d51f67d48a10aaa3717c9281f861d9fc0042
|
data/.travis.yml
CHANGED
@@ -5,14 +5,14 @@ rvm:
|
|
5
5
|
- 2.2
|
6
6
|
- 2.3
|
7
7
|
- 2.4
|
8
|
+
- 2.5
|
8
9
|
- ruby-head
|
9
10
|
matrix:
|
10
11
|
allow_failures:
|
11
12
|
- rvm: ruby-head
|
12
|
-
|
13
|
-
- rvm: 2.4
|
13
|
+
- rvm: 2.0
|
14
14
|
os: osx
|
15
|
-
- rvm:
|
15
|
+
- rvm: 2.4
|
16
16
|
os: osx
|
17
17
|
os:
|
18
18
|
- linux
|
@@ -22,4 +22,4 @@ addons:
|
|
22
22
|
code_climate:
|
23
23
|
repo_token: c250bc1551dd13a07efdd5bc8a594924f6f762f7be9762e79da0c8f065cf93dd
|
24
24
|
after_success:
|
25
|
-
- bundle exec codeclimate-test-reporter
|
25
|
+
- bundle exec codeclimate-test-reporter
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
|
-
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.4.4] - 2018-01-31
|
10
|
+
### Changed
|
11
|
+
- fixed a bug in SugarUtils::File.read_json which it would raise an exception
|
12
|
+
instead of returning an empty Hash, when :raise_on_missing was disabled and
|
13
|
+
there was an error reading the file
|
4
14
|
|
5
15
|
## [0.4.3] - 2017-08-25
|
6
16
|
### Added
|
data/lib/sugar_utils/file.rb
CHANGED
@@ -91,8 +91,12 @@ module SugarUtils
|
|
91
91
|
#
|
92
92
|
# @return [Object]
|
93
93
|
def self.read_json(filename, options = {})
|
94
|
-
options[:value_on_missing] =
|
95
|
-
|
94
|
+
options[:value_on_missing] = :missing
|
95
|
+
|
96
|
+
read_result = read(filename, options)
|
97
|
+
return {} if read_result == :missing
|
98
|
+
|
99
|
+
MultiJson.load(read_result)
|
96
100
|
rescue MultiJson::ParseError
|
97
101
|
raise(Error, "Cannot parse #{filename}")
|
98
102
|
end
|
data/lib/sugar_utils/version.rb
CHANGED
@@ -94,13 +94,14 @@ describe SugarUtils::File do
|
|
94
94
|
|
95
95
|
before do
|
96
96
|
allow(described_class).to receive(:read)
|
97
|
-
.with(:filename, key: :value, value_on_missing:
|
97
|
+
.with(:filename, key: :value, value_on_missing: :missing)
|
98
98
|
.and_return(file_content)
|
99
99
|
end
|
100
100
|
|
101
101
|
inputs :file_content
|
102
102
|
raise_error_with 'I am not json', described_class::Error
|
103
103
|
raise_error_with 'I am not json', 'Cannot parse filename'
|
104
|
+
it_with :missing, Hash[]
|
104
105
|
it_with Hash['key' => 'value'].to_json, Hash['key' => 'value']
|
105
106
|
end
|
106
107
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugar_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Sullivan Cant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|