Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e464d43
Add Rails installer
sergii Dec 3, 2024
67cacb1
Add bin/rubocop. Fix rubocop issues
sergii Dec 3, 2024
9a4dbd9
Update GitHub workflow. Add bin/ci script
sergii Dec 3, 2024
66f2dfc
Add newline at the end of the file
sergii Dec 3, 2024
34a4026
Rename and update bin/ci to bin/check
sergii Dec 3, 2024
94af0a3
WIP: Play with github-workflow
sergii Dec 3, 2024
ab2844f
WIP: Add bundle exec to the brakeman invocation in the bin/check
sergii Dec 3, 2024
71dc448
WIP: Update bin/check
sergii Dec 3, 2024
918bee6
WIP: Update github-workflow
sergii Dec 3, 2024
4278d25
Update CI workflow name
sergii Dec 3, 2024
938df58
Mention particular ruby versions supported on CI check
sergii Dec 3, 2024
6a680f5
Remove brakeman since it is specifically designed for Rails projects.
sergii Dec 3, 2024
2f4d788
WIP: Move appropriate gems into development group
sergii Dec 3, 2024
a16912d
Forget to add updated Gemfile.lock
sergii Dec 3, 2024
fd03e96
Fix Rubocop issues
sergii Dec 3, 2024
dc1e677
Explicitly specifying bundler-with: development in the CI workflow en…
sergii Dec 3, 2024
c6e104a
Dynamically includes Ruby version in the job name
sergii Dec 3, 2024
cdaf57c
Correctly evaluates Ruby version
sergii Dec 3, 2024
02e24b4
Update names in CI workflow. Add installing gems in parallel
sergii Dec 3, 2024
459a2e6
Move back parallelism
sergii Dec 3, 2024
3226b5b
Add parallelism back
sergii Dec 3, 2024
d4c7a94
Update rails install README.md
sergii Dec 4, 2024
1a385b4
Update README of Rails setup
sergii Dec 4, 2024
1813894
Add TargetRubyVersion to rubocop config
dmytroshevchuk Feb 9, 2025
a743d69
Clean up check.yml file for CI
dmytroshevchuk Feb 9, 2025
51e91cf
Bump dependencies
dmytroshevchuk Feb 9, 2025
8cbc25d
Drop incomplete installers
dmytroshevchuk Feb 9, 2025
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
19 changes: 12 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check Branch
name: CI Workflow

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [main]

jobs:
Check-Branch:
Test-Ruby:
runs-on: ubuntu-latest

strategy:
Expand All @@ -18,18 +18,23 @@ jobs:
- '3.2'
- '3.3'

name: Ruby ${{ matrix.ruby }}

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install dependencies
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
bundler-with: development
ruby-version: ${{ matrix.ruby }}

- name: Run unit tests
run: bundle exec rake
- name: Debug Environment
run: |
echo "Ruby version: $(ruby -v)"
echo "Bundler version: $(bundle -v)"

- name: Run Rubocop
run: bundle exec rubocop
- name: Run CI pipeline for the gem
run: bin/check
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ require:
AllCops:
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: 3.0

Metrics/MethodLength:
Exclude:
Expand Down
10 changes: 6 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in scalar_ruby.gemspec
#
gemspec

gem 'minitest'
gem 'rake'

gem 'rubocop', '~> 1.68'
gem 'rubocop-minitest', '~> 0.36.0'
gem 'rubocop-performance', '~> 1.23'
group :development do
gem 'bundler-audit', require: false
gem 'rubocop'
gem 'rubocop-minitest'
gem 'rubocop-performance'
end
37 changes: 22 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,55 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
json (2.8.2)
language_server-protocol (3.17.0.3)
minitest (5.25.1)
bundler-audit (0.9.2)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
json (2.9.1)
language_server-protocol (3.17.0.4)
minitest (5.25.4)
parallel (1.26.3)
parser (3.3.6.0)
parser (3.3.7.1)
ast (~> 2.4.1)
racc
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.2)
rubocop (1.68.0)
regexp_parser (2.10.0)
rubocop (1.71.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.36.1)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.0)
parser (>= 3.3.1.0)
rubocop-minitest (0.36.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.23.0)
rubocop-performance (1.23.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
unicode-display_width (2.6.0)
thor (1.3.2)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)

PLATFORMS
arm64-darwin-23
ruby

DEPENDENCIES
bundler-audit
minitest
rake
rubocop (~> 1.68)
rubocop-minitest (~> 0.36.0)
rubocop-performance (~> 1.23)
rubocop
rubocop-minitest
rubocop-performance
scalar_ruby!

BUNDLED WITH
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

This gem simplifies the integration of [Scalar](https://scalar.com), a modern open-source developer experience platform for your APIs into Ruby applications.

## Requirements

This gem is tested and supported on the following Ruby versions:

- Ruby 3.0, 3.1, 3.2, 3.3

Other Ruby versions might work but are not officially supported.

## Installation

Add the gem to your application's Gemfile by executing in the terminal:
Expand All @@ -15,6 +23,11 @@ bundle add scalar_ruby

## Getting Started

#### Integrations
You can use in-build generator to setup gem into [Ruby in Rails](https://rubyonrails.org) framework followed by instructions:

Setup gem with [Ruby on Rails](lib/scalar/installers/rails/README.md)

Statistically, you will likely use the gem for the Ruby on Rails application, so here are instructions on how to set up the Scalar for this framework. In the future, we'll add examples for other popular Ruby frameworks.

Once you have installed the gem, go to `config/routes.rb` and mount the `Scalar::UI` to your application.
Expand Down
18 changes: 18 additions & 0 deletions bin/check
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e # Exit immediately if a command exits with a non-zero status
set -o pipefail # Fail if any part of a pipeline fails

# Run bundle audit (checks for vulnerabilities in gem dependencies)
echo "🔍 [ bin/check ] Analyzing Ruby gems for security vulnerabilities..."
bundle exec bundle-audit check --update || { echo "❌ [ bin/check ] Bundle audit failed"; exit 1; }

# Run tests
echo "🧪 [ bin/check ] Running Minitest tests..."
bundle exec rake test || { echo "❌ [ bin/check ] Tests failed"; exit 1; }

# Run RuboCop (linter and style checker)
echo "🤖 [ bin/check ] Running Rubocop..."
bundle exec rubocop || { echo "❌ [ bin/check ] Rubocop failed"; exit 1; }

echo "✅ [ bin/check ] Done."
11 changes: 11 additions & 0 deletions lib/generators/scalar/install/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Description:
Installs Scalar, modern open-source developer experience platform for your APIs

Example:
bin/rails generate scalar:install

This will update:
config/routes.rb

This will create:
config/initializers/scalar.rb
37 changes: 37 additions & 0 deletions lib/generators/scalar/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

module Scalar
module Generators
class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path('templates', __dir__)

desc 'Installs Scalar into a Rails app'

def introduction
say <<~INTRODUCTION

👋 Let's install Scalar into your Rails app!

INTRODUCTION
end

def update_routes
insert_into_file Rails.root.join('config/routes.rb'), after: 'Rails.application.routes.draw do' do
"\n mount Scalar::UI, at: \"/docs\""
end
end

def create_initializer
template 'initializer.rb', 'config/initializers/scalar.rb'
end

def farewell
say <<~FAREWELL

We're done! Your can run "/docs" to observe a scalar API platform

FAREWELL
end
end
end
end
21 changes: 21 additions & 0 deletions lib/generators/scalar/install/templates/initializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

Scalar.setup do |config|
# Specify the specific version of the Scalar. By default it uses the latest one
#
# config.library_url = "https://cdn.jsdelivr.net/npm/@scalar/api-reference"

# Add custom page title displayed in the browser tab
#
# config.page_title = "API Reference"

# Pass your API specification. It may be URL or file content in OpenAPI format
#
# config.specification = File.read(Rails.root.join("docs/openapi.yml"))

# Additional Scalar configuration (e.g. theme) can be set here
#
# config.scalar_configuration = {
# theme: "purple"
# }
end
2 changes: 1 addition & 1 deletion scalar_ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
spec.files = Dir['{lib}/**/*', 'Rakefile', 'README.md']
spec.require_paths = ['lib']

spec.required_ruby_version = '>= 2.5.5'
spec.required_ruby_version = '>= 3.0'
end
Loading