ucasy 0.3.1 → 0.3.3
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 +4 -4
- data/.rubocop.yml +2 -2
- data/README.md +53 -5
- data/lib/generators/ucasy/copy/copy_generator.rb +24 -0
- data/lib/ucasy/base.rb +0 -5
- data/lib/ucasy/version.rb +1 -1
- data/lib/ucasy.rb +13 -4
- data/ucasy.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5e5904dd30d87337aa27b5ad679cca1f25882051f6bf3bb36fc0293d276310f
|
4
|
+
data.tar.gz: 492e0637d273e6f7437c5877b7f36a1f517555df3fb10b1a07b00c520f0283dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb3691249d2e7878bfba66eca4e1affa93efc74bca84821ae03cc7d77d64982a92fb8c0a51febe07ad2730a061f7b3dc360644ccd8bfa982b8080c9afc65cc07
|
7
|
+
data.tar.gz: 21f497deca4b040fe94bacca005240e2d3779d1235f809d07c7765a8bb1252ec719925262affe5574a8976cc3eed27f0883a6ff2b9f90a476bf356aa0170b69c
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -4,33 +4,59 @@ Description soon!
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
### As gem dependence
|
8
|
+
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
9
11
|
```ru
|
10
|
-
gem "ucasy", "~> 0.
|
12
|
+
gem "ucasy", "~> 0.3.3"
|
11
13
|
```
|
12
14
|
|
13
15
|
And then execute:
|
14
16
|
|
15
17
|
```bash
|
16
|
-
bundle install
|
18
|
+
bin/bundle install
|
17
19
|
```
|
18
20
|
|
19
21
|
Or install it yourself as:
|
20
22
|
|
21
23
|
```bash
|
22
|
-
bundle add ucasy
|
24
|
+
bin/bundle add ucasy
|
25
|
+
```
|
26
|
+
|
27
|
+
### Copying files
|
28
|
+
|
29
|
+
Add this line to your application's Gemfile:
|
30
|
+
|
31
|
+
```ru
|
32
|
+
group :development do
|
33
|
+
gem "ucasy", "~> 0.3.3", require: false
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
And then execute:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
bin/bundle install
|
41
|
+
```
|
42
|
+
|
43
|
+
Or install it yourself as:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
bin/bundle add ucasy --require false --group development
|
23
47
|
```
|
24
48
|
|
25
49
|
## Create base file
|
26
50
|
|
27
51
|
You can use a Rails generator to create setup `UseCaseBase` file:
|
28
52
|
|
53
|
+
### As gem dependence
|
54
|
+
|
29
55
|
```sh
|
30
|
-
rails g ucasy:install
|
56
|
+
bin/rails g ucasy:install
|
31
57
|
```
|
32
58
|
|
33
|
-
This will create `app/use_cases/use_case_base.rb`
|
59
|
+
This will only create `app/use_cases/use_case_base.rb`
|
34
60
|
|
35
61
|
```rb
|
36
62
|
class UseCaseBase < Ucasy::Base
|
@@ -39,6 +65,28 @@ class UseCaseBase < Ucasy::Base
|
|
39
65
|
end
|
40
66
|
```
|
41
67
|
|
68
|
+
And you need use ucasy gem as production dependence
|
69
|
+
|
70
|
+
### Copying files
|
71
|
+
|
72
|
+
```sh
|
73
|
+
bin/rails g ucasy:copy
|
74
|
+
```
|
75
|
+
This will copy all needed code to your rails application:
|
76
|
+
|
77
|
+
```
|
78
|
+
create app/use_cases/use_case_base.rb
|
79
|
+
create app/use_cases/ucasy
|
80
|
+
create app/use_cases/ucasy/base.rb
|
81
|
+
create app/use_cases/ucasy/callable.rb
|
82
|
+
create app/use_cases/ucasy/context.rb
|
83
|
+
create app/use_cases/ucasy/failure.rb
|
84
|
+
create app/use_cases/ucasy/flow.rb
|
85
|
+
create app/use_cases/ucasy/validators/required_attributes.rb
|
86
|
+
create app/use_cases/ucasy/validators/validate.rb
|
87
|
+
create app/use_cases/ucasy/version.rb
|
88
|
+
```
|
89
|
+
|
42
90
|
## Basic usage
|
43
91
|
|
44
92
|
You can create a simple use case to `app/use_cases/authenticate_user.rb`:
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Ucasy
|
2
|
+
class CopyGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path("../../..", __dir__)
|
4
|
+
|
5
|
+
desc "Copy Ucasy code to application"
|
6
|
+
def create_use_case_base
|
7
|
+
system "bin/rails g ucasy:install"
|
8
|
+
|
9
|
+
directory "ucasy", use_case_path
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def use_case_path
|
15
|
+
Rails.root.join("app/#{generator_folder_name}/ucasy")
|
16
|
+
end
|
17
|
+
|
18
|
+
def generator_folder_name
|
19
|
+
return Ucasy::GENERATOR_FOLDER_NAME if defined?(Ucasy::GENERATOR_FOLDER_NAME)
|
20
|
+
|
21
|
+
Ucasy::DEFAULT_GENERATOR_FOLDER_NAME
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/ucasy/base.rb
CHANGED
data/lib/ucasy/version.rb
CHANGED
data/lib/ucasy.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
require_relative "ucasy/version"
|
2
|
-
require_relative "ucasy/callable"
|
3
|
-
require_relative "ucasy/base"
|
4
|
-
require_relative "ucasy/flow"
|
5
2
|
|
6
3
|
module Ucasy
|
7
|
-
|
4
|
+
DEFAULT_GENERATOR_FOLDER_NAME = "use_cases"
|
5
|
+
|
6
|
+
autoload :Callable, "ucasy/callable"
|
7
|
+
autoload :Context, "ucasy/context"
|
8
|
+
autoload :Failure, "ucasy/failure"
|
9
|
+
|
10
|
+
module Validators
|
11
|
+
autoload :Validate, "ucasy/validators/validate"
|
12
|
+
autoload :RequiredAttributes, "ucasy/validators/required_attributes"
|
13
|
+
end
|
14
|
+
|
15
|
+
autoload :Base, "ucasy/base"
|
16
|
+
autoload :Flow, "ucasy/flow"
|
8
17
|
|
9
18
|
class Error < StandardError
|
10
19
|
end
|
data/ucasy.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucasy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lavenda Software
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- Makefile
|
37
37
|
- README.md
|
38
38
|
- Rakefile
|
39
|
+
- lib/generators/ucasy/copy/copy_generator.rb
|
39
40
|
- lib/generators/ucasy/install/install_generator.rb
|
40
41
|
- lib/generators/ucasy/install/templates/use_case_base.rb.tt
|
41
42
|
- lib/ucasy.rb
|