Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
AllCops:
TargetRubyVersion: 2.7.5
Exclude:
- 'frontend/node_modules/**/*'
- 'README.md'
NewCops: enable

Bundler/OrderedGems:
Enabled: false

Layout/DotPosition:
EnforcedStyle: leading

Layout/LeadingCommentSpace:
Enabled: false

Layout/MultilineMethodCallIndentation:
Enabled: false

Layout/RescueEnsureAlignment:
Enabled: false

Lint/EmptyBlock:
Enabled: false

Lint/AmbiguousOperator:
Enabled: false

Lint/NonLocalExitFromIterator:
Enabled: false

Lint/ScriptPermission:
Enabled: false

Metrics:
Enabled: false

Naming/AccessorMethodName:
Enabled: false

Naming/FileName:
Enabled: false

Naming/PredicateName:
Enabled: false

Naming/RescuedExceptionsVariableName:
Enabled: false

Security:
Enabled: true

Style/BlockDelimiters:
EnforcedStyle: braces_for_chaining

Style/Documentation:
Enabled: false

Style/NumericLiteralPrefix:
Enabled: false

Style/NumericLiterals:
Enabled: false

Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': ()
'%i': '[]'
'%I': '[]'
'%q': ()
'%Q': ()
'%r': '{}'
'%s': ()
'%w': '[]'
'%W': '[]'
'%x': ()

Style/StringLiterals:
Enabled: false

Style/StringLiteralsInInterpolation:
Enabled: false

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: no_comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: no_comma
5 changes: 5 additions & 0 deletions ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'sinatra'
Expand All @@ -10,4 +12,7 @@ gem 'mx-platform-ruby'
group :test do
# Test it with RSpec (BDD for Ruby)
gem 'rspec-core'

# Keep files consistent
gem 'rubocop', require: false
end
21 changes: 21 additions & 0 deletions ruby/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
dotenv (2.7.6)
faraday (1.10.0)
faraday-em_http (~> 1.0)
Expand Down Expand Up @@ -30,12 +31,30 @@ GEM
ruby2_keywords (~> 0.0.1)
mx-platform-ruby (0.11.2)
faraday (~> 1.0, >= 1.0.1)
parallel (1.22.1)
parser (3.1.1.0)
ast (~> 2.4.1)
rack (2.2.3)
rack-protection (2.2.0)
rack
rainbow (3.1.1)
regexp_parser (2.2.1)
rexml (3.2.5)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.26.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.16.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
sinatra (2.2.0)
mustermann (~> 1.0)
Expand All @@ -44,6 +63,7 @@ GEM
tilt (~> 2.0)
sinatra-cross_origin (0.3.2)
tilt (2.0.10)
unicode-display_width (2.1.0)

PLATFORMS
x86_64-darwin-20
Expand All @@ -52,6 +72,7 @@ DEPENDENCIES
dotenv (~> 2.7)
mx-platform-ruby
rspec-core
rubocop
sinatra
sinatra-cross_origin (~> 0.3.1)

Expand Down
8 changes: 5 additions & 3 deletions ruby/app.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Load env vars from .env file
require 'dotenv'
Dotenv.load('./../.env')
Expand Down Expand Up @@ -43,7 +45,7 @@
mx_platform_api = ::MxPlatformRuby::MxPlatformApi.new(api_client)

get '/api/test' do
{ :test => 'hit' }.to_json
{ test: 'hit' }.to_json
end

get '/api/users' do
Expand Down Expand Up @@ -73,7 +75,7 @@ def create_user(user_id, mx_platform_api)
content_type :json

begin
request.body.rewind # in case someone already read it
request.body.rewind # in case someone already read it
data = JSON.parse(request.body.read)
external_id = data['user_id'].empty? ? nil : data['user_id']

Expand Down Expand Up @@ -137,7 +139,7 @@ def create_user(user_id, mx_platform_api)
post '/api/balances' do
content_type :json
begin
request.body.rewind # in case someone already read it
request.body.rewind # in case someone already read it
data = JSON.parse(request.body.read)

response = mx_platform_api.check_balances(data['member_guid'], data['user_guid'])
Expand Down
2 changes: 2 additions & 0 deletions ruby/spec/app_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe "app" do
it 'should be implemented' do; end
end
4 changes: 3 additions & 1 deletion ruby/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
::Dir[File.expand_path("spec/**/*.rb")].each { |f| require f }
# frozen_string_literal: true

::Dir[File.expand_path("spec/**/*.rb")].sort.each { |f| require f }