metaractor 3.3.4 → 3.4.1

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: eac48231fc113f9844493fff4e4c679798f97369b6f5fdf73eaa334e3d560416
4
- data.tar.gz: f0c4f4c7dee520927a8d6957fa16e9078250546a4bb2fc5731820a8807aca208
3
+ metadata.gz: 54f810c7379560bdedc30b5b748fdfea64ee6ee6040b021f1c7315ebd82d6d25
4
+ data.tar.gz: 1b78f912f057e8c5bc8e9490e7c427f9203c240442561efc2acaecc72a16fa80
5
5
  SHA512:
6
- metadata.gz: 1dfbdf5da9a96faa12023f409276fb25cd4b0ded28e3ae7014f4baf4deaec865e1c354d630bce57826c363d1ff74a0ba434f77f91aa3b8e43a7d8b68b26c3610
7
- data.tar.gz: 266737d67f3b4e6d3d04b147ebc74dc89af1f657eea694624bb497589e65b561186d82047a21c7404b65e0361b36041ddc88654762fa1e00a7d2d9c2fcfeca0c
6
+ metadata.gz: cf8e038791c2611ed349dc6265cf349a68989f8aa227abc5e6c1458f50afc1f3b5c71dbfb9a12e8e56dbedbadfe8600fcb1f96e05533804393d0760c7dbd9821
7
+ data.tar.gz: 2909274be834f5621a739893803d1e5551e5aeebc9da404e216e07cb9b5947b725a78fbb5069b085c24f0c0ba4811026e370c92bb25a8099ef9d2ee4916a248f
@@ -0,0 +1,37 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ push:
8
+ name: Push gem
9
+ runs-on: ubuntu-latest
10
+ environment: rubygems
11
+
12
+ permissions:
13
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
14
+ contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
21
+ ruby-version: ruby # Use latest ruby
22
+
23
+ - name: Set Environment Variables
24
+ run: |
25
+ version=$(ruby -e 'require_relative "lib/metaractor/version.rb"; puts Metaractor::VERSION')
26
+ echo "APP_VERSION=$version" >> $GITHUB_ENV
27
+
28
+ # Release
29
+ - uses: rubygems/release-gem@v1
30
+
31
+ # GitHub release
32
+ - uses: ncipollo/release-action@v1
33
+ with:
34
+ artifacts: "pkg/*.gem"
35
+ generateReleaseNotes: true
36
+ skipIfReleaseExists: true
37
+ tag: ${{ env.APP_VERSION }}
@@ -6,8 +6,9 @@ jobs:
6
6
  test:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
- - uses: actions/checkout@v3
10
- - uses: ruby/setup-ruby@v1
11
- with:
12
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
13
- - run: bundle exec rspec spec
9
+ - uses: actions/checkout@v4
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
13
+
14
+ - run: bundle exec rspec spec
data/.gitignore CHANGED
@@ -7,8 +7,3 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
-
11
- # Devenv
12
- .devenv*
13
- devenv.local.nix
14
- .direnv*
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 4.0.3
data/README.md CHANGED
@@ -12,13 +12,14 @@ gem 'metaractor'
12
12
 
13
13
  And then execute:
14
14
 
15
- $ bundle
15
+ bundle
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install metaractor
19
+ gem install metaractor
20
20
 
21
21
  ## Usage
22
+
22
23
  ```ruby
23
24
  class HighFiveUser
24
25
  include Metaractor
@@ -52,6 +53,7 @@ result.error_messages
52
53
  See Interactor's [README](https://github.com/collectiveidea/interactor/blob/master/README.md) for more information.
53
54
 
54
55
  ### Configuration
56
+
55
57
  Metaractor is meant to be extensible (hence the 'meta'). You can add additional modules in the following way:
56
58
 
57
59
  ```ruby
@@ -64,29 +66,37 @@ end
64
66
  ```
65
67
 
66
68
  ### Required Parameters
69
+
67
70
  Metaractor supports complex required parameter statements and you can chain these together in any manner using `and`, `or`, and `xor`.
71
+
68
72
  ```ruby
69
73
  required and: [:token, or: [:recipient_id, :recipient] ]
70
74
  ```
71
75
 
72
76
  You can also mark a parameter as required with the `required` option:
77
+
73
78
  ```ruby
74
79
  parameter :user, required: true
75
80
  ```
76
81
 
77
82
  ### Optional Parameters
83
+
78
84
  As optional parameters have no enforcement, they are merely advisory.
85
+
79
86
  ```ruby
80
87
  optional :enable_logging
81
88
  ```
82
89
 
83
90
  ### Parameter Options
91
+
84
92
  Metaractor supports arbitrary parameter options. The following are currently built in.
85
93
  Note that you can specify a block of `required` or `optional` parameters and then use
86
94
  `parameter` or `parameters` to add options to one or more of them.
87
95
 
88
96
  #### Skipping Blank Parameter Removal
97
+
89
98
  By default Metaractor removes blank values that are passed in. You may skip this behavior on a per-parameter basis:
99
+
90
100
  ```ruby
91
101
  parameter :name, allow_blank: true
92
102
  ```
@@ -94,28 +104,35 @@ parameter :name, allow_blank: true
94
104
  You may check to see if a parameter exists via `context.has_key?`.
95
105
 
96
106
  #### Default Values
107
+
97
108
  You can specify a default value for a parameter:
109
+
98
110
  ```ruby
99
111
  optional :role, default: :user
100
112
  ```
101
113
 
102
114
  This works with `allow_blank` and can also be anything that responds to `#call`.
115
+
103
116
  ```ruby
104
117
  parameter :role, allow_blank: true, default: -> { context.default_role }
105
118
  ```
106
119
 
107
120
  #### Typecasting/Coersion
121
+
108
122
  You can supply Metaractor with a callable that will typecast incoming parameters:
123
+
109
124
  ```ruby
110
125
  optional :needs_to_be_a_string, type: ->(value) { value.to_s }
111
126
  ```
112
127
 
113
128
  You can also configure Metaractor with named types and use them:
129
+
114
130
  ```ruby
115
131
  Metaractor.configure do |config|
116
132
  config.register_type(:boolean, ->(value) { ActiveModel::Type::Boolean.new.cast(value) })
117
133
  end
118
134
  ```
135
+
119
136
  ```ruby
120
137
  required :is_awesome, type: :boolean
121
138
  ```
@@ -123,7 +140,9 @@ required :is_awesome, type: :boolean
123
140
  **Note**: Typecasters will _not_ be called on `nil` values.
124
141
 
125
142
  ### Custom Validation
143
+
126
144
  Metaractor supports doing custom validation before any user supplied before_hooks run.
145
+
127
146
  ```ruby
128
147
  validate_parameters do
129
148
  if context.foo == :bar
@@ -137,6 +156,7 @@ end
137
156
  ```
138
157
 
139
158
  If you need to require a parameter from a `before_hook` for any reason, use the bang version of the method:
159
+
140
160
  ```ruby
141
161
  before do
142
162
  # Be careful with this approach as some user code may run before the parameter validation
@@ -145,7 +165,9 @@ end
145
165
  ```
146
166
 
147
167
  ### Structured Errors
168
+
148
169
  As of v2.0.0, metaractor supports structured errors.
170
+
149
171
  ```ruby
150
172
  class UpdateUser
151
173
  include Metaractor
@@ -202,7 +224,9 @@ result.errors.to_h
202
224
  ```
203
225
 
204
226
  ### I18n
227
+
205
228
  As of v3.0.0, metaractor supports i18n along with structured errors.
229
+
206
230
  ```ruby
207
231
  module Users
208
232
  class UpdateUser
@@ -225,6 +249,7 @@ end
225
249
  ```
226
250
 
227
251
  Locale:
252
+
228
253
  ```yaml
229
254
  en:
230
255
  errors:
@@ -246,10 +271,12 @@ You can see that above with the `users` key in the locale.
246
271
 
247
272
  The i18n integration will walk its way from the most specific message to the least specific one, stopping at the first one it can find.
248
273
  We currently expose the following variables for use in the message:
274
+
249
275
  - `error_key`: the error we added (ex: `blank` or `invalid_configuration`)
250
276
  - `parameter`: the name of the parameter
251
277
 
252
278
  You can also use this feature to work with machine readable keys:
279
+
253
280
  ```ruby
254
281
  result = Users::UpdateUser.call
255
282
  if result.failure? &&
@@ -260,7 +287,9 @@ end
260
287
  ```
261
288
 
262
289
  ### Spec Helpers
290
+
263
291
  Enable the helpers and/or matchers:
292
+
264
293
  ```ruby
265
294
  RSpec.configure do |config|
266
295
  config.include Metaractor::Spec::Helpers
@@ -269,7 +298,9 @@ end
269
298
  ```
270
299
 
271
300
  #### Helpers
301
+
272
302
  - `context_creator`
303
+
273
304
  ```ruby
274
305
  # context_creator(error_message: nil, error_messages: [], errors: [], valid: nil, invalid: nil, success: nil, failure: nil, **attributes)
275
306
 
@@ -300,7 +331,9 @@ context_creator(
300
331
  ```
301
332
 
302
333
  #### Matchers
334
+
303
335
  - `include_errors`
336
+
304
337
  ```ruby
305
338
  result = context_creator(
306
339
  errors: {
@@ -320,7 +353,9 @@ expect(result).to include_errors('user.title cannot be blank')
320
353
  ```
321
354
 
322
355
  ### Hash Formatting
356
+
323
357
  Metaractor customizes the output for `Metaractor::Errors#inspect` and `Interactor::Failure`:
358
+
324
359
  ```
325
360
  Interactor::Failure:
326
361
  Errors:
@@ -334,6 +369,7 @@ Interactor::Failure:
334
369
  ```
335
370
 
336
371
  You can further customize the hash formatting:
372
+
337
373
  ```ruby
338
374
  Metaractor.configure do |config|
339
375
  # Configure Metaractor to use awesome_print
@@ -342,22 +378,21 @@ end
342
378
  ```
343
379
 
344
380
  ### Further Reading
381
+
345
382
  For more examples of all of the above approaches, please see the specs.
346
383
 
347
384
  ## Development
348
385
 
349
- - `docker compose build --pull`
350
- - `docker compose run --rm metaractor` to run specs
351
-
352
- or with the Deskfile loaded:
386
+ - `flox pull ryansch/ruby-4-0`
387
+ - `flox activate`
388
+ - `bundle`
353
389
  - `rspec spec`
354
390
 
355
391
  To release a new version:
392
+
356
393
  - Update the version number in `version.rb` and commit the result.
357
- - `docker compose build --pull`
358
- - `docker compose run --rm release`
394
+ - Trigger the Release workflow.
359
395
 
360
396
  ## Contributing
361
397
 
362
- Bug reports and pull requests are welcome on GitHub at https://github.com/metaractor/metaractor.
363
-
398
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/metaractor/metaractor>.
@@ -12,5 +12,15 @@ module Metaractor
12
12
  context.fail_from_context(context: e.context)
13
13
  raise
14
14
  end
15
+
16
+ def run(...)
17
+ run!(...)
18
+ rescue Interactor::Failure
19
+ # Intentionally rescue all Failures as we're
20
+ # handling child errors by failing the parents
21
+ # instead of allowing the child to raise
22
+ # all of the way up.
23
+ # Needed since Interactor v3.2.0.
24
+ end
15
25
  end
16
26
  end
@@ -27,6 +27,8 @@ module Metaractor
27
27
  end
28
28
 
29
29
  def add_errors(messages: [], errors: {}, **args)
30
+ retry! if args.delete(:retry)
31
+
30
32
  if !messages.empty?
31
33
  self.errors.add(errors: {base: messages}, **args)
32
34
  else
@@ -37,6 +39,14 @@ module Metaractor
37
39
  def error_messages
38
40
  errors.full_messages
39
41
  end
42
+
43
+ def fail_from_context(context:)
44
+ return if context.equal?(self)
45
+
46
+ invalidate! if context.invalid?
47
+ add_errors(errors: context.errors.to_h)
48
+ @failure = true
49
+ end
40
50
  end
41
51
  end
42
52
 
@@ -0,0 +1,29 @@
1
+ module Metaractor
2
+ module ContextMethods
3
+ def valid?
4
+ !invalid?
5
+ end
6
+
7
+ def invalid?
8
+ @invalid || false
9
+ end
10
+
11
+ def invalidate!
12
+ @invalid = true
13
+ end
14
+
15
+ def has_key?(key)
16
+ @table.has_key?(key.to_sym)
17
+ end
18
+
19
+ def retry?
20
+ @retry || false
21
+ end
22
+
23
+ def retry!
24
+ @retry = true
25
+ end
26
+ end
27
+ end
28
+
29
+ Interactor::Context.send(:include, Metaractor::ContextMethods)
@@ -0,0 +1,16 @@
1
+ module Metaractor
2
+ module Delegation
3
+ def respond_to_missing?(name, include_private = false)
4
+ return false if name == :marshal_dump || name == :_dump
5
+ context.has_key?(name) || super
6
+ end
7
+
8
+ def method_missing(name, ...)
9
+ if context.has_key?(name)
10
+ context.public_send(name, ...)
11
+ else
12
+ super
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Metaractor
2
- VERSION = "3.3.4"
2
+ VERSION = "3.4.1"
3
3
  end
data/lib/metaractor.rb CHANGED
@@ -3,13 +3,12 @@ require "interactor"
3
3
  require "metaractor/errors"
4
4
  require "metaractor/handle_errors"
5
5
  require "metaractor/context_errors"
6
+ require "metaractor/context_methods"
6
7
  require "metaractor/parameters"
7
8
  require "metaractor/run_with_context"
8
- require "metaractor/context_validity"
9
9
  require "metaractor/chain_failures"
10
- require "metaractor/fail_from_context"
11
- require "metaractor/context_has_key"
12
10
  require "metaractor/failure_output"
11
+ require "metaractor/delegation"
13
12
  require "i18n"
14
13
  require "metaractor/namespace"
15
14
  require "metaractor/organizer"
@@ -47,7 +46,8 @@ module Metaractor
47
46
  {module: Metaractor::Parameters, method: :include},
48
47
  {module: Metaractor::RunWithContext, method: :include},
49
48
  {module: Metaractor::ChainFailures, method: :include},
50
- {module: Metaractor::Namespace, method: :include}
49
+ {module: Metaractor::Namespace, method: :include},
50
+ {module: Metaractor::Delegation, method: :include}
51
51
  ]
52
52
  end
53
53
 
data/metaractor.gemspec CHANGED
@@ -20,14 +20,15 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_runtime_dependency "interactor", "~> 3.1"
23
+ spec.add_runtime_dependency "interactor", "~> 3.2"
24
24
  spec.add_runtime_dependency "metaractor-sycamore", "~> 0.4", ">= 0.4.3"
25
- spec.add_runtime_dependency "i18n", "~> 1.8"
25
+ spec.add_runtime_dependency "i18n", "~> 1.14"
26
+ spec.add_runtime_dependency "ostruct", "~> 0.6"
26
27
 
27
- spec.add_development_dependency "bundler", "~> 2"
28
+ spec.add_development_dependency "bundler", "~> 4"
28
29
  spec.add_development_dependency "rake", "~> 13.0"
29
- spec.add_development_dependency "rspec", "~> 3.9"
30
- spec.add_development_dependency "awesome_print", "~> 1.8"
31
- spec.add_development_dependency "pry-byebug", "~> 3.9"
32
- spec.add_development_dependency "activemodel", "~> 6.1"
30
+ spec.add_development_dependency "rspec", "~> 3.13"
31
+ spec.add_development_dependency "amazing_print", "~> 2.0"
32
+ spec.add_development_dependency "debug", "~> 1.10"
33
+ spec.add_development_dependency "activemodel", "~> 8"
33
34
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.4
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Schlesinger
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: interactor
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '3.1'
18
+ version: '3.2'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '3.1'
25
+ version: '3.2'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: metaractor-sycamore
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -50,28 +49,42 @@ dependencies:
50
49
  requirements:
51
50
  - - "~>"
52
51
  - !ruby/object:Gem::Version
53
- version: '1.8'
52
+ version: '1.14'
54
53
  type: :runtime
55
54
  prerelease: false
56
55
  version_requirements: !ruby/object:Gem::Requirement
57
56
  requirements:
58
57
  - - "~>"
59
58
  - !ruby/object:Gem::Version
60
- version: '1.8'
59
+ version: '1.14'
60
+ - !ruby/object:Gem::Dependency
61
+ name: ostruct
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.6'
67
+ type: :runtime
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.6'
61
74
  - !ruby/object:Gem::Dependency
62
75
  name: bundler
63
76
  requirement: !ruby/object:Gem::Requirement
64
77
  requirements:
65
78
  - - "~>"
66
79
  - !ruby/object:Gem::Version
67
- version: '2'
80
+ version: '4'
68
81
  type: :development
69
82
  prerelease: false
70
83
  version_requirements: !ruby/object:Gem::Requirement
71
84
  requirements:
72
85
  - - "~>"
73
86
  - !ruby/object:Gem::Version
74
- version: '2'
87
+ version: '4'
75
88
  - !ruby/object:Gem::Dependency
76
89
  name: rake
77
90
  requirement: !ruby/object:Gem::Requirement
@@ -92,64 +105,63 @@ dependencies:
92
105
  requirements:
93
106
  - - "~>"
94
107
  - !ruby/object:Gem::Version
95
- version: '3.9'
108
+ version: '3.13'
96
109
  type: :development
97
110
  prerelease: false
98
111
  version_requirements: !ruby/object:Gem::Requirement
99
112
  requirements:
100
113
  - - "~>"
101
114
  - !ruby/object:Gem::Version
102
- version: '3.9'
115
+ version: '3.13'
103
116
  - !ruby/object:Gem::Dependency
104
- name: awesome_print
117
+ name: amazing_print
105
118
  requirement: !ruby/object:Gem::Requirement
106
119
  requirements:
107
120
  - - "~>"
108
121
  - !ruby/object:Gem::Version
109
- version: '1.8'
122
+ version: '2.0'
110
123
  type: :development
111
124
  prerelease: false
112
125
  version_requirements: !ruby/object:Gem::Requirement
113
126
  requirements:
114
127
  - - "~>"
115
128
  - !ruby/object:Gem::Version
116
- version: '1.8'
129
+ version: '2.0'
117
130
  - !ruby/object:Gem::Dependency
118
- name: pry-byebug
131
+ name: debug
119
132
  requirement: !ruby/object:Gem::Requirement
120
133
  requirements:
121
134
  - - "~>"
122
135
  - !ruby/object:Gem::Version
123
- version: '3.9'
136
+ version: '1.10'
124
137
  type: :development
125
138
  prerelease: false
126
139
  version_requirements: !ruby/object:Gem::Requirement
127
140
  requirements:
128
141
  - - "~>"
129
142
  - !ruby/object:Gem::Version
130
- version: '3.9'
143
+ version: '1.10'
131
144
  - !ruby/object:Gem::Dependency
132
145
  name: activemodel
133
146
  requirement: !ruby/object:Gem::Requirement
134
147
  requirements:
135
148
  - - "~>"
136
149
  - !ruby/object:Gem::Version
137
- version: '6.1'
150
+ version: '8'
138
151
  type: :development
139
152
  prerelease: false
140
153
  version_requirements: !ruby/object:Gem::Requirement
141
154
  requirements:
142
155
  - - "~>"
143
156
  - !ruby/object:Gem::Version
144
- version: '6.1'
145
- description:
157
+ version: '8'
146
158
  email:
147
159
  - ryan@ryanschlesinger.com
148
160
  executables: []
149
161
  extensions: []
150
162
  extra_rdoc_files: []
151
163
  files:
152
- - ".envrc"
164
+ - ".github/workflows/release.yml"
153
165
  - ".github/workflows/specs.yml"
154
166
  - ".gitignore"
155
167
  - ".rspec"
@@ -158,15 +170,12 @@ files:
158
170
  - LICENSE
159
171
  - README.md
160
172
  - Rakefile
161
- - flake.lock
162
- - flake.nix
163
173
  - lib/metaractor.rb
164
174
  - lib/metaractor/chain_failures.rb
165
175
  - lib/metaractor/context_errors.rb
166
- - lib/metaractor/context_has_key.rb
167
- - lib/metaractor/context_validity.rb
176
+ - lib/metaractor/context_methods.rb
177
+ - lib/metaractor/delegation.rb
168
178
  - lib/metaractor/errors.rb
169
- - lib/metaractor/fail_from_context.rb
170
179
  - lib/metaractor/failure_output.rb
171
180
  - lib/metaractor/handle_errors.rb
172
181
  - lib/metaractor/namespace.rb
@@ -176,13 +185,11 @@ files:
176
185
  - lib/metaractor/spec.rb
177
186
  - lib/metaractor/version.rb
178
187
  - metaractor.gemspec
179
- homepage:
180
188
  licenses:
181
189
  - Apache-2.0
182
190
  metadata:
183
191
  homepage_uri: https://github.com/metaractor/metaractor
184
192
  source_code_uri: https://github.com/metaractor/metaractor
185
- post_install_message:
186
193
  rdoc_options: []
187
194
  require_paths:
188
195
  - lib
@@ -197,8 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
204
  - !ruby/object:Gem::Version
198
205
  version: '0'
199
206
  requirements: []
200
- rubygems_version: 3.4.10
201
- signing_key:
207
+ rubygems_version: 4.0.10
202
208
  specification_version: 4
203
209
  summary: Adds parameter validation and error control to interactor
204
210
  test_files: []
data/.envrc DELETED
@@ -1,5 +0,0 @@
1
- if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
2
- source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
3
- fi
4
-
5
- use flake . --impure
data/flake.lock DELETED
@@ -1,417 +0,0 @@
1
- {
2
- "nodes": {
3
- "dev-cli": {
4
- "inputs": {
5
- "flake-compat": "flake-compat",
6
- "flake-parts": "flake-parts",
7
- "nixpkgs": [
8
- "nixpkgs"
9
- ]
10
- },
11
- "locked": {
12
- "lastModified": 1688133858,
13
- "narHash": "sha256-UeibsB2V5vozsqJAazx36d9oRmzXqlid8cpRdE9Hj1c=",
14
- "owner": "detaso",
15
- "repo": "dev-cli",
16
- "rev": "bb6f0c892a67e90efd8119d5ceb0873b48b28e68",
17
- "type": "github"
18
- },
19
- "original": {
20
- "owner": "detaso",
21
- "repo": "dev-cli",
22
- "type": "github"
23
- }
24
- },
25
- "devenv": {
26
- "inputs": {
27
- "flake-compat": "flake-compat_2",
28
- "nix": "nix",
29
- "nixpkgs": "nixpkgs",
30
- "pre-commit-hooks": "pre-commit-hooks"
31
- },
32
- "locked": {
33
- "lastModified": 1688639977,
34
- "narHash": "sha256-nLpc6Qr3HB+xGVTkl9lrEpr06vGf4khuxG/7ay3gNuI=",
35
- "owner": "cachix",
36
- "repo": "devenv",
37
- "rev": "b98d24ddc6d46252df1920fea44241f8fb6e45b2",
38
- "type": "github"
39
- },
40
- "original": {
41
- "owner": "cachix",
42
- "repo": "devenv",
43
- "type": "github"
44
- }
45
- },
46
- "flake-compat": {
47
- "flake": false,
48
- "locked": {
49
- "lastModified": 1673956053,
50
- "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
51
- "owner": "edolstra",
52
- "repo": "flake-compat",
53
- "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
54
- "type": "github"
55
- },
56
- "original": {
57
- "owner": "edolstra",
58
- "repo": "flake-compat",
59
- "type": "github"
60
- }
61
- },
62
- "flake-compat_2": {
63
- "flake": false,
64
- "locked": {
65
- "lastModified": 1673956053,
66
- "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
67
- "owner": "edolstra",
68
- "repo": "flake-compat",
69
- "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
70
- "type": "github"
71
- },
72
- "original": {
73
- "owner": "edolstra",
74
- "repo": "flake-compat",
75
- "type": "github"
76
- }
77
- },
78
- "flake-compat_3": {
79
- "flake": false,
80
- "locked": {
81
- "lastModified": 1673956053,
82
- "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
83
- "owner": "edolstra",
84
- "repo": "flake-compat",
85
- "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
86
- "type": "github"
87
- },
88
- "original": {
89
- "owner": "edolstra",
90
- "repo": "flake-compat",
91
- "type": "github"
92
- }
93
- },
94
- "flake-parts": {
95
- "inputs": {
96
- "nixpkgs-lib": "nixpkgs-lib"
97
- },
98
- "locked": {
99
- "lastModified": 1687762428,
100
- "narHash": "sha256-DIf7mi45PKo+s8dOYF+UlXHzE0Wl/+k3tXUyAoAnoGE=",
101
- "owner": "hercules-ci",
102
- "repo": "flake-parts",
103
- "rev": "37dd7bb15791c86d55c5121740a1887ab55ee836",
104
- "type": "github"
105
- },
106
- "original": {
107
- "owner": "hercules-ci",
108
- "repo": "flake-parts",
109
- "type": "github"
110
- }
111
- },
112
- "flake-parts_2": {
113
- "inputs": {
114
- "nixpkgs-lib": "nixpkgs-lib_2"
115
- },
116
- "locked": {
117
- "lastModified": 1688466019,
118
- "narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=",
119
- "owner": "hercules-ci",
120
- "repo": "flake-parts",
121
- "rev": "8e8d955c22df93dbe24f19ea04f47a74adbdc5ec",
122
- "type": "github"
123
- },
124
- "original": {
125
- "id": "flake-parts",
126
- "type": "indirect"
127
- }
128
- },
129
- "flake-utils": {
130
- "inputs": {
131
- "systems": "systems"
132
- },
133
- "locked": {
134
- "lastModified": 1685518550,
135
- "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
136
- "owner": "numtide",
137
- "repo": "flake-utils",
138
- "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
139
- "type": "github"
140
- },
141
- "original": {
142
- "owner": "numtide",
143
- "repo": "flake-utils",
144
- "type": "github"
145
- }
146
- },
147
- "flake-utils_2": {
148
- "locked": {
149
- "lastModified": 1667395993,
150
- "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
151
- "owner": "numtide",
152
- "repo": "flake-utils",
153
- "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
154
- "type": "github"
155
- },
156
- "original": {
157
- "owner": "numtide",
158
- "repo": "flake-utils",
159
- "type": "github"
160
- }
161
- },
162
- "gitignore": {
163
- "inputs": {
164
- "nixpkgs": [
165
- "devenv",
166
- "pre-commit-hooks",
167
- "nixpkgs"
168
- ]
169
- },
170
- "locked": {
171
- "lastModified": 1660459072,
172
- "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
173
- "owner": "hercules-ci",
174
- "repo": "gitignore.nix",
175
- "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
176
- "type": "github"
177
- },
178
- "original": {
179
- "owner": "hercules-ci",
180
- "repo": "gitignore.nix",
181
- "type": "github"
182
- }
183
- },
184
- "lowdown-src": {
185
- "flake": false,
186
- "locked": {
187
- "lastModified": 1633514407,
188
- "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
189
- "owner": "kristapsdz",
190
- "repo": "lowdown",
191
- "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
192
- "type": "github"
193
- },
194
- "original": {
195
- "owner": "kristapsdz",
196
- "repo": "lowdown",
197
- "type": "github"
198
- }
199
- },
200
- "nix": {
201
- "inputs": {
202
- "lowdown-src": "lowdown-src",
203
- "nixpkgs": [
204
- "devenv",
205
- "nixpkgs"
206
- ],
207
- "nixpkgs-regression": "nixpkgs-regression"
208
- },
209
- "locked": {
210
- "lastModified": 1676545802,
211
- "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=",
212
- "owner": "domenkozar",
213
- "repo": "nix",
214
- "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f",
215
- "type": "github"
216
- },
217
- "original": {
218
- "owner": "domenkozar",
219
- "ref": "relaxed-flakes",
220
- "repo": "nix",
221
- "type": "github"
222
- }
223
- },
224
- "nixpkgs": {
225
- "locked": {
226
- "lastModified": 1678875422,
227
- "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=",
228
- "owner": "NixOS",
229
- "repo": "nixpkgs",
230
- "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459",
231
- "type": "github"
232
- },
233
- "original": {
234
- "owner": "NixOS",
235
- "ref": "nixpkgs-unstable",
236
- "repo": "nixpkgs",
237
- "type": "github"
238
- }
239
- },
240
- "nixpkgs-lib": {
241
- "locked": {
242
- "dir": "lib",
243
- "lastModified": 1685564631,
244
- "narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=",
245
- "owner": "NixOS",
246
- "repo": "nixpkgs",
247
- "rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a",
248
- "type": "github"
249
- },
250
- "original": {
251
- "dir": "lib",
252
- "owner": "NixOS",
253
- "ref": "nixos-unstable",
254
- "repo": "nixpkgs",
255
- "type": "github"
256
- }
257
- },
258
- "nixpkgs-lib_2": {
259
- "locked": {
260
- "dir": "lib",
261
- "lastModified": 1688049487,
262
- "narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=",
263
- "owner": "NixOS",
264
- "repo": "nixpkgs",
265
- "rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9",
266
- "type": "github"
267
- },
268
- "original": {
269
- "dir": "lib",
270
- "owner": "NixOS",
271
- "ref": "nixos-unstable",
272
- "repo": "nixpkgs",
273
- "type": "github"
274
- }
275
- },
276
- "nixpkgs-regression": {
277
- "locked": {
278
- "lastModified": 1643052045,
279
- "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
280
- "owner": "NixOS",
281
- "repo": "nixpkgs",
282
- "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
283
- "type": "github"
284
- },
285
- "original": {
286
- "owner": "NixOS",
287
- "repo": "nixpkgs",
288
- "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
289
- "type": "github"
290
- }
291
- },
292
- "nixpkgs-ruby": {
293
- "inputs": {
294
- "flake-compat": "flake-compat_3",
295
- "flake-utils": "flake-utils_2",
296
- "nixpkgs": [
297
- "nixpkgs"
298
- ]
299
- },
300
- "locked": {
301
- "lastModified": 1688103575,
302
- "narHash": "sha256-VkkUAm6U9sogXYFGhru0xIb0KI+mrVbk5PKjCD8rnV4=",
303
- "owner": "bobvanderlinden",
304
- "repo": "nixpkgs-ruby",
305
- "rev": "e6ae16647947d0858a99e033ce695c33d6212852",
306
- "type": "github"
307
- },
308
- "original": {
309
- "owner": "bobvanderlinden",
310
- "repo": "nixpkgs-ruby",
311
- "type": "github"
312
- }
313
- },
314
- "nixpkgs-stable": {
315
- "locked": {
316
- "lastModified": 1685801374,
317
- "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
318
- "owner": "NixOS",
319
- "repo": "nixpkgs",
320
- "rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
321
- "type": "github"
322
- },
323
- "original": {
324
- "owner": "NixOS",
325
- "ref": "nixos-23.05",
326
- "repo": "nixpkgs",
327
- "type": "github"
328
- }
329
- },
330
- "nixpkgs_2": {
331
- "locked": {
332
- "lastModified": 1688585123,
333
- "narHash": "sha256-+xFOB4WaRUHuZI7H1tWHTrwY4BnbPmh8M1n/XhPRH0w=",
334
- "owner": "NixOS",
335
- "repo": "nixpkgs",
336
- "rev": "23de9f3b56e72632c628d92b71c47032e14a3d4d",
337
- "type": "github"
338
- },
339
- "original": {
340
- "owner": "NixOS",
341
- "ref": "nixpkgs-unstable",
342
- "repo": "nixpkgs",
343
- "type": "github"
344
- }
345
- },
346
- "pre-commit-hooks": {
347
- "inputs": {
348
- "flake-compat": [
349
- "devenv",
350
- "flake-compat"
351
- ],
352
- "flake-utils": "flake-utils",
353
- "gitignore": "gitignore",
354
- "nixpkgs": [
355
- "devenv",
356
- "nixpkgs"
357
- ],
358
- "nixpkgs-stable": "nixpkgs-stable"
359
- },
360
- "locked": {
361
- "lastModified": 1688056373,
362
- "narHash": "sha256-2+SDlNRTKsgo3LBRiMUcoEUb6sDViRNQhzJquZ4koOI=",
363
- "owner": "cachix",
364
- "repo": "pre-commit-hooks.nix",
365
- "rev": "5843cf069272d92b60c3ed9e55b7a8989c01d4c7",
366
- "type": "github"
367
- },
368
- "original": {
369
- "owner": "cachix",
370
- "repo": "pre-commit-hooks.nix",
371
- "type": "github"
372
- }
373
- },
374
- "root": {
375
- "inputs": {
376
- "dev-cli": "dev-cli",
377
- "devenv": "devenv",
378
- "flake-parts": "flake-parts_2",
379
- "nixpkgs": "nixpkgs_2",
380
- "nixpkgs-ruby": "nixpkgs-ruby",
381
- "systems": "systems_2"
382
- }
383
- },
384
- "systems": {
385
- "locked": {
386
- "lastModified": 1681028828,
387
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
388
- "owner": "nix-systems",
389
- "repo": "default",
390
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
391
- "type": "github"
392
- },
393
- "original": {
394
- "owner": "nix-systems",
395
- "repo": "default",
396
- "type": "github"
397
- }
398
- },
399
- "systems_2": {
400
- "locked": {
401
- "lastModified": 1681028828,
402
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
403
- "owner": "nix-systems",
404
- "repo": "default",
405
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
406
- "type": "github"
407
- },
408
- "original": {
409
- "owner": "nix-systems",
410
- "repo": "default",
411
- "type": "github"
412
- }
413
- }
414
- },
415
- "root": "root",
416
- "version": 7
417
- }
data/flake.nix DELETED
@@ -1,67 +0,0 @@
1
- {
2
- inputs = {
3
- nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4
- systems.url = "github:nix-systems/default";
5
- devenv.url = "github:cachix/devenv";
6
- nixpkgs-ruby.url = "github:bobvanderlinden/nixpkgs-ruby";
7
- nixpkgs-ruby.inputs.nixpkgs.follows = "nixpkgs";
8
- dev-cli.url = "github:detaso/dev-cli";
9
- dev-cli.inputs.nixpkgs.follows = "nixpkgs";
10
- };
11
-
12
- outputs = inputs@{ flake-parts, ... }:
13
- flake-parts.lib.mkFlake { inherit inputs; } {
14
- imports = [
15
- inputs.devenv.flakeModule
16
- ];
17
- systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
18
-
19
- perSystem = { config, self', inputs', pkgs, system, ... }: {
20
- # Per-system attributes can be defined here. The self' and inputs'
21
- # module parameters provide easy access to attributes of the same
22
- # system.
23
-
24
- devenv.shells.default = let
25
- dev-cli = inputs.dev-cli.packages.${system}.default;
26
- in {
27
- # https://devenv.sh/reference/options/
28
-
29
- packages = with pkgs; [
30
- git
31
- nodejs-18_x
32
- yarn
33
- postgresql_14
34
- zlib
35
- zstd
36
- libiconv
37
- tmux
38
- tmuxPlugins.sensible
39
- tmuxPlugins.yank
40
- reattach-to-user-namespace
41
- ] ++ [
42
- dev-cli
43
- ];
44
-
45
- languages.ruby.enable = true;
46
- languages.ruby.bundler.enable = false;
47
- languages.ruby.version = "3.2.2";
48
-
49
- enterShell = ''
50
- export BUNDLE_BIN="$DEVENV_ROOT/.devenv/bin"
51
- export PATH="$DEVENV_PROFILE/bin:$DEVENV_ROOT/bin:$BUNDLE_BIN:$PATH"
52
- export BOOTSNAP_CACHE_DIR="$DEVENV_ROOT/.devenv/state"
53
-
54
- if [ ! -f ~/.tmux.conf ] && [ ! -f ~/.config/tmux/tmux.conf ] && [ -f "$DEVENV_ROOT/.overmind.tmux.conf" ]; then
55
- export OVERMIND_TMUX_CONFIG="$DEVENV_ROOT/.overmind.tmux.conf"
56
- fi
57
- '';
58
-
59
- env.OVERMIND_NO_PORT=1;
60
- env.OVERMIND_ANY_CAN_DIE=1;
61
- process.implementation = "overmind";
62
-
63
- env.RUBY_DEBUG_SOCK_DIR = "/tmp/";
64
- };
65
- };
66
- };
67
- }
@@ -1,9 +0,0 @@
1
- module Metaractor
2
- module ContextHasKey
3
- def has_key?(key)
4
- @table.has_key?(key.to_sym)
5
- end
6
- end
7
- end
8
-
9
- Interactor::Context.send(:include, Metaractor::ContextHasKey)
@@ -1,17 +0,0 @@
1
- module Metaractor
2
- module ContextValidity
3
- def valid?
4
- !invalid?
5
- end
6
-
7
- def invalid?
8
- @invalid || false
9
- end
10
-
11
- def invalidate!
12
- @invalid = true
13
- end
14
- end
15
- end
16
-
17
- Interactor::Context.send(:include, Metaractor::ContextValidity)
@@ -1,13 +0,0 @@
1
- module Metaractor
2
- module FailFromContext
3
- def fail_from_context(context:)
4
- return if context.equal?(self)
5
-
6
- invalidate! if context.invalid?
7
- add_errors(errors: context.errors.to_h)
8
- @failure = true
9
- end
10
- end
11
- end
12
-
13
- Interactor::Context.send(:include, Metaractor::FailFromContext)