abstrakt 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: 6e6bec7dd365809cbcf34127fa959e6fb6d841182d1c00a09912c90e2b527101
4
+ data.tar.gz: 81df444e38c811df5203be41f462cb0e771a6fcd87b05975005199d61d3be96a
5
+ SHA512:
6
+ metadata.gz: 4321f0e3ad69361c74fcafc66c1ee421b33161fc8f0ca8798f05d6dbf52a35db9f0e9cc7477920389a571a8c628119e77c821fadfc68106ad78e30d93f376336
7
+ data.tar.gz: bac213e81b63aeba7cf8f3fcbdf1db3c49207caf353038edc9cf3d9c626106a3eaf6026404d0a8711b3d7b4652d6f1e1e6320a68cd17677b473b33cccb0e9b1d
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.0.pre.1
@@ -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 cyrilvixp@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 [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in abstrakt.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ abstrakt (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.11.3)
10
+ rake (12.3.3)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ abstrakt!
17
+ bundler (~> 2.1.a)
18
+ minitest (~> 5.0)
19
+ rake (~> 12.0)
20
+
21
+ BUNDLED WITH
22
+ 2.1.0.pre.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Cyril ViXP
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,128 @@
1
+ <p align="center">
2
+ <img src="images/full_logo.svg" alt="Abstrakt" style="border: none"/>
3
+ </p>
4
+
5
+ This GEM adds support of standard OOP entities such as **Abstract Class**
6
+ (and **Interface** in *TODO*) on class declaration level. It means, that your
7
+ interpreter will raise exceptions in case if your class, which inherits from the
8
+ Abstract class, does not implement defined abstract methods.
9
+
10
+ Described behaviour imitates Java compilation errors.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'abstrakt'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle install
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install abstrakt
27
+
28
+ ## Usage
29
+ Don't forget to `require 'abstrakt'` in your source code!
30
+
31
+ ### Abstract class declaration
32
+ To define your own abstract class, you need to extend `Abstract::Builder`
33
+ module in your abstract class declaration:
34
+ ```ruby
35
+ class MyAbstraktClass
36
+ extend Abstrakt::Builder
37
+ end
38
+ ```
39
+ Now you can declare your **abstract methods**, by using the Abstrakt DSL words:
40
+ - `abstract :method_name` or `public_abstract :method_name` to define abstract
41
+ **public** method;
42
+ - `protected_abstract :method_name` to define **protected** abstract method;
43
+ - `private_abstract :method_name` to define **private** abstract method;
44
+
45
+ As any other abstract class, your class can also define non-abstract methods
46
+ implementations, as well as class singleton methods as usual.
47
+
48
+ Example:
49
+ ```ruby
50
+ class AbstractStringInstrument
51
+ extend Abstrakt::Builder
52
+
53
+ abstract :play
54
+ public_abstract :tune
55
+
56
+ protected_abstract :strings_number
57
+ private_abstract :weight
58
+
59
+ def present!
60
+ puts "I am a #{self.class} instrument with #{strings_number} strings!"
61
+ end
62
+ end
63
+ ```
64
+
65
+ If you will try to create an instance of the abstract class, it will throw
66
+ `Abstrakt::Exceptions::InstantiationError` exception.
67
+
68
+ ### Abstract class implementation declaration
69
+ While Java uses *extends* word for class inheritance, we will stick to the
70
+ regular Ruby inheritance operator instead. So, for creating the class, which implements your abstract class, you simply inherit from it and declare all
71
+ abstract methods in your implementation!
72
+
73
+ Implementation example:
74
+ ```ruby
75
+ class Guitar < AbstractStringInstrument
76
+ def initialize(brand:, model:, weight:)
77
+ @brand, @model, @weight = brand, model, weight
78
+ end
79
+
80
+ def play # this implements public abstract method
81
+ p 'I am playing!'
82
+ end
83
+
84
+ def tune # and this too
85
+ p 'Getting in EBGDAE tuning...'
86
+ sleep 2
87
+ p 'Done!'
88
+ end
89
+
90
+ protected
91
+
92
+ def strings_number # this implements protected method
93
+ 6
94
+ end
95
+
96
+ private
97
+
98
+ attr_reader :weight # and this is private one
99
+ end
100
+
101
+ # Instantiation:
102
+ lp = Guitar.new brand: :gibson, model: :les_paul, weight: 5
103
+ lp.present!
104
+ ```
105
+
106
+ If you forgot to implement any of them, your intepreter will raise
107
+ `Abstrakt::Exceptions::InstanceMethodNotImplementedError` exception.
108
+
109
+ ## Future development and TODO
110
+
111
+ Interfaces entities and interfaces inheritance functionality are also planned to
112
+ be implemented as a separate module of `Abstrakt` GEM in future.
113
+
114
+ ## Contributing
115
+
116
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ViXP/abstrakt. This project is intended to be a safe, welcoming space for
117
+ collaboration, and contributors are expected to adhere to the
118
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
119
+
120
+ ## License
121
+
122
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
123
+
124
+ ## Code of Conduct
125
+
126
+ Everyone interacting in the Abstrakt project’s codebases, issue trackers, chat
127
+ rooms and mailing lists is expected to follow the
128
+ [code of conduct](https://github.com/ViXP/abstrakt/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,36 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "abstrakt/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "abstrakt"
7
+ spec.version = Abstrakt::VERSION
8
+ spec.authors = ["Cyril ViXP"]
9
+ spec.email = ["cyrilvixp@gmail.com"]
10
+
11
+ spec.summary = %q{Adds abstract classes support to Ruby on declaration
12
+ level}
13
+ spec.description = %q{Standard OOP abstract entities for proper SOLID
14
+ implementation on class declaration level}
15
+ spec.homepage = "https://github.com/ViXP/abstrakt"
16
+ spec.license = "MIT"
17
+
18
+ #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/ViXP/abstrakt"
22
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ end
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_development_dependency "bundler", "~> 2.1.a"
34
+ spec.add_development_dependency "rake", "~> 12.0"
35
+ spec.add_development_dependency "minitest", "~> 5.0"
36
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "abstrakt"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ 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,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="403.75" height="177.12" version="1.1" viewBox="0 0 53.412117 23.431927" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
3
+ <g transform="translate(-8.9821 -121.48)" stroke="#21201e">
4
+ <path d="m56.535 129.87 5.6856 8.2382-49.571-0.83463-3.5535-2.3016 3.7311-8.1472z" fill="#fc0" stroke-width=".18"/>
5
+ <path d="m44.01 142.3 2.5513-18.37 9.3549-1.871-2.8915 18.71z" fill="#808080" stroke-width=".1125"/>
6
+ <path d="m43.237 135.2 7.0022-11.154 4.9693 12.885z" fill="#f00" stroke-width=".18"/>
7
+ <path d="m11.242 139.39 6.192 5.4578 28.888-5.3276z" fill="#ccc" stroke-width=".10702"/>
8
+ <path d="m16.25 121.79 19.724 8.1749 6.7352-8.4386z" fill="#ccc" stroke-width=".10596"/>
9
+ <g transform="matrix(.22878 0 0 .22128 14.085 97.509)" stroke-width=".8" aria-label="AbstraKt">
10
+ <path d="m11.875 161.65q0 2.5368-2.2726 2.5897 0.26426 1.2156 1.1627 3.2768-0.05285 1.1627-0.95132 1.9026-0.89847 0.73992-2.114 0.73992-0.95132 0-2.2197-0.58136-0.68706-1.3741-0.68706-3.2768 0-0.47566 0.052851-1.3741t0.052851-1.3213q0 0.36996-1.7441 0.36996-2.9597 0-7.0292 0.26426-5.8136 0.3171-6.3421 0.89846-0.47566 0.58136-0.63421 5.6551-0.68706 1.0042-1.7441 1.0042-1.1099 0-2.2726-0.89847-1.1627-0.95132-1.1627-2.0083 0-0.36995 0.95132-2.9596 1.057-3.7524 3.4353-11.257 7.082-19.396 11.786-19.396 4.598 0 7.082 10.253 1.1099 4.598 2.0612 14.111 1.3741 0.3171 1.7441 0.52851 0.84562 0.47566 0.84562 1.4798zm-7.3991-2.0083q-2.3254-18.445-4.1752-18.445-1.4798 0-5.1794 8.6676-2.6426 6.2364-4.1752 10.834 1.6912-0.36996 5.0208-0.89847 3.0125-0.36996 8.509-0.15855z"/>
11
+ <path d="m39.03 159.01q0 4.7566-1.6384 8.0862-2.114 4.2809-6.395 4.2809-1.3741 0-4.3338-1.0042 0.05285 0.36996 0.05285 0.68707 0 1.7441-1.9555 1.7441-1.427 0-2.3254-1.057-0.42281-0.47566-0.68706-3.2768-0.26426-2.3254-0.26426-3.6467v-0.21141l0.79276-29.861q0.84562-1.3213 2.0083-1.1099 0.26426-0.1057 0.52851-0.1057 0.95132 0 1.7441 1.1627 0.84562 1.1099 0.84562 2.114 0 2.2726-0.42281 6.0779-0.52851 4.3866-0.58136 6.025 1.5327-1.8498 3.9638-1.8498 2.9068 0 5.2322 2.114 2.3254 2.0612 3.0125 5.0208 0.42281 1.7969 0.42281 4.8094zm-4.9151-0.36996q0-7.1877-3.0125-7.1877-2.5368 0-3.8581 3.6467-1.0042 2.7482-1.0042 5.8665 0 6.6592 4.0167 6.6592 3.8581 0 3.8581-8.9847z"/>
12
+ <path d="m65.132 165.67q0 2.484-2.114 4.3338-2.3254 2.0083-6.2364 2.0083-1.6912 0.0529-3.6467-0.68706-6.3421-2.3783-6.3421-3.8581 0-2.3254 3.3296-2.3254 0.47566 0 1.0042 0.0529 0.15855 1.5855 2.5368 2.5368 2.0612 0.84562 3.9638 0.68707 1.5327-0.10571 1.5327-1.1099 0-0.15855-0.1057-0.47565-0.05285-0.31711-0.05285-0.47566 0-0.21141-2.0083-0.84562-2.2726-0.68706-2.5368-0.79277-6.025-3.5939-6.025-8.6676 0-3.0654 1.7441-5.6551 1.9555-2.854 4.8623-2.854 2.1669 0 4.9151 1.6912 2.8011 1.6912 3.4353 3.6467 0.42281 1.3741 0.42281 2.2726 0 0.95132-0.26426 1.5855-0.31711 0.79277-0.63421 1.5855-1.0042 0.68707-2.0083 0.68707-0.52851 0-1.7969-0.63422-1.2156-0.68706-1.2156-1.1627 0-0.2114 0.63421-1.3741 0.36996-0.68706 0.36996-1.1627 0-3.1711-2.484-3.1711-1.4798 0-2.2726 1.9026-0.58136 1.4798-0.58136 3.1711 0 2.114 3.0125 3.8053 2.7483 1.2156 5.5494 2.484 3.0125 1.3741 3.0125 2.8011z"/>
13
+ <path d="m86.319 152.09q0 1.427-4.3866 2.0083-0.1057 1.1627-0.1057 5.2851v3.4882q0 1.057 0.31711 3.1182 0.36996 2.0612 0.36996 3.0654 0 0.84561-0.84562 1.5327-0.84562 0.63421-1.6912 0.63421-1.3213 0-2.2197-2.2726-0.68706-1.7441-0.68706-3.3825v-11.204q-2.4311-0.36996-2.8011-0.47566-1.3741-0.42281-1.3741-1.2156 0-0.2114 0.1057-0.47566 1.3741-1.9555 3.0654-1.9555 0.1057 0 0.31711 0 0.2114 0.0529 0.31711 0.0529 1.1099 0 1.057-2.5897v-3.8581q-0.31711-0.58136-0.31711-1.0042 0-0.68706 0.79276-1.2156 0.84562-0.58136 1.5855-0.58136 1.1099 0 2.114 1.057 1.0042 1.0042 1.0042 2.1669 0 1.2684-0.42281 2.5368-0.36996 1.2156-0.31711 2.5368v0.2114q4.1224 0.42281 4.1224 2.5368z"/>
14
+ <path d="m107.99 152.83q0 0.36995-0.1057 1.1627-1.1099 1.5855-2.3254 1.5855-1.0042 0-1.7969-1.1627-0.1057-2.3783-1.6912-2.3783-0.95132 0-2.3254 5.0208-0.63421 2.2197-0.63421 6.1836 0 3.7524 0.36996 4.5452 0.42281 1.0042 0.42281 1.3741 0 0.89847-0.84562 1.4798-0.79276 0.52851-1.7969 0.52851-2.854 0-2.854-2.6426 0-0.26426 0.1057-0.73992 0.15855-0.47566 0.15855-0.68706 0-2.6954-0.26426-7.9805-0.26426-5.338-0.26426-7.9805 0-2.3783 2.854-2.3783 1.6912 0 2.3254 1.0042 1.4798-1.6384 3.3296-1.6384 1.2684 0 2.4312 0.68706 0.79276 0.42281 1.8498 1.8498 1.057 1.3741 1.057 2.1669z"/>
15
+ <path d="m132.71 162.02q0 6.8178-0.42281 9.6189-0.26425 1.6384-2.2197 1.6384-2.9596 0-2.6426-2.9597-2.6426 1.2684-5.4965 1.2684-2.7483 0-5.2322-1.3741-2.9597-1.6384-2.9597-4.1752 0-2.484 3.3825-4.6509 3.0654-1.9555 5.7608-1.9555h4.4923v-1.2684q0.0528-5.5494-3.2768-5.5494-4.1752 0-4.1752 3.911 0 1.3213-1.4798 1.3213-0.89847 0-1.9026-0.79276-0.95132-0.84562-0.95132-1.7441 0-2.9596 2.114-4.8623 2.114-1.9026 5.0737-1.9026 9.936 0 9.936 13.477zm-5.338 1.9026q0-1.057-1.5855-1.057-6.6064 0-6.6064 3.1182 0 1.6912 2.9068 1.6912 1.7969 0 3.3825-1.0042 1.9026-1.1099 1.9026-2.7482z"/>
16
+ <path d="m170.72 166.78q0 1.427-1.7441 2.2726-1.427 0.63421-3.0125 0.63421-7.3463 0-14.798-13.741-4.4395 5.1265-4.4395 6.9763 0 4.8623 1.2156 6.9235l0.15856 1.4798q-1.1627 1.3213-2.3254 1.3213-1.7441 0-2.9597-2.7483-1.1627-2.8011-1.1627-19.608 0-9.6189 0.68706-13.371 0.42281-2.2197 2.4312-2.2197 1.2684 0 2.854 1.0042t1.5855 2.1669q0 0.79276-0.47566 1.057-0.47566 0.26425-0.84562 0.47566-0.36996 0.42281-0.84561 7.3463-0.31711 5.3908-0.42281 8.2448 14.217-19.502 17.864-19.502 0.58136 0 1.3213 0.31711 0.58136 0.73991 1.1099 1.5327 0.68706 0.95132 0.68706 1.6912 0 0.68706-0.52851 1.2156-0.47566 0.47565-1.1627 0.47565-0.42281 0-1.1099-0.3171l-0.15856-0.15855q-1.2684 0.15855-5.1794 4.8094-3.8581 4.6509-3.8581 6.0779 0 3.0654 3.541 8.7733 3.6996 6.0779 6.5007 6.0779 0.36996 0 1.3741-0.42281 1.057-0.47566 1.7441-0.47566 1.9555 0 1.9555 1.6912z" fill="#fff"/>
17
+ <path d="m191.63 152.09q0 1.427-4.3866 2.0083-0.1057 1.1627-0.1057 5.2851v3.4882q0 1.057 0.3171 3.1182 0.36996 2.0612 0.36996 3.0654 0 0.84561-0.84562 1.5327-0.84561 0.63421-1.6912 0.63421-1.3213 0-2.2197-2.2726-0.68706-1.7441-0.68706-3.3825v-11.204q-2.4312-0.36996-2.8011-0.47566-1.3741-0.42281-1.3741-1.2156 0-0.2114 0.1057-0.47566 1.3741-1.9555 3.0654-1.9555 0.1057 0 0.3171 0 0.21141 0.0529 0.31711 0.0529 1.1099 0 1.057-2.5897v-3.8581q-0.31711-0.58136-0.31711-1.0042 0-0.68706 0.79277-1.2156 0.84561-0.58136 1.5855-0.58136 1.1099 0 2.114 1.057 1.0042 1.0042 1.0042 2.1669 0 1.2684-0.42281 2.5368-0.36996 1.2156-0.31711 2.5368v0.2114q4.1224 0.42281 4.1224 2.5368z"/>
18
+ </g>
19
+ </g>
20
+ </svg>
@@ -0,0 +1,7 @@
1
+ module Abstrakt
2
+ SECURITY_LEVELS = %i[private protected public]
3
+ end
4
+
5
+ require 'abstrakt/version'
6
+ require 'abstrakt/exceptions'
7
+ require 'abstrakt/builder'
@@ -0,0 +1,58 @@
1
+ module Abstrakt
2
+ module Builder
3
+ def self.extended(klass)
4
+ super(klass)
5
+ class << klass
6
+ alias_method :_new, :new
7
+ alias_method :new, :abstract_class_instantiation
8
+ end
9
+ end
10
+
11
+ def abstract_class_instantiation
12
+ raise Abstrakt::Exceptions::InstantiationError.new(self)
13
+ end
14
+
15
+ private
16
+
17
+ Abstrakt::SECURITY_LEVELS.each do |level|
18
+ define_method("#{level}_abstract") do |method_name|
19
+ abstract(method_name, level)
20
+ end
21
+ end
22
+
23
+ def inherited(klass)
24
+ class << klass
25
+ alias_method :new, :_new
26
+ end
27
+ super(klass)
28
+ TracePoint.new(:end) do |trace|
29
+ if trace.self == klass
30
+ klass.check_abstract_methods
31
+ trace.disable
32
+ end
33
+ end.enable
34
+ end
35
+
36
+ def abstract(method_name, level = :public)
37
+ @abstract_methods ||= {}
38
+ @abstract_methods[level] ||= []
39
+ @abstract_methods[level] << method_name
40
+ end
41
+
42
+ protected
43
+
44
+ def check_abstract_methods
45
+ abstractions = self.superclass.instance_variable_get(:@abstract_methods)
46
+
47
+ return unless abstractions && abstractions.any?
48
+
49
+ Abstrakt::SECURITY_LEVELS.each do |level|
50
+ abstractions[level] && abstractions[level].each do |method_name|
51
+ next if self.send("#{level}_instance_methods").include? method_name
52
+ raise Abstrakt::Exceptions::InstanceMethodNotImplementedError.new(
53
+ level: level, object: self, method: method_name)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,16 @@
1
+ module Abstrakt
2
+ module Exceptions
3
+ class InstanceMethodNotImplementedError < NotImplementedError
4
+ def initialize(level:, object:, method:)
5
+ super("not implemented #{level} instance method '#{method}' for class "\
6
+ "#{object.to_s}")
7
+ end
8
+ end
9
+
10
+ class InstantiationError < RuntimeError
11
+ def initialize(object)
12
+ super("class '#{object}' can not be instantiated")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Abstrakt
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: abstrakt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Cyril ViXP
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.a
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.a
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: "Standard OOP abstract entities for proper SOLID \n implementation
56
+ on class declaration level"
57
+ email:
58
+ - cyrilvixp@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - abstrakt.gemspec
72
+ - bin/console
73
+ - bin/setup
74
+ - images/full_logo.svg
75
+ - lib/abstrakt.rb
76
+ - lib/abstrakt/builder.rb
77
+ - lib/abstrakt/exceptions.rb
78
+ - lib/abstrakt/version.rb
79
+ homepage: https://github.com/ViXP/abstrakt
80
+ licenses:
81
+ - MIT
82
+ metadata:
83
+ homepage_uri: https://github.com/ViXP/abstrakt
84
+ source_code_uri: https://github.com/ViXP/abstrakt
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubygems_version: 3.0.6
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Adds abstract classes support to Ruby on declaration level
104
+ test_files: []