diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fec5ab4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: Ruby CI + +on: + push: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + ruby-version: [3.1.0, 3.0.0, 2.7.5] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby ${{ matrix.ruby-version }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Install dependencies + run: bundle install + + - name: Run tests + run: bundle exec rake spec diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c6b86f0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,17 @@ +name: Linting + +on: + push: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + bundler-cache: true + - run: bundle install + - name: Rubocop + run: bundle exec rake rubocop diff --git a/.gitignore b/.gitignore index 20bf1d5..9ddffcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,4 @@ -# File generated by script/bootstrap -/.bundle/ -/bin -/vendor/ruby -/vendor/gems/ -/vendor/cache/ruby/ - +*.gem *.rbc .bundle .config @@ -17,6 +11,7 @@ spec/reports test/tmp test/version_tmp tmp +vendor/cache Gemfile.lock out/ @@ -28,5 +23,8 @@ docs/ # YARD artifacts .yardoc _yardoc -doc/ + .DS_Store +.idea +.byebug_history +.vscode diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..08d42f3 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,6 @@ +inherit_gem: + rubocop-standard: + - config/default.yml + +Naming/FileName: + Enabled: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3cc1286..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: ruby -script: "./script/cibuild" -rvm: - - 2.4 - - 2.5 - - 2.6 - - 2.7 - -sudo: false -cache: bundler - -notifications: - email: - on_success: never - on_failure: never - -git: - depth: 10 diff --git a/Gemfile b/Gemfile index d65e2a6..f7200f1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' gemspec diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/README.md b/README.md index 880f17d..b228c3f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # ecma-re-validator -[![Build Status](https://travis-ci.org/gjtorikian/ecma-re-validator.svg?branch=master)](https://travis-ci.org/gjtorikian/ecma-re-validator) - Pass in a string to validate if it would work in ECMA-262, aka JavaScript. The information for what is valid and what isn't comes from . diff --git a/Rakefile b/Rakefile index 72f3920..b438f3a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler' Bundler::GemHelper.install_tasks @@ -5,4 +7,8 @@ require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -task :default => [:spec] +task default: [:spec] + +require 'rubocop/rake_task' + +RuboCop::RakeTask.new(:rubocop) diff --git a/ecma-re-validator.gemspec b/ecma-re-validator.gemspec index afcd03b..7d796a6 100644 --- a/ecma-re-validator.gemspec +++ b/ecma-re-validator.gemspec @@ -12,14 +12,19 @@ Gem::Specification.new do |gem| gem.summary = %(Validate a regular expression string against what ECMA-262 can actually do.) gem.homepage = 'https://github.com/gjtorikian/ecma-re-validator' gem.license = 'MIT' - gem.files = `git ls-files -z`.split("\x0").reject { |f| f =~ %r{^vendor/.*} } + gem.files = `git ls-files -z`.split("\x0").grep_v(%r{^vendor/.*}) gem.test_files = gem.files.grep(%r{^(spec)/}) gem.require_paths = ['lib'] + gem.required_ruby_version = ['>= 2.6.0', '< 4.0'] gem.add_dependency 'regexp_parser', '~> 2.2' - gem.add_development_dependency 'rspec', '~> 3.1' - gem.add_development_dependency 'rake', '~> 13.0' gem.add_development_dependency 'awesome_print' - gem.add_development_dependency 'pry', '~> 0.10' + gem.add_development_dependency 'rake', '~> 13.0' + gem.add_development_dependency 'rspec', '~> 3.1' + + gem.add_development_dependency 'rubocop' + gem.add_development_dependency 'rubocop-rspec' + gem.add_development_dependency 'rubocop-standard' + gem.metadata['rubygems_mfa_required'] = 'true' end diff --git a/lib/ecma-re-validator.rb b/lib/ecma-re-validator.rb index c6242fb..08c6238 100644 --- a/lib/ecma-re-validator.rb +++ b/lib/ecma-re-validator.rb @@ -1,12 +1,8 @@ -begin - require 'awesome_print' - require 'pry' -rescue LoadError; end +# frozen_string_literal: true require 'regexp_parser' module EcmaReValidator - # JS doesn't have Unicode matching UNICODE_CHARACTERS = Regexp::Syntax::Token::UnicodeProperty::All @@ -27,7 +23,7 @@ module EcmaReValidator :condition_open, # JS doesn't support comments :comment - ] + ].freeze INVALID_TOKENS = INVALID_REGEXP + UNICODE_CHARACTERS diff --git a/spec/anchors_spec.rb b/spec/anchors_spec.rb index d8429e4..5992a79 100644 --- a/spec/anchors_spec.rb +++ b/spec/anchors_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::Anchors' do diff --git a/spec/atomic_grouping_spec.rb b/spec/atomic_grouping_spec.rb index c8c7f58..be4bf7c 100644 --- a/spec/atomic_grouping_spec.rb +++ b/spec/atomic_grouping_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::AtomicGrouping' do diff --git a/spec/comments_spec.rb b/spec/comments_spec.rb index f9149f5..182dd97 100644 --- a/spec/comments_spec.rb +++ b/spec/comments_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::Comments' do @@ -8,15 +10,14 @@ end it 'should fail if regexp has inline comments across lines' do - re = %r{ + re = / start # some text \s # white space char (group) # first group (?:alt1|alt2) # some alternation end - }x + /x expect(EcmaReValidator.valid?(re)).to eql(false) end - end diff --git a/spec/conditionals_spec.rb b/spec/conditionals_spec.rb index 57746e3..4c5b27d 100644 --- a/spec/conditionals_spec.rb +++ b/spec/conditionals_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::Conditionals' do diff --git a/spec/lookbehind_spec.rb b/spec/lookbehind_spec.rb index 9dc89f6..7a7dd95 100644 --- a/spec/lookbehind_spec.rb +++ b/spec/lookbehind_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::Lookbehind' do diff --git a/spec/mode_modifiers_spec.rb b/spec/mode_modifiers_spec.rb index fc1f543..f1fa269 100644 --- a/spec/mode_modifiers_spec.rb +++ b/spec/mode_modifiers_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::ModeModifiers' do diff --git a/spec/named_capture_groups_spec.rb b/spec/named_capture_groups_spec.rb index 39beb61..3e3c53d 100644 --- a/spec/named_capture_groups_spec.rb +++ b/spec/named_capture_groups_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::NamedCaptureGroups' do diff --git a/spec/possesive_quantifiers_spec.rb b/spec/possesive_quantifiers_spec.rb index 2d3dd80..48f031d 100644 --- a/spec/possesive_quantifiers_spec.rb +++ b/spec/possesive_quantifiers_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::PossesiveQuantifiers' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f155b43..7526b75 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'bundler/setup' -require_relative "../lib/ecma-re-validator" +require_relative '../lib/ecma-re-validator' RSpec.configure do |config| # Use color in STDOUT diff --git a/spec/unicode_spec.rb b/spec/unicode_spec.rb index d7ac9ea..32dd769 100644 --- a/spec/unicode_spec.rb +++ b/spec/unicode_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaReValidator::Unicode' do diff --git a/spec/validator_spec.rb b/spec/validator_spec.rb index 38d0ed6..068854a 100644 --- a/spec/validator_spec.rb +++ b/spec/validator_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'EcmaRe' do @@ -14,7 +16,7 @@ end it 'passes for a valid regexp string' do - re = "[Ss]mith\\\\b" + re = '[Ss]mith\\\\b' expect(EcmaReValidator.valid?(re)).to eql(true) end diff --git a/vendor/cache/coderay-1.1.3.gem b/vendor/cache/coderay-1.1.3.gem deleted file mode 100644 index 3475820..0000000 Binary files a/vendor/cache/coderay-1.1.3.gem and /dev/null differ diff --git a/vendor/cache/method_source-1.0.0.gem b/vendor/cache/method_source-1.0.0.gem deleted file mode 100644 index 2e035c3..0000000 Binary files a/vendor/cache/method_source-1.0.0.gem and /dev/null differ diff --git a/vendor/cache/rspec-3.10.0.gem b/vendor/cache/rspec-3.10.0.gem deleted file mode 100644 index 8932c9c..0000000 Binary files a/vendor/cache/rspec-3.10.0.gem and /dev/null differ