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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36772577f62b9ff9bf97a43c288103e1b653f580
4
- data.tar.gz: '089ef8678c5b4bd1c3dd82bd2c31dd5a9cde3f72'
3
+ metadata.gz: b470d625c6383906e21070cde292ed14a90fd80e
4
+ data.tar.gz: 455983e1fc7a18e0d6a2eea4f9cef67ed25a2804
5
5
  SHA512:
6
- metadata.gz: 27010891b94741f46f21632a5b335115d65534745bf374a3a9d78d9c8125a2b355d0b8b8d5dd9cca2ee9eaf6fcab75f11d7efa73bd332ea6a85aae7dddd4aba4
7
- data.tar.gz: 694e4ffec92625ef4154ab9cbfb71ed795c7816ecd090e09f866608a358911dee1c69d98fbdb66aa2f17fd2be6c08f6a1acc0dbb34d6cdd56c4cdf84db4099c6
6
+ metadata.gz: cddd4ee3cabe8b6e76f93d4ac9c2be1be91d0a441d408f8234e07fddadd269d6a9ac257e527b8e9aba5203ae12d2157d40fa2107b15490968710010d413601f1
7
+ data.tar.gz: 01b451f98527ac178922e6c1f0f9bf6bc493fa6632cd3633d87f6a245f644e9b8a7ea577052e8b3db2942b2f8968d51f67d48a10aaa3717c9281f861d9fc0042
@@ -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
- exclude:
13
- - rvm: 2.4
13
+ - rvm: 2.0
14
14
  os: osx
15
- - rvm: ruby-head
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
@@ -1,6 +1,16 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
- This project adheres to [Semantic Versioning](http://semver.org/).
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
@@ -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
- MultiJson.load(read(filename, options))
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
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module SugarUtils
5
- VERSION = '0.4.3'
5
+ VERSION = '0.4.4'
6
6
  end
@@ -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.3
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: 2017-08-26 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json