command 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2feec1b1778fddab832f6f719eb7796790b563c15c937e831c5d70ea7465b35a
4
+ data.tar.gz: '058e7871cfbac7c323479e65d11f6e7a665d61b31846c4be21ac5a7d4c8b38a8'
5
+ SHA512:
6
+ metadata.gz: 7868a8074275120545491a4472736acdffe9ea9c87ff9c3f06e1e9b1b87673a824c59d7992a03e23f2b02277fd610dea4c81a8036e0569fb45821e439b778944
7
+ data.tar.gz: 7c50aadd5515ed34eb1fddb12c3f9de47db73fbfa80947c3944a555e0ba64ace3e394f2414681f25ecebc59317af97120fc15349b3a88269682962fec684c8e5
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Eric Garside
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.
@@ -0,0 +1,48 @@
1
+ # Command
2
+
3
+ A behavioral approach for building extensible business objects in Rails applications
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/command.svg)](https://badge.fury.io/rb/command)
6
+ [![Build Status](https://semaphoreci.com/api/v1/projects/0f108338-9688-4292-a358-ea7d4418747b/3017780/badge.svg)](https://semaphoreci.com/freshly/command)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/67c636f92aa81595fb6c/maintainability)](https://codeclimate.com/github/Freshly/command/maintainability)
8
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/67c636f92aa81595fb6c/test_coverage)](https://codeclimate.com/github/Freshly/command/test_coverage)
9
+
10
+ * [Installation](#installation)
11
+ * [Usage](#usage)
12
+ * [Development](#development)
13
+ * [Contributing](#contributing)
14
+ * [License](#license)
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'command'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install command
31
+
32
+ ## Usage
33
+
34
+ TODO: Write usage instructions here
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Freshly/command.
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support"
4
+
5
+ require "spicerack"
6
+
7
+ require "flow"
8
+
9
+ require "command/version"
10
+
11
+ require "command/field_error"
12
+ require "command/command_base"
13
+
14
+ module Command; end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Command
4
+ module Command
5
+ module Core
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ delegate :flow_class, to: :class
10
+ delegate :pending?, :triggered?, :success?, :failed?, :state, :output, to: :flow, prefix: true
11
+ delegate :failed_operation, to: :flow
12
+ delegate :operation_failure, to: :failed_operation, allow_nil: true
13
+
14
+ private
15
+
16
+ attr_reader :flow
17
+ end
18
+
19
+ class_methods do
20
+ def flow_class
21
+ conjugate!(Flow::FlowBase)
22
+ end
23
+ end
24
+
25
+ def initialize(input = {})
26
+ @flow = flow_class.new(**input.symbolize_keys)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Command
4
+ module Command
5
+ module Execute
6
+ extend ActiveSupport::Concern
7
+
8
+ class_methods do
9
+ def execute(input = {})
10
+ new(input).tap(&:execute)
11
+ end
12
+ end
13
+
14
+ def execute
15
+ flow.trigger
16
+
17
+ flow_success? ? handle_success : handle_failure
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Command
4
+ module Command
5
+ module Failure
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ define_callbacks_with_handler :failure
10
+ end
11
+
12
+ private
13
+
14
+ def handle_failure
15
+ run_callbacks(:failure)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Command
4
+ module Command
5
+ module Success
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ define_callbacks_with_handler :success
10
+ end
11
+
12
+ private
13
+
14
+ def handle_success
15
+ run_callbacks(:success)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "command/core"
4
+ require_relative "command/success"
5
+ require_relative "command/failure"
6
+ require_relative "command/execute"
7
+
8
+ module Command
9
+ class CommandBase < Spicerack::RootObject
10
+ include Conjunction::Conjunctive
11
+
12
+ include Command::Core
13
+ include Command::Success
14
+ include Command::Failure
15
+ include Command::Execute
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Command
4
+ class FieldError < Spicerack::InputObject
5
+ argument :field_name
6
+ argument :error_code
7
+ argument :message
8
+
9
+ class << self
10
+ def collection_from_json(field_error_hashes)
11
+ field_error_hashes.map { |field_error_hash| new(**field_error_hash.symbolize_keys) }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Command
4
+ VERSION = "0.1.0"
5
+ end
metadata ADDED
@@ -0,0 +1,266 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: command
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Garside
8
+ - Allen Rettberg
9
+ - Jordan Minneti
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2019-11-15 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: 5.2.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: 5.2.1
29
+ - !ruby/object:Gem::Dependency
30
+ name: spicerack
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.18.0
36
+ - - "<"
37
+ - !ruby/object:Gem::Version
38
+ version: '1.0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.18.0
46
+ - - "<"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.0'
49
+ - !ruby/object:Gem::Dependency
50
+ name: flow
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.10.3
56
+ - - "<"
57
+ - !ruby/object:Gem::Version
58
+ version: '1.0'
59
+ type: :runtime
60
+ prerelease: false
61
+ version_requirements: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 0.10.3
66
+ - - "<"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: faker
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.7.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.7.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.16'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.16'
153
+ - !ruby/object:Gem::Dependency
154
+ name: timecop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 0.9.1
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 0.9.1
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspice
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 0.18.0
174
+ - - "<"
175
+ - !ruby/object:Gem::Version
176
+ version: '1.0'
177
+ type: :development
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: 0.18.0
184
+ - - "<"
185
+ - !ruby/object:Gem::Version
186
+ version: '1.0'
187
+ - !ruby/object:Gem::Dependency
188
+ name: spicerack-styleguide
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: 0.18.0
194
+ - - "<"
195
+ - !ruby/object:Gem::Version
196
+ version: '1.0'
197
+ type: :development
198
+ prerelease: false
199
+ version_requirements: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: 0.18.0
204
+ - - "<"
205
+ - !ruby/object:Gem::Version
206
+ version: '1.0'
207
+ - !ruby/object:Gem::Dependency
208
+ name: shoulda-matchers
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - '='
212
+ - !ruby/object:Gem::Version
213
+ version: 4.0.1
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - '='
219
+ - !ruby/object:Gem::Version
220
+ version: 4.0.1
221
+ description: A behavioral approach for building extensible business objects in Rails
222
+ applications
223
+ email:
224
+ - garside@gmail.com
225
+ - allen.rettberg@freshly.com
226
+ - jordan.minneti@freshly.com
227
+ executables: []
228
+ extensions: []
229
+ extra_rdoc_files: []
230
+ files:
231
+ - LICENSE.txt
232
+ - README.md
233
+ - lib/command.rb
234
+ - lib/command/command/core.rb
235
+ - lib/command/command/execute.rb
236
+ - lib/command/command/failure.rb
237
+ - lib/command/command/success.rb
238
+ - lib/command/command_base.rb
239
+ - lib/command/field_error.rb
240
+ - lib/command/version.rb
241
+ homepage: https://github.com/Freshly/command
242
+ licenses:
243
+ - MIT
244
+ metadata: {}
245
+ post_install_message:
246
+ rdoc_options: []
247
+ require_paths:
248
+ - lib
249
+ required_ruby_version: !ruby/object:Gem::Requirement
250
+ requirements:
251
+ - - ">="
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ required_rubygems_version: !ruby/object:Gem::Requirement
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ version: '0'
259
+ requirements: []
260
+ rubyforge_project:
261
+ rubygems_version: 2.7.6
262
+ signing_key:
263
+ specification_version: 4
264
+ summary: Define what your application does with service objects that adapt to your
265
+ architecture
266
+ test_files: []