finapps_core 2.0.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.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +21 -0
  3. data/.gitignore +53 -0
  4. data/.hound.yml +2 -0
  5. data/.rspec +4 -0
  6. data/.rubocop.yml +271 -0
  7. data/.ruby-gemset +1 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +14 -0
  10. data/Gemfile +3 -0
  11. data/Gemfile.lock +98 -0
  12. data/LICENSE +21 -0
  13. data/README.md +21 -0
  14. data/Rakefile +2 -0
  15. data/finapps_core.gemspec +39 -0
  16. data/lib/core_extensions/object/blank.rb +69 -0
  17. data/lib/core_extensions/object/is_integer.rb +10 -0
  18. data/lib/core_extensions/string/json_to_hash.rb +10 -0
  19. data/lib/finapps_core.rb +30 -0
  20. data/lib/finapps_core/error.rb +17 -0
  21. data/lib/finapps_core/middleware/middleware.rb +22 -0
  22. data/lib/finapps_core/middleware/request/accept_json.rb +14 -0
  23. data/lib/finapps_core/middleware/request/no_encoding_basic_authentication.rb +21 -0
  24. data/lib/finapps_core/middleware/request/tenant_authentication.rb +20 -0
  25. data/lib/finapps_core/middleware/request/user_agent.rb +15 -0
  26. data/lib/finapps_core/middleware/response/custom_logger.rb +39 -0
  27. data/lib/finapps_core/middleware/response/raise_error.rb +46 -0
  28. data/lib/finapps_core/rest/base_client.rb +118 -0
  29. data/lib/finapps_core/rest/configuration.rb +32 -0
  30. data/lib/finapps_core/rest/connection.rb +35 -0
  31. data/lib/finapps_core/rest/credentials.rb +21 -0
  32. data/lib/finapps_core/rest/defaults.rb +19 -0
  33. data/lib/finapps_core/rest/resources.rb +62 -0
  34. data/lib/finapps_core/utils/loggeable.rb +14 -0
  35. data/lib/finapps_core/utils/parameter_filter.rb +32 -0
  36. data/lib/finapps_core/version.rb +4 -0
  37. data/lib/tasks/releaser.rake +9 -0
  38. data/spec/core_extensions/object/blank_spec.rb +44 -0
  39. data/spec/core_extensions/object/is_integer_spec.rb +17 -0
  40. data/spec/middleware/request/accept_json_spec.rb +12 -0
  41. data/spec/middleware/request/no_encoding_basic_authentication_spec.rb +32 -0
  42. data/spec/middleware/request/tenant_authentication_spec.rb +34 -0
  43. data/spec/middleware/request/user_agent_spec.rb +12 -0
  44. data/spec/middleware/response/raise_error_spec.rb +24 -0
  45. data/spec/rest/base_client_spec.rb +110 -0
  46. data/spec/rest/configuration_spec.rb +43 -0
  47. data/spec/rest/credentials_spec.rb +20 -0
  48. data/spec/rest/relevance_ruleset_names.json +47 -0
  49. data/spec/rest/timeout_spec.rb +7 -0
  50. data/spec/spec_helper.rb +37 -0
  51. data/spec/spec_helpers/client.rb +8 -0
  52. data/spec/support/fake_api.rb +34 -0
  53. data/spec/support/fixtures/error.json +5 -0
  54. data/spec/support/fixtures/relevance_ruleset_names.json +47 -0
  55. data/spec/support/fixtures/resource.json +3 -0
  56. data/spec/support/fixtures/resource_not_found.json +5 -0
  57. data/spec/support/fixtures/resources.json +11 -0
  58. data/spec/support/fixtures/unauthorized.json +5 -0
  59. data/spec/utils/parameter_filter_spec.rb +23 -0
  60. metadata +353 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 59f8656631c01dda538e16aebfa171dc4e7ee7e2
4
+ data.tar.gz: aac01a575a6a183a2c4c4655b8c539b7b523afd0
5
+ SHA512:
6
+ metadata.gz: 50252ffd05debb3b977a43f0a2135e8d59b6140cd32b3e7cc7407f4bf9157a5b5f38b45d45f28c6868cea8b477c8c20eac4cc9aae314fcf48f02fd28c161071e
7
+ data.tar.gz: 374187548c53a86daf1c09d70eeb5aab97e9f213ae636c038941017d910ca4b3cc9d8695e265a567d96cfc2faabeb2808e70c95b814f4b80d163097c8e3d83d2
@@ -0,0 +1,21 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: true
4
+ brakeman:
5
+ enabled: false
6
+ eslint:
7
+ enabled: false
8
+ csslint:
9
+ enabled: false
10
+ duplication:
11
+ enabled: true
12
+ config:
13
+ languages:
14
+ - ruby
15
+ ratings:
16
+ paths:
17
+ - lib/**
18
+ - "**.rb"
19
+ exclude_paths:
20
+ - spec/**/*
21
+ - "**/vendor/**/*"
@@ -0,0 +1,53 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ # Rubymine
53
+ .idea/
@@ -0,0 +1,2 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
4
+ --fail-fast
@@ -0,0 +1,271 @@
1
+ Rails:
2
+ Enabled: true
3
+
4
+ AllCops:
5
+ DisplayCopNames: true
6
+ Exclude:
7
+ - "vendor/**/*"
8
+ - "db/schema.rb"
9
+ - "bin/**/*"
10
+ - "finapps_core.gemspec"
11
+ UseCache: false
12
+
13
+ # Commonly used screens these days easily fit more than 80 characters.
14
+ Metrics/LineLength:
15
+ Max: 120
16
+
17
+ # No space makes the method definition shorter and differentiates
18
+ # from a regular assignment.
19
+ Style/SpaceAroundEqualsInParameterDefault:
20
+ EnforcedStyle: no_space
21
+
22
+ Style/SpaceInsideBlockBraces:
23
+ # The space here provides no real gain in readability while consuming
24
+ # horizontal space that could be used for a better parameter name.
25
+ # Also {| differentiates better from a hash than { | does.
26
+ SpaceBeforeBlockParameters: false
27
+
28
+ # No trailing space differentiates better from the block:
29
+ # foo} means hash, foo } means block.
30
+ Style/SpaceInsideHashLiteralBraces:
31
+ EnforcedStyle: no_space
32
+
33
+
34
+ Style/CollectionMethods:
35
+ Description: Preferred collection methods.
36
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
37
+ Enabled: true
38
+ PreferredMethods:
39
+ collect: map
40
+ collect!: map!
41
+ find: detect
42
+ find_all: select
43
+ reduce: inject
44
+ Style/DotPosition:
45
+ Description: Checks the position of the dot in multi-line method calls.
46
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
47
+ Enabled: true
48
+ EnforcedStyle: leading
49
+ SupportedStyles:
50
+ - leading
51
+ - trailing
52
+ Style/FileName:
53
+ Description: Use snake_case for source file names.
54
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
55
+ Enabled: false
56
+ Exclude: []
57
+ Style/GuardClause:
58
+ Description: Check for conditionals that can be replaced with guard clauses
59
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
60
+ Enabled: false
61
+ MinBodyLength: 1
62
+ Style/IfUnlessModifier:
63
+ Description: Favor modifier if/unless usage when you have a single-line body.
64
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
65
+ Enabled: false
66
+ MaxLineLength: 80
67
+ Style/OptionHash:
68
+ Description: Don't use option hashes when you can use keyword arguments.
69
+ Enabled: false
70
+ Style/PercentLiteralDelimiters:
71
+ Description: Use `%`-literal delimiters consistently
72
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
73
+ Enabled: false
74
+ PreferredDelimiters:
75
+ "%": "()"
76
+ "%i": "()"
77
+ "%q": "()"
78
+ "%Q": "()"
79
+ "%r": "{}"
80
+ "%s": "()"
81
+ "%w": "()"
82
+ "%W": "()"
83
+ "%x": "()"
84
+ Style/PredicateName:
85
+ Description: Check the names of predicate methods.
86
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
87
+ Enabled: true
88
+ NamePrefix:
89
+ - is_
90
+ - has_
91
+ - have_
92
+ NamePrefixBlacklist:
93
+ - is_
94
+ Exclude:
95
+ - spec/**/*
96
+ Style/RaiseArgs:
97
+ Description: Checks the arguments passed to raise/fail.
98
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
99
+ Enabled: false
100
+ EnforcedStyle: exploded
101
+ SupportedStyles:
102
+ - compact
103
+ - exploded
104
+ Style/SignalException:
105
+ Description: Checks for proper usage of fail and raise.
106
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
107
+ Enabled: false
108
+ EnforcedStyle: semantic
109
+ SupportedStyles:
110
+ - only_raise
111
+ - only_fail
112
+ - semantic
113
+ Style/SingleLineBlockParams:
114
+ Description: Enforces the names of some block params.
115
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
116
+ Enabled: false
117
+ Methods:
118
+ - reduce:
119
+ - a
120
+ - e
121
+ - inject:
122
+ - a
123
+ - e
124
+ Style/SingleLineMethods:
125
+ Description: Avoid single-line methods.
126
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
127
+ Enabled: false
128
+ AllowIfMethodIsEmpty: true
129
+ Style/StringLiterals:
130
+ Description: Checks if uses of quotes match the configured preference.
131
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
132
+ Enabled: true
133
+ EnforcedStyle: single_quotes
134
+ SupportedStyles:
135
+ - single_quotes
136
+ - double_quotes
137
+ Style/StringLiteralsInInterpolation:
138
+ Description: Checks if uses of quotes inside expressions in interpolated strings
139
+ match the configured preference.
140
+ Enabled: true
141
+ EnforcedStyle: single_quotes
142
+ SupportedStyles:
143
+ - single_quotes
144
+ - double_quotes
145
+ Style/TrailingCommaInArguments:
146
+ Description: 'Checks for trailing comma in argument lists.'
147
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
148
+ Enabled: false
149
+ EnforcedStyleForMultiline: no_comma
150
+ SupportedStyles:
151
+ - comma
152
+ - consistent_comma
153
+ - no_comma
154
+ Style/TrailingCommaInLiteral:
155
+ Description: 'Checks for trailing comma in array and hash literals.'
156
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
157
+ Enabled: false
158
+ EnforcedStyleForMultiline: no_comma
159
+ SupportedStyles:
160
+ - comma
161
+ - consistent_comma
162
+ - no_comma
163
+ Metrics/AbcSize:
164
+ Description: A calculated magnitude based on number of assignments, branches, and
165
+ conditions.
166
+ Enabled: false
167
+ Max: 15
168
+ Metrics/ClassLength:
169
+ Description: Avoid classes longer than 100 lines of code.
170
+ Enabled: false
171
+ CountComments: false
172
+ Max: 100
173
+ Metrics/ModuleLength:
174
+ CountComments: false
175
+ Max: 100
176
+ Description: Avoid modules longer than 100 lines of code.
177
+ Enabled: false
178
+ Metrics/CyclomaticComplexity:
179
+ Description: A complexity metric that is strongly correlated to the number of test
180
+ cases needed to validate a method.
181
+ Enabled: false
182
+ Max: 6
183
+ Metrics/MethodLength:
184
+ Description: Avoid methods longer than 10 lines of code.
185
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
186
+ Enabled: false
187
+ CountComments: false
188
+ Max: 10
189
+ Metrics/ParameterLists:
190
+ Description: Avoid parameter lists longer than three or four parameters.
191
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
192
+ Enabled: false
193
+ Max: 5
194
+ CountKeywordArgs: true
195
+ Metrics/PerceivedComplexity:
196
+ Description: A complexity metric geared towards measuring complexity for a human
197
+ reader.
198
+ Enabled: false
199
+ Max: 7
200
+ Lint/AssignmentInCondition:
201
+ Description: Don't use assignment in conditions.
202
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
203
+ Enabled: false
204
+ AllowSafeAssignment: true
205
+ Style/InlineComment:
206
+ Description: Avoid inline comments.
207
+ Enabled: false
208
+ Style/AccessorMethodName:
209
+ Description: Check the naming of accessor methods for get_/set_.
210
+ Enabled: false
211
+ Style/Alias:
212
+ Description: Use alias_method instead of alias.
213
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
214
+ Enabled: false
215
+ Style/Documentation:
216
+ Description: Document classes and non-namespace modules.
217
+ Enabled: false
218
+ Style/DoubleNegation:
219
+ Description: Checks for uses of double negation (!!).
220
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
221
+ Enabled: false
222
+ Style/EachWithObject:
223
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
224
+ Enabled: false
225
+ Style/EmptyLiteral:
226
+ Description: Prefer literals to Array.new/Hash.new/String.new.
227
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
228
+ Enabled: false
229
+ Style/ModuleFunction:
230
+ Description: Checks for usage of `extend self` in modules.
231
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
232
+ Enabled: false
233
+ Style/OneLineConditional:
234
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
235
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
236
+ Enabled: false
237
+ Style/PerlBackrefs:
238
+ Description: Avoid Perl-style regex back references.
239
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
240
+ Enabled: false
241
+ Style/Send:
242
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
243
+ may overlap with existing methods.
244
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
245
+ Enabled: false
246
+ Style/SpecialGlobalVars:
247
+ Description: Avoid Perl-style global variables.
248
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
249
+ Enabled: false
250
+ Style/VariableInterpolation:
251
+ Description: Don't interpolate global, instance and class variables directly in
252
+ strings.
253
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
254
+ Enabled: false
255
+ Style/WhenThen:
256
+ Description: Use when x then ... for one-line cases.
257
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
258
+ Enabled: false
259
+ Lint/EachWithObjectArgument:
260
+ Description: Check for immutable argument given to each_with_object.
261
+ Enabled: true
262
+ Lint/HandleExceptions:
263
+ Description: Don't suppress exception.
264
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
265
+ Enabled: false
266
+ Lint/LiteralInCondition:
267
+ Description: Checks of literals used in conditions.
268
+ Enabled: false
269
+ Lint/LiteralInInterpolation:
270
+ Description: Checks for literals used in interpolation.
271
+ Enabled: false
@@ -0,0 +1 @@
1
+ ruby-client-core
@@ -0,0 +1 @@
1
+ ruby-2.3.1
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.3.1
5
+ before_install:
6
+ - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
7
+ script:
8
+ - bundle exec rspec
9
+ notifications:
10
+ email: false
11
+ slack: financialapps:fA8XwEcap3hHZk0iNmPPJvT1
12
+ addons:
13
+ code_climate:
14
+ repo_token: 5a8d194cbc23aa4c171e3478e3b6bbea9dd96041071380ec25bf80c07770b39a
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+ gemspec
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ finapps_core (2.0.1)
5
+ faraday (~> 0.9, >= 0.9.2)
6
+ faraday_middleware (~> 0.10, >= 0.10.0)
7
+ rash (~> 0.4, >= 0.4.0)
8
+ typhoeus (~> 1.0, >= 1.0.2)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.5.0)
14
+ public_suffix (~> 2.0, >= 2.0.2)
15
+ ast (2.3.0)
16
+ codeclimate-test-reporter (0.6.0)
17
+ simplecov (>= 0.7.1, < 1.0.0)
18
+ crack (0.4.3)
19
+ safe_yaml (~> 1.0.0)
20
+ diff-lcs (1.3)
21
+ docile (1.1.5)
22
+ ethon (0.10.1)
23
+ ffi (>= 1.3.0)
24
+ faraday (0.11.0)
25
+ multipart-post (>= 1.2, < 3)
26
+ faraday_middleware (0.11.0.1)
27
+ faraday (>= 0.7.4, < 1.0)
28
+ ffi (1.9.17)
29
+ hashdiff (0.3.2)
30
+ hashie (2.0.5)
31
+ json (2.0.3)
32
+ multipart-post (2.0.0)
33
+ parser (2.4.0.0)
34
+ ast (~> 2.2)
35
+ powerpack (0.1.1)
36
+ public_suffix (2.0.5)
37
+ rack (1.6.5)
38
+ rack-protection (1.5.3)
39
+ rack
40
+ rainbow (2.2.1)
41
+ rake (11.3.0)
42
+ rash (0.4.0)
43
+ hashie (~> 2.0.0)
44
+ rspec (3.5.0)
45
+ rspec-core (~> 3.5.0)
46
+ rspec-expectations (~> 3.5.0)
47
+ rspec-mocks (~> 3.5.0)
48
+ rspec-core (3.5.4)
49
+ rspec-support (~> 3.5.0)
50
+ rspec-expectations (3.5.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.5.0)
53
+ rspec-mocks (3.5.0)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.5.0)
56
+ rspec-support (3.5.0)
57
+ rubocop (0.45.0)
58
+ parser (>= 2.3.1.1, < 3.0)
59
+ powerpack (~> 0.1)
60
+ rainbow (>= 1.99.1, < 3.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (~> 1.0, >= 1.0.1)
63
+ ruby-progressbar (1.8.1)
64
+ safe_yaml (1.0.4)
65
+ simplecov (0.13.0)
66
+ docile (~> 1.1.0)
67
+ json (>= 1.8, < 3)
68
+ simplecov-html (~> 0.10.0)
69
+ simplecov-html (0.10.0)
70
+ sinatra (1.4.8)
71
+ rack (~> 1.5)
72
+ rack-protection (~> 1.4)
73
+ tilt (>= 1.3, < 3)
74
+ tilt (2.0.6)
75
+ typhoeus (1.1.2)
76
+ ethon (>= 0.9.0)
77
+ unicode-display_width (1.1.3)
78
+ webmock (2.3.2)
79
+ addressable (>= 2.3.6)
80
+ crack (>= 0.3.2)
81
+ hashdiff
82
+
83
+ PLATFORMS
84
+ ruby
85
+
86
+ DEPENDENCIES
87
+ bundler (~> 1.11, >= 1.11.2)
88
+ codeclimate-test-reporter (~> 0.6.0)
89
+ finapps_core!
90
+ rake (~> 11.2, >= 11.2.2)
91
+ rspec (~> 3.4, >= 3.4.0)
92
+ rubocop (= 0.45.0)
93
+ simplecov (~> 0.11, >= 0.11.2)
94
+ sinatra (~> 1.4, >= 1.4.7)
95
+ webmock (~> 2.1, >= 2.1.0)
96
+
97
+ BUNDLED WITH
98
+ 1.14.3