typed_operation 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53850ead13d940ad019c674a59e7831ba89da9ec70168d6a81de50711f343523
4
- data.tar.gz: e76a1321066eff1a9034aeaab66140d58732eeab7adf30ff8d51f455ce68f483
3
+ metadata.gz: b3c88c55bf10a3d9d6582adfbb253c94a1fd6cf287794089775c9a8dbf1dfd86
4
+ data.tar.gz: baee565ac599fb5351d1758fe720587e6793114c8ec830cbe3db6d5dc40b2d61
5
5
  SHA512:
6
- metadata.gz: 057de15499ac13647de16cd3905d23ddf390b00d0951449061e1fc30020ba0c2e546d1c1f38495911012177604740f5c3947426c94ee9dd9763f94df9629ae17
7
- data.tar.gz: f73dd9c04f0e5c3f87861c4d086059d595c296cc85783a85d9c13ef03f04ff7f87f46a4ec0b5cb1f9e9123d9f23ee0274a61d89f534ac666ad778db2f592dee0
6
+ metadata.gz: 32a92d0277fee468925bd0a3c5b4b377ebb8107b3202ea13f1c23925532df4665efffaac90e76c32060f629cb9a476e654abba406e80c28da7bcf590e504c445
7
+ data.tar.gz: 82d9ae76e6ba43564a3632d577ddf99ab92758c4b44cfad985a812b121c1c63efee7ceba0d92e1839c8fc6b5a0476a4914d4a33fdeca6a84bce9f0caca6c7789
data/README.md CHANGED
@@ -1,7 +1,4 @@
1
1
  # TypedOperation
2
- Short description and motivation.
3
-
4
- ## Usage
5
2
 
6
3
  An implementation of a Command pattern, which is callable, and can be partially applied (curried).
7
4
 
@@ -96,6 +93,26 @@ Or install it yourself as:
96
93
  $ gem install typed_operation
97
94
  ```
98
95
 
96
+ ## Add an `ApplicationOperation` to your project
97
+
98
+ ```ruby
99
+ bin/rails g typed_operation:install
100
+ ```
101
+
102
+ ## Generate a new Operation
103
+
104
+ ```ruby
105
+ bin/rails g typed_operation TestOperation
106
+ ```
107
+
108
+ You can optionally specify the directory to generate the operation in:
109
+
110
+ ```ruby
111
+ bin/rails g typed_operation TestOperation --path=app/operations
112
+ ```
113
+
114
+ The default path is `app/operations`.
115
+
99
116
  ## Contributing
100
117
  Contribution directions go here.
101
118
 
@@ -0,0 +1,25 @@
1
+ Operation Generator
2
+ ===================
3
+
4
+ Description:
5
+ ------------
6
+ This generator creates an 'TypedOperation' class that inherits from ApplicationOperation.
7
+
8
+ Command:
9
+ --------
10
+ rails generate typed_operation NAME [options]
11
+
12
+ Arguments:
13
+ ----------
14
+ NAME: The class name of the Operation class to be generated, e.g. 'MyOperation'.
15
+
16
+ Options:
17
+ --------
18
+ --path=path/to/directory: The path to the directory in which the operation class should be generated. The generated class will be namespaced according to the provided path.
19
+
20
+ Example:
21
+ --------
22
+ rails generate typed_operation MyOperation --path=app/operations
23
+
24
+ This will create the following file:
25
+ app/operations/my_operation.rb
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ <% if namespace_name.present? %>
4
+ module <%= namespace_name %>
5
+ class <%= name %> < ::ApplicationOperation
6
+ # Replace with implementation...
7
+ param :param1, String, convert: true
8
+
9
+ def prepare
10
+ # Prepare...
11
+ end
12
+
13
+ def call
14
+ # Perform...
15
+ end
16
+ end
17
+ end
18
+ <% else %>
19
+ class <%= name %> < ::ApplicationOperation
20
+ # Replace with implementation...
21
+ param :param1, String, convert: true
22
+
23
+ def prepare
24
+ # Prepare...
25
+ end
26
+
27
+ def call
28
+ # Perform...
29
+ end
30
+ end
31
+ <% end %>
@@ -0,0 +1,13 @@
1
+ Install Generator
2
+ =================
3
+
4
+ Description:
5
+ ------------
6
+ This generator installs a `ApplicationOperation` class which is your base class for all Operations.
7
+
8
+ Command:
9
+ --------
10
+ rails generate typed_operation:install
11
+
12
+ This will create the following file:
13
+ app/operations/application_operation.rb
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/base"
4
+
5
+ module TypedOperation
6
+ module Install
7
+ class InstallGenerator < Rails::Generators::Base
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ def copy_application_operation_file
11
+ copy_file "application_operation.rb", "app/operations/application_operation.rb"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationOperation < ::TypedOperation::Base
4
+ # Common properties & methods for operations of this application...
5
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/named_base"
4
+
5
+ class TypedOperationGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ class_option :path, type: :string, default: "app/operations"
9
+
10
+ def generate_operation
11
+ template_path = File.join(self.class.source_root, "operation.rb")
12
+ dest_path = File.join(options[:path], "#{file_name}.rb")
13
+
14
+ template(template_path, dest_path)
15
+ end
16
+
17
+ private
18
+
19
+ def namespace_name
20
+ namespace_path = options[:path].gsub(/^app\/[^\/]*\//, "")
21
+ namespace_path.split("/").map(&:camelize).join("::")
22
+ end
23
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "dry/monads"
4
+ require "vident/typed"
4
5
  require "vident/typed/attributes"
5
6
 
6
7
  module TypedOperation
@@ -1,4 +1,8 @@
1
1
  module TypedOperation
2
2
  class Railtie < ::Rails::Railtie
3
+ generators do
4
+ require "generators/typed_operation/install/install_generator"
5
+ require "generators/typed_operation_generator"
6
+ end
3
7
  end
4
8
  end
@@ -1,3 +1,3 @@
1
1
  module TypedOperation
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -4,7 +4,6 @@ require "typed_operation/base"
4
4
  require "typed_operation/partially_applied"
5
5
  require "typed_operation/prepared"
6
6
 
7
-
8
7
  module TypedOperation
9
8
  # Your code goes here...
10
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typed_operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ierodiaconou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-04 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: '6.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '8.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '7.0'
29
+ version: '6.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '8.0'
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 0.1.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: dry-initializer
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: dry-monads
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -64,7 +78,8 @@ dependencies:
64
78
  - - "<"
65
79
  - !ruby/object:Gem::Version
66
80
  version: '2'
67
- description: TypedOperation is a command pattern implementation
81
+ description: TypedOperation is a command pattern implementation where inputs can be
82
+ defined with runtime type checks. Operations can be partially applied.
68
83
  email:
69
84
  - stevegeek@gmail.com
70
85
  executables: []
@@ -74,6 +89,12 @@ files:
74
89
  - MIT-LICENSE
75
90
  - README.md
76
91
  - Rakefile
92
+ - lib/generators/USAGE
93
+ - lib/generators/templates/operation.rb
94
+ - lib/generators/typed_operation/install/USAGE
95
+ - lib/generators/typed_operation/install/install_generator.rb
96
+ - lib/generators/typed_operation/install/templates/application_operation.rb
97
+ - lib/generators/typed_operation_generator.rb
77
98
  - lib/tasks/typed_operation_tasks.rake
78
99
  - lib/typed_operation.rb
79
100
  - lib/typed_operation/base.rb