opera 0.1.0 → 0.2.2

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: a62cea42daf06dd2b7b751e109c25c4d04cec6f8a3369e96556e1474304962ae
4
- data.tar.gz: b5b698a1a6c55ef91198a7613fc0568e3f4b56f1ace013d7e0b1b2ec7dc54e2d
3
+ metadata.gz: 9a43643bc863d6fd8535fa08b7e55d1d0d3141dd35f24894a8ebbeca55989b25
4
+ data.tar.gz: 7fb3c80f08215391d687cde118d5cac0e88db838c771ea34c01a2a3c5ba004c5
5
5
  SHA512:
6
- metadata.gz: 38121aebabefe9c8bde3fdebfbd10f1e28a15c6c99962ae340746c23862729d78d3efb0c70ddac1a0148008416b6ebf677688c7c4caa2ac5bdba99f1f783e40c
7
- data.tar.gz: 164c6cc6915f9ed56fde54d25824cd3794636269df436143f45d6eee86d69e8419a9732b34670b4baae879014b91def0145f915e627dbbb239f029ebb34927fe
6
+ metadata.gz: 7470108eef670d9038412c4f6e86e4bc88f7b71189d299ebae99f71e61b7c1e09e530ed28ac9a8e55ee3cc2165d0354d25eea5d0bd95d804d994f239021019b1
7
+ data.tar.gz: d49010222f63b3e669e1d7070863cdcc216e5c19e63471fc672a650ab50e0c9df7e2550613d851363966854024b1c4902b1e8b0faf57cae8038e39028684e50b
@@ -0,0 +1,66 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby-version: [ '2.6', '2.7', '3.0' ]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
18
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
19
+ # uses: ruby/setup-ruby@v1
20
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: false # runs 'bundle install' and caches installed gems automatically
24
+ - name: Install gems
25
+ run: bundle install
26
+ - name: Run tests
27
+ run: bundle exec rspec
28
+
29
+ tag:
30
+ needs: test
31
+ runs-on: ubuntu-latest
32
+
33
+ steps:
34
+ - uses: actions/checkout@v2
35
+
36
+ - name: Tag automatically
37
+ run: git tag v`cat lib/opera/version.rb | grep 'VERSION' | awk '{ print $3 $4 }' | sed "s/'//g"`
38
+
39
+ - name: Push tags
40
+ run: git push origin --tags
41
+
42
+ publish:
43
+ needs: tag
44
+ name: Build + Publish
45
+ runs-on: ubuntu-latest
46
+ permissions:
47
+ contents: read
48
+ packages: write
49
+
50
+ steps:
51
+ - uses: actions/checkout@v2
52
+ - name: Set up Ruby 2.6
53
+ uses: actions/setup-ruby@v1
54
+ with:
55
+ ruby-version: 2.6.x
56
+
57
+ - name: Publish to RubyGems
58
+ run: |
59
+ mkdir -p $HOME/.gem
60
+ touch $HOME/.gem/credentials
61
+ chmod 0600 $HOME/.gem/credentials
62
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
63
+ gem build *.gemspec
64
+ gem push *.gem
65
+ env:
66
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,34 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Specs
9
+
10
+ on:
11
+ pull_request:
12
+ branches: []
13
+
14
+ jobs:
15
+ test:
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ matrix:
19
+ ruby-version: ['2.6', '2.7', '3.0']
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ bundler-cache: false # runs 'bundle install' and caches installed gems automatically
31
+ - name: Install gems
32
+ run: bundle install
33
+ - name: Run tests
34
+ run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -4,3 +4,10 @@
4
4
 
5
5
  - Initial release
6
6
 
7
+ ## 0.2.1 - July 7, 2021
8
+
9
+ - Support for transaction options
10
+
11
+ ## 0.2.2 - July 7, 2021
12
+
13
+ - Test release using Github Actions
data/Dockerfile ADDED
@@ -0,0 +1,20 @@
1
+ FROM ruby:3
2
+
3
+ MAINTAINER ProFinda Developers <dev@profinda.com>
4
+
5
+ ENV LANG C.UTF-8
6
+ ENV LC_ALL C.UTF-8
7
+
8
+ RUN apt-get update -y && \
9
+ apt-get install -y cmake \
10
+ build-essential
11
+
12
+ ENV APP_HOME /usr/src/app
13
+ RUN mkdir -p $APP_HOME
14
+ WORKDIR $APP_HOME
15
+
16
+ COPY . $APP_HOME
17
+
18
+ RUN bundle install -j 8
19
+
20
+ COPY . $APP_HOME
data/Gemfile CHANGED
@@ -8,4 +8,5 @@ gem 'rspec', '~> 3.0'
8
8
 
9
9
  group :test, :development do
10
10
  gem 'dry-validation'
11
+ gem 'pry-byebug', require: false
11
12
  end
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opera (0.1.0)
4
+ opera (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ byebug (11.1.3)
10
+ coderay (1.1.3)
9
11
  concurrent-ruby (1.1.7)
10
12
  diff-lcs (1.4.4)
11
13
  dry-configurable (0.11.6)
@@ -15,28 +17,44 @@ GEM
15
17
  dry-container (0.7.2)
16
18
  concurrent-ruby (~> 1.0)
17
19
  dry-configurable (~> 0.1, >= 0.1.3)
18
- dry-core (0.4.9)
20
+ dry-core (0.5.0)
19
21
  concurrent-ruby (~> 1.0)
20
22
  dry-equalizer (0.3.0)
21
23
  dry-inflector (0.2.0)
22
- dry-logic (0.6.1)
24
+ dry-initializer (3.0.4)
25
+ dry-logic (1.0.8)
23
26
  concurrent-ruby (~> 1.0)
24
27
  dry-core (~> 0.2)
25
28
  dry-equalizer (~> 0.2)
26
- dry-types (0.14.0)
29
+ dry-schema (1.5.6)
30
+ concurrent-ruby (~> 1.0)
31
+ dry-configurable (~> 0.8, >= 0.8.3)
32
+ dry-core (~> 0.4)
33
+ dry-equalizer (~> 0.2)
34
+ dry-initializer (~> 3.0)
35
+ dry-logic (~> 1.0)
36
+ dry-types (~> 1.4)
37
+ dry-types (1.4.0)
27
38
  concurrent-ruby (~> 1.0)
28
39
  dry-container (~> 0.3)
29
40
  dry-core (~> 0.4, >= 0.4.4)
30
- dry-equalizer (~> 0.2)
41
+ dry-equalizer (~> 0.3)
31
42
  dry-inflector (~> 0.1, >= 0.1.2)
32
- dry-logic (~> 0.5, >= 0.5)
33
- dry-validation (0.13.0)
43
+ dry-logic (~> 1.0, >= 1.0.2)
44
+ dry-validation (1.6.0)
34
45
  concurrent-ruby (~> 1.0)
35
- dry-configurable (~> 0.1, >= 0.1.3)
36
- dry-core (~> 0.2, >= 0.2.1)
46
+ dry-container (~> 0.7, >= 0.7.1)
47
+ dry-core (~> 0.4)
37
48
  dry-equalizer (~> 0.2)
38
- dry-logic (~> 0.5, >= 0.5.0)
39
- dry-types (~> 0.14, >= 0.14)
49
+ dry-initializer (~> 3.0)
50
+ dry-schema (~> 1.5, >= 1.5.2)
51
+ method_source (1.0.0)
52
+ pry (0.13.1)
53
+ coderay (~> 1.1)
54
+ method_source (~> 1.0)
55
+ pry-byebug (3.9.0)
56
+ byebug (~> 11.0)
57
+ pry (~> 0.13.0)
40
58
  rake (12.3.3)
41
59
  rspec (3.9.0)
42
60
  rspec-core (~> 3.9.0)
@@ -58,6 +76,7 @@ PLATFORMS
58
76
  DEPENDENCIES
59
77
  dry-validation
60
78
  opera!
79
+ pry-byebug
61
80
  rake (~> 12.0)
62
81
  rspec (~> 3.0)
63
82
 
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Opera
2
2
 
3
+ ![Master](https://github.com/Profinda/opera/actions/workflows/release.yml/badge.svg?branch=master)
4
+
5
+
3
6
  Simple DSL for services/interactions classes.
4
7
 
5
8
  Opera was born to mimic some of the philosophy of the dry gems but keeping the DSL simple.
@@ -31,7 +34,8 @@ Simply initialise the configuration and chose what method you want to use to rep
31
34
  Opera::Operation::Config.configure do |config|
32
35
  config.transaction_class = ActiveRecord::Base
33
36
  config.transaction_method = :transaction
34
- config.reporter = if defined?(Rollbar) then Rollbar else Rails.logger
37
+ config.transaction_options = { requires_new: true }
38
+ config.reporter = defined?(Rollbar) ? Rollbar : Rails.logger
35
39
  end
36
40
  ```
37
41
 
@@ -0,0 +1,7 @@
1
+ version: '3.1'
2
+
3
+ services:
4
+ app:
5
+ build: .
6
+ volumes:
7
+ - .:/usr/src/app
@@ -3,11 +3,12 @@
3
3
  module Opera
4
4
  module Operation
5
5
  class Config
6
- attr_accessor :transaction_class, :transaction_method, :reporter
6
+ attr_accessor :transaction_class, :transaction_method, :transaction_options, :reporter
7
7
 
8
8
  def initialize
9
9
  @transaction_class = self.class.transaction_class
10
10
  @transaction_method = self.class.transaction_method || :transaction
11
+ @transaction_options = self.class.transaction_options
11
12
  @reporter = custom_reporter || self.class.reporter
12
13
  end
13
14
 
@@ -20,7 +21,7 @@ module Opera
20
21
  end
21
22
 
22
23
  class << self
23
- attr_accessor :transaction_class, :transaction_method, :reporter
24
+ attr_accessor :transaction_class, :transaction_method, :transaction_options, :reporter
24
25
 
25
26
  def configure
26
27
  yield self
@@ -8,6 +8,7 @@ module Opera
8
8
  def call(instruction)
9
9
  instruction[:kind] = :step
10
10
  operation_result = super
11
+ save_information(operation_result)
11
12
 
12
13
  if operation_result.success?
13
14
  add_instruction_output(instruction, operation_result.output)
@@ -18,6 +19,14 @@ module Opera
18
19
  result.add_exceptions(operation_result.exceptions)
19
20
  end
20
21
  end
22
+
23
+ private
24
+
25
+ def save_information(operation_result)
26
+ return unless operation_result.respond_to?(:information)
27
+
28
+ result.add_information(operation_result.information)
29
+ end
21
30
  end
22
31
  end
23
32
  end
@@ -8,7 +8,8 @@ module Opera
8
8
  class RollbackTransactionError < Opera::Error; end
9
9
 
10
10
  def call(instruction)
11
- transaction_class.send(transaction_method) do
11
+ arguments = transaction_options ? [transaction_method, transaction_options] : [transaction_method]
12
+ transaction_class.send(*arguments) do
12
13
  super
13
14
 
14
15
  return if !operation.finished? && result.success?
@@ -26,6 +27,10 @@ module Opera
26
27
  def transaction_method
27
28
  config.transaction_method
28
29
  end
30
+
31
+ def transaction_options
32
+ config.transaction_options
33
+ end
29
34
  end
30
35
  end
31
36
  end
@@ -14,7 +14,8 @@ module Opera
14
14
  def evaluate_instruction(instruction)
15
15
  instruction[:kind] = :step
16
16
  dry_result = super
17
- add_instruction_output(instruction, dry_result.output)
17
+
18
+ add_instruction_output(instruction, dry_result.to_h)
18
19
  result.add_errors(dry_result.errors) unless dry_result.success?
19
20
  end
20
21
  end
@@ -10,6 +10,8 @@ module Opera
10
10
 
11
11
  attr_accessor :output # Final object returned if success?
12
12
 
13
+ alias to_h output
14
+
13
15
  def initialize(output: nil, errors: {})
14
16
  @errors = errors
15
17
  @exceptions = {}
@@ -43,7 +45,7 @@ module Opera
43
45
  # rubocop:enable Metrics/MethodLength
44
46
 
45
47
  def add_errors(errors)
46
- errors.each_pair do |key, value|
48
+ errors.to_h.each_pair do |key, value|
47
49
  add_error(key, value)
48
50
  end
49
51
  end
data/lib/opera/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Opera
2
- VERSION = "0.1.0"
2
+ VERSION = '0.2.2'
3
3
  end
data/opera.gemspec CHANGED
@@ -4,16 +4,16 @@ Gem::Specification.new do |spec|
4
4
  spec.name = 'opera'
5
5
  spec.version = Opera::VERSION
6
6
  spec.authors = ['ProFinda Development Team']
7
- spec.email = ['francisco.ruiz@profinda.com']
7
+ spec.email = ['dev@profinda.com']
8
8
 
9
9
  spec.summary = 'Use simple DSL language to keep your Operations clean and maintainable'
10
10
  spec.homepage = 'https://github.com/Profinda/opera'
11
11
  spec.license = 'MIT'
12
12
  spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
13
13
 
14
- spec.metadata["homepage_uri"] = spec.homepage
15
- spec.metadata["source_code_uri"] = spec.homepage
16
- spec.metadata["changelog_uri"] = 'https://github.com/Profinda/opera/blob/master/CHANGELOG.md'
14
+ spec.metadata['homepage_uri'] = spec.homepage
15
+ spec.metadata['source_code_uri'] = spec.homepage
16
+ spec.metadata['changelog_uri'] = 'https://github.com/Profinda/opera/blob/master/CHANGELOG.md'
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -24,5 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_development_dependency 'dry-validation'
27
+ spec.add_development_dependency 'dry-validation', '>= 1.0'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec'
28
30
  end
metadata CHANGED
@@ -1,17 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ProFinda Development Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-12 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-validation
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
45
  - - ">="
@@ -24,18 +52,21 @@ dependencies:
24
52
  - - ">="
25
53
  - !ruby/object:Gem::Version
26
54
  version: '0'
27
- description:
55
+ description:
28
56
  email:
29
- - francisco.ruiz@profinda.com
57
+ - dev@profinda.com
30
58
  executables: []
31
59
  extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
62
+ - ".github/workflows/release.yml"
63
+ - ".github/workflows/specs.yml"
34
64
  - ".gitignore"
35
65
  - ".rspec"
36
66
  - ".travis.yml"
37
67
  - CHANGELOG.md
38
68
  - CODE_OF_CONDUCT.md
69
+ - Dockerfile
39
70
  - Gemfile
40
71
  - Gemfile.lock
41
72
  - LICENSE.txt
@@ -43,6 +74,7 @@ files:
43
74
  - Rakefile
44
75
  - bin/console
45
76
  - bin/setup
77
+ - docker-compose.yml
46
78
  - lib/opera.rb
47
79
  - lib/opera/errors.rb
48
80
  - lib/opera/operation.rb
@@ -68,7 +100,7 @@ metadata:
68
100
  homepage_uri: https://github.com/Profinda/opera
69
101
  source_code_uri: https://github.com/Profinda/opera
70
102
  changelog_uri: https://github.com/Profinda/opera/blob/master/CHANGELOG.md
71
- post_install_message:
103
+ post_install_message:
72
104
  rdoc_options: []
73
105
  require_paths:
74
106
  - lib
@@ -83,8 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
115
  - !ruby/object:Gem::Version
84
116
  version: '0'
85
117
  requirements: []
86
- rubygems_version: 3.1.2
87
- signing_key:
118
+ rubygems_version: 3.0.3.1
119
+ signing_key:
88
120
  specification_version: 4
89
121
  summary: Use simple DSL language to keep your Operations clean and maintainable
90
122
  test_files: []