odsl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3381098ae987f86e0112bd8dd2da9b3e8967f8f1ff877db7b3276fd4953c252a
4
+ data.tar.gz: 4f80c98a9b2545b5b34b98a224cc09b4f079b9cb16160976fa89bd41e67547c4
5
+ SHA512:
6
+ metadata.gz: fc52a73349084832f0d5b33abf0cce2ae2dc66bfe69c4d1c7f56820b29c823a3ea75c66a79b6446e8104dc709ba18916f5e13ff172c3146633c74bd17aab27a5
7
+ data.tar.gz: 83412e38868589940d872853ae46e7fe34f9954bc19e2c460eb7597a7c5511df591ff9747fd61720c38a7f42a5228f319b82ee8e9ad3d73ef0aac03259bd6821
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-07-03
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at alejandro.gurovich@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 alejandro gurovich
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.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Object DSL
2
+
3
+ This is a prototype oriented to use OOP and a functional programming approach by providing a DSL to decouple code logic from coding itself while enforcing good practices and providing:
4
+
5
+ - Design patterns
6
+ - Inmutability
7
+ - Dry off
8
+ - Decouple aspects from code ( background, paralelization )
9
+
10
+ # Your code
11
+
12
+ ```
13
+ module Game
14
+ def start(game_type)
15
+ @game = Struct.new(game_type: game_type, player: @player.name)
16
+ self
17
+ end
18
+ end
19
+
20
+ module Player
21
+ def with_player(player)
22
+ @player = Struct.new(name: player)
23
+ self
24
+ end
25
+ end
26
+
27
+ module Game
28
+ module Crud
29
+ def create
30
+ build(Game, Players)
31
+ .get(:game_object)
32
+
33
+ with(:args, :game_object)
34
+ .set(:new_game)
35
+ .get(:game_instance)
36
+
37
+ finish_with(:game_instance)
38
+ end
39
+
40
+ def delete(id)
41
+ end
42
+
43
+ private
44
+
45
+ def new_game(args, game_object)
46
+
47
+ game_object
48
+ .with_player(args[:player])
49
+ .start(args[:game_name])
50
+ end
51
+ end
52
+ end
53
+
54
+ module Game
55
+ class Service < Odsl:Dsl
56
+ include Crud
57
+
58
+ inmutable true
59
+ end
60
+ end
61
+ ```
62
+
63
+ # How to use call it.
64
+
65
+ ```
66
+ Games::Service
67
+ .new(player: { name: 'alejandro' } , game: 'chez')
68
+ .run(:create)
69
+ ```
70
+
71
+
72
+ # Future development
73
+
74
+ .run_in_background()
75
+ .run_in_parallel()
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "test"
8
+ t.test_files = FileList["test/**/*_spec.rb"]
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => :test
@@ -0,0 +1,29 @@
1
+
2
+ module Odsl
3
+ class Builder
4
+ class << self
5
+ def build(*modules)
6
+ business_class = begin
7
+ Object.const_get class_name(modules)
8
+ rescue StandardError
9
+ nil
10
+ end
11
+ business_class ||= Object.const_set(class_name(modules), Class.new)
12
+
13
+ modules.each do |mod|
14
+ business_class.send(:include, mod)
15
+ end
16
+
17
+ business_class
18
+ end
19
+
20
+ def class_name(modules)
21
+ "Builder_#{modules.map(&:to_s).join('_')}".gsub('::','_')
22
+ end
23
+
24
+ def method_from_bool(mode)
25
+ mode ? :on : :off
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ module Odsl
2
+ module Configurable
3
+ def self.configuration
4
+ @configuration ||= {}
5
+ end
6
+
7
+ def self.configure
8
+ yield(configuration)
9
+ end
10
+ end
11
+ end
data/lib/odsl/dsl.rb ADDED
@@ -0,0 +1,55 @@
1
+ require_relative "builder"
2
+ require_relative "runners"
3
+ require_relative "methods"
4
+ require_relative "configurable"
5
+
6
+ module Odsl
7
+ class Dsl
8
+ include Runners
9
+ include Methods
10
+ extend Configurable
11
+
12
+ def initialize(**kwargs)
13
+
14
+ @kwargs = kwargs
15
+ @context = {}
16
+ @last_results = []
17
+ @with_attributes = nil
18
+ @finish_with = nil
19
+
20
+ kwargs.each do |key, value|
21
+ instance_variable_set("@#{key}", value)
22
+ @context[key] = value
23
+ end
24
+ end
25
+
26
+ class << self
27
+ attr_reader :inmutable_mode
28
+
29
+ def inmutable(bool)
30
+ @inmutable_mode = bool
31
+ end
32
+ end
33
+
34
+ protected
35
+
36
+ def build(*modules)
37
+ @last_results = [ Odsl::Builder.build(*modules).new ]
38
+ self
39
+ end
40
+
41
+ def with(*arguments)
42
+ @with_attributes = arguments
43
+ self
44
+ end
45
+
46
+ def value_return(with)
47
+ @finish_with = with
48
+ end
49
+
50
+ alias make call
51
+ alias link call
52
+ alias get to
53
+ alias execute run
54
+ end
55
+ end
data/lib/odsl/error.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Odsl
2
+ class Error < StandardError; end
3
+ end
4
+ end
@@ -0,0 +1,19 @@
1
+ module Odsl
2
+ module Methods
3
+ def call(methodo)
4
+
5
+ @last_results = send(methodo, *@with_attributes.map { |attribute| instance_variable_get("@#{attribute}") })
6
+ @last_results = [@last_results] unless @last_results.is_a? Array
7
+
8
+ self
9
+ end
10
+
11
+ def to(*variables)
12
+ variables.each_with_index do |variable, index|
13
+ instance_variable_set("@#{variable}", @last_results[index])
14
+ end
15
+
16
+ self
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module Odsl
2
+ module Runners
3
+ def run(method)
4
+
5
+ instance_eval(method.to_s)
6
+ instance_variable_get "@#{@finish_with}"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Odsl
4
+ VERSION = "0.1.0"
5
+ end
data/lib/odsl.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'odsl/version'
2
+ require 'odsl/dsl'
data/odsl.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(
4
+ File.join('..', 'lib', 'odsl', 'version'),
5
+ __FILE__
6
+ )
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "odsl"
10
+ spec.version = Odsl::VERSION
11
+ spec.authors = ["alejandro gurovich"]
12
+ spec.email = ["alejandro.gurovich@gmail.com"]
13
+
14
+ spec.summary = "DSL Approach to OOP and functional programming."
15
+ spec.description = "This is a prototype oriented to use OOP and a functional programming approach by providing a DSL to decouple code logic from coding itself while enforcing good practices and providing - Design patterns
16
+ - Inmutability
17
+ - Dry off
18
+ - Decouple aspects from code ( background, paralelization )."
19
+ spec.homepage = "https://github.com/aleguro/ODSL."
20
+ spec.license = "MIT"
21
+ spec.required_ruby_version = ">= 2.6.0"
22
+
23
+ spec.metadata["homepage_uri"] = spec.homepage
24
+ spec.metadata["source_code_uri"] = "https://github.com/aleguro/ODSL"
25
+ spec.metadata["changelog_uri"] = "https://github.com/aleguro/ODSL/blob/master/CHANGELOG.md"
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(__dir__) do
30
+ `git ls-files -z`.split("\x0").reject do |f|
31
+ (File.expand_path(f) == __FILE__) ||
32
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
33
+ end
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "minitest", ">= 5.8"
40
+ spec.add_development_dependency "minitest-reporters", ">= 1.1"
41
+
42
+ # For more information and examples about making a new gem, check out our
43
+ # guide at: https://bundler.io/guides/creating_gem.html
44
+ end
data/sig/odsl.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Odsl
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: odsl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - alejandro gurovich
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest-reporters
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ description: |-
42
+ This is a prototype oriented to use OOP and a functional programming approach by providing a DSL to decouple code logic from coding itself while enforcing good practices and providing - Design patterns
43
+ - Inmutability
44
+ - Dry off
45
+ - Decouple aspects from code ( background, paralelization ).
46
+ email:
47
+ - alejandro.gurovich@gmail.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - CHANGELOG.md
53
+ - CODE_OF_CONDUCT.md
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - lib/odsl.rb
58
+ - lib/odsl/builder.rb
59
+ - lib/odsl/configurable.rb
60
+ - lib/odsl/dsl.rb
61
+ - lib/odsl/error.rb
62
+ - lib/odsl/methods.rb
63
+ - lib/odsl/runners.rb
64
+ - lib/odsl/version.rb
65
+ - odsl.gemspec
66
+ - sig/odsl.rbs
67
+ homepage: https://github.com/aleguro/ODSL.
68
+ licenses:
69
+ - MIT
70
+ metadata:
71
+ homepage_uri: https://github.com/aleguro/ODSL.
72
+ source_code_uri: https://github.com/aleguro/ODSL
73
+ changelog_uri: https://github.com/aleguro/ODSL/blob/master/CHANGELOG.md
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 2.6.0
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 3.3.7
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: DSL Approach to OOP and functional programming.
93
+ test_files: []