finapps_core 5.0.7 → 5.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/release-drafter.yml +49 -0
  3. data/.github/workflows/main.yaml +37 -0
  4. data/.github/workflows/release-drafter.yml +15 -0
  5. data/.github/workflows/release.yml +54 -0
  6. data/.github/workflows/verify-pr-labeled.yml +14 -0
  7. data/.rubocop.yml +123 -73
  8. data/.ruby-version +1 -1
  9. data/.tmuxinator.yml +20 -0
  10. data/.travis.yml +5 -6
  11. data/finapps_core.gemspec +11 -11
  12. data/lib/finapps_core.rb +1 -0
  13. data/lib/finapps_core/middleware/middleware.rb +6 -3
  14. data/lib/finapps_core/middleware/request/accept_json.rb +2 -1
  15. data/lib/finapps_core/middleware/request/x_tenant_id.rb +20 -0
  16. data/lib/finapps_core/middleware/response/raise_error.rb +36 -7
  17. data/lib/finapps_core/rest/base_client.rb +20 -32
  18. data/lib/finapps_core/rest/configuration.rb +18 -5
  19. data/lib/finapps_core/rest/connection.rb +32 -22
  20. data/lib/finapps_core/rest/defaults.rb +1 -1
  21. data/lib/finapps_core/utils/loggeable.rb +1 -1
  22. data/lib/finapps_core/utils/validatable.rb +1 -1
  23. data/lib/finapps_core/version.rb +1 -1
  24. data/spec/core_extensions/object/is_integer_spec.rb +6 -7
  25. data/spec/middleware/request/accept_json_spec.rb +7 -3
  26. data/spec/middleware/request/no_encoding_basic_authentication_spec.rb +15 -6
  27. data/spec/middleware/request/request_id_spec.rb +4 -4
  28. data/spec/middleware/request/tenant_authentication_spec.rb +21 -14
  29. data/spec/middleware/request/user_agent_spec.rb +8 -3
  30. data/spec/middleware/request/x_consumer_id_spec.rb +4 -4
  31. data/spec/middleware/request/x_tenant_id_spec.rb +16 -0
  32. data/spec/middleware/response/raise_error_spec.rb +47 -15
  33. data/spec/rest/base_client_spec.rb +87 -43
  34. data/spec/rest/configuration_spec.rb +25 -18
  35. data/spec/rest/credentials_spec.rb +4 -4
  36. data/spec/rest/defaults_spec.rb +1 -1
  37. data/spec/rest/resources_spec.rb +10 -20
  38. data/spec/spec_helper.rb +3 -3
  39. data/spec/support/fake_api.rb +1 -1
  40. data/spec/utils/validatable_spec.rb +9 -8
  41. metadata +78 -69
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7da6746a9d41a5a653232294b795c91e9a12b5c6879e3fcd3cef0ae199c7856
4
- data.tar.gz: e6cd9df962d35834b073dea681bc56c4a0283130e535dd9e38e03b0431febc76
3
+ metadata.gz: '048fa78b23468e14dd5756a875178f323687de38537d46db6b0f7da842bbf375'
4
+ data.tar.gz: fe171551416bfc98902f958cae69220f4923f6e9b0445883689a3d4edff73c08
5
5
  SHA512:
6
- metadata.gz: c0adf1096463f145ced38476aed16b78a9e1db262881614e727e74eb6a015fc80fae7a6c15a4452e3bc16de47b3536379caeb19b63da86980da890971885c720
7
- data.tar.gz: d856c0cd51760de8fb94e2b1907acfe594c3bfb8b8afc54f1bf8447c8759b60ecbaedbfae9c533d46d5eacf7af14c088bc9ca0fdd81166e8ffeed19a9c025370
6
+ metadata.gz: 947a8a2ee8caff1d0de36924480926db3c12e4dc76d3904735929265f3a981e98062695dfbd54dfebdde462fd8a6244086a86f5a3e2d2877d52ee3cc4187a3c3
7
+ data.tar.gz: c5b3d107db58545e5eafadf8ab09c87e834af608ba8294ae857cb15abb16eb6ec3079eff290cb8f04322c7a3b66bdf4fad0ecf6d2a81af57d0dcc9727feacebf
@@ -0,0 +1,49 @@
1
+ name-template: 'version $RESOLVED_VERSION'
2
+ tag-template: 'v$RESOLVED_VERSION'
3
+ categories:
4
+ - title: 'Added'
5
+ labels: 'enhancement'
6
+ - title: 'Changed'
7
+ labels: 'change'
8
+ - title: 'Deprecated'
9
+ labels: 'deprecated'
10
+ - title: 'Removed'
11
+ labels: 'removed'
12
+ - title: 'Fixed'
13
+ labels: 'bug'
14
+ - title: 'Security'
15
+ label: 'dependencies'
16
+ - title: 'Documentation updates'
17
+ label: 'documentation'
18
+ - title: 'Maintenance'
19
+ labels: 'internal'
20
+
21
+ change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
22
+
23
+ version-resolver:
24
+ major:
25
+ labels:
26
+ - 'major'
27
+ minor:
28
+ labels:
29
+ - 'minor'
30
+ patch:
31
+ labels:
32
+ - 'patch'
33
+ default: patch
34
+
35
+ exclude-labels:
36
+ - reverted
37
+ - no-changelog
38
+ - skip-changelog
39
+ - invalid
40
+
41
+ template: |
42
+ ## [$RESOLVED_VERSION](https://github.com/finapps/ruby-client-core/compare/$PREVIOUS_TAG...$RESOLVED_VERSION)
43
+ $CHANGES
44
+
45
+ replacers:
46
+ - search: '/CVE-(\d{4})-(\d+)/g'
47
+ replace: 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-$1-$2'
48
+ - search: '@dependabot-preview'
49
+ replace: '@dependabot'
@@ -0,0 +1,37 @@
1
+ name: Continuous Integration
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ ci:
7
+ if: "!contains(github.event.head_commit.message, 'skip ci')"
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ fail-fast: true
12
+
13
+ steps:
14
+ - name: Checkout source code
15
+ uses: actions/checkout@v2
16
+
17
+ - name: Install required ruby version
18
+ uses: ruby/setup-ruby@v1
19
+
20
+ - uses: actions/cache@v2
21
+ with:
22
+ path: vendor/bundle
23
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
24
+ restore-keys: |
25
+ ${{ runner.os }}-gems-
26
+
27
+ - name: Install gems
28
+ run: |
29
+ gem install -N bundler
30
+ bundle config path vendor/bundle
31
+ bundle install --jobs 4 --retry 3
32
+
33
+ - name: Run rubocop
34
+ run: bundle exec rubocop
35
+
36
+ - name: Run tests
37
+ run: bundle exec rspec
@@ -0,0 +1,15 @@
1
+ name: Release Drafter
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ update_release_draft:
10
+ if: "!contains(github.event.head_commit.message, 'skip ci')"
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: release-drafter/release-drafter@v5
14
+ env:
15
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,54 @@
1
+ name: Bump version and Release
2
+ on:
3
+ release:
4
+ types: [published]
5
+
6
+ jobs:
7
+ release:
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ fail-fast: true
11
+
12
+ steps:
13
+ - name: Checkout source code
14
+ uses: actions/checkout@v2
15
+ with:
16
+ persist-credentials: false
17
+ fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
18
+
19
+ - name: Install required ruby version
20
+ uses: ruby/setup-ruby@v1
21
+
22
+ - name: Get version from latest tag
23
+ id: get_version
24
+ uses: battila7/get-version-action@v2
25
+
26
+ - name: Bump version
27
+ run: |
28
+ gem install -N gem-release
29
+ git config --local user.email "action@github.com"
30
+ git config --local user.name "GitHub Action"
31
+ gem bump --skip-ci --version ${{ steps.get_version.outputs.version-without-v }}
32
+
33
+ - name: Push changes
34
+ uses: ad-m/github-push-action@master
35
+ with:
36
+ # GitHub Actions token does not support pushing to protected branches.
37
+ # github_token: ${{ secrets.GITHUB_TOKEN }}
38
+ #
39
+ # A manually populated`PERSONAL_ACCESS_TOKEN` environment variable
40
+ # with permissions to push to a protected branch must be used.
41
+ # not ideal - keep eyes open for a better solution
42
+ github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
43
+
44
+ - name: Release gem to rubygems.org
45
+ run: |
46
+ set +x
47
+ mkdir -p ~/.gem
48
+ cat << EOF > ~/.gem/credentials
49
+ ---
50
+ :rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
51
+ EOF
52
+ chmod 0600 ~/.gem/credentials
53
+ set -x
54
+ gem release
@@ -0,0 +1,14 @@
1
+ name: "Require PR labels"
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, labeled, unlabeled, synchronize]
6
+ jobs:
7
+ label:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: mheap/github-action-required-labels@v1
11
+ with:
12
+ mode: exactly
13
+ count: 1
14
+ labels: "bug, change, enhancement"
@@ -1,24 +1,81 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-performance
4
+
1
5
  AllCops:
2
- DisplayCopNames: true
6
+ TargetRubyVersion: 2.6
3
7
  Exclude:
4
- - "finapps_core.gemspec"
5
- UseCache: false
6
-
7
- # Commonly used screens these days easily fit more than 80 characters.
8
- Layout/LineLength:
9
- Max: 120
10
-
11
- # Re-enable this when the following is resolved:
12
- # https://github.com/rubocop-hq/rubocop/issues/5953
13
- Style/AccessModifierDeclarations:
14
- Enabled: false
8
+ - "vendor/**/*"
9
+ - "bin/**/*"
10
+ CacheRootDirectory: tmp
11
+ NewCops: enable
15
12
 
13
+ Layout/SpaceAroundMethodCallOperator:
14
+ Enabled: true
15
+ Layout/EmptyLinesAroundAttributeAccessor:
16
+ Enabled: true
16
17
  Layout/SpaceInsideBlockBraces:
17
18
  # The space here provides no real gain in readability while consuming
18
19
  # horizontal space that could be used for a better parameter name.
19
20
  # Also {| differentiates better from a hash than { | does.
20
21
  SpaceBeforeBlockParameters: false
22
+ Layout/SpaceInsideHashLiteralBraces:
23
+ EnforcedStyle: no_space
24
+ Layout/DotPosition:
25
+ Description: Checks the position of the dot in multi-line method calls.
26
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
27
+ Enabled: true
28
+ EnforcedStyle: leading
29
+ SupportedStyles:
30
+ - leading
31
+ - trailing
32
+ Layout/LineLength:
33
+ Max: 110
34
+
35
+ Lint/DeprecatedOpenSSLConstant:
36
+ Enabled: true
37
+ Lint/MixedRegexpCaptureTypes:
38
+ Enabled: true
39
+ Lint/RaiseException:
40
+ Enabled: true
41
+ Lint/StructNewOverride:
42
+ Enabled: true
43
+
44
+ Metrics/ClassLength:
45
+ Exclude:
46
+ - app/controllers/orders_controller.rb
47
+ - app/models/order.rb
48
+ Metrics/BlockLength:
49
+ IgnoredMethods: ['describe', 'context']
50
+ Exclude:
51
+ - finapps_core.gemspec
52
+ - config/environments/**/**
53
+ - Guardfile
54
+ - config/routes.rb
55
+ - config/Guardfile
56
+
57
+ Naming/PredicateName:
58
+ Description: Check the names of predicate methods.
59
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
60
+ Enabled: true
61
+ NamePrefix:
62
+ - is_
63
+ - has_
64
+ - have_
65
+ ForbiddenPrefixes:
66
+ - is_
67
+ Exclude:
68
+ - spec/**/*
21
69
 
70
+ RSpec/FilePath:
71
+ Enabled: false
72
+ Gemspec/RequiredRubyVersion:
73
+ Enabled: false
74
+
75
+ Style/RedundantRegexpCharacterClass:
76
+ Enabled: true
77
+ Style/RedundantRegexpEscape:
78
+ Enabled: true
22
79
  Style/CollectionMethods:
23
80
  Description: Preferred collection methods.
24
81
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
@@ -29,73 +86,66 @@ Style/CollectionMethods:
29
86
  find: detect
30
87
  find_all: select
31
88
  reduce: inject
89
+ Style/GuardClause:
90
+ Description: Check for conditionals that can be replaced with guard clauses
91
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
92
+ Enabled: true
93
+ MinBodyLength: 1
32
94
  Style/OptionHash:
33
95
  Description: Don't use option hashes when you can use keyword arguments.
34
96
  Enabled: false
35
- Naming/PredicateName:
36
- Description: Check the names of predicate methods.
37
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
38
- Enabled: true
39
- NamePrefix:
40
- - is_
41
- - has_
42
- - have_
43
- ForbiddenPrefixes:
44
- - is_
45
- Exclude:
46
- - spec/**/*
47
- Metrics/AbcSize:
48
- Description: A calculated magnitude based on number of assignments, branches, and
49
- conditions.
97
+ Style/PercentLiteralDelimiters:
98
+ Description: Use `%`-literal delimiters consistently
99
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
50
100
  Enabled: false
51
- Max: 15
52
- Metrics/BlockLength:
53
- ExcludedMethods: ['describe', 'context']
54
- Metrics/ClassLength:
55
- Description: Avoid classes longer than 100 lines of code.
56
- Enabled: false
57
- CountComments: false
58
- Max: 100
59
- Metrics/ModuleLength:
60
- CountComments: false
61
- Max: 100
62
- Description: Avoid modules longer than 100 lines of code.
63
- Enabled: false
64
- Metrics/CyclomaticComplexity:
65
- Description: A complexity metric that is strongly correlated to the number of test
66
- cases needed to validate a method.
67
- Enabled: false
68
- Max: 6
69
- Metrics/MethodLength:
70
- Description: Avoid methods longer than 10 lines of code.
71
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
72
- Enabled: false
73
- CountComments: false
74
- Max: 10
75
- Metrics/ParameterLists:
76
- Description: Avoid parameter lists longer than three or four parameters.
77
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
78
- Enabled: false
79
- Max: 5
80
- CountKeywordArgs: true
81
- Metrics/PerceivedComplexity:
82
- Description: A complexity metric geared towards measuring complexity for a human
83
- reader.
84
- Enabled: false
85
- Max: 7
101
+ PreferredDelimiters:
102
+ "%": "()"
103
+ "%i": "()"
104
+ "%q": "()"
105
+ "%Q": "()"
106
+ "%r": "{}"
107
+ "%s": "()"
108
+ "%w": "()"
109
+ "%W": "()"
110
+ "%x": "()"
111
+ Style/SignalException:
112
+ Description: Checks for proper usage of fail and raise.
113
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
114
+ Enabled: true
115
+ EnforcedStyle: semantic
116
+ SupportedStyles:
117
+ - only_raise
118
+ - only_fail
119
+ - semantic
120
+ Style/StringLiterals:
121
+ Description: Checks if uses of quotes match the configured preference.
122
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
123
+ Enabled: true
124
+ EnforcedStyle: single_quotes
125
+ SupportedStyles:
126
+ - single_quotes
127
+ - double_quotes
128
+ Style/StringLiteralsInInterpolation:
129
+ Description: Checks if uses of quotes inside expressions in interpolated strings
130
+ match the configured preference.
131
+ Enabled: true
132
+ EnforcedStyle: single_quotes
133
+ SupportedStyles:
134
+ - single_quotes
135
+ - double_quotes
86
136
  Style/Documentation:
87
137
  Description: Document classes and non-namespace modules.
88
138
  Enabled: false
89
- Style/EmptyLiteral:
90
- Description: Prefer literals to Array.new/Hash.new/String.new.
91
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
139
+ Style/OneLineConditional:
140
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
141
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
92
142
  Enabled: false
93
- Style/VariableInterpolation:
94
- Description: Don't interpolate global, instance and class variables directly in
95
- strings.
96
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
143
+ Style/OptionalBooleanParameter:
97
144
  Enabled: false
98
- Lint/SuppressedException:
99
- Description: Don't suppress exception.
100
- StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
101
- Enabled: false
145
+
146
+ RSpec/NestedGroups:
147
+ Max: 5
148
+ RSpec/DescribeClass:
149
+ Exclude:
150
+ - spec/system/*
151
+ - spec/factories_spec.rb
@@ -1 +1 @@
1
- ruby-2.6.3
1
+ ruby-2.7.2
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: ruby-client-core
3
+ root: ~/projects/ruby-client-core/
4
+ windows:
5
+ -
6
+ editor:
7
+ layout: main-vertical
8
+ panes:
9
+ - vim: $EDITOR
10
+ - bash:
11
+ - git pull
12
+ - git status
13
+ - bundle
14
+ - bundle outdated
15
+ -
16
+ guard:
17
+ layout: even-horizontal
18
+ panes:
19
+ - guard:
20
+ - bundle exec guard
@@ -1,17 +1,16 @@
1
- sudo: false
2
1
  language: ruby
2
+ os: ["linux"]
3
+ dist: "xenial"
4
+
3
5
  cache:
4
6
  bundler: true
5
7
 
6
8
  rvm:
7
- - 2.5
8
9
  - 2.6
9
- # - ruby-head
10
10
 
11
11
  before_install:
12
12
  - "echo 'gem: --no-document' > ~/.gemrc"
13
- - gem update --system
14
- - gem install bundler -v "~>2.0"
13
+ - gem install bundler --force --quiet
15
14
 
16
15
  script:
17
16
  - bundle exec rspec
@@ -23,4 +22,4 @@ addons:
23
22
  code_climate:
24
23
  repo_token: 5a8d194cbc23aa4c171e3478e3b6bbea9dd96041071380ec25bf80c07770b39a
25
24
  after_success:
26
- - bundle exec codeclimate-test-reporter
25
+ - bundle exec codeclimate-test-reporter