u-case 4.5.1 → 4.5.2

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: b3b6d430bc2e38d5c9e26b06ad06dc506e24616acc19cc788c6fefbdec4e8060
4
- data.tar.gz: 1deb14177315c48126e01c52c24a8aea1371de5d09f6d442ce3c257971bb0fe3
3
+ metadata.gz: e548c5eca296db7c02caeba9bd5a05962959f68dd4a7024518c3ec00c1349cc7
4
+ data.tar.gz: c02d785e60c995a6f088df9ff1b33e16c73deaa4a3c4c727410140eb198b1a7b
5
5
  SHA512:
6
- metadata.gz: fe8e553554fa2f664869ad481e545a12ba231027877de8099d074e64b57ac18a5573559772a34049ccbb1389054cf285a35e5bf53479cb583297fc673746645b
7
- data.tar.gz: 492b4489377c918a5347ff205edd5babb3bb9ca6c8df7efb6fb2244626a2025d895b44a39e3ecd97c6a8fa01aa145f4d49948bc43f07958293188a0226598e61
6
+ metadata.gz: b1319dcfd0e2139a21b7d38831d0920a17a8fa4fbe0824f19e6f2245e007dbd7546b49e2aad70bded0c118f502e80e303ce69fee36ea10ada746ee71ffa8f021
7
+ data.tar.gz: 9ba626fd38078d07179f1b7e261a4a26bb0a8eee565b2a5a013b50778206c4bbfcb34cf34231df1dc3c3b99c994745e23a78dc64d1c37c7ad444cf5725645906
@@ -0,0 +1,27 @@
1
+
2
+ name: build
3
+ on: [push, pull_request]
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 3.0, 3.1]
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: ${{ matrix.ruby }}
15
+ bundler-cache: true
16
+ - name: Test and generate coverage
17
+ run: bin/test
18
+ - name: Format coverage
19
+ if: ${{ matrix.ruby >= 3 }}
20
+ run: bin/prepare_coverage
21
+ - uses: paambaati/codeclimate-action@v2.7.5
22
+ if: ${{ matrix.ruby >= 3 }}
23
+ env:
24
+ CC_TEST_REPORTER_ID: 0377ece62be9c7042557d76e4e38b867e51c51b2a42d10ef5102b613ac077eab
25
+ with:
26
+ debug: true
27
+ coverageLocations: coverage/.resultset.json:simplecov
@@ -0,0 +1,8 @@
1
+ {
2
+ "cSpell.enabled": true,
3
+ "cSpell.ignoreWords": [
4
+ "paambaati",
5
+ "resultset",
6
+ "simplecov"
7
+ ]
8
+ }
data/Gemfile CHANGED
@@ -4,23 +4,24 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  activerecord_version = ENV.fetch('ACTIVERECORD_VERSION', '7')
6
6
 
7
- activerecord = case activerecord_version
8
- when '3.2' then '3.2.22'
9
- when '4.0' then '4.0.13'
10
- when '4.1' then '4.1.16'
11
- when '4.2' then '4.2.11'
12
- when '5.0' then '5.0.7'
13
- when '5.1' then '5.1.7'
14
- when '5.2' then '5.2.4'
15
- when '6.0' then '6.0.3.4'
16
- when '6.1' then '6.1.2'
17
- end
7
+ activerecord =
8
+ case activerecord_version
9
+ when '3.2' then '3.2.22'
10
+ when '4.0' then '4.0.13'
11
+ when '4.1' then '4.1.16'
12
+ when '4.2' then '4.2.11'
13
+ when '5.0' then '5.0.7'
14
+ when '5.1' then '5.1.7'
15
+ when '5.2' then '5.2.4'
16
+ when '6.0' then '6.0.3.4'
17
+ when '6.1' then '6.1.2'
18
+ end
18
19
 
19
20
  simplecov_version =
20
21
  case RUBY_VERSION
21
22
  when /\A2.[23]/ then '~> 0.17.1'
22
23
  when /\A2.4/ then '~> 0.18.5'
23
- else '~> 0.19'
24
+ else '~> 0.21.2'
24
25
  end
25
26
 
26
27
  group :test do
data/README.md CHANGED
@@ -12,8 +12,8 @@
12
12
  <img alt="Gem" src="https://img.shields.io/gem/v/u-case.svg?style=flat-square">
13
13
  </a>
14
14
 
15
- <a href="https://travis-ci.com/serradura/u-case">
16
- <img alt="Build Status" src="https://travis-ci.com/serradura/u-case.svg?branch=main">
15
+ <a href="https://github.com/serradura/u-case/actions/workflows/ci.yml">
16
+ <img alt="Build Status" src="https://github.com/serradura/u-case/actions/workflows/ci.yml/badge.svg">
17
17
  </a>
18
18
 
19
19
  <a href="https://codeclimate.com/github/serradura/u-case/maintainability">
data/README.pt-BR.md CHANGED
@@ -12,8 +12,8 @@
12
12
  <img alt="Gem" src="https://img.shields.io/gem/v/u-case.svg?style=flat-square">
13
13
  </a>
14
14
 
15
- <a href="https://travis-ci.com/serradura/u-case">
16
- <img alt="Build Status" src="https://travis-ci.com/serradura/u-case.svg?branch=main">
15
+ <a href="https://github.com/serradura/u-case/actions/workflows/ci.yml">
16
+ <img alt="Build Status" src="https://github.com/serradura/u-case/actions/workflows/ci.yml/badge.svg">
17
17
  </a>
18
18
 
19
19
  <a href="https://codeclimate.com/github/serradura/u-case/maintainability">
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ # Borrowed from https://gist.github.com/qortex/7e7c49f3731391a91ee898336183acef
4
+
5
+ # Temporary hack to get CodeClimate to work with SimpleCov 0.18 JSON format until issue is fixed
6
+ # upstream: https://github.com/codeclimate/test-reporter/issues/413
7
+
8
+ require "json"
9
+
10
+ filename = "coverage/.resultset.json"
11
+ contents = JSON.parse(File.read(filename))
12
+
13
+ def remove_lines_key(obj)
14
+ case obj
15
+ when Hash
16
+ obj.transform_values do |val|
17
+ val.is_a?(Hash) && val.key?("lines") ? val["lines"] : remove_lines_key(val)
18
+ end
19
+ else
20
+ obj
21
+ end
22
+ end
23
+
24
+ # overwrite
25
+ File.write(filename, JSON.generate(remove_lines_key(contents)))
26
+
27
+ puts Dir['coverage/.*.json']
data/bin/test ADDED
@@ -0,0 +1,53 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ RUBY_V=$(ruby -v)
6
+
7
+ function reset_gemfile_and_test {
8
+ rm Gemfile.lock
9
+
10
+ eval "$1 bundle update"
11
+ eval "$1 ENABLE_TRANSITIONS=true bundle exec rake test"
12
+ eval "$1 ENABLE_TRANSITIONS=false bundle exec rake test"
13
+ }
14
+
15
+ function test_with_activerecord {
16
+ reset_gemfile_and_test "ACTIVERECORD_VERSION=$1"
17
+ }
18
+
19
+ RUBY_2_2345="ruby 2.[2345]."
20
+ RUBY_2_234="ruby 2.[234]."
21
+ RUBY_2_567="ruby 2.[567]."
22
+ RUBY_2_23="ruby 2.[23]."
23
+ RUBY_2_2="ruby 2.2."
24
+ RUBY_3_01="ruby 3.[01]."
25
+
26
+ if [[ $RUBY_V =~ $RUBY_2_2345 ]]; then
27
+ if [[ $RUBY_V =~ $RUBY_2_234 ]]; then
28
+ reset_gemfile_and_test
29
+ fi
30
+
31
+ if [[ $RUBY_V =~ $RUBY_2_2 ]]; then
32
+ test_with_activerecord "3.2"
33
+ fi
34
+
35
+ if [[ $RUBY_V =~ $RUBY_2_23 ]]; then
36
+ test_with_activerecord "4.0"
37
+ test_with_activerecord "4.1"
38
+ test_with_activerecord "4.2"
39
+ fi
40
+
41
+ test_with_activerecord "5.0"
42
+ test_with_activerecord "5.1"
43
+ test_with_activerecord "5.2"
44
+ fi
45
+
46
+ if [[ $RUBY_V =~ $RUBY_2_567 ]] || [[ $RUBY_V =~ $RUBY_3_01 ]]; then
47
+ gem install bundler -v ">= 2" --no-doc
48
+
49
+ reset_gemfile_and_test
50
+
51
+ test_with_activerecord "6.0"
52
+ test_with_activerecord "6.1"
53
+ fi
@@ -3,12 +3,12 @@
3
3
  module Micro::Case::Utils
4
4
 
5
5
  module Hashes
6
- def self.respond_to?(hash, method)
6
+ def self.hash_respond_to?(hash, method)
7
7
  Kind::Hash[hash].respond_to?(method)
8
8
  end
9
9
 
10
10
  def self.symbolize_keys(hash)
11
- return hash.transform_keys { |key| key.to_sym rescue key } if respond_to?(hash, :transform_keys)
11
+ return hash.transform_keys { |key| key.to_sym rescue key } if hash_respond_to?(hash, :transform_keys)
12
12
 
13
13
  hash.each_with_object({}) do |(k, v), memo|
14
14
  key = k.to_sym rescue k
@@ -17,13 +17,13 @@ module Micro::Case::Utils
17
17
  end
18
18
 
19
19
  def self.stringify_keys(hash)
20
- return hash.transform_keys(&:to_s) if respond_to?(hash, :transform_keys)
20
+ return hash.transform_keys(&:to_s) if hash_respond_to?(hash, :transform_keys)
21
21
 
22
22
  hash.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v }
23
23
  end
24
24
 
25
25
  def self.slice(hash, keys)
26
- return hash.slice(*keys) if respond_to?(hash, :slice)
26
+ return hash.slice(*keys) if hash_respond_to?(hash, :slice)
27
27
 
28
28
  hash.select { |key, _value| keys.include?(key) }
29
29
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  class Case
5
- VERSION = '4.5.1'.freeze
5
+ VERSION = '4.5.2'.freeze
6
6
  end
7
7
  end
data/lib/micro/case.rb CHANGED
@@ -117,7 +117,7 @@ module Micro
117
117
  def self.__call__!
118
118
  return const_get(FLOW_STEP) if const_defined?(FLOW_STEP, false)
119
119
 
120
- class_eval("class #{FLOW_STEP} < #{self.name}; private def __call; __call_use_case; end; end")
120
+ class_eval("class #{FLOW_STEP} < #{self.name}; private def __call; __call_use_case; end; end; #{FLOW_STEP}")
121
121
  end
122
122
 
123
123
  private_class_method def self.__flow_use_cases
@@ -21,9 +21,11 @@ module Micro
21
21
 
22
22
  GetUseCaseResult = -> (hash) do
23
23
  -> (use_case) do
24
- return use_case.call(hash) unless use_case.is_a?(Array)
25
-
26
- use_case[0].call(hash.merge(use_case[1]))
24
+ if use_case.is_a?(Array)
25
+ use_case[0].call(hash.merge(use_case[1]))
26
+ else
27
+ use_case.call(hash)
28
+ end
27
29
  end
28
30
  end
29
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-case
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.1
4
+ version: 4.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kind
@@ -86,10 +86,10 @@ executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
88
88
  files:
89
+ - ".github/workflows/ci.yml"
89
90
  - ".gitignore"
90
91
  - ".tool-versions"
91
- - ".travis.sh"
92
- - ".travis.yml"
92
+ - ".vscode/settings.json"
93
93
  - CODE_OF_CONDUCT.md
94
94
  - Gemfile
95
95
  - LICENSE.txt
@@ -97,7 +97,9 @@ files:
97
97
  - README.pt-BR.md
98
98
  - Rakefile
99
99
  - bin/console
100
+ - bin/prepare_coverage
100
101
  - bin/setup
102
+ - bin/test
101
103
  - lib/micro/case.rb
102
104
  - lib/micro/case/config.rb
103
105
  - lib/micro/case/error.rb
@@ -117,13 +119,12 @@ files:
117
119
  - lib/micro/cases/utils.rb
118
120
  - lib/u-case.rb
119
121
  - lib/u-case/with_activemodel_validation.rb
120
- - test.sh
121
122
  - u-case.gemspec
122
123
  homepage: https://github.com/serradura/u-case
123
124
  licenses:
124
125
  - MIT
125
126
  metadata: {}
126
- post_install_message:
127
+ post_install_message:
127
128
  rdoc_options: []
128
129
  require_paths:
129
130
  - lib
@@ -138,8 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubygems_version: 3.0.6
142
- signing_key:
142
+ rubygems_version: 3.3.22
143
+ signing_key:
143
144
  specification_version: 4
144
145
  summary: Represent use cases in a simple and powerful way while writing modular, expressive
145
146
  and sequentially logical code.
data/.travis.sh DELETED
@@ -1,46 +0,0 @@
1
- #!/bin/bash
2
-
3
- RUBY_V=$(ruby -v)
4
-
5
- function run_with_bundler {
6
- rm Gemfile.lock
7
-
8
- if [ ! -z "$1" ]; then
9
- bundle_cmd="bundle _$1_"
10
- else
11
- bundle_cmd="bundle"
12
- fi
13
-
14
- eval "$2 $bundle_cmd update"
15
- eval "$2 ENABLE_TRANSITIONS=true $bundle_cmd exec rake test"
16
- eval "$2 ENABLE_TRANSITIONS=false $bundle_cmd exec rake test"
17
- }
18
-
19
- function run_with_ar_version_and_bundler {
20
- run_with_bundler "$2" "ACTIVERECORD_VERSION=$1"
21
- }
22
-
23
- RUBY_2_2345="ruby 2.[2345]."
24
-
25
- if [[ $RUBY_V =~ $RUBY_2_2345 ]]; then
26
- run_with_bundler "$BUNDLER_V1"
27
-
28
- run_with_ar_version_and_bundler "3.2" "$BUNDLER_V1"
29
- run_with_ar_version_and_bundler "4.0" "$BUNDLER_V1"
30
- run_with_ar_version_and_bundler "4.1" "$BUNDLER_V1"
31
- run_with_ar_version_and_bundler "4.2" "$BUNDLER_V1"
32
- run_with_ar_version_and_bundler "5.0" "$BUNDLER_V1"
33
- run_with_ar_version_and_bundler "5.1" "$BUNDLER_V1"
34
- run_with_ar_version_and_bundler "5.2" "$BUNDLER_V1"
35
- fi
36
-
37
- RUBY_2_567="ruby 2.[567]."
38
- RUBY_3_x_x="ruby 3.0."
39
-
40
- if [[ $RUBY_V =~ $RUBY_2_567 ]] || [[ $RUBY_V =~ $RUBY_3_x_x ]]; then
41
- gem install bundler -v ">= 2" --no-doc
42
-
43
- run_with_bundler
44
- run_with_ar_version_and_bundler "6.0"
45
- run_with_ar_version_and_bundler "6.1"
46
- fi
data/.travis.yml DELETED
@@ -1,33 +0,0 @@
1
- language: ruby
2
-
3
- cache:
4
- bundler: true
5
- directories:
6
- - /home/travis/.rvm/
7
-
8
- rvm:
9
- - 2.2.2
10
- - 2.3.0
11
- - 2.4.0
12
- - 2.5.0
13
- - 2.6.0
14
- - 2.7.0
15
- - 3.0.0
16
-
17
- env:
18
- - BUNDLER_V1="1.17.3"
19
-
20
- before_install:
21
- - gem install bundler -v "$BUNDLER_V1"
22
-
23
- install: bundle install --jobs=3 --retry=3
24
-
25
- before_script:
26
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
27
- - chmod +x ./cc-test-reporter
28
- - "./cc-test-reporter before-build"
29
-
30
- script: "./.travis.sh"
31
-
32
- after_success:
33
- - "./cc-test-reporter after-build -t simplecov"
data/test.sh DELETED
@@ -1,11 +0,0 @@
1
- #!/bin/bash
2
-
3
- bundle
4
-
5
- rm Gemfile.lock
6
-
7
- source $(dirname $0)/.travis.sh
8
-
9
- rm Gemfile.lock
10
-
11
- bundle