serialized-hashie 0.0.0.dev → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b305ccfa0e54e4a808259f967ed9d4ebc7cc95b7fa52b8930196ae97d6db5a39
4
- data.tar.gz: 77edb806bc4dd9f7b425ddacc4c566925debc1d5e5fd02add53b7b883fcccf4d
3
+ metadata.gz: 3b6cb66d2cf6a88d0c9e5cfb7604f377a771c841acf684220d613e5437fdd91d
4
+ data.tar.gz: 431e698faa570e3b7d01aaedff1da2e10deacb7b8eb48650f4bf616b91bbd256
5
5
  SHA512:
6
- metadata.gz: b417aa6c94e37ca8eb989faf359ffea46d145f66174f9560a7e4ecd1b4f02909bc86190c79da913c76e388c63971dbe0a24f68db9b2c204ad846cf593c6f49ab
7
- data.tar.gz: 6c486630d660930d70e7bfd740d53013c7c35ea4d683309e4d7277fd30efd76b5b24ca4f34fb2367a91f0b8b8e4455733aa91e23290b4b9e1144e77a23caf43f
6
+ metadata.gz: 5520e6b7e143d19c05c7b80098df83efd68885ac481fd89ba188046e77ff9373ddb55fe87c93a87b15c295887e11c9850f1d4d66245b28e3b4388a06b2e20dc9
7
+ data.tar.gz: 70a503e80d67008b47681ae3889afe73dd2f60459532052d761e652c5681a3038056a7d42143fc8314d6c22832eb4b57505e78218a9f8d280c3f7b38d48965d1
@@ -16,6 +16,6 @@ jobs:
16
16
  ruby-version: ${{ matrix.ruby_version }}
17
17
  - uses: actions/checkout@v2
18
18
  - name: Install dependencies
19
- run: bundle install && bundle exec appraisal install
19
+ run: bundle install
20
20
  - name: Run tests
21
- run: bundle exec appraisal rspec
21
+ run: bundle exec rspec
@@ -15,14 +15,11 @@ jobs:
15
15
  - name: Set up Ruby 2.6
16
16
  uses: actions/setup-ruby@v1
17
17
  with:
18
- ruby-version: 2.6.x
18
+ version: 2.6.x
19
19
 
20
20
  - name: Build Gem
21
21
  run: gem build *.gemspec
22
22
 
23
- - name: Export version from tag name
24
- run: echo "${GITHUB_REF/refs\/tags\//}" > VERSION
25
-
26
23
  - name: Setup credentials
27
24
  run: |
28
25
  mkdir -p $HOME/.gem
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -8,10 +7,5 @@
8
7
  /spec/reports/
9
8
  /tmp/
10
9
 
11
- # Appraisals generated Gemfiles
12
- /gemfiles/
13
-
14
10
  # rspec failure tracking
15
11
  .rspec_status
16
- .rubocop-http*
17
- VERSION
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ serialized-hashie (1.0.1)
5
+ hashie (>= 4.0, < 5.0)
6
+ json (>= 2.0, < 3.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.0)
12
+ diff-lcs (1.3)
13
+ hashie (4.1.0)
14
+ json (2.1.0)
15
+ parallel (1.19.1)
16
+ parser (2.7.1.2)
17
+ ast (~> 2.4.0)
18
+ rainbow (3.0.0)
19
+ rake (12.3.3)
20
+ rexml (3.2.4)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.2)
26
+ rspec-support (~> 3.9.3)
27
+ rspec-expectations (3.9.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.3)
34
+ rubocop (0.83.0)
35
+ parallel (~> 1.10)
36
+ parser (>= 2.7.0.1)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ rexml
39
+ ruby-progressbar (~> 1.7)
40
+ unicode-display_width (>= 1.4.0, < 2.0)
41
+ ruby-progressbar (1.10.1)
42
+ unicode-display_width (1.7.0)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ rake (~> 12.0)
49
+ rspec (~> 3.0)
50
+ rubocop
51
+ serialized-hashie!
52
+
53
+ BUNDLED WITH
54
+ 2.1.4
@@ -10,13 +10,22 @@ module SerializedHashie
10
10
  class << self
11
11
 
12
12
  def dump(obj)
13
- hash = dump_hash(obj)
14
- hash.to_json
13
+ obj = obj.reject { |_, v| blank?(v) }
14
+ obj.each do |key, value|
15
+ if value.is_a?(Array)
16
+ obj[key] = value.reject { |v| blank?(v) }
17
+ end
18
+
19
+ obj[key] = SerializedHashie.dump_extensions.run(obj[key])
20
+ end
21
+ obj.to_h.to_json
15
22
  end
16
23
 
17
24
  def load(raw_hash)
18
25
  hash = JSON.parse(presence(raw_hash) || '{}')
19
- hash = load_hash(hash)
26
+ hash.each do |key, value|
27
+ hash[key] = SerializedHashie.load_extensions.run(value)
28
+ end
20
29
  new(hash)
21
30
  end
22
31
 
@@ -33,42 +42,6 @@ module SerializedHashie
33
42
  blank?(value) ? nil : value
34
43
  end
35
44
 
36
- def dump_hash(hash)
37
- hash = hash.transform_values do |value|
38
- dump_value(value)
39
- end
40
- hash.reject { |_, v| blank?(v) }
41
- end
42
-
43
- def dump_value(value)
44
- if blank?(value)
45
- return nil
46
- end
47
-
48
- if value.is_a?(::Hash)
49
- return dump_hash(value)
50
- end
51
-
52
- if value.is_a?(::Array)
53
- return value.map { |v| dump_value(v) }.compact
54
- end
55
-
56
- SerializedHashie.dump_extensions.run(value)
57
- end
58
-
59
- def load_hash(hash)
60
- hash.transform_values do |value|
61
- load_value(value)
62
- end
63
- end
64
-
65
- def load_value(value)
66
- return load_hash(value) if value.is_a?(::Hash)
67
- return value.map { |v| load_value(v) } if value.is_a?(Array)
68
-
69
- SerializedHashie.load_extensions.run(value)
70
- end
71
-
72
45
  end
73
46
 
74
47
  end
@@ -2,11 +2,6 @@
2
2
 
3
3
  module SerializedHashie
4
4
 
5
- VERSION_FILE_ROOT = File.expand_path('../../VERSION', __dir__)
6
- if File.file?(VERSION_FILE_ROOT)
7
- VERSION = File.read(VERSION_FILE_ROOT).strip.delete_prefix('v')
8
- else
9
- VERSION = '0.0.0.dev'
10
- end
5
+ VERSION = '1.0.1'
11
6
 
12
7
  end
@@ -7,11 +7,10 @@ Gem::Specification.new do |spec|
7
7
  spec.version = SerializedHashie::VERSION
8
8
  spec.authors = ['Adam Cooke']
9
9
  spec.email = ['adam@krystal.uk']
10
+
10
11
  spec.summary = 'Helpers to serialize data into ActiveRecord models as JSON and returning a Hashie::Mash'
11
12
  spec.description = spec.summary
12
13
  spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
13
- spec.licenses = ['MIT']
14
- spec.homepage = 'https://github.com/krystal/serialized-hashie'
15
14
 
16
15
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
16
  `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
@@ -20,8 +19,6 @@ Gem::Specification.new do |spec|
20
19
  spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
21
20
  spec.require_paths = ['lib']
22
21
 
23
- spec.add_development_dependency 'appraisal', '~> 2.3'
24
-
25
22
  spec.add_runtime_dependency 'hashie', '>= 4.0', '< 5.0'
26
- spec.add_runtime_dependency 'json', '>= 1.8', '< 3.0'
23
+ spec.add_runtime_dependency 'json', '>= 2.0', '< 3.0'
27
24
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serialized-hashie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.dev
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-05 00:00:00.000000000 Z
11
+ date: 2020-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: appraisal
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.3'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.3'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: hashie
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +36,7 @@ dependencies:
50
36
  requirements:
51
37
  - - ">="
52
38
  - !ruby/object:Gem::Version
53
- version: '1.8'
39
+ version: '2.0'
54
40
  - - "<"
55
41
  - !ruby/object:Gem::Version
56
42
  version: '3.0'
@@ -60,7 +46,7 @@ dependencies:
60
46
  requirements:
61
47
  - - ">="
62
48
  - !ruby/object:Gem::Version
63
- version: '1.8'
49
+ version: '2.0'
64
50
  - - "<"
65
51
  - !ruby/object:Gem::Version
66
52
  version: '3.0'
@@ -76,9 +62,8 @@ files:
76
62
  - ".github/workflows/package.yml"
77
63
  - ".gitignore"
78
64
  - ".rubocop.yml"
79
- - Appraisals
80
65
  - Gemfile
81
- - MIT-LICENSE
66
+ - Gemfile.lock
82
67
  - README.md
83
68
  - bin/console
84
69
  - bin/setup
@@ -87,9 +72,8 @@ files:
87
72
  - lib/serialized_hashie/hash.rb
88
73
  - lib/serialized_hashie/version.rb
89
74
  - serialized-hashie.gemspec
90
- homepage: https://github.com/krystal/serialized-hashie
91
- licenses:
92
- - MIT
75
+ homepage:
76
+ licenses: []
93
77
  metadata: {}
94
78
  post_install_message:
95
79
  rdoc_options: []
@@ -102,9 +86,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
86
  version: 2.3.0
103
87
  required_rubygems_version: !ruby/object:Gem::Requirement
104
88
  requirements:
105
- - - ">"
89
+ - - ">="
106
90
  - !ruby/object:Gem::Version
107
- version: 1.3.1
91
+ version: '0'
108
92
  requirements: []
109
93
  rubygems_version: 3.0.3
110
94
  signing_key:
data/Appraisals DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise 'json-1.8' do
4
- gem 'json', '~> 1.8.0'
5
- end
6
-
7
- appraise 'json-2' do
8
- gem 'json', '~> 2.0'
9
- end
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2020 Krystal Hosting Ltd
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.