From e464d4352298b7b6fda51f8d54510b19f23d7a42 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Tue, 3 Dec 2024 16:18:06 +0200 Subject: [PATCH 01/27] Add Rails installer --- README.md | 5 +++ lib/generators/scalar/install/USAGE | 11 ++++++ .../scalar/install/install_generator.rb | 35 +++++++++++++++++++ .../scalar/install/templates/initializer.rb | 20 +++++++++++ lib/scalar/installers/grape/README.md | 1 + lib/scalar/installers/grape/installer.rb | 20 +++++++++++ lib/scalar/installers/rails/README.md | 26 ++++++++++++++ lib/scalar/installers/rails/installer.rb | 11 ++++++ lib/scalar/installers/sinatra/README.md | 1 + lib/scalar/installers/sinatra/installer.rb | 20 +++++++++++ lib/tasks/scalar_install.rake | 21 +++++++++++ 11 files changed, 171 insertions(+) create mode 100644 lib/generators/scalar/install/USAGE create mode 100644 lib/generators/scalar/install/install_generator.rb create mode 100644 lib/generators/scalar/install/templates/initializer.rb create mode 100644 lib/scalar/installers/grape/README.md create mode 100644 lib/scalar/installers/grape/installer.rb create mode 100644 lib/scalar/installers/rails/README.md create mode 100644 lib/scalar/installers/rails/installer.rb create mode 100644 lib/scalar/installers/sinatra/README.md create mode 100644 lib/scalar/installers/sinatra/installer.rb create mode 100644 lib/tasks/scalar_install.rake diff --git a/README.md b/README.md index 9f218e8..4dd99f4 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ bundle add scalar_ruby ## Getting Started +#### Integrations +- [x] [Ruby on Rails]https://rubyonrails.org) + +[Setup with Rails framework](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. diff --git a/lib/generators/scalar/install/USAGE b/lib/generators/scalar/install/USAGE new file mode 100644 index 0000000..0df0a84 --- /dev/null +++ b/lib/generators/scalar/install/USAGE @@ -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 diff --git a/lib/generators/scalar/install/install_generator.rb b/lib/generators/scalar/install/install_generator.rb new file mode 100644 index 0000000..50bb567 --- /dev/null +++ b/lib/generators/scalar/install/install_generator.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Scalar::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 diff --git a/lib/generators/scalar/install/templates/initializer.rb b/lib/generators/scalar/install/templates/initializer.rb new file mode 100644 index 0000000..a28e95d --- /dev/null +++ b/lib/generators/scalar/install/templates/initializer.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +Scalar.setup do |config| + # Configuration for the scalar + # + # config.page_title = "API Reference" + # config.library_url = "https://cdn.jsdelivr.net/npm/@scalar/api-reference" + # config.specification = File.read(Rails.root.join("docs/openapi.yml")) + # config.scalar_configuration = { + # # Whether the Swagger editor should be shown. + # isEditable: true, + # spec: { + # # Content: String. Directly pass an OpenAPI/Swagger spec. + # content: '{ ... }', + # # Content: String. Pass the URL of a spec file (JSON or Yaml). + # url: '/openapi.json' + # }, + # # ... + # } +end diff --git a/lib/scalar/installers/grape/README.md b/lib/scalar/installers/grape/README.md new file mode 100644 index 0000000..2fd9f95 --- /dev/null +++ b/lib/scalar/installers/grape/README.md @@ -0,0 +1 @@ +TBD \ No newline at end of file diff --git a/lib/scalar/installers/grape/installer.rb b/lib/scalar/installers/grape/installer.rb new file mode 100644 index 0000000..3656970 --- /dev/null +++ b/lib/scalar/installers/grape/installer.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Scalar + module Installers + class Grape::Installer + def self.install + File.write('config/initializer_scalar.rb', grape_initializer_content) + end + + def self.grape_initializer_content + <<~CONTENT + # Scalar Grape configuration + Scalar.configure do |config| + # Add custom configurations + end + CONTENT + end + end + end +end diff --git a/lib/scalar/installers/rails/README.md b/lib/scalar/installers/rails/README.md new file mode 100644 index 0000000..7e76f87 --- /dev/null +++ b/lib/scalar/installers/rails/README.md @@ -0,0 +1,26 @@ +--- +title: Getting started with Rails +--- + +# Getting started with Scalar on Rails + +While Scalar can be used in any Ruby project, it’s especially great with [Rails](https://rubyonrails.org). + +## Setup + +To use Scalar with Rails, you’ll need to install the [`scalar_ruby`](https://rubygems.org/gems/scalar_ruby) gem. Add your gem into the project Gemfile via bundler: + +```bash +bundle add scalar_ruby +``` + +Once the gem is installed, run the install generator. + +```bash +bin/rails generate scalar:install +``` + +This script will: + +1. update `config/routes.rb` to mount `/docs` route. +2. generate `config/initializers/scalar.rb` diff --git a/lib/scalar/installers/rails/installer.rb b/lib/scalar/installers/rails/installer.rb new file mode 100644 index 0000000..2a571e5 --- /dev/null +++ b/lib/scalar/installers/rails/installer.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Scalar + module Installers + class Rails::Installer + def self.install + system('bin/rails generate scalar:rails') + end + end + end +end diff --git a/lib/scalar/installers/sinatra/README.md b/lib/scalar/installers/sinatra/README.md new file mode 100644 index 0000000..2fd9f95 --- /dev/null +++ b/lib/scalar/installers/sinatra/README.md @@ -0,0 +1 @@ +TBD \ No newline at end of file diff --git a/lib/scalar/installers/sinatra/installer.rb b/lib/scalar/installers/sinatra/installer.rb new file mode 100644 index 0000000..3a3cc4f --- /dev/null +++ b/lib/scalar/installers/sinatra/installer.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Scalar + module Installers + class Sinatra::Installer + def self.install + File.write('config/initializer_scalar.rb', sinatra_initializer_content) + end + + def self.sinatra_initializer_content + <<~CONTENT + # Scalar Sinatra configuration + Scalar.configure do |config| + # Add custom configurations + end + CONTENT + end + end + end +end diff --git a/lib/tasks/scalar_install.rake b/lib/tasks/scalar_install.rake new file mode 100644 index 0000000..64c2414 --- /dev/null +++ b/lib/tasks/scalar_install.rake @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +namespace :scalar do + desc "Install Scalar for a specific framework" + task :install, [:framework] do |_t, args| + framework = args[:framework]&.downcase + case framework + when 'rails' + require_relative '../scalar/installers/rails_installer' + Scalar::Installers::RailsInstaller.install + when 'sinatra' + require_relative '../scalar/installers/sinatra_installer' + Scalar::Installers::SinatraInstaller.install + when 'grape' + require_relative '../scalar/installers/grape_installer' + Scalar::Installers::GrapeInstaller.install + else + puts "Unsupported framework. Please specify 'rails', 'sinatra', or 'grape'." + end + end +end From 67cacb1a33cf6ed3691556bdc955771685266560 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Tue, 3 Dec 2024 20:02:12 +0200 Subject: [PATCH 02/27] Add bin/rubocop. Fix rubocop issues --- bin/rubocop | 10 +++++ .../scalar/install/install_generator.rb | 42 ++++++++++--------- lib/scalar/installers/grape/installer.rb | 24 ++++++----- lib/scalar/installers/rails/installer.rb | 8 ++-- lib/scalar/installers/sinatra/installer.rb | 24 ++++++----- lib/tasks/scalar_install.rake | 2 +- 6 files changed, 64 insertions(+), 46 deletions(-) create mode 100755 bin/rubocop diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..f45b065 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'rubygems' +require 'bundler/setup' + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift('--config', File.expand_path('../.rubocop.yml', __dir__)) + +load Gem.bin_path('rubocop', 'rubocop') diff --git a/lib/generators/scalar/install/install_generator.rb b/lib/generators/scalar/install/install_generator.rb index 50bb567..8edad53 100644 --- a/lib/generators/scalar/install/install_generator.rb +++ b/lib/generators/scalar/install/install_generator.rb @@ -1,35 +1,37 @@ # frozen_string_literal: true -module Scalar::Generators - class InstallGenerator < ::Rails::Generators::Base - source_root File.expand_path("templates", __dir__) +module Scalar + module Generators + class InstallGenerator < ::Rails::Generators::Base + source_root File.expand_path('templates', __dir__) - desc "Installs Scalar into a Rails app" + desc 'Installs Scalar into a Rails app' - def introduction - say <<-INTRODUCTION + def introduction + say <<~INTRODUCTION -πŸ‘‹ Let's install Scalar into your Rails app! + πŸ‘‹ Let's install Scalar into your Rails app! - INTRODUCTION - end + 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\"" + 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 - end - def create_initializer - template "initializer.rb", "config/initializers/scalar.rb" - end + def create_initializer + template 'initializer.rb', 'config/initializers/scalar.rb' + end - def farewell - say <<-FAREWELL + def farewell + say <<~FAREWELL -We're done! Your can run "/docs" to observe a scalar API platform + We're done! Your can run "/docs" to observe a scalar API platform - FAREWELL + FAREWELL + end end end end diff --git a/lib/scalar/installers/grape/installer.rb b/lib/scalar/installers/grape/installer.rb index 3656970..e2451e7 100644 --- a/lib/scalar/installers/grape/installer.rb +++ b/lib/scalar/installers/grape/installer.rb @@ -2,18 +2,20 @@ module Scalar module Installers - class Grape::Installer - def self.install - File.write('config/initializer_scalar.rb', grape_initializer_content) - end + module Grape + class Installer + def self.install + File.write('config/initializer_scalar.rb', grape_initializer_content) + end - def self.grape_initializer_content - <<~CONTENT - # Scalar Grape configuration - Scalar.configure do |config| - # Add custom configurations - end - CONTENT + def self.grape_initializer_content + <<~CONTENT + # Scalar Grape configuration + Scalar.configure do |config| + # Add custom configurations + end + CONTENT + end end end end diff --git a/lib/scalar/installers/rails/installer.rb b/lib/scalar/installers/rails/installer.rb index 2a571e5..af68a92 100644 --- a/lib/scalar/installers/rails/installer.rb +++ b/lib/scalar/installers/rails/installer.rb @@ -2,9 +2,11 @@ module Scalar module Installers - class Rails::Installer - def self.install - system('bin/rails generate scalar:rails') + module Rails + class Installer + def self.install + system('bin/rails generate scalar:rails') + end end end end diff --git a/lib/scalar/installers/sinatra/installer.rb b/lib/scalar/installers/sinatra/installer.rb index 3a3cc4f..6b8d3f9 100644 --- a/lib/scalar/installers/sinatra/installer.rb +++ b/lib/scalar/installers/sinatra/installer.rb @@ -2,18 +2,20 @@ module Scalar module Installers - class Sinatra::Installer - def self.install - File.write('config/initializer_scalar.rb', sinatra_initializer_content) - end + module Sinatra + class Installer + def self.install + File.write('config/initializer_scalar.rb', sinatra_initializer_content) + end - def self.sinatra_initializer_content - <<~CONTENT - # Scalar Sinatra configuration - Scalar.configure do |config| - # Add custom configurations - end - CONTENT + def self.sinatra_initializer_content + <<~CONTENT + # Scalar Sinatra configuration + Scalar.configure do |config| + # Add custom configurations + end + CONTENT + end end end end diff --git a/lib/tasks/scalar_install.rake b/lib/tasks/scalar_install.rake index 64c2414..a27015b 100644 --- a/lib/tasks/scalar_install.rake +++ b/lib/tasks/scalar_install.rake @@ -1,7 +1,7 @@ # frozen_string_literal: true namespace :scalar do - desc "Install Scalar for a specific framework" + desc 'Install Scalar for a specific framework' task :install, [:framework] do |_t, args| framework = args[:framework]&.downcase case framework From 9a4dbd9e3475e091f4fdb693ff8f04c01c81afc1 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Tue, 3 Dec 2024 21:45:25 +0200 Subject: [PATCH 03/27] Update GitHub workflow. Add bin/ci script --- .github/workflows/check.yml | 6 ++++++ Gemfile | 4 ++++ Gemfile.lock | 8 ++++++++ bin/ci | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100755 bin/ci diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 559904d..de047c1 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -33,3 +33,9 @@ jobs: - name: Run Rubocop run: bundle exec rubocop + + - name: Run Brakeman + run: bundle exec brakeman --force + + - name: Run Bundle Audit + run: bundle exec bundle audit \ No newline at end of file diff --git a/Gemfile b/Gemfile index 0bf5bac..0c95dfe 100644 --- a/Gemfile +++ b/Gemfile @@ -12,3 +12,7 @@ gem 'rake' gem 'rubocop', '~> 1.68' gem 'rubocop-minitest', '~> 0.36.0' gem 'rubocop-performance', '~> 1.23' + +gem 'brakeman', '~> 6.2', require: false + +gem 'bundler-audit', '~> 0.9.2' diff --git a/Gemfile.lock b/Gemfile.lock index deec0c8..897a403 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,6 +7,11 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.2) + brakeman (6.2.2) + racc + bundler-audit (0.9.2) + bundler (>= 1.2.0, < 3) + thor (~> 1.0) json (2.8.2) language_server-protocol (3.17.0.3) minitest (5.25.1) @@ -37,6 +42,7 @@ GEM rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (1.13.0) + thor (1.3.2) unicode-display_width (2.6.0) PLATFORMS @@ -44,6 +50,8 @@ PLATFORMS ruby DEPENDENCIES + brakeman (~> 6.2) + bundler-audit (~> 0.9.2) minitest rake rubocop (~> 1.68) diff --git a/bin/ci b/bin/ci new file mode 100755 index 0000000..18af2f7 --- /dev/null +++ b/bin/ci @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +echo "[ bin/ci ] Running unit tests" +rake test + +echo "[ bin/ci ] Analyzing code for security vulnerabilities." +echo "[ bin/ci ] Output will be in tmp/brakeman.html, which" +echo "[ bin/ci ] can be opened in your browser." +bundle exec brakeman --force + +echo "[ bin/ci ] Analyzing Ruby gems for" +echo "[ bin/ci ] security vulnerabilities" +bundle exec bundle audit check --update + +echo "[ bin/ci ] Run Rubocop" +bin/rubocop + +echo "[ bin/ci ] Done" From 66f2dfcd8ec3e3b5b17bc1bdfaef198df784598f Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Tue, 3 Dec 2024 21:48:03 +0200 Subject: [PATCH 04/27] Add newline at the end of the file --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index de047c1..16844c9 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -38,4 +38,4 @@ jobs: run: bundle exec brakeman --force - name: Run Bundle Audit - run: bundle exec bundle audit \ No newline at end of file + run: bundle exec bundle audit From 34a402669d9bd951a1e479978940433bbaeab084 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 00:27:17 +0200 Subject: [PATCH 05/27] Rename and update bin/ci to bin/check --- bin/check | 24 ++++++++++++++++++++++++ bin/ci | 20 -------------------- bin/rubocop | 10 ---------- 3 files changed, 24 insertions(+), 30 deletions(-) create mode 100755 bin/check delete mode 100755 bin/ci delete mode 100755 bin/rubocop diff --git a/bin/check b/bin/check new file mode 100755 index 0000000..e348705 --- /dev/null +++ b/bin/check @@ -0,0 +1,24 @@ +#!/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 + +echo "🚧 [ bin/check ] Running CI pipeline for the gem..." + +# Run Brakeman (static analysis for security vulnerabilities in Rails apps) +echo "πŸ” [ bin/check ] Analyzing code for security vulnerabilities..." +brakeman --force || { echo "❌ [ bin/check ] Brakeman failed"; exit 1; } + +# Run bundle audit (checks for vulnerabilities in gem dependencies) +echo "πŸ” [ bin/check ] Analyzing Ruby gems for security vulnerabilities..." +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. All CI steps completed successfully!" diff --git a/bin/ci b/bin/ci deleted file mode 100755 index 18af2f7..0000000 --- a/bin/ci +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -set -e - -echo "[ bin/ci ] Running unit tests" -rake test - -echo "[ bin/ci ] Analyzing code for security vulnerabilities." -echo "[ bin/ci ] Output will be in tmp/brakeman.html, which" -echo "[ bin/ci ] can be opened in your browser." -bundle exec brakeman --force - -echo "[ bin/ci ] Analyzing Ruby gems for" -echo "[ bin/ci ] security vulnerabilities" -bundle exec bundle audit check --update - -echo "[ bin/ci ] Run Rubocop" -bin/rubocop - -echo "[ bin/ci ] Done" diff --git a/bin/rubocop b/bin/rubocop deleted file mode 100755 index f45b065..0000000 --- a/bin/rubocop +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require 'rubygems' -require 'bundler/setup' - -# explicit rubocop config increases performance slightly while avoiding config confusion. -ARGV.unshift('--config', File.expand_path('../.rubocop.yml', __dir__)) - -load Gem.bin_path('rubocop', 'rubocop') From 94af0a31caf9d32b70926794ccd226b9db6f8872 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 00:29:29 +0200 Subject: [PATCH 06/27] WIP: Play with github-workflow --- .github/workflows/check.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 16844c9..d8d3614 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -28,14 +28,5 @@ jobs: bundler-cache: true ruby-version: ${{ matrix.ruby }} - - name: Run unit tests - run: bundle exec rake - - - name: Run Rubocop - run: bundle exec rubocop - - - name: Run Brakeman - run: bundle exec brakeman --force - - - name: Run Bundle Audit - run: bundle exec bundle audit + - name: Running CI pipeline for the gem... + run: bin/check From ab2844f6decf0446de96c5f9f2428791d1144dee Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 00:32:50 +0200 Subject: [PATCH 07/27] WIP: Add bundle exec to the brakeman invocation in the bin/check --- bin/check | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/check b/bin/check index e348705..ab8788b 100755 --- a/bin/check +++ b/bin/check @@ -3,11 +3,9 @@ set -e # Exit immediately if a command exits with a non-zero status set -o pipefail # Fail if any part of a pipeline fails -echo "🚧 [ bin/check ] Running CI pipeline for the gem..." - # Run Brakeman (static analysis for security vulnerabilities in Rails apps) echo "πŸ” [ bin/check ] Analyzing code for security vulnerabilities..." -brakeman --force || { echo "❌ [ bin/check ] Brakeman failed"; exit 1; } +bundle exec brakeman --force || { echo "❌ [ bin/check ] Brakeman failed"; exit 1; } # Run bundle audit (checks for vulnerabilities in gem dependencies) echo "πŸ” [ bin/check ] Analyzing Ruby gems for security vulnerabilities..." From 71dc448092dd0cc01eba57c324d97c4ea10842c0 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 00:38:46 +0200 Subject: [PATCH 08/27] WIP: Update bin/check --- bin/check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/check b/bin/check index ab8788b..ff2c2ac 100755 --- a/bin/check +++ b/bin/check @@ -9,7 +9,7 @@ bundle exec brakeman --force || { echo "❌ [ bin/check ] Brakeman failed"; exit # Run bundle audit (checks for vulnerabilities in gem dependencies) echo "πŸ” [ bin/check ] Analyzing Ruby gems for security vulnerabilities..." -bundle audit check --update || { echo "❌ [ bin/check ] Bundle audit failed"; exit 1; } +bundle exec bundle-audit check --update || { echo "❌ [ bin/check ] Bundle audit failed"; exit 1; } # Run tests echo "πŸ§ͺ [ bin/check ] Running Minitest tests..." From 918bee600646e2173fb7ee0b5348f0485d9fefa7 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 00:41:43 +0200 Subject: [PATCH 09/27] WIP: Update github-workflow --- .github/workflows/check.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index d8d3614..a080d49 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -22,11 +22,26 @@ jobs: - name: Check out repository code uses: actions/checkout@v4 - - name: Install dependencies + - name: Install Ruby dependencies uses: ruby/setup-ruby@v1 with: bundler-cache: true ruby-version: ${{ matrix.ruby }} - - name: Running CI pipeline for the gem... + - name: Debug Environment + run: | + echo "Ruby version: $(ruby -v)" + echo "Bundler version: $(bundle -v)" + + - name: Ensure required gems are installed + run: bundle install + + - name: Run CI pipeline for the gem run: bin/check + + - name: Collect Brakeman warnings (Optional) + if: always() + run: | + mkdir -p reports + bin/check > reports/brakeman.log || true + continue-on-error: true From 4278d257b46815e5e4f442493ef814195be6a02d Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 00:52:43 +0200 Subject: [PATCH 10/27] Update CI workflow name --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a080d49..4eb1d41 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,4 +1,4 @@ -name: Check Branch +name: CI Workflow on: push: From 938df5881bae63b7c5097323cacebbff9b61450e Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 00:53:10 +0200 Subject: [PATCH 11/27] Mention particular ruby versions supported on CI check --- README.md | 8 ++++++++ scalar_ruby.gemspec | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4dd99f4..81d97df 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/scalar_ruby.gemspec b/scalar_ruby.gemspec index 70a671f..30f13f7 100644 --- a/scalar_ruby.gemspec +++ b/scalar_ruby.gemspec @@ -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', '< 3.4' end From 6a680f572525bd701dce7d13173d34c4e86d942d Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 00:58:18 +0200 Subject: [PATCH 12/27] Remove brakeman since it is specifically designed for Rails projects. --- .github/workflows/check.yml | 7 ------- Gemfile | 2 -- bin/check | 6 +----- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4eb1d41..cab2b7c 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -38,10 +38,3 @@ jobs: - name: Run CI pipeline for the gem run: bin/check - - - name: Collect Brakeman warnings (Optional) - if: always() - run: | - mkdir -p reports - bin/check > reports/brakeman.log || true - continue-on-error: true diff --git a/Gemfile b/Gemfile index 0c95dfe..f60322e 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,4 @@ gem 'rubocop', '~> 1.68' gem 'rubocop-minitest', '~> 0.36.0' gem 'rubocop-performance', '~> 1.23' -gem 'brakeman', '~> 6.2', require: false - gem 'bundler-audit', '~> 0.9.2' diff --git a/bin/check b/bin/check index ff2c2ac..08ed6cb 100755 --- a/bin/check +++ b/bin/check @@ -3,10 +3,6 @@ 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 Brakeman (static analysis for security vulnerabilities in Rails apps) -echo "πŸ” [ bin/check ] Analyzing code for security vulnerabilities..." -bundle exec brakeman --force || { echo "❌ [ bin/check ] Brakeman failed"; exit 1; } - # 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; } @@ -19,4 +15,4 @@ bundle exec rake test || { echo "❌ [ bin/check ] Tests failed"; exit 1; } echo "πŸ€– [ bin/check ] Running Rubocop..." bundle exec rubocop || { echo "❌ [ bin/check ] Rubocop failed"; exit 1; } -echo "βœ… [ bin/check ] Done. All CI steps completed successfully!" +echo "βœ… [ bin/check ] Done." From 2f4d788d7a7872b86026af5091ef34b63ab3fb35 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:02:50 +0200 Subject: [PATCH 13/27] WIP: Move appropriate gems into development group --- Gemfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index f60322e..0896f03 100644 --- a/Gemfile +++ b/Gemfile @@ -3,14 +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' - -gem 'bundler-audit', '~> 0.9.2' +group :development do + gem 'rubocop', '~> 1.68' + gem 'rubocop-minitest', '~> 0.36.0' + gem 'rubocop-performance', '~> 1.23' + gem 'bundler-audit', '~> 0.9.2', require: false +end From a16912d0a8a734cf0915a714deadd9abad98e576 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:05:08 +0200 Subject: [PATCH 14/27] Forget to add updated Gemfile.lock --- Gemfile.lock | 3 --- 1 file changed, 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 897a403..d612c57 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,8 +7,6 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.2) - brakeman (6.2.2) - racc bundler-audit (0.9.2) bundler (>= 1.2.0, < 3) thor (~> 1.0) @@ -50,7 +48,6 @@ PLATFORMS ruby DEPENDENCIES - brakeman (~> 6.2) bundler-audit (~> 0.9.2) minitest rake From fd03e9689f1286bfff421face3823190004a604a Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:06:33 +0200 Subject: [PATCH 15/27] Fix Rubocop issues --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 0896f03..3776ad7 100644 --- a/Gemfile +++ b/Gemfile @@ -9,8 +9,8 @@ gem 'minitest' gem 'rake' group :development do + gem 'bundler-audit', '~> 0.9.2', require: false gem 'rubocop', '~> 1.68' gem 'rubocop-minitest', '~> 0.36.0' gem 'rubocop-performance', '~> 1.23' - gem 'bundler-audit', '~> 0.9.2', require: false end From dc1e677f7fb5098f7af49bed9979c9932be75a22 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:11:27 +0200 Subject: [PATCH 16/27] Explicitly specifying bundler-with: development in the CI workflow ensures clarity and future-proofing --- .github/workflows/check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index cab2b7c..29dbd77 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -25,8 +25,9 @@ jobs: - name: Install Ruby dependencies uses: ruby/setup-ruby@v1 with: - bundler-cache: true ruby-version: ${{ matrix.ruby }} + bundler-cache: true + bundler-with: development - name: Debug Environment run: | From c6e104a3dd89f5da7b1e7dd7ac5c37816e843d16 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:18:10 +0200 Subject: [PATCH 17/27] Dynamically includes Ruby version in the job name --- .github/workflows/check.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 29dbd77..22f896c 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -7,7 +7,7 @@ on: branches: [main] jobs: - Check-Branch: + Test-Ruby: runs-on: ubuntu-latest strategy: @@ -18,6 +18,8 @@ jobs: - '3.2' - '3.3' + name: Ruby (${ { matrix.ruby } }) + steps: - name: Check out repository code uses: actions/checkout@v4 From cdaf57c1acd2df9524a9831e367bdd445bca14c3 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:20:25 +0200 Subject: [PATCH 18/27] Correctly evaluates Ruby version --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 22f896c..afa02d2 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -18,7 +18,7 @@ jobs: - '3.2' - '3.3' - name: Ruby (${ { matrix.ruby } }) + name: Ruby ${{ matrix.ruby }} steps: - name: Check out repository code From 02e24b44ce898e3cfe075ef6494d57bb7c69e8b8 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:29:14 +0200 Subject: [PATCH 19/27] Update names in CI workflow. Add installing gems in parallel --- .github/workflows/check.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index afa02d2..affaf70 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -24,7 +24,7 @@ jobs: - name: Check out repository code uses: actions/checkout@v4 - - name: Install Ruby dependencies + - name: Install Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -36,8 +36,8 @@ jobs: echo "Ruby version: $(ruby -v)" echo "Bundler version: $(bundle -v)" - - name: Ensure required gems are installed - run: bundle install + - name: Install dependencies + run: bundle install --jobs 4 --retry 3 - name: Run CI pipeline for the gem run: bin/check From 459a2e6c874a7af5878c4b94bceb06646a326c39 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:30:44 +0200 Subject: [PATCH 20/27] Move back parallelism --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index affaf70..00dc047 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -37,7 +37,7 @@ jobs: echo "Bundler version: $(bundle -v)" - name: Install dependencies - run: bundle install --jobs 4 --retry 3 + run: bundle install - name: Run CI pipeline for the gem run: bin/check From 3226b5b5964a293e738dda3aa7d2f2f5f5ab2fce Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 01:36:23 +0200 Subject: [PATCH 21/27] Add parallelism back With parallelism enabled: The average duration is 9.0 seconds. With parallelism disabled: The average duration is 12.75 seconds. This means that enabling parallelism made the process approximately 29.41% faster. This demonstrates the benefit of using the --jobs 4 option in our case. --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 00dc047..affaf70 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -37,7 +37,7 @@ jobs: echo "Bundler version: $(bundle -v)" - name: Install dependencies - run: bundle install + run: bundle install --jobs 4 --retry 3 - name: Run CI pipeline for the gem run: bin/check From d4c7a94520029c9af2065c91153714cc3ccb0e14 Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 02:22:32 +0200 Subject: [PATCH 22/27] Update rails install README.md --- lib/scalar/installers/rails/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/scalar/installers/rails/README.md b/lib/scalar/installers/rails/README.md index 7e76f87..f192283 100644 --- a/lib/scalar/installers/rails/README.md +++ b/lib/scalar/installers/rails/README.md @@ -4,7 +4,7 @@ title: Getting started with Rails # Getting started with Scalar on Rails -While Scalar can be used in any Ruby project, it’s especially great with [Rails](https://rubyonrails.org). +While Scalar can be used in any Ruby project, it’s especially great with [Ruby on Rails](https://rubyonrails.org). ## Setup @@ -22,5 +22,5 @@ bin/rails generate scalar:install This script will: -1. update `config/routes.rb` to mount `/docs` route. -2. generate `config/initializers/scalar.rb` +1. Update `config/routes.rb` to mount `/docs` route. +2. Generate `config/initializers/scalar.rb` From 1a385b4ece21df744134d6fccbc08d4183ee9dbf Mon Sep 17 00:00:00 2001 From: Serhii Ponomarov Date: Wed, 4 Dec 2024 02:32:46 +0200 Subject: [PATCH 23/27] Update README of Rails setup --- README.md | 4 ++-- lib/scalar/installers/rails/README.md | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 81d97df..b7f1dcc 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ bundle add scalar_ruby ## Getting Started #### Integrations -- [x] [Ruby on Rails]https://rubyonrails.org) +You can use in-build generator to setup gem into [Ruby in Rails](https://rubyonrails.org) framework followed by instructions: -[Setup with Rails framework](lib/scalar/installers/rails/README.md) +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. diff --git a/lib/scalar/installers/rails/README.md b/lib/scalar/installers/rails/README.md index f192283..6f2e117 100644 --- a/lib/scalar/installers/rails/README.md +++ b/lib/scalar/installers/rails/README.md @@ -1,7 +1,3 @@ ---- -title: Getting started with Rails ---- - # Getting started with Scalar on Rails While Scalar can be used in any Ruby project, it’s especially great with [Ruby on Rails](https://rubyonrails.org). From 181389496f86cd075959bf360ba93cc6e8655b9c Mon Sep 17 00:00:00 2001 From: Dmytro Date: Sun, 9 Feb 2025 22:08:21 +0200 Subject: [PATCH 24/27] Add TargetRubyVersion to rubocop config --- .rubocop.yml | 1 + scalar_ruby.gemspec | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index e03d38e..ba2a80d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,7 @@ require: AllCops: NewCops: enable SuggestExtensions: false + TargetRubyVersion: 3.0 Metrics/MethodLength: Exclude: diff --git a/scalar_ruby.gemspec b/scalar_ruby.gemspec index 30f13f7..c20a9d3 100644 --- a/scalar_ruby.gemspec +++ b/scalar_ruby.gemspec @@ -19,5 +19,5 @@ Gem::Specification.new do |spec| spec.files = Dir['{lib}/**/*', 'Rakefile', 'README.md'] spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 3.0', '< 3.4' + spec.required_ruby_version = '>= 3.0' end From a743d69324054118a1a388315c5c398cbeb1ea43 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Sun, 9 Feb 2025 22:13:56 +0200 Subject: [PATCH 25/27] Clean up check.yml file for CI --- .github/workflows/check.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index affaf70..9a4dda8 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -27,17 +27,14 @@ jobs: - name: Install Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} bundler-cache: true bundler-with: development + ruby-version: ${{ matrix.ruby }} - name: Debug Environment run: | echo "Ruby version: $(ruby -v)" echo "Bundler version: $(bundle -v)" - - name: Install dependencies - run: bundle install --jobs 4 --retry 3 - - name: Run CI pipeline for the gem run: bin/check From 51e91cfe8678599390ebb3c905eafe57b190ec9d Mon Sep 17 00:00:00 2001 From: Dmytro Date: Sun, 9 Feb 2025 22:16:29 +0200 Subject: [PATCH 26/27] Bump dependencies --- Gemfile | 8 ++++---- Gemfile.lock | 34 ++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Gemfile b/Gemfile index 3776ad7..88232e4 100644 --- a/Gemfile +++ b/Gemfile @@ -9,8 +9,8 @@ gem 'minitest' gem 'rake' group :development do - gem 'bundler-audit', '~> 0.9.2', require: false - gem 'rubocop', '~> 1.68' - gem 'rubocop-minitest', '~> 0.36.0' - gem 'rubocop-performance', '~> 1.23' + gem 'bundler-audit', require: false + gem 'rubocop' + gem 'rubocop-minitest' + gem 'rubocop-performance' end diff --git a/Gemfile.lock b/Gemfile.lock index d612c57..7db7539 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,50 +10,52 @@ GEM bundler-audit (0.9.2) bundler (>= 1.2.0, < 3) thor (~> 1.0) - json (2.8.2) - language_server-protocol (3.17.0.3) - minitest (5.25.1) + 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) thor (1.3.2) - unicode-display_width (2.6.0) + 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 (~> 0.9.2) + 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 From 8cbc25d33d8d2750cb9ca8ede7184bcc19086477 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Sun, 9 Feb 2025 22:36:28 +0200 Subject: [PATCH 27/27] Drop incomplete installers --- .../scalar/install/install_generator.rb | 2 +- .../scalar/install/templates/initializer.rb | 23 ++++++++++--------- lib/scalar/installers/grape/README.md | 1 - lib/scalar/installers/grape/installer.rb | 22 ------------------ lib/scalar/installers/rails/README.md | 22 ------------------ lib/scalar/installers/rails/installer.rb | 13 ----------- lib/scalar/installers/sinatra/README.md | 1 - lib/scalar/installers/sinatra/installer.rb | 22 ------------------ lib/tasks/scalar_install.rake | 21 ----------------- 9 files changed, 13 insertions(+), 114 deletions(-) delete mode 100644 lib/scalar/installers/grape/README.md delete mode 100644 lib/scalar/installers/grape/installer.rb delete mode 100644 lib/scalar/installers/rails/README.md delete mode 100644 lib/scalar/installers/rails/installer.rb delete mode 100644 lib/scalar/installers/sinatra/README.md delete mode 100644 lib/scalar/installers/sinatra/installer.rb delete mode 100644 lib/tasks/scalar_install.rake diff --git a/lib/generators/scalar/install/install_generator.rb b/lib/generators/scalar/install/install_generator.rb index 8edad53..0db086d 100644 --- a/lib/generators/scalar/install/install_generator.rb +++ b/lib/generators/scalar/install/install_generator.rb @@ -28,7 +28,7 @@ def create_initializer def farewell say <<~FAREWELL - We're done! Your can run "/docs" to observe a scalar API platform + We're done! Your can run "/docs" to observe a scalar API platform FAREWELL end diff --git a/lib/generators/scalar/install/templates/initializer.rb b/lib/generators/scalar/install/templates/initializer.rb index a28e95d..fcaff00 100644 --- a/lib/generators/scalar/install/templates/initializer.rb +++ b/lib/generators/scalar/install/templates/initializer.rb @@ -1,20 +1,21 @@ # frozen_string_literal: true Scalar.setup do |config| - # Configuration for the scalar + # Specify the specific version of the Scalar. By default it uses the latest one # - # config.page_title = "API Reference" # 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 = { - # # Whether the Swagger editor should be shown. - # isEditable: true, - # spec: { - # # Content: String. Directly pass an OpenAPI/Swagger spec. - # content: '{ ... }', - # # Content: String. Pass the URL of a spec file (JSON or Yaml). - # url: '/openapi.json' - # }, - # # ... + # theme: "purple" # } end diff --git a/lib/scalar/installers/grape/README.md b/lib/scalar/installers/grape/README.md deleted file mode 100644 index 2fd9f95..0000000 --- a/lib/scalar/installers/grape/README.md +++ /dev/null @@ -1 +0,0 @@ -TBD \ No newline at end of file diff --git a/lib/scalar/installers/grape/installer.rb b/lib/scalar/installers/grape/installer.rb deleted file mode 100644 index e2451e7..0000000 --- a/lib/scalar/installers/grape/installer.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Scalar - module Installers - module Grape - class Installer - def self.install - File.write('config/initializer_scalar.rb', grape_initializer_content) - end - - def self.grape_initializer_content - <<~CONTENT - # Scalar Grape configuration - Scalar.configure do |config| - # Add custom configurations - end - CONTENT - end - end - end - end -end diff --git a/lib/scalar/installers/rails/README.md b/lib/scalar/installers/rails/README.md deleted file mode 100644 index 6f2e117..0000000 --- a/lib/scalar/installers/rails/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Getting started with Scalar on Rails - -While Scalar can be used in any Ruby project, it’s especially great with [Ruby on Rails](https://rubyonrails.org). - -## Setup - -To use Scalar with Rails, you’ll need to install the [`scalar_ruby`](https://rubygems.org/gems/scalar_ruby) gem. Add your gem into the project Gemfile via bundler: - -```bash -bundle add scalar_ruby -``` - -Once the gem is installed, run the install generator. - -```bash -bin/rails generate scalar:install -``` - -This script will: - -1. Update `config/routes.rb` to mount `/docs` route. -2. Generate `config/initializers/scalar.rb` diff --git a/lib/scalar/installers/rails/installer.rb b/lib/scalar/installers/rails/installer.rb deleted file mode 100644 index af68a92..0000000 --- a/lib/scalar/installers/rails/installer.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module Scalar - module Installers - module Rails - class Installer - def self.install - system('bin/rails generate scalar:rails') - end - end - end - end -end diff --git a/lib/scalar/installers/sinatra/README.md b/lib/scalar/installers/sinatra/README.md deleted file mode 100644 index 2fd9f95..0000000 --- a/lib/scalar/installers/sinatra/README.md +++ /dev/null @@ -1 +0,0 @@ -TBD \ No newline at end of file diff --git a/lib/scalar/installers/sinatra/installer.rb b/lib/scalar/installers/sinatra/installer.rb deleted file mode 100644 index 6b8d3f9..0000000 --- a/lib/scalar/installers/sinatra/installer.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Scalar - module Installers - module Sinatra - class Installer - def self.install - File.write('config/initializer_scalar.rb', sinatra_initializer_content) - end - - def self.sinatra_initializer_content - <<~CONTENT - # Scalar Sinatra configuration - Scalar.configure do |config| - # Add custom configurations - end - CONTENT - end - end - end - end -end diff --git a/lib/tasks/scalar_install.rake b/lib/tasks/scalar_install.rake deleted file mode 100644 index a27015b..0000000 --- a/lib/tasks/scalar_install.rake +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -namespace :scalar do - desc 'Install Scalar for a specific framework' - task :install, [:framework] do |_t, args| - framework = args[:framework]&.downcase - case framework - when 'rails' - require_relative '../scalar/installers/rails_installer' - Scalar::Installers::RailsInstaller.install - when 'sinatra' - require_relative '../scalar/installers/sinatra_installer' - Scalar::Installers::SinatraInstaller.install - when 'grape' - require_relative '../scalar/installers/grape_installer' - Scalar::Installers::GrapeInstaller.install - else - puts "Unsupported framework. Please specify 'rails', 'sinatra', or 'grape'." - end - end -end