Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to modern FbF standards #1

Merged
merged 5 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
charset=utf-8
19 changes: 9 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
name: tests

on:
- push

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ['2.x']
steps:
- name: check out source
uses: actions/checkout@v2
- name: set up ruby
uses: actions/setup-ruby@v1
- name: Checkout source
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: build and test
bundler-cache: true
- name: Build and test
run: |
gem install bundler
bundle install --jobs 4 --retry 3
Expand All @@ -23,7 +22,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
mkdir ~/.gem
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
Expand Down
166 changes: 166 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
AllCops:
NewCops: enable
TargetRubyVersion: 3.3.0

Bundler/OrderedGems:
Enabled: false

Layout/ArgumentAlignment:
Enabled: false
EnforcedStyle: with_fixed_indentation

Layout/BlockEndNewline:
Enabled: false

Layout/DefEndAlignment:
EnforcedStyleAlignWith: 'start_of_line'

Layout/ElseAlignment:
Enabled: false

Layout/EndAlignment:
EnforcedStyleAlignWith: 'start_of_line'

Layout/FirstArgumentIndentation:
EnforcedStyle: 'consistent'

Layout/FirstArrayElementIndentation:
EnforcedStyle: 'consistent'

Layout/FirstHashElementIndentation:
EnforcedStyle: 'consistent'

Layout/HashAlignment:
Exclude:
- 'lib/tasks/auto_annotate_models.rake'

Layout/IndentationWidth:
Enabled: false

Layout/LineLength:
Enabled: false

Layout/MultilineBlockLayout:
Enabled: false

Layout/MultilineMethodCallBraceLayout:
Enabled: false

Layout/MultilineMethodCallIndentation:
Enabled: false

Layout/ParameterAlignment:
EnforcedStyle: 'with_first_parameter'

Layout/RescueEnsureAlignment:
Enabled: false

Lint/AmbiguousBlockAssociation:
Enabled: false

Lint/ShadowingOuterLocalVariable:
Enabled: false

Lint/SuppressedException:
Exclude:
- 'db/**/*'

Lint/UnusedMethodArgument:
AllowUnusedKeywordArguments: true

Metrics/AbcSize:
Max: 66
Exclude:
- '**/db/**/*'

Metrics/BlockLength:
Enabled: false

Metrics/ClassLength:
Enabled: false

Metrics/CyclomaticComplexity:
Max: 15

Metrics/MethodLength:
Enabled: false

Metrics/ModuleLength:
Enabled: false

Metrics/ParameterLists:
Max: 6

Metrics/PerceivedComplexity:
Max: 15

Naming/VariableNumber:
CheckSymbols: false

Naming/BlockForwarding:
Enabled: false

Style/Alias:
EnforcedStyle: 'prefer_alias_method'

Style/NumericLiterals:
AllowedPatterns:
- \d{4}_\d{2}_\d{2}_\d{6}

Style/Documentation:
Enabled: false

Style/EmptyMethod:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Style/HashAsLastArrayItem:
EnforcedStyle: no_braces

Style/IfInsideElse:
Enabled: false

Style/IfUnlessModifier:
Enabled: false

Style/Lambda:
EnforcedStyle: 'literal'

Style/MixinUsage:
Exclude:
- 'bin/*'

Style/MultilineBlockChain:
Enabled: false

Style/MutableConstant:
Enabled: false

Style/OpenStructUse:
Enabled: false

Style/PercentLiteralDelimiters:
Enabled: false

Style/PerlBackrefs:
Enabled: false

Style/RegexpLiteral:
AllowInnerSlashes: true

Style/RescueModifier:
Enabled: false

Style/RescueStandardError:
Enabled: false

Style/SymbolArray:
EnforcedStyle: 'brackets'

Style/WordArray:
Enabled: false

Style/HashSyntax:
Enabled: false
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.0
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in rich-text.gemspec
gemspec
12 changes: 6 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require "bundler/gem_tasks"
require "rake/testtask"
require "yard"
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'yard'

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end

YARD::Rake::YardocTask.new(:doc)

task :default => :test
task default: :test
109 changes: 109 additions & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'bundle' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "rubygems"

m = Module.new do
module_function

def invoked_as_script?
File.expand_path($0) == File.expand_path(__FILE__)
end

def env_var_version
ENV["BUNDLER_VERSION"]
end

def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1
update_index = i
end
bundler_version
end

def gemfile
gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?

File.expand_path("../Gemfile", __dir__)
end

def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
end

def lockfile_version
return unless File.file?(lockfile)
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Regexp.last_match(1)
end

def bundler_requirement
@bundler_requirement ||=
env_var_version ||
cli_arg_version ||
bundler_requirement_for(lockfile_version)
end

def bundler_requirement_for(version)
return "#{Gem::Requirement.default}.a" unless version

bundler_gem_version = Gem::Version.new(version)

bundler_gem_version.approximate_recommendation
end

def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile

activate_bundler
end

def activate_bundler
gem_error = activation_error_handling do
gem "bundler", bundler_requirement
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
end
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end

def activation_error_handling
yield
nil
rescue StandardError, LoadError => e
e
end
end

m.load_bundler!

if m.invoked_as_script?
load Gem.bin_path("bundler", "bundle")
end
27 changes: 27 additions & 0 deletions bin/htmldiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'htmldiff' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("diff-lcs", "htmldiff")
Loading