crossbeam 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b64e651b82a1643650011351595188dafc9c609e42b4051d73cf75a9611cb2a8
4
- data.tar.gz: 9d51296e74fdc2b014c916124d77427ecb12a7e8d90584fd8286e15a78acc1e5
3
+ metadata.gz: fce83921b90a45e552c736513a354ef5d104a745cc8d599f0001055ca7d7de71
4
+ data.tar.gz: bb311a52667479ccf148f20b3ab5a8d52e205236a50746ad0d3a43dc7177ef9b
5
5
  SHA512:
6
- metadata.gz: f12b259277b699799db158302015ce6dcef771c38f2a74acaa8c15185e9389bdc3b2f23d7ed9cde55d411845cda7e4f24ae121f2f2bb421fdbc8f29305e865c3
7
- data.tar.gz: fdae532476ab1a4900225550690599b15268d5c87a7d912e3553b8a5f7c1bf5022b18b4a098f60ef083f123912aa7e7a8a3aa7013774c675c4683b22d7b5f3fe
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.0', T.untyped)
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Crossbeam
4
4
  # @return [String]
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
@@ -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/services/#{filename}.rb", force: true
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/services/#{filename}_spec.rb", force: true
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]
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rails_helper'
4
4
 
5
- RSpec.describe <%= class_name.classify %>, type: :helper do
5
+ RSpec.describe <%= class_name.classify %>, type: :<%= class_type_label %> do
6
6
  subject { described_class.call }
7
7
 
8
8
  describe 'an example' do
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.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-01-06 00:00:00.000000000 Z
11
+ date: 2024-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel