ucasy 0.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 +7 -0
- data/.rspec +4 -0
- data/.rubocop.yml +11 -0
- data/.standard.yml +3 -0
- data/LICENSE.txt +21 -0
- data/Makefile +8 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/lib/generators/ucasy/install/install_generator.rb +23 -0
- data/lib/generators/ucasy/install/templates/.rspec +4 -0
- data/lib/generators/ucasy/install/templates/use_case_base.rb +2 -0
- data/lib/ucasy/base.rb +61 -0
- data/lib/ucasy/context.rb +23 -0
- data/lib/ucasy/failure.rb +11 -0
- data/lib/ucasy/flow.rb +22 -0
- data/lib/ucasy/version.rb +3 -0
- data/lib/ucasy.rb +10 -0
- data/sig/ucasy/spec.rbs +4 -0
- data/ucasy.gemspec +31 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 17ebb25fba3f59ded4ef25011e7f2d43854619c775f9c2f2b2c3b64ac9bccd51
|
4
|
+
data.tar.gz: 99d93a1383bc0ec0695cd432c6016b7fc80677b8f198188de12e87643b885efd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a33b805568f830558b8fa1755794bf476dd14fb9b3153d9dda2ec8009abb89c4cf3758547f43f304b956c46e960c05bbc627ab155ee8b18aef809b14142ce39c
|
7
|
+
data.tar.gz: 0152edaa9a8d096e02be2acabacf97500b9117ac6ce6f310cd218ca1074d8843d75baa5e8f6600e3894efdaf4dbed7a398b627cb222bd4f598050bd5b433f1e1
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.standard.yml
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Lavenda Software
|
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/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Ucasy
|
2
|
+
|
3
|
+
Description soon!
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ru
|
10
|
+
gem "ucasy", "~> 0.0.1"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
bundle add ucasy
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
You can use a Rails generator to create setup files:
|
28
|
+
|
29
|
+
```sh
|
30
|
+
rails g ucasy:install
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ucasy.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Ucasy
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path("templates", __dir__)
|
4
|
+
|
5
|
+
desc "Generates a application use case base."
|
6
|
+
def create_use_case_base
|
7
|
+
copy_file "use_case_base.rb", use_case_path
|
8
|
+
copy_file ".rspec", Rails.root.join(".rspec")
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def use_case_path
|
14
|
+
Rails.root.join("app/#{GENERATOR_FOLDER_NAME}/use_case_base.rb")
|
15
|
+
end
|
16
|
+
|
17
|
+
def GENERATOR_FOLDER_NAME
|
18
|
+
return Ucasy::GENERATOR_FOLDER_NAME if defined?(Ucasy::GENERATOR_FOLDER_NAME)
|
19
|
+
|
20
|
+
Ucasy::DEFAULT_GENERATOR_FOLDER_NAME
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/ucasy/base.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative "context"
|
2
|
+
require_relative "failure"
|
3
|
+
|
4
|
+
module Ucasy
|
5
|
+
class Base
|
6
|
+
class << self
|
7
|
+
def call(context)
|
8
|
+
new(context).perform
|
9
|
+
end
|
10
|
+
|
11
|
+
def required_attributes(*attributes)
|
12
|
+
@required_attributes = attributes
|
13
|
+
end
|
14
|
+
|
15
|
+
def _required_attributes
|
16
|
+
@required_attributes || []
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(context = {})
|
21
|
+
@context = Context.build(context)
|
22
|
+
end
|
23
|
+
|
24
|
+
def perform
|
25
|
+
return if failure?
|
26
|
+
|
27
|
+
validate_context!
|
28
|
+
before if respond_to?(:before)
|
29
|
+
call
|
30
|
+
after if respond_to?(:after)
|
31
|
+
|
32
|
+
self
|
33
|
+
rescue Failure
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def call
|
38
|
+
raise StandardError, "You must implement call method"
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
attr_reader :context
|
44
|
+
|
45
|
+
def validate_context!
|
46
|
+
self.class._required_attributes.each do |attribute|
|
47
|
+
next if context.respond_to?(attribute)
|
48
|
+
|
49
|
+
raise ArgumentError, "You must set '#{attribute}' variable"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def method_missing(method_name, *, &block)
|
54
|
+
context.public_send(method_name)
|
55
|
+
end
|
56
|
+
|
57
|
+
def respond_to_missing?(method_name, include_private = false)
|
58
|
+
context.respond_to?(method_name, include_private)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
|
3
|
+
module Ucasy
|
4
|
+
class Context < OpenStruct
|
5
|
+
def self.build(context = {})
|
6
|
+
(self === context) ? context : new(context)
|
7
|
+
end
|
8
|
+
|
9
|
+
def fail!(options = {})
|
10
|
+
options.each { |key, value| self[key.to_sym] = value }
|
11
|
+
@failure = true
|
12
|
+
raise Failure, self
|
13
|
+
end
|
14
|
+
|
15
|
+
def failure?
|
16
|
+
@failure || false
|
17
|
+
end
|
18
|
+
|
19
|
+
def success?
|
20
|
+
!failure?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/ucasy/flow.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Ucasy
|
2
|
+
class Flow < Base
|
3
|
+
class << self
|
4
|
+
def service_classes(*service_classes)
|
5
|
+
@service_classes = service_classes
|
6
|
+
end
|
7
|
+
alias_method :flow, :service_classes
|
8
|
+
|
9
|
+
def _service_classes
|
10
|
+
@service_classes || []
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
self.class._service_classes.each do |service_class|
|
16
|
+
service_class.call(context)
|
17
|
+
end
|
18
|
+
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/ucasy.rb
ADDED
data/sig/ucasy/spec.rbs
ADDED
data/ucasy.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative "lib/ucasy/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "ucasy"
|
5
|
+
spec.version = Ucasy::VERSION
|
6
|
+
spec.authors = ["Lavenda Software"]
|
7
|
+
spec.email = ["lavenda@lavenda.com.br"]
|
8
|
+
|
9
|
+
spec.summary = "Ucasy is just a quick test suite setup for Rails application"
|
10
|
+
spec.homepage = "https://github.com/LavendaSoftware/ucasy"
|
11
|
+
spec.license = "MIT"
|
12
|
+
spec.required_ruby_version = ">= 3.0.0"
|
13
|
+
|
14
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "#{spec.homepage}/blob/main/README.md"
|
18
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/commits/main"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
23
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
(File.expand_path(f) == __FILE__) ||
|
25
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ucasy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lavenda Software
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- lavenda@lavenda.com.br
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".rspec"
|
21
|
+
- ".rubocop.yml"
|
22
|
+
- ".standard.yml"
|
23
|
+
- LICENSE.txt
|
24
|
+
- Makefile
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/generators/ucasy/install/install_generator.rb
|
28
|
+
- lib/generators/ucasy/install/templates/.rspec
|
29
|
+
- lib/generators/ucasy/install/templates/use_case_base.rb
|
30
|
+
- lib/ucasy.rb
|
31
|
+
- lib/ucasy/base.rb
|
32
|
+
- lib/ucasy/context.rb
|
33
|
+
- lib/ucasy/failure.rb
|
34
|
+
- lib/ucasy/flow.rb
|
35
|
+
- lib/ucasy/version.rb
|
36
|
+
- sig/ucasy/spec.rbs
|
37
|
+
- ucasy.gemspec
|
38
|
+
homepage: https://github.com/LavendaSoftware/ucasy
|
39
|
+
licenses:
|
40
|
+
- MIT
|
41
|
+
metadata:
|
42
|
+
allowed_push_host: https://rubygems.org
|
43
|
+
homepage_uri: https://github.com/LavendaSoftware/ucasy
|
44
|
+
source_code_uri: https://github.com/LavendaSoftware/ucasy/blob/main/README.md
|
45
|
+
changelog_uri: https://github.com/LavendaSoftware/ucasy/commits/main
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubygems_version: 3.5.9
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: Ucasy is just a quick test suite setup for Rails application
|
65
|
+
test_files: []
|