smart_value-object 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9e0f7838bb5e84699979410861b16817ddbf984aa44323221cd00c29e8217d1a
4
+ data.tar.gz: fae20970f3694bde16ecdb6af0ee5015c4f6e95ec8e098d546619f670da62285
5
+ SHA512:
6
+ metadata.gz: 8f6e8b6e40389e4b6f7598b5357e4d73f2cc0c44a370212d8207aa54a4c13990c5d828bbe1350d402cf7548254133fcbde09f41a04c540c8c1a2e727597a199f
7
+ data.tar.gz: f0c3f4487abe3a58072b157f5deceec5a404c344941f92b66ba5702fec77bf193407e7b63e64dd1abff7005b028c6fc9ea96e79c94fbbf09ef1f2e2e9fdcf971
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .rspec_status
10
+ /.idea
11
+ .ruby-version
12
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,23 @@
1
+ inherit_gem:
2
+ armitage-rubocop:
3
+ - lib/rubocop.general.yml
4
+ - lib/rubocop.rake.yml
5
+ - lib/rubocop.rspec.yml
6
+
7
+ AllCops:
8
+ TargetRubyVersion: 2.7.1
9
+ Include:
10
+ - lib/**/*.rb
11
+ - spec/**/*.rb
12
+ - Gemfile
13
+ - Rakefile
14
+ - smart_value-object.gemspec
15
+ - bin/console
16
+
17
+ # NOTE: It is not suitable for infrastracture-level frameworks
18
+ Metrics/ParameterLists:
19
+ Enabled: false
20
+
21
+ Naming/FileName:
22
+ Exclude:
23
+ - lib/smart_core/value-object.rb
@@ -0,0 +1,23 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ os: linux
5
+ dist: xenial
6
+ jobs:
7
+ fast_finish: true
8
+ include:
9
+ - rvm: 2.4.10
10
+ - rvm: 2.5.8
11
+ - rvm: 2.6.6
12
+ - rvm: 2.7.1
13
+ - rvm: jruby-head
14
+ - rvm: ruby-head
15
+ - rvm: truffleruby
16
+ allow_failures:
17
+ - rvm: ruby-head
18
+ - rvm: jruby-head
19
+ - rvm: truffleruby
20
+ before_install: gem install bundler
21
+ script:
22
+ - bundle exec rake rubocop
23
+ - bundle exec rake rspec
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ ## [0.1.0] - 2020-07-12
5
+ - Release :)
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at iamdaiver@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,108 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ smart_value-object (0.1.0)
5
+ smart_initializer (~> 0.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (6.0.3.2)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
+ armitage-rubocop (0.87.1.2)
17
+ rubocop (= 0.87.1)
18
+ rubocop-performance (= 1.7.0)
19
+ rubocop-rails (= 2.6.0)
20
+ rubocop-rake (= 0.5.1)
21
+ rubocop-rspec (= 1.42.0)
22
+ ast (2.4.1)
23
+ coderay (1.1.3)
24
+ concurrent-ruby (1.1.6)
25
+ diff-lcs (1.4.4)
26
+ docile (1.3.2)
27
+ i18n (1.8.3)
28
+ concurrent-ruby (~> 1.0)
29
+ method_source (1.0.0)
30
+ minitest (5.14.1)
31
+ parallel (1.19.2)
32
+ parser (2.7.1.4)
33
+ ast (~> 2.4.1)
34
+ pry (0.13.1)
35
+ coderay (~> 1.1)
36
+ method_source (~> 1.0)
37
+ qonfig (0.24.1)
38
+ rack (2.2.3)
39
+ rainbow (3.0.0)
40
+ rake (13.0.1)
41
+ regexp_parser (1.7.1)
42
+ rexml (3.2.4)
43
+ rspec (3.9.0)
44
+ rspec-core (~> 3.9.0)
45
+ rspec-expectations (~> 3.9.0)
46
+ rspec-mocks (~> 3.9.0)
47
+ rspec-core (3.9.2)
48
+ rspec-support (~> 3.9.3)
49
+ rspec-expectations (3.9.2)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.9.0)
52
+ rspec-mocks (3.9.1)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.9.0)
55
+ rspec-support (3.9.3)
56
+ rubocop (0.87.1)
57
+ parallel (~> 1.10)
58
+ parser (>= 2.7.1.1)
59
+ rainbow (>= 2.2.2, < 4.0)
60
+ regexp_parser (>= 1.7)
61
+ rexml
62
+ rubocop-ast (>= 0.1.0, < 1.0)
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 1.4.0, < 2.0)
65
+ rubocop-ast (0.1.0)
66
+ parser (>= 2.7.0.1)
67
+ rubocop-performance (1.7.0)
68
+ rubocop (>= 0.82.0)
69
+ rubocop-rails (2.6.0)
70
+ activesupport (>= 4.2.0)
71
+ rack (>= 1.1)
72
+ rubocop (>= 0.82.0)
73
+ rubocop-rake (0.5.1)
74
+ rubocop
75
+ rubocop-rspec (1.42.0)
76
+ rubocop (>= 0.87.0)
77
+ ruby-progressbar (1.10.1)
78
+ simplecov (0.18.5)
79
+ docile (~> 1.1)
80
+ simplecov-html (~> 0.11)
81
+ simplecov-html (0.12.2)
82
+ smart_engine (0.7.0)
83
+ smart_initializer (0.3.2)
84
+ qonfig (~> 0.24)
85
+ smart_engine (~> 0.7)
86
+ smart_types (~> 0.1.0)
87
+ smart_types (0.1.0)
88
+ smart_engine (~> 0.6)
89
+ thread_safe (0.3.6)
90
+ tzinfo (1.2.7)
91
+ thread_safe (~> 0.1)
92
+ unicode-display_width (1.7.0)
93
+ zeitwerk (2.3.1)
94
+
95
+ PLATFORMS
96
+ ruby
97
+
98
+ DEPENDENCIES
99
+ armitage-rubocop (~> 0.87)
100
+ bundler (~> 2.1)
101
+ pry (~> 0.13)
102
+ rake (~> 13.0)
103
+ rspec (~> 3.9)
104
+ simplecov (~> 0.18)
105
+ smart_value-object!
106
+
107
+ BUNDLED WITH
108
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Rustam Ibragimov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,98 @@
1
+ # SmartCore::ValueObject &middot; [![Gem Version](https://badge.fury.io/rb/smart_value-object.svg)](https://badge.fury.io/rb/smart_value-object) [![Build Status](https://travis-ci.org/smart-rb/smart_value-object.svg?branch=master)](https://travis-ci.org/smart-rb/smart_value-object)
2
+
3
+ Value Object pattern realized in scope of Ruby.
4
+
5
+ ---
6
+
7
+ ## Major featurs
8
+
9
+ - `attribute` and `property` semantics;
10
+ - primitive immutability based on `#freeze` invocation;
11
+ - read-only instance attributes and properties;
12
+ - support for hash representation (other formats coming soon);
13
+ - support for:
14
+ - semantic comparability (`Comparable`, `#<=>`, `#eql?`) (based on object's type and object's attributes and parameters);
15
+ - semantic enumerability (`Enumerable`, `#each`) (enumerates itself by default);
16
+ - (`soon`) `#clone` and `#dup`;
17
+
18
+ ---
19
+
20
+ ## Installation
21
+
22
+ ```ruby
23
+ gem 'smart_value-object'
24
+ ```
25
+
26
+ ```shell
27
+ bundle install
28
+ # --- or ---
29
+ gem install smart_value-object
30
+ ```
31
+
32
+ ```ruby
33
+ require 'smart_core/value-object'
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Synopsis
39
+
40
+ ```ruby
41
+ class Address < SmartCore::ValueObject
42
+ attribute :country, 'string'
43
+ attribute :city, 'string'
44
+ property :location, 'string'
45
+ property :capital, 'boolean'
46
+ end
47
+
48
+ khabarovsk = Address.new('Russia', 'Khabaovsk', location: '48.4814/135.0721', capital: false)
49
+ same_city = Address.new('Russia', 'Khabaovsk', location: '48.4814/135.0721', capital: false)
50
+ another_city = Address.new('Russia', 'Moscow', location: '59.9311/30.3609', capital: false)
51
+ ```
52
+
53
+ ```ruby
54
+ khabarovsk.frozen? # => true
55
+ ```
56
+
57
+ ```ruby
58
+ khabarovsk.country # => 'Russia'
59
+ khabarovsk.city # => 'Khabarovsk'
60
+ khabarovsk.location # => '48.4814/135.0721'
61
+ khabarovsk.capital # => false
62
+ ```
63
+
64
+ ```ruby
65
+ khabarovsk.to_h # or #as_hash or #to_hash
66
+ # => returns:
67
+ { city: 'Russia', country: 'Khabaovsk', location: '48.4814/135.0721', capital: false }
68
+ ```
69
+
70
+ ```ruby
71
+ # comparability:
72
+ khabarovsk == same_city # => true
73
+ khabarovsk == another_city # false
74
+ ```
75
+
76
+ ```ruby
77
+ # default Enumerable behavior:
78
+ khabarovsk.to_a # => [khabarovsk]
79
+ khabarovsk.each { |entity| puts entity } # => outputs itself
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Contributing
85
+
86
+ - Fork it ( https://github.com/smart-rb/smart_value-object )
87
+ - Create your feature branch (`git checkout -b feature/my-new-feature`)
88
+ - Commit your changes (`git commit -am '[feature_context] Add some feature'`)
89
+ - Push to the branch (`git push origin feature/my-new-feature`)
90
+ - Create new Pull Request
91
+
92
+ ## License
93
+
94
+ Released under MIT License.
95
+
96
+ ## Authors
97
+
98
+ [Rustam Ibragimov](https://github.com/0exp)
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop'
6
+ require 'rubocop/rake_task'
7
+ require 'rubocop-performance'
8
+ require 'rubocop-rspec'
9
+ require 'rubocop-rake'
10
+
11
+ RuboCop::RakeTask.new(:rubocop) do |t|
12
+ config_path = File.expand_path(File.join('.rubocop.yml'), __dir__)
13
+ t.options = ['--config', config_path]
14
+ t.requires << 'rubocop-rspec'
15
+ t.requires << 'rubocop-performance'
16
+ t.requires << 'rubocop-rake'
17
+ end
18
+
19
+ RSpec::Core::RakeTask.new(:rspec)
20
+
21
+ task default: :rspec
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'smart_core/value-object'
6
+
7
+ require 'irb'
8
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'value_object'
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'smart_core/initializer'
4
+
5
+ # @api pulbic
6
+ # @since 0.1.0
7
+ module SmartCore
8
+ # @api pulbic
9
+ # @since 0.1.0
10
+ class ValueObject
11
+ require_relative 'value_object/version'
12
+ require_relative 'value_object/interface'
13
+
14
+ # @since 0.1.0
15
+ include Interface::Constructor
16
+ # @since 0.1.0
17
+ include Interface::Comparable
18
+ # @since 0.1.0
19
+ include Interface::Enumerable
20
+ # @since 0.1.0
21
+ include Interface::Serializable
22
+
23
+ # @!method <=>(another_object)
24
+ # @!method eql?(another_object)
25
+ # @!method each(&block)
26
+ end
27
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ # @since 0.1.0
5
+ module SmartCore::ValueObject::Interface
6
+ require_relative 'interface/constructor'
7
+ require_relative 'interface/comparable'
8
+ require_relative 'interface/enumerable'
9
+ require_relative 'interface/serializable'
10
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ # @since 0.1.0
5
+ module SmartCore::ValueObject::Interface::Comparable
6
+ class << self
7
+ # @param base_klass [Class<SmartCore::ValueObject>]
8
+ # @return [void]
9
+ #
10
+ # @api private
11
+ # @since 0.1.0
12
+ def included(base_klass)
13
+ base_klass.include(::Comparable)
14
+ base_klass.include(Comparability)
15
+ end
16
+ end
17
+
18
+ # @api private
19
+ # @since 0.1.0
20
+ module Comparability
21
+ # @param another_object [Any]
22
+ # @return [Boolean]
23
+ #
24
+ # @api public
25
+ # @since 0.1.0
26
+ def <(another_object)
27
+ false
28
+ end
29
+
30
+ # @param another_object [Any]
31
+ # @return [Boolean]
32
+ #
33
+ # @api public
34
+ # @since 0.1.0
35
+ def <=(another_object)
36
+ false
37
+ end
38
+
39
+ # @param another_object [Any]
40
+ # @return [Boolean]
41
+ #
42
+ # @api public
43
+ # @since 0.1.0
44
+ def >(another_object)
45
+ false
46
+ end
47
+
48
+ # @param another_object [Any]
49
+ # @return [Boolean]
50
+ #
51
+ # @api public
52
+ # @since 0.1.0
53
+ def >=(another_object)
54
+ false
55
+ end
56
+
57
+ # @param another_object [SmartCore::ValueObject]
58
+ # @return [Boolean]
59
+ #
60
+ # @api public
61
+ # @since 0.1.0
62
+ def eql?(another_object)
63
+ self.class <= another_object.class && (
64
+ self.class.__params__.all? do |attribute|
65
+ self.__send__(attribute.name) == another_object.__send__(attribute.name)
66
+ end
67
+ ) && (
68
+ self.class.__options__.all? do |property|
69
+ self.__send__(property.name) == another_object.__send__(property.name)
70
+ end
71
+ )
72
+ end
73
+ alias_method :==, :eql?
74
+ end
75
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ # @since 0.1.0
5
+ module SmartCore::ValueObject::Interface::Constructor
6
+ class << self
7
+ # @param base_klass [Class<SmartCore::ValueObject>]
8
+ # @return [void]
9
+ #
10
+ # @api private
11
+ # @since 0.1.0
12
+ def included(base_klass)
13
+ base_klass.include(::SmartCore::Initializer)
14
+ base_klass.singleton_class.class_eval do
15
+ alias_method :attribute, :param
16
+ alias_method :property, :option
17
+ alias_method :attributes, :params
18
+ alias_method :properties, :options
19
+ end
20
+ base_klass.include(AttributeAccess)
21
+ base_klass.extend_initialization_flow(&ImmutabilityControl)
22
+ end
23
+ end
24
+
25
+ # @api private
26
+ # @since 0.1.0
27
+ module AttributeAccess
28
+ # @return [Hash<Symbol,Any>]
29
+ #
30
+ # @note strongly depends on SmartCore::Initializer implementaiton
31
+ #
32
+ # @api public
33
+ # @since 0.1.0
34
+ def __attributes__
35
+ __collect_params__
36
+ end
37
+
38
+ # @return [Hash<Symbol,Any>]
39
+ #
40
+ # @note strongly depends on SmartCore::Initializer implementaiton
41
+ #
42
+ # @api public
43
+ # @since 0.1.0
44
+ def __properties__
45
+ __collect_options__
46
+ end
47
+
48
+ # @return [Hash<Symbol,Any>]
49
+ #
50
+ # @note strongly depends on SmartCore::Initializer implementaiton
51
+ #
52
+ # @api public
53
+ # @since 0.1.0
54
+ def __params__
55
+ __collect_params__.merge(__collect_options__)
56
+ end
57
+ end
58
+
59
+ # @api private
60
+ # @since 0.1.0
61
+ module ImmutabilityControl
62
+ class << self
63
+ # @param instance [SmartCore::ValueObject]
64
+ # @return [void]
65
+ #
66
+ # @note strongly depends on SmartCore::Initializer implementation
67
+ #
68
+ # @api private
69
+ # @since 0.1.0
70
+ def freeze_instance(instance)
71
+ instance.freeze unless instance.frozen?
72
+ end
73
+
74
+ # @return [Proc]
75
+ #
76
+ # @note strongly depends on SmartCore::Initializer implementation
77
+ #
78
+ # @api private
79
+ # @since 0.1.0
80
+ def to_proc
81
+ proc { |instance| freeze_instance(instance) }
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ # @since 0.1.0
5
+ module SmartCore::ValueObject::Interface::Enumerable
6
+ class << self
7
+ # @param base_klass [Class<SmartCore::ValueObject>]
8
+ # @return [void]
9
+ #
10
+ # @api private
11
+ # @since 0.1.0
12
+ def included(base_klass)
13
+ base_klass.include(::Enumerable)
14
+ base_klass.include(Enumerability)
15
+ end
16
+ end
17
+
18
+ # @api private
19
+ # @since 0.1.0
20
+ module Enumerability
21
+ # @param block [Block]
22
+ # @return [Enumerable]
23
+ #
24
+ # @api public
25
+ # @since 0.1.0
26
+ def each(&block)
27
+ block_given? ? yield(self) : (Enumerator.new { |yielder| yielder.yield(self) }.each)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ # @since 0.1.0
5
+ module SmartCore::ValueObject::Interface::Serializable
6
+ class << self
7
+ # @param base_klass [Class<SmartCore::ValueObject>]
8
+ # @return [void]
9
+ #
10
+ # @api private
11
+ # @since 0.1.0
12
+ def included(base_klass)
13
+ base_klass.include(AsHash)
14
+ end
15
+ end
16
+
17
+ # @api private
18
+ # @since 0.1.0
19
+ module AsHash
20
+ # @return [Hash<Symbol,Any>]
21
+ #
22
+ # @note strongly dependes on SmartCore::Initializer implementation
23
+ #
24
+ # @api public
25
+ # @since 0.1.0
26
+ def to_h
27
+ __collect_params__.merge(__collect_options__)
28
+ end
29
+ alias_method :to_hash, :to_h
30
+ alias_method :as_hash, :to_h
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SmartCore
4
+ class ValueObject
5
+ # @return [String]
6
+ #
7
+ # @api public
8
+ # @since 0.1.0
9
+ VERSION = '0.1.0'
10
+ end
11
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/smart_core/value_object/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.4.10')
7
+
8
+ spec.name = 'smart_value-object'
9
+ spec.version = SmartCore::ValueObject::VERSION
10
+ spec.authors = ['Rustam Ibragimov']
11
+ spec.email = ['iamdaiver@gmail.com']
12
+
13
+ spec.summary = 'ValueObject pattern realized in scope of Ruby.'
14
+ spec.description = 'ValueObject pattern realized in scope of Ruby.'
15
+ spec.homepage = 'https://github.com/smart-rb/smart_value-object'
16
+ spec.license = 'MIT'
17
+
18
+ spec.metadata['homepage_uri'] =
19
+ spec.homepage
20
+ spec.metadata['source_code_uri'] =
21
+ 'https://github.com/smart-rb/smart_value-object'
22
+ spec.metadata['changelog_uri'] =
23
+ 'https://github.com/smart-rb/smart_value-object/blob/master/CHANGELOG.md'
24
+
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_runtime_dependency 'smart_initializer', '~> 0.3'
34
+
35
+ spec.add_development_dependency 'armitage-rubocop', '~> 0.87'
36
+ spec.add_development_dependency 'bundler', '~> 2.1'
37
+ spec.add_development_dependency 'pry', '~> 0.13'
38
+ spec.add_development_dependency 'rake', '~> 13.0'
39
+ spec.add_development_dependency 'rspec', '~> 3.9'
40
+ spec.add_development_dependency 'simplecov', '~> 0.18'
41
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smart_value-object
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rustam Ibragimov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: smart_initializer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: armitage-rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.87'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.87'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.13'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '13.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '13.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.18'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.18'
111
+ description: ValueObject pattern realized in scope of Ruby.
112
+ email:
113
+ - iamdaiver@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".rubocop.yml"
121
+ - ".travis.yml"
122
+ - CHANGELOG.md
123
+ - CODE_OF_CONDUCT.md
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - lib/smart_core/value-object.rb
132
+ - lib/smart_core/value_object.rb
133
+ - lib/smart_core/value_object/interface.rb
134
+ - lib/smart_core/value_object/interface/comparable.rb
135
+ - lib/smart_core/value_object/interface/constructor.rb
136
+ - lib/smart_core/value_object/interface/enumerable.rb
137
+ - lib/smart_core/value_object/interface/serializable.rb
138
+ - lib/smart_core/value_object/version.rb
139
+ - smart_value-object.gemspec
140
+ homepage: https://github.com/smart-rb/smart_value-object
141
+ licenses:
142
+ - MIT
143
+ metadata:
144
+ homepage_uri: https://github.com/smart-rb/smart_value-object
145
+ source_code_uri: https://github.com/smart-rb/smart_value-object
146
+ changelog_uri: https://github.com/smart-rb/smart_value-object/blob/master/CHANGELOG.md
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: 2.4.10
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubygems_version: 3.1.2
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: ValueObject pattern realized in scope of Ruby.
166
+ test_files: []