Skip to content

Commit c713c7e

Browse files
authored
Update GitHub actions (#50)
- update github actions build; add new MRI versions and JRuby - add Dockerfile - rm some dev dependencies - update Readme - update RAW data
1 parent 5593e40 commit c713c7e

File tree

17 files changed

+186
-155
lines changed

17 files changed

+186
-155
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Gemfile.lock

.github/workflows/build.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,27 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v4
1010
- uses: ruby/setup-ruby@v1
1111
with:
12-
ruby-version: 2.7
13-
- name: install gems
14-
run: |
15-
gem install bundler
16-
bundle install --jobs 4 --retry 3
12+
ruby-version: '3.0'
13+
bundler-cache: true
1714
- run: bundle exec rubocop
1815
test:
1916
needs: lint
2017
runs-on: ubuntu-latest
2118
strategy:
2219
fail-fast: false
2320
matrix:
24-
ruby: [2.5, 2.6, 2.7, 3.0, 3.1]
21+
ruby: [2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, jruby-9.3, jruby-head]
2522
test-group: [1, 2, 3, 4]
2623
name: Ruby ${{ matrix.ruby }}, test-group ${{ matrix.test-group }}
2724
steps:
28-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v4
2926
- uses: ruby/setup-ruby@v1
3027
with:
3128
ruby-version: ${{ matrix.ruby }}
32-
- name: install gems
33-
run: |
34-
gem install bundler
35-
bundle install --jobs 4 --retry 3
29+
bundler-cache: true
3630
- name: test
3731
run: |
3832
bundle exec parallel_rspec spec/ -n 4 --only-group ${{ matrix.test-group }} --group-by runtime --runtime-log spec/fixtures/parallel_runtime_rspec.log

.gitignore

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,58 @@
1-
/.bundle/
2-
/.yardoc
3-
/_yardoc/
1+
*.gem
2+
*.rbc
3+
/.config
44
/coverage/
5-
/doc/
5+
/InstalledFiles
66
/pkg/
77
/spec/reports/
8+
/spec/examples.txt
9+
/test/tmp/
10+
/test/version_tmp/
811
/tmp/
912

10-
# rspec failure tracking
11-
.rspec_status
13+
# Used by dotenv library to load environment variables.
14+
# .env
15+
16+
# Ignore Byebug command history file.
17+
.byebug_history
18+
19+
## Specific to RubyMotion:
20+
.dat*
21+
.repl_history
22+
build/
23+
*.bridgesupport
24+
build-iPhoneOS/
25+
build-iPhoneSimulator/
26+
27+
## Specific to RubyMotion (use of CocoaPods):
28+
#
29+
# We recommend against adding the Pods directory to your .gitignore. However
30+
# you should judge for yourself, the pros and cons are mentioned at:
31+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32+
#
33+
# vendor/Pods/
34+
35+
## Documentation cache and generated files:
36+
/.yardoc/
37+
/_yardoc/
38+
/doc/
39+
/rdoc/
40+
41+
## Environment normalization:
42+
/.bundle/
43+
/vendor/bundle
44+
/lib/bundler/man/
45+
46+
# for a library or gem, you might want to ignore these files since the code is
47+
# intended to run in multiple environments; otherwise, check them in:
48+
Gemfile.lock
49+
.ruby-version
50+
.ruby-gemset
51+
52+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53+
.rvmrc
54+
55+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
56+
# .rubocop-https?--*
57+
58+
.idea

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ inherit_gem:
55
- lib/rubocop.rspec.yml
66

77
AllCops:
8-
TargetRubyVersion: 2.7.1
8+
TargetRubyVersion: 2.5
9+
NewCops: enable
910
Include:
1011
- lib/**/*.rb
1112
- spec/**/*.rb

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ARG RUBY_VERSION="2.5"
2+
FROM ruby:$RUBY_VERSION-alpine
3+
4+
ARG BUNDLER_VERSION="2.3"
5+
RUN gem install bundler -v $BUNDLER_VERSION
6+
7+
RUN apk add --no-cache --update --upgrade \
8+
git make gcc libc-dev
9+
10+
WORKDIR /app
11+
12+
COPY crawler_detect.gemspec ./
13+
COPY Gemfile ./
14+
COPY lib/crawler_detect/version.rb ./lib/crawler_detect/
15+
16+
RUN bundle install
17+
18+
COPY . .
19+
20+
CMD ["bundle", "exec", "rubocop"]

Gemfile.lock

Lines changed: 0 additions & 117 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Comparing with other popular bot-detection gems:
1717

1818
In order to remain up-to-date, this gem does not accept any crawler data updates – any PRs to edit the crawler data should be offered to the original [JayBizzle/CrawlerDetect](https://github.com/JayBizzle/Crawler-Detect) project.
1919

20+
## Requirements
21+
22+
- Ruby: MRI 2.5+ or JRuby 9.3+.
23+
2024
## Installation
2125
Add this line to your application's Gemfile:
2226

@@ -69,5 +73,14 @@ end
6973
```
7074
Make sure that your files are correct JSON files.
7175
Look at [the raw files](https://github.com/loadkpi/crawler_detect/tree/master/lib/crawler_detect/library/raw) which are used by default for more information.
76+
77+
## Development
78+
79+
You can run `rubocop` \ `rspec` with any ruby version using docker like this:
80+
```bash
81+
docker build --build-arg RUBY_VERSION=3.3 --build-arg BUNDLER_VERSION=2.5 -t crawler_detect:3.3 .
82+
docker run -it crawler_detect:3.3 bundle exec rspec
83+
```
84+
7285
## License
7386
MIT License

crawler_detect.gemspec

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ Gem::Specification.new do |spec|
2424
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2525
spec.require_paths = ["lib"]
2626

27-
spec.add_dependency "qonfig", "~> 0.24"
27+
spec.add_dependency "qonfig", ">= 0.24"
2828

29-
spec.add_development_dependency "activesupport", "~> 6.0.3"
30-
spec.add_development_dependency "bundler", ">= 1.15"
31-
spec.add_development_dependency "fuubar", "~> 2.0"
32-
spec.add_development_dependency "parallel_tests", "~> 2.0"
33-
spec.add_development_dependency "pry-meta", "~> 0.0.10"
34-
spec.add_development_dependency "rack-test", "~> 1.1"
35-
spec.add_development_dependency "rake", ">= 10.0"
36-
spec.add_development_dependency "rspec", "~> 3.0"
37-
spec.add_development_dependency "armitage-rubocop", "0.82"
29+
spec.add_development_dependency "activesupport", ">= 6.0"
30+
spec.add_development_dependency "fuubar", ">= 2.5"
31+
spec.add_development_dependency "parallel_tests", ">= 3.0"
32+
spec.add_development_dependency "rack-test", ">= 2.1"
33+
spec.add_development_dependency "rake", ">= 13.1"
34+
spec.add_development_dependency "rspec", ">= 3.13"
35+
spec.add_development_dependency "armitage-rubocop", ">= 0.82"
36+
37+
spec.required_ruby_version = ">= 2.5.0"
3838
end

docker-compose.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: "3"
2+
services:
3+
ruby2.5:
4+
build:
5+
context: ./
6+
dockerfile: Dockerfile
7+
args:
8+
RUBY_VERSION: 2.5
9+
BUNDLER_VERSION: 2.3
10+
ruby2.6:
11+
build:
12+
context: ./
13+
dockerfile: Dockerfile
14+
args:
15+
RUBY_VERSION: 2.6
16+
BUNDLER_VERSION: 2.4
17+
ruby2.7:
18+
build:
19+
context: ./
20+
dockerfile: Dockerfile
21+
args:
22+
RUBY_VERSION: 2.7
23+
BUNDLER_VERSION: 2.4
24+
ruby3.0:
25+
build:
26+
context: ./
27+
dockerfile: Dockerfile
28+
args:
29+
RUBY_VERSION: 3.0
30+
BUNDLER_VERSION: 2.4
31+
ruby3.3:
32+
build:
33+
context: ./
34+
dockerfile: Dockerfile
35+
args:
36+
RUBY_VERSION: 3.3
37+
BUNDLER_VERSION: 2.5

lib/crawler_detect/detector.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ def initialize(user_agent)
1111

1212
# @return [true, false] Is User-agent a crawler?
1313
def is_crawler?
14-
@is_crawler ||= begin
15-
!completely_exclusion? && matches_crawler_list?
16-
end
14+
@is_crawler ||= !completely_exclusion? && matches_crawler_list?
1715
end
1816

1917
# @return [String] The detected crawler name from RAW data
@@ -28,7 +26,7 @@ def crawler_name
2826
# @return [true, false] Is User-agent in white-list?
2927
def completely_exclusion?
3028
@user_agent.gsub!(exclusions_matcher, "")
31-
@user_agent.strip.length.zero?
29+
@user_agent.strip.empty?
3230
end
3331

3432
# @private

0 commit comments

Comments
 (0)