alba 0.13.0 → 1.2.0

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.
data/lib/alba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Alba
2
- VERSION = '0.13.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
data/sider.yml CHANGED
@@ -49,10 +49,8 @@ linter:
49
49
  # norc: true
50
50
 
51
51
  # # https://help.sider.review/getting-started/custom-configuration#ignore
52
- # ignore:
53
- # - "*.pdf"
54
- # - "*.mp4"
55
- # - "images/**"
52
+ ignore:
53
+ - 'test/**/*'
56
54
 
57
55
  # # https://help.sider.review/getting-started/custom-configuration#branchesexclude
58
56
  # branches:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OKURA Masafumi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-22 00:00:00.000000000 Z
11
+ date: 2021-05-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Alba is designed to be a simple, easy to use and fast alternative to
14
14
  existing JSON serializers. Its performance is better than almost all gems which
@@ -19,26 +19,34 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
23
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
24
+ - ".github/dependabot.yml"
25
+ - ".github/workflows/main.yml"
22
26
  - ".gitignore"
23
27
  - ".rubocop.yml"
24
- - ".travis.yml"
25
28
  - ".yardopts"
29
+ - CHANGELOG.md
26
30
  - CODE_OF_CONDUCT.md
27
31
  - Gemfile
28
- - Gemfile.lock
29
32
  - LICENSE.txt
30
33
  - README.md
31
34
  - Rakefile
35
+ - SECURITY.md
32
36
  - alba.gemspec
37
+ - benchmark/local.rb
33
38
  - bin/console
34
39
  - bin/setup
40
+ - codecov.yml
41
+ - gemfiles/all.gemfile
42
+ - gemfiles/without_active_support.gemfile
43
+ - gemfiles/without_oj.gemfile
35
44
  - lib/alba.rb
36
45
  - lib/alba/association.rb
37
46
  - lib/alba/key_transformer.rb
38
47
  - lib/alba/many.rb
39
48
  - lib/alba/one.rb
40
49
  - lib/alba/resource.rb
41
- - lib/alba/serializer.rb
42
50
  - lib/alba/version.rb
43
51
  - sider.yml
44
52
  homepage: https://github.com/okuramasafumi/alba
@@ -47,7 +55,7 @@ licenses:
47
55
  metadata:
48
56
  homepage_uri: https://github.com/okuramasafumi/alba
49
57
  source_code_uri: https://github.com/okuramasafumi/alba
50
- changelog_uri: https://github.com/okuramasafumi/alba/CHANGELOG.md
58
+ changelog_uri: https://github.com/okuramasafumi/alba/blob/master/CHANGELOG.md
51
59
  post_install_message:
52
60
  rdoc_options: []
53
61
  require_paths:
@@ -56,14 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
64
  requirements:
57
65
  - - ">="
58
66
  - !ruby/object:Gem::Version
59
- version: 2.5.7
67
+ version: 2.5.0
60
68
  required_rubygems_version: !ruby/object:Gem::Requirement
61
69
  requirements:
62
70
  - - ">="
63
71
  - !ruby/object:Gem::Version
64
72
  version: '0'
65
73
  requirements: []
66
- rubygems_version: 3.0.3
74
+ rubygems_version: 3.2.16
67
75
  signing_key:
68
76
  specification_version: 4
69
77
  summary: Alba is the fastest JSON serializer for Ruby.
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.5.8
6
- - 2.6.6
7
- - 2.7.1
8
- # - ruby-head # oj doesn't work with Ruby 2.8.0
9
- - truffleruby
10
- before_install: gem install bundler -v 2.1.4
data/Gemfile.lock DELETED
@@ -1,92 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- alba (0.13.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- activesupport (6.1.1)
10
- concurrent-ruby (~> 1.0, >= 1.0.2)
11
- i18n (>= 1.6, < 2)
12
- minitest (>= 5.1)
13
- tzinfo (~> 2.0)
14
- zeitwerk (~> 2.3)
15
- ast (2.4.1)
16
- concurrent-ruby (1.1.7)
17
- coveralls (0.8.23)
18
- json (>= 1.8, < 3)
19
- simplecov (~> 0.16.1)
20
- term-ansicolor (~> 1.3)
21
- thor (>= 0.19.4, < 2.0)
22
- tins (~> 1.6)
23
- docile (1.3.2)
24
- i18n (1.8.7)
25
- concurrent-ruby (~> 1.0)
26
- json (2.3.1)
27
- minitest (5.14.3)
28
- oj (3.11.0)
29
- parallel (1.20.1)
30
- parser (3.0.0.0)
31
- ast (~> 2.4.1)
32
- rainbow (3.0.0)
33
- rake (13.0.3)
34
- regexp_parser (2.0.3)
35
- rexml (3.2.4)
36
- rubocop (1.8.1)
37
- parallel (~> 1.10)
38
- parser (>= 3.0.0.0)
39
- rainbow (>= 2.2.2, < 4.0)
40
- regexp_parser (>= 1.8, < 3.0)
41
- rexml
42
- rubocop-ast (>= 1.2.0, < 2.0)
43
- ruby-progressbar (~> 1.7)
44
- unicode-display_width (>= 1.4.0, < 3.0)
45
- rubocop-ast (1.4.0)
46
- parser (>= 2.7.1.5)
47
- rubocop-minitest (0.10.3)
48
- rubocop (>= 0.87, < 2.0)
49
- rubocop-performance (1.9.2)
50
- rubocop (>= 0.90.0, < 2.0)
51
- rubocop-ast (>= 0.4.0)
52
- rubocop-rake (0.5.1)
53
- rubocop
54
- rubocop-sensible (0.3.0)
55
- rubocop (>= 0.60.0)
56
- ruby-progressbar (1.11.0)
57
- simplecov (0.16.1)
58
- docile (~> 1.1)
59
- json (>= 1.8, < 3)
60
- simplecov-html (~> 0.10.0)
61
- simplecov-html (0.10.2)
62
- sync (0.5.0)
63
- term-ansicolor (1.7.1)
64
- tins (~> 1.0)
65
- thor (1.0.1)
66
- tins (1.25.0)
67
- sync
68
- tzinfo (2.0.4)
69
- concurrent-ruby (~> 1.0)
70
- unicode-display_width (2.0.0)
71
- yard (0.9.26)
72
- zeitwerk (2.4.2)
73
-
74
- PLATFORMS
75
- ruby
76
-
77
- DEPENDENCIES
78
- activesupport
79
- alba!
80
- coveralls
81
- minitest (~> 5.14)
82
- oj (~> 3.11)
83
- rake (~> 13.0)
84
- rubocop (>= 0.79.0)
85
- rubocop-minitest (~> 0.10.3)
86
- rubocop-performance (~> 1.9.2)
87
- rubocop-rake (>= 0.5.1)
88
- rubocop-sensible (~> 0.3.0)
89
- yard
90
-
91
- BUNDLED WITH
92
- 2.2.6
@@ -1,77 +0,0 @@
1
- module Alba
2
- # This module represents how a resource should be serialized.
3
- module Serializer
4
- # @!parse include InstanceMethods
5
- # @!parse extend ClassMethods
6
-
7
- # @private
8
- def self.included(base)
9
- super
10
- base.class_eval do
11
- @_opts = {} unless instance_variable_defined?('@_opts')
12
- @_metadata = {} unless instance_variable_defined?('@_metadata')
13
- end
14
- base.include InstanceMethods
15
- base.extend ClassMethods
16
- end
17
-
18
- # Instance methods
19
- module InstanceMethods
20
- # @param resource [Alba::Resource]
21
- def initialize(resource)
22
- @resource = resource
23
- @hash = resource.serializable_hash
24
- @hash = {key.to_sym => @hash} if key
25
- return if metadata.empty?
26
-
27
- # @hash is either Hash or Array
28
- @hash.is_a?(Hash) ? @hash.merge!(metadata.to_h) : @hash << metadata
29
- end
30
-
31
- # Use real encoder to actually serialize to JSON
32
- #
33
- # @return [String] JSON string
34
- def serialize
35
- Alba.encoder.call(@hash)
36
- end
37
-
38
- private
39
-
40
- def key
41
- opts = self.class._opts
42
- opts[:key] == true ? @resource.key : opts[:key]
43
- end
44
-
45
- def metadata
46
- metadata = self.class._metadata
47
- metadata.transform_values { |block| block.call(@resource.object) }
48
- end
49
- end
50
-
51
- # Class methods
52
- module ClassMethods
53
- attr_reader :_opts, :_metadata
54
-
55
- # @private
56
- def inherited(subclass)
57
- super
58
- %w[_opts _metadata].each { |name| subclass.instance_variable_set("@#{name}", public_send(name).clone) }
59
- end
60
-
61
- # Set options, currently key only
62
- #
63
- # @param key [Boolean, Symbol]
64
- def set(key: false)
65
- @_opts[:key] = key
66
- end
67
-
68
- # Set metadata
69
- #
70
- # @param name [String, Symbol] key for the metadata
71
- # @param block [Block] the content of the metadata
72
- def metadata(name, &block)
73
- @_metadata[name.to_sym] = block
74
- end
75
- end
76
- end
77
- end