diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3c0eb46 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a33a04a..4c9d32b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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 diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..2993003 --- /dev/null +++ b/.rubocop.yml @@ -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 diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..15a2799 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.3.0 diff --git a/Gemfile b/Gemfile index 1795cc9..fa75df1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in rich-text.gemspec gemspec diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000..50da5fd --- /dev/null +++ b/bin/bundle @@ -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 diff --git a/bin/console b/bin/console index 994a555..51b2752 100755 --- a/bin/console +++ b/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env ruby -require 'bundler/setup' -require 'rich-text' +require "bundler/setup" +require "rich-text" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. @@ -10,5 +10,5 @@ require 'rich-text' # require "pry" # Pry.start -require 'irb' +require "irb" IRB.start diff --git a/bin/htmldiff b/bin/htmldiff new file mode 100755 index 0000000..0aeaec8 --- /dev/null +++ b/bin/htmldiff @@ -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") diff --git a/bin/ldiff b/bin/ldiff new file mode 100755 index 0000000..8173ede --- /dev/null +++ b/bin/ldiff @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'ldiff' 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", "ldiff") diff --git a/bin/nokogiri b/bin/nokogiri new file mode 100755 index 0000000..c00ec26 --- /dev/null +++ b/bin/nokogiri @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'nokogiri' 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("nokogiri", "nokogiri") diff --git a/bin/racc b/bin/racc new file mode 100755 index 0000000..8190015 --- /dev/null +++ b/bin/racc @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'racc' 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("racc", "racc") diff --git a/bin/rake b/bin/rake index 5aa8950..4eb7d7b 100755 --- a/bin/rake +++ b/bin/rake @@ -8,14 +8,12 @@ # this file is here to facilitate running it. # -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', - Pathname.new(__FILE__).realpath) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -bundle_binstub = File.expand_path('bundle', __dir__) +bundle_binstub = File.expand_path("bundle", __dir__) if File.file?(bundle_binstub) - if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/ + 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. @@ -23,7 +21,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this end end -require 'rubygems' -require 'bundler/setup' +require "rubygems" +require "bundler/setup" -load Gem.bin_path('rake', 'rake') +load Gem.bin_path("rake", "rake") diff --git a/bin/yard b/bin/yard new file mode 100755 index 0000000..ea9daf5 --- /dev/null +++ b/bin/yard @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'yard' 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("yard", "yard") diff --git a/bin/yardoc b/bin/yardoc new file mode 100755 index 0000000..e1324dc --- /dev/null +++ b/bin/yardoc @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'yardoc' 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("yard", "yardoc") diff --git a/bin/yri b/bin/yri new file mode 100755 index 0000000..f968fde --- /dev/null +++ b/bin/yri @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'yri' 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("yard", "yri") diff --git a/lib/rich-text/version.rb b/lib/rich-text/version.rb index 94e9bca..8e1cecd 100644 --- a/lib/rich-text/version.rb +++ b/lib/rich-text/version.rb @@ -1,3 +1,3 @@ module RichText - VERSION = '0.4.0' + VERSION = '0.4.0'.freeze end diff --git a/rich-text.gemspec b/rich-text.gemspec index 75e0616..f13a4f1 100644 --- a/rich-text.gemspec +++ b/rich-text.gemspec @@ -19,14 +19,14 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.7.0' + spec.required_ruby_version = '>= 3.3.0' - spec.add_dependency 'activesupport', '>= 3.0.0' - spec.add_dependency 'diff-lcs', '~> 1.5.1' - spec.add_dependency 'nokogiri', '>= 1.0.0' + spec.add_dependency 'activesupport', '>= 7.1.3' + spec.add_dependency 'diff-lcs', '>= 1.5.1' + spec.add_dependency 'nokogiri', '>= 1.16.2' spec.add_development_dependency 'bundler' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'minitest' + spec.add_development_dependency 'rake' spec.add_development_dependency 'yard' end diff --git a/test/unit/delta_test.rb b/test/unit/delta_test.rb index eff35ee..f1bdcac 100644 --- a/test/unit/delta_test.rb +++ b/test/unit/delta_test.rb @@ -208,9 +208,6 @@ # end # end - describe '=~' do - end - describe 'compose' do let(:a) { RichText::Delta.new.insert('a') } let(:b) { RichText::Delta.new.insert('b') }