diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..cd40236 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1 @@ +FROM ghcr.io/rails/devcontainer/images/ruby:3.3.6 diff --git a/.devcontainer/compose.yml b/.devcontainer/compose.yml new file mode 100644 index 0000000..2e720dd --- /dev/null +++ b/.devcontainer/compose.yml @@ -0,0 +1,22 @@ +name: "app" +services: + html2rss-web: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + ports: + - "3000:3000" + volumes: + - ../..:/workspaces:cached + - type: bind + source: ../config/feeds.yml + target: /app/config/feeds.yml + read_only: true + environment: + RACK_ENV: development + HEALTH_CHECK_USERNAME: health + HEALTH_CHECK_PASSWORD: please-set-YOUR-OWN-veeeeeery-l0ng-aNd-h4rd-to-gue55-Passw0rd! + AUTO_SOURCE_ENABLED: true + AUTO_SOURCE_USERNAME: foo + AUTO_SOURCE_PASSWORD: bar + AUTO_SOURCE_ALLOWED_ORIGINS: 127.0.0.1:3000 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..1c72b25 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "app", + "service": "html2rss-web", + "dockerComposeFile": "compose.yml", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + "forwardPorts": [ + 3000 + ], + "customizations": { + "vscode": { + "settings": { + "ruby.format": true, + "ruby.lint": true + }, + "extensions": [ + "Shopify.ruby-lsp" + ] + } + }, + "postCreateCommand": "bundle install" +} diff --git a/.rubocop.yml b/.rubocop.yml index 57ebd90..b6e4977 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,7 +11,7 @@ AllCops: Metrics/BlockLength: Exclude: - Rakefile - ExcludedMethods: + AllowedMethods: - route Naming/RescuedExceptionsVariableName: diff --git a/.ruby-version b/.ruby-version index 15a2799..9c25013 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.0 +3.3.6 diff --git a/README.md b/README.md index 6619447..775c136 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,10 @@ When you specify `SENTRY_DSN` in your environment variables, the application wil Check out the git repository and… +### using Devcontainer (recommended) + +Open the cloned repository in your devcontainer supporting IDE (i.e. VSCode). That's it. Happy coding. + ### Using Docker This approach allows you to experiment without installing Ruby on your machine. diff --git a/app.rb b/app.rb index a75142c..2acccca 100644 --- a/app.rb +++ b/app.rb @@ -56,13 +56,7 @@ def self.development? = ENV['RACK_ENV'] == 'development' plugin :typecast_params plugin :basic_auth - Dir['routes/**/*.rb'].each do |f| - if development? - Unreloader.require f - else - require_relative f - end - end + Dir['routes/**/*.rb'].each { |f| require_relative f } route do |r| r.public @@ -83,13 +77,7 @@ def self.development? = ENV['RACK_ENV'] == 'development' end end - Dir['helpers/*.rb'].each do |f| - if development? - Unreloader.require f - else - require_relative f - end - end + Dir['helpers/*.rb'].each { |f| require_relative f } end end end diff --git a/config.ru b/config.ru index 9f084cd..e381d66 100644 --- a/config.ru +++ b/config.ru @@ -29,7 +29,12 @@ if ENV.key?('SENTRY_DSN') end dev = ENV.fetch('RACK_ENV', nil) == 'development' -requires = Dir['app/**/*.rb'] +requires = Dir[ + 'app/**/*.rb', + 'helpers/**/*.rb', + 'roda/**/*.rb', + 'routes/**/*.rb', +] if dev require 'logger' diff --git a/spec/html2rss/web/helpers/auto_source_spec.rb b/spec/html2rss/web/helpers/auto_source_spec.rb index e9e6b2d..64022af 100644 --- a/spec/html2rss/web/helpers/auto_source_spec.rb +++ b/spec/html2rss/web/helpers/auto_source_spec.rb @@ -10,6 +10,15 @@ RSpec.describe Html2rss::Web::AutoSource do # rubocop:disable RSpec/SpecFilePathFormat context 'when ENV variables are not set' do + around do |example| + ClimateControl.modify AUTO_SOURCE_ENABLED: nil, + AUTO_SOURCE_USERNAME: nil, + AUTO_SOURCE_PASSWORD: nil, + AUTO_SOURCE_ALLOWED_ORIGINS: nil do + example.run + end + end + describe '.enabled?' do subject { described_class.enabled? }