metaractor 3.0.1 → 3.1.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: d8b28e07d981c3224d3e209a34961e685de8859e7bec198c8f64ac08456219e7
4
- data.tar.gz: d2ea3446b24661a347bb38087df37b6208ce62a742f7a7edfd2332a7137e1acd
3
+ metadata.gz: 285b4aecd4d684716db6d574e443464ba4fecaca03f49417153d4eb2d49994e4
4
+ data.tar.gz: bea5769c3cb76692d1f1a1218fae8937500ae2cdec53dfda5d17066170a723b8
5
5
  SHA512:
6
- metadata.gz: 61e4852078088812a0a53b33601d555aa8a2bdd3b5d50f56bd96c8c50729f45aa7a788eb305f82bb747f973bfde421c2904385c35a4428687bd7f9621ab382e3
7
- data.tar.gz: 2cd047d8213c8c4197395545ab4f1b448aea33c6985f0ec0dc6901a66d923195be2ac510e0a73ee414643200d22b5d5b8c88da90ce53cb22d7cb9f35b825beaa
6
+ metadata.gz: 78226f45df08e38363d19cf03e3ec7867d0788700abf11daa08d5eca31ff62f3e9c43460d39be9d9422a686ee1a0da35de323df54d49ea06962876a809f3ad06
7
+ data.tar.gz: 76dee36d5fd30560f4bb7ebee50cf1e59d984e70bc219107e2d439024523ed2992056baacb17227e294466f4cff75b58cd96c7bb8fc0b680438ee8bf367e057c
@@ -0,0 +1,92 @@
1
+ env:
2
+ BUILDKITE_PLUGIN_DOCKER_CACHE_S3_BUCKET: "outstand-buildkite-cache"
3
+ # BUILDKITE_PLUGIN_DOCKER_CACHE_VOLUME_DEBUG: "true"
4
+ BUILDKITE_PLUGIN_DOCKER_COMPOSE_SHELL: "false"
5
+ # BUILDKITE_PLUGIN_DOCKER_COMPOSE_UPLOAD_CONTAINER_LOGS: "always"
6
+ BUILDKITE_PLUGIN_DOCKER_COMPOSE_PULL_RETRIES: 5
7
+ BUILDKITE_PLUGIN_DOCKER_COMPOSE_PUSH_RETRIES: 5
8
+ PLUGIN_DOCKER_COMPOSE_VERSION: "17bac3aaee1360e39381b89bb45513b11838238e"
9
+ PLUGIN_DOCKER_CACHE_VERSION: "f3d8feb52a25c69c75565e9f0b80375eae51850a"
10
+
11
+ steps:
12
+ - label: ":docker: Build"
13
+ command: ./docker/ci-prep.sh
14
+ key: build
15
+ plugins:
16
+ - seek-oss/aws-sm#v2.2.1:
17
+ env:
18
+ DOCKER_LOGIN_PASSWORD: "/buildkite/docker_password"
19
+
20
+ - docker-login#v2.0.1:
21
+ username: outstandci
22
+
23
+ - ecr#v2.1.1:
24
+ login: true
25
+ region: "us-east-1"
26
+
27
+ - https://github.com/outstand/docker-compose-buildkite-plugin.git#${PLUGIN_DOCKER_COMPOSE_VERSION}:
28
+ build: metaractor
29
+ image-repository: 786715713882.dkr.ecr.us-east-1.amazonaws.com/ci-images
30
+ config:
31
+ - docker-compose.yml
32
+
33
+ - label: ":bundler: :rubygems:"
34
+ key: bundle_install
35
+ command: bundle install
36
+ depends_on: build
37
+ plugins:
38
+ - seek-oss/aws-sm#v2.2.1:
39
+ env:
40
+ DOCKER_LOGIN_PASSWORD: "/buildkite/docker_password"
41
+
42
+ - docker-login#v2.0.1:
43
+ username: outstandci
44
+
45
+ - ecr#v2.1.1:
46
+ login: true
47
+ region: "us-east-1"
48
+
49
+ - https://github.com/outstand/docker-compose-buildkite-plugin.git#${PLUGIN_DOCKER_COMPOSE_VERSION}:
50
+ run: metaractor
51
+ dependencies: false
52
+ config:
53
+ - docker-compose.yml
54
+
55
+ - https://github.com/outstand/docker-cache-buildkite-plugin.git#${PLUGIN_DOCKER_CACHE_VERSION}:
56
+ name: bundler-cache
57
+ keys:
58
+ - v1-bundler-cache-{{ arch }}-{{ checksum "metaractor.gemspec" }}-{{ checksum "Gemfile" }}
59
+ - v1-bundler-cache-{{ arch }}-
60
+ save: true
61
+ volumes:
62
+ - bundler-data
63
+
64
+ - label: ":ruby: Specs"
65
+ command: rspec spec
66
+ depends_on: bundle_install
67
+ plugins:
68
+ - seek-oss/aws-sm#v2.2.1:
69
+ env:
70
+ DOCKER_LOGIN_PASSWORD: "/buildkite/docker_password"
71
+ json-to-env:
72
+ - secret-id: "/buildkite/rails/env_vars"
73
+
74
+ - docker-login#v2.0.1:
75
+ username: outstandci
76
+
77
+ - ecr#v2.1.1:
78
+ login: true
79
+ region: "us-east-1"
80
+
81
+ - https://github.com/outstand/docker-compose-buildkite-plugin.git#${PLUGIN_DOCKER_COMPOSE_VERSION}:
82
+ run: metaractor
83
+ config:
84
+ - docker-compose.yml
85
+
86
+ - https://github.com/outstand/docker-cache-buildkite-plugin.git#${PLUGIN_DOCKER_CACHE_VERSION}:
87
+ name: bundler-cache
88
+ keys:
89
+ - v1-bundler-cache-{{ arch }}-{{ checksum "metaractor.gemspec" }}-{{ checksum "Gemfile" }}
90
+ - v1-bundler-cache-{{ arch }}-
91
+ volumes:
92
+ - bundler-data
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /Deskfile
data/.rspec CHANGED
@@ -1,2 +1,4 @@
1
1
  --color
2
2
  --require spec_helper
3
+ --format progress
4
+ --format RSpec::Buildkite::AnnotationFormatter
data/Dockerfile CHANGED
@@ -1,4 +1,6 @@
1
- FROM ruby:2.6.5-alpine
1
+ FROM outstand/fixuid as fixuid
2
+
3
+ FROM ruby:2.7.3-alpine
2
4
  LABEL maintainer="Ryan Schlesinger <ryan@outstand.com>"
3
5
 
4
6
  RUN addgroup -g 1000 -S metaractor && \
@@ -11,7 +13,14 @@ RUN addgroup -g 1000 -S metaractor && \
11
13
  git \
12
14
  openssh
13
15
 
14
- ENV BUNDLER_VERSION 2.1.4
16
+ COPY --from=fixuid /usr/local/bin/fixuid /usr/local/bin/fixuid
17
+ RUN chmod 4755 /usr/local/bin/fixuid && \
18
+ USER=metaractor && \
19
+ GROUP=metaractor && \
20
+ mkdir -p /etc/fixuid && \
21
+ printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml
22
+
23
+ ENV BUNDLER_VERSION 2.2.16
15
24
  RUN gem install bundler -v ${BUNDLER_VERSION} -i /usr/local/lib/ruby/gems/$(ls /usr/local/lib/ruby/gems) --force
16
25
 
17
26
  WORKDIR /metaractor
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
- gem 'pry-byebug'
5
- gem 'awesome_print'
4
+ gem 'rspec-buildkite', github: 'outstand/rspec-buildkite', branch: 'error-output'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Metaractor
1
+ # Metaractor [![Build status](https://badge.buildkite.com/70063a5154eb7366b8b7fd65a875c5f64301bc60f6d29a2ad7.svg)](https://buildkite.com/outstand/metaractor)
2
2
  Adds parameter validation and error control to [interactor](https://github.com/collectiveidea/interactor).
3
3
 
4
4
  ## Installation
@@ -103,6 +103,24 @@ This works with `allow_blank` and can also be anything that responds to `#call`.
103
103
  parameter :role, allow_blank: true, default: -> { context.default_role }
104
104
  ```
105
105
 
106
+ #### Typecasting/Coersion
107
+ You can supply Metaractor with a callable that will typecast incoming parameters:
108
+ ```ruby
109
+ optional :needs_to_be_a_string, type: ->(value) { value.to_s }
110
+ ```
111
+
112
+ You can also configure Metaractor with named types and use them:
113
+ ```ruby
114
+ Metaractor.configure do |config|
115
+ config.register_type(:boolean, ->(value) { ActiveModel::Type::Boolean.new.cast(value) })
116
+ end
117
+ ```
118
+ ```ruby
119
+ required :is_awesome, type: :boolean
120
+ ```
121
+
122
+ **Note**: Typecasters will _not_ be called on `nil` values.
123
+
106
124
  ### Custom Validation
107
125
  Metaractor supports doing custom validation before any user supplied before_hooks run.
108
126
  ```ruby
data/docker-compose.yml CHANGED
@@ -5,6 +5,9 @@ services:
5
5
  image: outstand/metaractor:dev
6
6
  stdin_open: true
7
7
  tty: true
8
+ environment:
9
+ FIXUID:
10
+ FIXGID:
8
11
  volumes:
9
12
  - bundler-data:/usr/local/bundle
10
13
  - .:/metaractor
@@ -13,6 +16,9 @@ services:
13
16
  stdin_open: true
14
17
  tty: true
15
18
  command: rake release
19
+ environment:
20
+ FIXUID:
21
+ FIXGID:
16
22
  volumes:
17
23
  - bundler-data:/usr/local/bundle
18
24
  - ~/.gitconfig:/home/metaractor/.gitconfig
data/docker-entrypoint.sh CHANGED
@@ -1,6 +1,19 @@
1
1
  #!/bin/sh
2
+
2
3
  set -e
3
4
 
5
+ su-exec ${FIXUID:?Missing FIXUID var}:${FIXGID:?Missing FIXGID var} fixuid
6
+
7
+ chown_dir() {
8
+ dir=$1
9
+ if [[ -d ${dir} ]] && [[ "$(stat -c %u:%g ${dir})" != "${FIXUID}:${FIXGID}" ]]; then
10
+ echo chown $dir
11
+ chown metaractor:metaractor $dir
12
+ fi
13
+ }
14
+
15
+ chown_dir /usr/local/bundle
16
+
4
17
  if [ "$(which "$1")" = '' ]; then
5
18
  if [ "$(ls -A /usr/local/bundle/bin)" = '' ]; then
6
19
  echo 'command not in path and bundler not initialized'
data/lib/metaractor.rb CHANGED
@@ -77,4 +77,16 @@ module Metaractor
77
77
  def self.hash_formatter=(callable)
78
78
  @hash_formatter = callable
79
79
  end
80
+
81
+ def self.types
82
+ @types ||= {}
83
+ end
84
+
85
+ def self.register_type(type, callable)
86
+ types[type] = callable
87
+ end
88
+
89
+ def self.clear_types!
90
+ @types = {}
91
+ end
80
92
  end
@@ -14,6 +14,7 @@ module Metaractor
14
14
  before :remove_blank_values
15
15
  before :apply_defaults
16
16
  before :validate_required_parameters
17
+ before :apply_types
17
18
  end
18
19
  end
19
20
 
@@ -160,6 +161,23 @@ module Metaractor
160
161
  end
161
162
  end
162
163
 
164
+ def apply_types
165
+ parameters.each do |name, parameter|
166
+ next unless parameter[:type]
167
+
168
+ if context.has_key?(name) && context[name] != nil
169
+ callable = parameter[:type]
170
+
171
+ if callable.is_a?(Symbol)
172
+ callable = Metaractor.types[callable]
173
+ raise ArgumentError, "No such type: #{parameter[:type]}" if callable.nil?
174
+ end
175
+
176
+ context[name] = callable.call(context[name])
177
+ end
178
+ end
179
+ end
180
+
163
181
  def validate_required_parameters
164
182
  context.errors ||= []
165
183
 
@@ -1,3 +1,3 @@
1
1
  module Metaractor
2
- VERSION = "3.0.1"
2
+ VERSION = "3.1.0"
3
3
  end
data/metaractor.gemspec CHANGED
@@ -11,7 +11,10 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['ryan@outstand.com']
12
12
 
13
13
  spec.summary = %q{Adds parameter validation and error control to interactor}
14
- spec.homepage = 'https://github.com/outstand/metaractor'
14
+ spec.metadata = {
15
+ "homepage_uri" => "https://github.com/outstand/metaractor",
16
+ "source_code_uri" => "https://github.com/outstand/metaractor"
17
+ }
15
18
 
16
19
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
20
  spec.bindir = 'exe'
@@ -27,4 +30,5 @@ Gem::Specification.new do |spec|
27
30
  spec.add_development_dependency 'rspec', '~> 3.9'
28
31
  spec.add_development_dependency 'awesome_print', '~> 1.8'
29
32
  spec.add_development_dependency 'pry-byebug', '~> 3.9'
33
+ spec.add_development_dependency 'activemodel', '~> 6.1'
30
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Schlesinger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-21 00:00:00.000000000 Z
11
+ date: 2021-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: interactor
@@ -122,13 +122,28 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.9'
125
- description:
125
+ - !ruby/object:Gem::Dependency
126
+ name: activemodel
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '6.1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '6.1'
139
+ description:
126
140
  email:
127
141
  - ryan@outstand.com
128
142
  executables: []
129
143
  extensions: []
130
144
  extra_rdoc_files: []
131
145
  files:
146
+ - ".buildkite/pipeline.yml"
132
147
  - ".gitignore"
133
148
  - ".rspec"
134
149
  - Dockerfile
@@ -153,11 +168,13 @@ files:
153
168
  - lib/metaractor/spec.rb
154
169
  - lib/metaractor/version.rb
155
170
  - metaractor.gemspec
156
- homepage: https://github.com/outstand/metaractor
171
+ homepage:
157
172
  licenses:
158
173
  - Apache-2.0
159
- metadata: {}
160
- post_install_message:
174
+ metadata:
175
+ homepage_uri: https://github.com/outstand/metaractor
176
+ source_code_uri: https://github.com/outstand/metaractor
177
+ post_install_message:
161
178
  rdoc_options: []
162
179
  require_paths:
163
180
  - lib
@@ -172,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
189
  - !ruby/object:Gem::Version
173
190
  version: '0'
174
191
  requirements: []
175
- rubygems_version: 3.0.3
176
- signing_key:
192
+ rubygems_version: 3.1.6
193
+ signing_key:
177
194
  specification_version: 4
178
195
  summary: Adds parameter validation and error control to interactor
179
196
  test_files: []