diff --git a/.cirrus.yaml b/.cirrus.yaml new file mode 100644 index 0000000..49ebeee --- /dev/null +++ b/.cirrus.yaml @@ -0,0 +1,114 @@ +bundle_cache: &bundle_cache + bundle_cache: + folder: /usr/local/bundle + fingerprint_script: + - echo $CIRRUS_OS + - ruby -v + - cat Gemfile + - cat *.gemspec + install_script: + - gem install bundler + - bundle update + +remark_task: + container: + image: node + node_modules_cache: + folder: node_modules + fingerprint_script: + - echo $CIRRUS_OS + - node -v + - cat package.json + install_script: npm install + lint_script: npm run remark + only_if: ($CIRRUS_BRANCH == 'master') || + changesInclude( + '.cirrus.yaml', '.gitignore', 'package.json', '.remarkrc.yaml', '**.md' + ) + +bundle-audit_task: + container: + image: ruby + <<: *bundle_cache + bundle-audit_script: bundle audit check --update + only_if: ($CIRRUS_BRANCH == 'master') || + changesInclude( + '.cirrus.yaml', '.gitignore', 'Gemfile', '*.gemspec' + ) + +rubocop_task: + container: + image: ruby + <<: *bundle_cache + lint_script: bundle exec rubocop + only_if: ($CIRRUS_BRANCH == 'master') || + changesInclude( + '.cirrus.yaml', '.gitignore', 'Gemfile', 'Rakefile', '.rubocop.yml', '*.gemspec', + '**.rb', '**.ru' + ) + +rspec_task: + + depends_on: + - remark + - rubocop + + container: + ## https://cirrus-ci.com/task/5233441622982656?command=bundle#L3 + image: ruby + + os_setup_script: + ## https://cirrus-ci.com/task/6357513148825600 + ## https://cirrus-ci.com/task/6270527041961984?command=os_setup#L535 + - apt update && apt upgrade -y && apt install git make gcc -y + + ## Modify `.bashrc` here because it doesn't run on cache hit: + ## https://cirrus-ci.com/task/6153771409473536?command=test#L42 + + ## https://cirrus-ci.com/task/6270527041961984?command=os_setup#L543 + - echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc + ## https://cirrus-ci.com/task/5656294977699840?command=os_setup#L633 + - echo 'eval "$(rbenv init -)"' >> ~/.bashrc + + ## https://cirrus-ci.com/task/6270527041961984?command=os_setup#L543 + - echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc + ## https://cirrus-ci.com/task/5656294977699840?command=os_setup#L633 + - echo 'eval "$(nodenv init -)"' >> ~/.bashrc + + always: + rbenv_cache: + folder: $HOME/.rbenv + populate_script: + - git clone https://github.com/rbenv/rbenv.git ~/.rbenv + + - source ~/.bashrc + + ## https://github.com/rbenv/ruby-build#installation + - mkdir -p "$(rbenv root)"/plugins + - git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build + + nodenv_cache: + folder: $HOME/.nodenv + populate_script: + - git clone https://github.com/nodenv/nodenv.git ~/.nodenv + + - source ~/.bashrc + + ## https://github.com/nodenv/node-build#installation + - mkdir -p "$(nodenv root)"/plugins + - git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build + + <<: *bundle_cache + + environment: + CODECOV_TOKEN: ENCRYPTED[5bfb9cd3d53a72c8423ce1b84b18cf7d30fbdcf3a56a25f9cd79dbdff1c3552542578272db8088ec27d7de7f2c363d72] + + test_script: + - source ~/.bashrc + - bundle exec rspec + + only_if: ($CIRRUS_BRANCH == 'master') || + changesInclude( + '.cirrus.yaml', '.gitignore', 'Gemfile', 'Rakefile', '.rspec', + '*.gemspec', 'lib/**', 'spec/**' + ) diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index d8baee0..0000000 --- a/.cirrus.yml +++ /dev/null @@ -1,25 +0,0 @@ -bundle_cache: &bundle_cache - bundle_cache: - folder: /usr/local/bundle - fingerprint_script: - - echo $CIRRUS_OS - - ruby -v - - cat Gemfile - - cat *.gemspec - install_script: - - gem install bundler - - bundle update - -test_task: - container: - image: ruby:2.6 - <<: *bundle_cache - environment: - CODECOV_TOKEN: ENCRYPTED[5bfb9cd3d53a72c8423ce1b84b18cf7d30fbdcf3a56a25f9cd79dbdff1c3552542578272db8088ec27d7de7f2c363d72] - test_script: bundle exec rake - -rubocop_task: - container: - image: ruby:2.6 - <<: *bundle_cache - rubocop_script: bundle exec rubocop diff --git a/.editorconfig b/.editorconfig index 686e508..9fab75a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,11 +2,17 @@ root = true [*] indent_style = tab +indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true +max_line_length = 100 [*.y{a,}ml] indent_style = space indent_size = 2 + +[*.md] +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore index 6f198b7..2f96481 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,10 @@ -Gemfile.lock -.ruby-version -!template/.ruby-version +/Gemfile.lock +/.ruby-version -# Gem files -*.gem +/node_modules/ +/package-lock.json +/yarn.lock -# Tests coverage -coverage/ +/coverage/ + +/pkg/ diff --git a/.remarkrc.yaml b/.remarkrc.yaml new file mode 100644 index 0000000..755a2b1 --- /dev/null +++ b/.remarkrc.yaml @@ -0,0 +1,2 @@ +plugins: + - remark-preset-lint-recommended diff --git a/.rspec b/.rspec index f308d93..c04af2f 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --require spec_helper.rb --warnings +--color diff --git a/.rubocop.yml b/.rubocop.yml index 389bfb9..c0f4925 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,23 +2,30 @@ require: - rubocop-performance - rubocop-rspec -Layout/Tab: - Enabled: false +inherit_mode: + merge: + - Include + - Exclude + +Layout/IndentationStyle: + EnforcedStyle: tabs IndentationWidth: 2 Layout/IndentationWidth: Width: 1 +Layout/LineLength: + Max: 100 Layout/MultilineMethodCallIndentation: EnforcedStyle: indented Layout/MultilineOperationIndentation: EnforcedStyle: indented -Layout/ParameterAlignment: - EnforcedStyle: with_fixed_indentation Layout/ArgumentAlignment: EnforcedStyle: with_fixed_indentation -Layout/FirstParameterIndentation: - EnforcedStyle: consistent +Layout/ParameterAlignment: + EnforcedStyle: with_fixed_indentation Layout/FirstArgumentIndentation: EnforcedStyle: consistent +Layout/FirstParameterIndentation: + EnforcedStyle: consistent Layout/FirstArrayElementIndentation: EnforcedStyle: consistent Layout/FirstHashElementIndentation: @@ -27,37 +34,23 @@ Layout/MultilineArrayBraceLayout: EnforcedStyle: new_line Layout/MultilineHashBraceLayout: EnforcedStyle: new_line -Layout/FirstArrayElementLineBreak: - Enabled: true -Layout/FirstHashElementLineBreak: - Enabled: true -Layout/FirstMethodArgumentLineBreak: - Enabled: true -Layout/FirstMethodParameterLineBreak: - Enabled: true Style/ParenthesesAroundCondition: AllowInMultilineConditions: true -Style/HashEachMethods: - Enabled: true -Style/HashTransformKeys: - Enabled: true -Style/HashTransformValues: - Enabled: true - -Lint/RaiseException: - Enabled: true -Lint/StructNewOverride: - Enabled: true AllCops: TargetRubyVersion: 2.6 + NewCops: enable Metrics/BlockLength: Exclude: - 'spec/**/*' - '*.gemspec' +RSpec/NestedGroups: + Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false ## Because of we're testing CLI through native calls RSpec/DescribeClass: Enabled: false diff --git a/.toys.rb b/.toys.rb new file mode 100644 index 0000000..7c5c925 --- /dev/null +++ b/.toys.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +include :bundler, static: true + +require 'gem_toys' +expand GemToys::Template + +alias_tool :g, :gem diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f755226 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## master (unreleased) + +* Initial release. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..a15107b --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Alexander Popov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae2d2f2 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Flame CLI + +[![Cirrus CI - Base Branch Build Status](https://img.shields.io/cirrus/github/AlexWayfer/flame-cli?style=flat-square)](https://cirrus-ci.com/github/AlexWayfer/flame-cli) +[![Codecov branch](https://img.shields.io/codecov/c/github/AlexWayfer/flame-cli/master.svg?style=flat-square)](https://codecov.io/gh/AlexWayfer/flame-cli) +[![Code Climate](https://img.shields.io/codeclimate/maintainability/AlexWayfer/flame-cli.svg?style=flat-square)](https://codeclimate.com/github/AlexWayfer/flame-cli) +[![Depfu](https://img.shields.io/depfu/AlexWayfer/flame-cli?style=flat-square)](https://depfu.com/repos/github/AlexWayfer/flame-cli) +[![Inline docs](https://inch-ci.org/github/AlexWayfer/flame-cli.svg?branch=master)](https://inch-ci.org/github/AlexWayfer/flame-cli) +[![license](https://img.shields.io/github/license/AlexWayfer/flame-cli.svg?style=flat-square)](https://github.com/AlexWayfer/flame-cli/blob/master/LICENSE.txt) +[![Gem](https://img.shields.io/gem/v/flame-cli.svg?style=flat-square)](https://rubygems.org/gems/flame-cli) + +CLI for [Flame web framework](https://github.com/AlexWayfer/flame). + +## Installation + +Install it globally as: + +```shell +gem install flame-cli +``` + +## Usage + +```ruby +flame --help +``` + +## Development + +After checking out the repo, run `bundle install` to install dependencies. + +Then, run `toys rspec` to run the tests. + +To install this gem onto your local machine, run `toys gem install`. + +To release a new version, run `toys gem release %version%`. +See how it works [here](https://github.com/AlexWayfer/gem_toys#release). + +## Contributing + +Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/flame-cli). + +## License + +The gem is available as open source under the terms of the +[MIT License](https://opensource.org/licenses/MIT). diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 4c8a81e..0000000 --- a/Rakefile +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -begin - require 'rspec/core/rake_task' - - RSpec::Core::RakeTask.new(:spec) - - task default: :spec -rescue LoadError - puts 'No RSpec available' -end diff --git a/flame-cli.gemspec b/flame-cli.gemspec index d6634b8..c283568 100644 --- a/flame-cli.gemspec +++ b/flame-cli.gemspec @@ -1,43 +1,49 @@ # frozen_string_literal: true -Gem::Specification.new do |s| - s.name = 'flame-cli' - s.version = '0.0.0' +Gem::Specification.new do |spec| + spec.name = 'flame-cli' + spec.version = '0.0.0' - s.summary = 'CLI for Flame Web-framework' - s.description = 'Generate new application and maybe something else.' + spec.summary = 'CLI for Flame web framework' + spec.description = 'Generate new application and maybe something else.' - s.authors = ['Alexander Popov'] - s.email = ['alex.wayfer@gmail.com'] - s.homepage = 'https://github.com/AlexWayfer/flame-cli' - s.license = 'MIT' + spec.authors = ['Alexander Popov'] + spec.email = ['alex.wayfer@gmail.com'] + spec.homepage = 'https://github.com/AlexWayfer/flame-cli' + spec.license = 'MIT' - s.metadata = { + spec.metadata = { 'bug_tracker_uri' => 'https://github.com/AlexWayfer/flame-cli/issues', 'documentation_uri' => - "http://www.rubydoc.info/gems/flame-cli/#{s.version}", + "http://www.rubydoc.info/gems/flame-cli/#{spec.version}", 'homepage_uri' => 'https://github.com/AlexWayfer/flame-cli', 'source_code_uri' => 'https://github.com/AlexWayfer/flame-cli', 'wiki_uri' => 'https://github.com/AlexWayfer/flame-cli/wiki' } - s.required_ruby_version = '>= 2.6' - - s.add_runtime_dependency 'clamp', '~> 1.3' - s.add_runtime_dependency 'gorilla_patch', '~> 3.0' - - s.add_development_dependency 'bundler', '~> 2.1' - s.add_development_dependency 'codecov', '~> 0.1' - s.add_development_dependency 'pry', '~> 0.12' - s.add_development_dependency 'pry-byebug', '~> 3.5' - s.add_development_dependency 'rake', '~> 13.0' - s.add_development_dependency 'rspec', '~> 3.7' - s.add_development_dependency 'rubocop', '~> 0.81.0' - s.add_development_dependency 'rubocop-performance', '~> 1.5' - s.add_development_dependency 'rubocop-rspec', '~> 1.38' - s.add_development_dependency 'simplecov', '~> 0.16' - - s.files = Dir.glob('{lib,template}/**/*', File::FNM_DOTMATCH) - s.bindir = 'exe' - s.executables = ['flame'] + spec.required_ruby_version = '~> 2.6' + + spec.add_runtime_dependency 'clamp', '~> 1.3' + spec.add_runtime_dependency 'gorilla_patch', '~> 4.0' + + spec.add_development_dependency 'pry-byebug', '~> 3.9' + + spec.add_development_dependency 'bundler', '~> 2.0' + spec.add_development_dependency 'gem_toys', '~> 0.5.0' + spec.add_development_dependency 'toys', '~> 0.11.0' + + spec.add_development_dependency 'bundler-audit', '~> 0.7.0' + + spec.add_development_dependency 'codecov', '~> 0.2.0' + spec.add_development_dependency 'rspec', '~> 3.9' + spec.add_development_dependency 'simplecov', '~> 0.20.0' + + spec.add_development_dependency 'example_file', '~> 0.2.0' + spec.add_development_dependency 'rubocop', '~> 1.0' + spec.add_development_dependency 'rubocop-performance', '~> 1.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.0' + + spec.files = Dir.glob('{lib,template}/**/*', File::FNM_DOTMATCH) + spec.bindir = 'exe' + spec.executables = ['flame'] end diff --git a/lib/flame/cli/new/app.rb b/lib/flame/cli/new/app.rb index ebe5986..a19ef23 100644 --- a/lib/flame/cli/new/app.rb +++ b/lib/flame/cli/new/app.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'date' + module Flame class CLI < Clamp::Command class New < Clamp::Command @@ -9,11 +11,11 @@ class App < Clamp::Command parameter 'APP_NAME', 'application name' + option ['-d', '--domain'], 'NAME', 'domain name for configuration' + option ['-p', '--project-name'], 'NAME', 'project name for code and configuration' + def execute - @app_name = app_name - @module_name = @app_name.camelize - @short_module_name = @module_name - .split(/([[:upper:]][[:lower:]]*)/).map! { |s| s[0] }.join + initialize_instance_variables make_dir do copy_template @@ -26,6 +28,17 @@ def execute private + def initialize_instance_variables + @app_name = app_name + + @module_name = project_name || @app_name.camelize + + @short_module_name = + @module_name.split(/([[:upper:]][[:lower:]]*)/).map! { |s| s[0] }.join + + @domain_name = domain || "#{@module_name.downcase}.com" + end + def make_dir(&block) puts "Creating '#{@app_name}' directory..." FileUtils.mkdir @app_name @@ -46,7 +59,7 @@ def clean_dirs def render_templates puts 'Replace module names in template...' - Dir.glob('**/*.erb', File::FNM_DOTMATCH).each do |file| + Dir.glob('**/*.erb', File::FNM_DOTMATCH).sort.each do |file| file_pathname = Pathname.new(file) basename_pathname = file_pathname.sub_ext('') puts "- #{basename_pathname}" @@ -56,9 +69,13 @@ def render_templates end end + PERMISSIONS = {}.freeze + def grant_permissions + return unless PERMISSIONS.any? + puts 'Grant permissions to files...' - File.chmod 0o744, 'server' + PERMISSIONS.each { |file, permissions| File.chmod permissions, file } end end end diff --git a/package.json b/package.json new file mode 100644 index 0000000..95f608a --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "scripts": { + "remark": "remark ." + }, + "devDependencies": { + "remark-cli": "^8.0.0", + "remark-preset-lint-recommended": "^4.0.0" + } +} diff --git a/spec/flame/cli/new/app_spec.rb b/spec/flame/cli/new/app_spec.rb index 0f8cc3f..5ae5e7e 100644 --- a/spec/flame/cli/new/app_spec.rb +++ b/spec/flame/cli/new/app_spec.rb @@ -3,20 +3,24 @@ require 'pathname' require 'net/http' +require 'example_file' + describe 'Flame::CLI::New::App' do subject(:execute_command) do - Bundler.with_original_env { `#{FLAME_CLI} new app #{app_name}` } + `#{FLAME_CLI} new app #{options} #{app_name}` end let(:app_name) { 'foo_bar' } + let(:options) { nil } let(:root_dir) { "#{__dir__}/../../../.." } let(:template_dir) { "#{root_dir}/template" } let(:template_dir_pathname) { Pathname.new(template_dir) } let(:template_ext) { '.erb' } + let(:temp_app_dir) { "#{root_dir}/#{app_name}" } after do - FileUtils.rm_r "#{root_dir}/#{app_name}" + FileUtils.rm_r temp_app_dir end describe 'output' do @@ -26,21 +30,37 @@ 'Copy template directories and files...', 'Clean directories...', 'Replace module names in template...', + '- .toys/.toys.rb', + '- README.md', + '- application.rb', '- config.ru', + '- config/database.example.yaml', + '- config/mail.example.yaml', + '- config/main.rb', + '- config/processors/mail.rb', + '- config/processors/r18n.rb', + '- config/processors/sentry.rb', + '- config/processors/server.rb', + '- config/processors/sequel.rb', + '- config/processors/shrine.rb', + '- config/puma.rb', + '- config/sentry.example.yaml', + '- config/site.example.yaml', '- constants.rb', - '- application.rb', '- controllers/_controller.rb', '- controllers/site/_controller.rb', '- controllers/site/index_controller.rb', - '- routes.rb', + '- forms/_base.rb', + '- mailers/_base.rb', + '- mailers/mail/_base.rb', + '- mailers/mail/default.rb', + '- rollup.config.js', + '- views/site/errors/400.html.erb', + '- views/site/errors/404.html.erb', + '- views/site/errors/500.html.erb', '- views/site/index.html.erb', '- views/site/layout.html.erb', - '- rollup.config.js', - '- config/config.rb', - '- config/site.example.yaml', - '- config/processors/logger.rb', - '- config/processors/sequel.rb.bak', - 'Grant permissions to files...', + # 'Grant permissions to files...', 'Done!' ] end @@ -82,7 +102,7 @@ end describe 'cleans directories' do - subject { Dir.glob("#{app_name}/**/.keep", File::FNM_DOTMATCH) } + subject { Dir.glob("#{temp_app_dir}/**/.keep", File::FNM_DOTMATCH) } before { execute_command } @@ -96,280 +116,687 @@ before { execute_command } - describe '.toys/config/check.rb' do - let(:expected_words) do - [ - 'ExampleFile.all(FB::Application.config[:config_dir])' - ] + describe 'default behavior' do + describe '.toys/.toys.rb' do + let(:expected_words) do + [ + 'FB::Application', + 'expand FlameGenerateToys::Template, namespace: FooBar' + ] + end + + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'application.rb' do + let(:expected_words) do + [ + 'module FooBar' + ] + end - describe '.toys/database/.preload.rb' do - let(:expected_words) do - [ - '@db_config = FB::Application.config[:database]', - '@db_connection = FB::Application.db_connection' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config.ru' do + let(:expected_words) do + [ + 'FB::Application.setup', + 'if FB::Application.config[:session]', + 'use Rack::Session::Cookie, FB::Application.config[:session][:cookie]', + 'use Rack::CommonLogger, FB::Application.logger', + 'FB::App = FB::Application', + 'run FB::Application' + ] + end - describe '.toys/generate/form/template.rb.erb' do - let(:expected_words) do - [ - 'module FooBar' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/main.rb' do + let(:expected_words) do + [ + 'config = FB::Application.config', + 'FB::Config::Processors.const_get(processor_name).new self' + ] + end - describe '.toys/generate/model/template.rb.erb' do - let(:expected_words) do - [ - 'module FooBar' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/puma.rb' do + let(:expected_words) do + [ + 'config = FB::Application.config' + ] + end - describe '.toys/routes.rb' do - let(:expected_words) do - [ - 'puts FB::Application.router.routes' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/database.example.yaml' do + let(:expected_words) do + [ + ":database: 'foo_bar'", + ":user: 'foo_bar'" + ] + end - describe 'application.rb' do - let(:expected_words) do - [ - 'module FooBar' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/mail.example.yaml' do + let(:expected_words) do + [ + ":name: 'FooBar.com'", + ":email: 'info@foobar.com'", + ":user_name: 'info@foobar.com'" + ] + end - describe 'config.ru' do - let(:expected_words) do - [ - 'FB::Application.require_dirs FB::APP_DIRS', - 'if FB::Application.config[:session]', - 'use Rack::Session::Cookie, ' \ - 'FB::Application.config[:session][:cookie]', - 'use Rack::CommonLogger, FB::Application.logger', - 'run FB::Application' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/sentry.example.yaml' do + let(:expected_words) do + [ + ':host: sentry.foobar.com' + ] + end - describe 'config/config.rb' do - let(:expected_words) do - [ - 'FB::Application.config.instance_exec do', - 'FB::ConfigProcessors.const_get(processor_name).new self' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/server.example.yaml' do + let(:expected_words) do + [ + ":unix: '/run/foo_bar/puma.sock'" + ] + end - describe 'config/processors/logger.rb' do - let(:expected_words) do - [ - 'module FooBar' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/processors/mail.rb' do + let(:expected_words) do + [ + 'module FooBar' + ] + end - describe 'config/processors/sequel.rb.bak' do - let(:expected_words) do - [ - 'module FooBar', - 'FB::Application.db_connection.extension extension_name', - 'FB::Application.db_connection.loggers << FB::Application.logger', - "FB::Application.db_connection.freeze unless ENV['RACK_CONSOLE']" - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/processors/r18n.rb' do + let(:expected_words) do + [ + 'module FooBar' + ] + end - describe 'constants.rb' do - let(:expected_words) do - [ - 'module FooBar', - '::FB = ::FooBar', - 'APP_DIRS =' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/processors/sentry.rb' do + let(:expected_words) do + [ + 'module FooBar', + 'FB::APP_DIRS' + ] + end - describe 'controllers/_controller.rb' do - let(:expected_words) do - [ - 'module FooBar', - 'FB::Application.logger' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/processors/server.rb' do + let(:expected_words) do + [ + 'module FooBar' + ] + end - describe 'controllers/site/_controller.rb' do - let(:expected_words) do - [ - 'module FooBar', - 'class Controller < FB::Controller' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/processors/sequel.rb' do + let(:expected_words) do + [ + 'module FooBar' + ] + end - describe 'controllers/site/index_controller.rb' do - let(:expected_words) do - [ - 'module FooBar', - 'class IndexController < FB::Site::Controller' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'config/processors/shrine.rb' do + let(:expected_words) do + [ + 'module FooBar' + ] + end - describe 'README.md' do - let(:expected_words) do - [ - '# FooBar', - '`createuser -U postgres foo_bar`', - '`createdb -U postgres foo_bar -O foo_bar`', - '`psql -U postgres -c "CREATE EXTENSION citext" foo_bar`', - 'Add UNIX-user for project: `adduser foo_bar`', - 'Make symbolic link of project directory to `/var/www/foo_bar`' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'constants.rb' do + let(:expected_words) do + [ + 'module FooBar', + '::FB = self' + ] + end - describe 'rollup.config.js' do - let(:expected_words) do - [ - "name: 'FB'" - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'controllers/_controller.rb' do + let(:expected_words) do + [ + 'module FooBar', + 'FB::Application.logger' + ] + end - describe 'routes.rb' do - let(:expected_words) do - [ - 'FB::Application.class_exec do' - ] + it { is_expected.to match_words(*expected_words) } end - it { is_expected.to match_words(*expected_words) } - end + describe 'controllers/site/_controller.rb' do + let(:expected_words) do + [ + 'module FooBar', + 'class Controller < FB::Controller' + ] + end - describe 'views/site/layout.html.erb' do - let(:expected_words) do - [ - '
', + '<% end %>', + '', + '<%= t.button.back %>' + ] + end + + it { is_expected.to match_words(*expected_words) } + end + + describe 'views/site/layout.html.erb' do + let(:expected_words) do + ## https://github.com/rubocop-hq/rubocop/issues/8416 + # rubocop:disable Lint/InterpolationCheck + [ + '<%==', + '%>
<%', + '%><%=', + '%>
<% end %><%=', + '%>
+ <%%= t.error.bad_request.text %> +
+ + + <%%= t.button.back %> + ++ <%%= t.error.unexpected_error.text %> +
+ + <%% if config[:environment] == 'development' %> ++ <%% end %> + +<%%== + "#{@exception.class} - #{@exception.message}" + %>
<%% + if @exception.respond_to? :sql + %><%%= + @exception.sql + %>
<%% end %><%%= + highlighted_backtrace_for @exception + %>