crossbeam 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/defs.rbi +9 -1
- data/lib/crossbeam/version.rb +1 -1
- data/lib/generators/crossbeam_generator.rb +17 -2
- data/lib/generators/templates/service_spec.rb.tt +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fce83921b90a45e552c736513a354ef5d104a745cc8d599f0001055ca7d7de71
|
4
|
+
data.tar.gz: bb311a52667479ccf148f20b3ab5a8d52e205236a50746ad0d3a43dc7177ef9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e4bdf4131de2c95211c645fe34d589a38a94d51182859e5451ed20d8a73f939079a637b70337577756a4d16c55a498e422a5239d4aae1b731777cac841870a3
|
7
|
+
data.tar.gz: 32ae16e01d67dbffc2178f34189c642b97b44fb9756864c102fa5d70277d343f4dacbea271ad8dea3cf17f87461859aa39de4dff99b84a7363ba8f56b893ba2f
|
data/README.md
CHANGED
@@ -279,6 +279,16 @@ class IdentityCheck
|
|
279
279
|
end
|
280
280
|
```
|
281
281
|
|
282
|
+
Not everyone wants to have their classes output to `app/services/**` sometimes you may prefer the class to be output to `app/commands/**`. Depending on the functionality you working on command classes are very regularly used design pattern.
|
283
|
+
|
284
|
+
The generator option in order to generate your classes as a command can be flagged with `--command`.
|
285
|
+
|
286
|
+
```shell
|
287
|
+
rails g crossbream AgeCheck --command
|
288
|
+
```
|
289
|
+
|
290
|
+
Running this will generate a file in `app/commands/age_check.rb` that you can use as a command class.
|
291
|
+
|
282
292
|
## Contributing
|
283
293
|
|
284
294
|
Bug reports and pull requests are welcome on GitHub at https://github.com/tarellel/crossbeam.
|
data/defs.rbi
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# typed: strong
|
2
2
|
# Crossbeam module to include with your service classes
|
3
3
|
module Crossbeam
|
4
|
-
VERSION = T.let('0.1.
|
4
|
+
VERSION = T.let('0.1.2', T.untyped)
|
5
5
|
|
6
6
|
# Used to include/extend modules into the current class
|
7
7
|
#
|
@@ -288,6 +288,14 @@ class CrossbeamGenerator < Rails::Generators::Base
|
|
288
288
|
sig { void }
|
289
289
|
def generate_test; end
|
290
290
|
|
291
|
+
# Used to deteremine if the class is a command vs service class
|
292
|
+
sig { returns(String) }
|
293
|
+
def class_directory; end
|
294
|
+
|
295
|
+
# Return the label of the class type
|
296
|
+
sig { returns(String) }
|
297
|
+
def class_type_label; end
|
298
|
+
|
291
299
|
# Returns a string to use as the service classes file name
|
292
300
|
sig { returns(String) }
|
293
301
|
def filename; end
|
data/lib/crossbeam/version.rb
CHANGED
@@ -10,22 +10,37 @@ if defined?(Rails)
|
|
10
10
|
|
11
11
|
argument :class_name, type: :string
|
12
12
|
argument :attributes, type: :array, default: [], banner: 'field[:type]'
|
13
|
+
class_option :command, type: :boolean, default: false
|
13
14
|
desc 'Generate a Crossbeam service class'
|
14
15
|
|
15
16
|
# @return [void]
|
16
17
|
def generate_service
|
17
|
-
template 'service_class.rb.tt', "app
|
18
|
+
template 'service_class.rb.tt', "app/#{class_directory}/#{filename}.rb", force: true
|
18
19
|
end
|
19
20
|
|
20
21
|
# @return [void]
|
21
22
|
def generate_test
|
22
23
|
return unless Rails.application&.config&.generators&.test_framework == :rspec
|
23
24
|
|
24
|
-
template 'service_spec.rb.tt', "spec
|
25
|
+
template 'service_spec.rb.tt', "spec/#{class_directory}/#{filename}_spec.rb", force: true
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
28
29
|
|
30
|
+
# Used to deteremine if the class is a command vs service class
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
def class_directory
|
34
|
+
@class_directory ||= options[:command] ? 'commands' : 'services'
|
35
|
+
end
|
36
|
+
|
37
|
+
# Return the label of the class type
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
def class_type_label
|
41
|
+
@class_type_label ||= options[:command] ? 'command' : 'service'
|
42
|
+
end
|
43
|
+
|
29
44
|
# Returns a string to use as the service classes file name
|
30
45
|
#
|
31
46
|
# @return [String]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crossbeam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Hicks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|