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

fix: refactor to Ruby 3.x.x compliance and latest build practices #1

Merged
merged 29 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0fc9a9e
fix: update rspec should syntax to use expect
davidjrice Apr 2, 2024
55259fa
fix: update Gemfile adding source and latest versions of rspec & deps
davidjrice Apr 2, 2024
e470c73
fix: deprecate jeweler and use bundler gem tasks instead
davidjrice Apr 3, 2024
101959d
fix: deprecate usage of rspec-rails, unrequired
davidjrice Apr 3, 2024
8680d9d
bump: version to 0.1.0
davidjrice Apr 3, 2024
523f1d5
fix: remove deprecated rubygems version management
davidjrice Apr 3, 2024
0f95909
fix: remove reference to rspec rails
davidjrice Apr 3, 2024
40fc612
feature: add github workflow to run rspec specs
davidjrice Apr 3, 2024
4c6777b
feature: test on multiple versions of ruby
davidjrice Apr 3, 2024
c5d8326
fix: github workflow declaration
davidjrice Apr 3, 2024
f75aa69
feature: add gem bundling check
davidjrice Apr 3, 2024
00b582d
fix: remove autotest from deps
davidjrice Apr 3, 2024
525ef73
feature: add rubygems release action
davidjrice Apr 3, 2024
f8ca429
fix: update Rakefile to use rspec
davidjrice Apr 4, 2024
cfe1a9e
fix: add rspec as development dependency and move to gemspec
davidjrice Apr 4, 2024
784e69a
fix: update gemspec to modern standards
davidjrice Apr 4, 2024
786c9cc
fix: add checksums to .gitignore
davidjrice Apr 4, 2024
3e5a836
bump: atco version in Gemfile.lock
davidjrice Apr 4, 2024
fddeecb
fix: rakefile instructions
davidjrice Apr 4, 2024
84a8d9d
docs: update TODOs
davidjrice Apr 4, 2024
61e6fa5
fix: update to modern Ruby syntax 🔥💎
davidjrice Apr 4, 2024
2479e7f
fix: more ruby modernisation
davidjrice Apr 4, 2024
39896b7
build: add rubocop
davidjrice Apr 4, 2024
ee71c43
docs: remove unncessary stuff
davidjrice Apr 4, 2024
3576628
fix: remove autotest (for now)
davidjrice Apr 4, 2024
9e9301d
fix: remove empty .rspec file
davidjrice Apr 4, 2024
2249b0a
docs: move the ATCO-CIF spec to docs
davidjrice Apr 4, 2024
283b6c7
docs: update README
davidjrice Apr 4, 2024
950df03
docs: refactor TODOs and README
davidjrice Apr 4, 2024
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
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .github/workflows/release.yml
jobs:
push:
name: Push gem to RubyGems.org
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

steps:
# Set up
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ruby

- name: Build gem
run: |
gem install bundler
bundle install --jobs 4 --retry 3
gem build *.gemspec

# Release
- uses: rubygems/release-gem@v1
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: RSpec

on:
push:
branches: [ master ]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [
'3.0.6',
'3.1.4',
'3.2.3',
'3.3.0'
]

steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Install dependencies
run: |
gem install bundler
bundle install --jobs 4 --retry 3

- name: Run tests
run: bundle exec rspec spec

- name: Test gem bundling
run: bundle check
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.DS_Store
test.output
fixture.output
pkg/*
pkg/*
checksums/*
Empty file removed .rspec
Empty file.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inherit_from: .rubocop_todo.yml
87 changes: 87 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-04-04 12:44:01 UTC using RuboCop version 1.62.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/DuplicatedAssignment:
Exclude:
- 'atco.gemspec'

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'atco.gemspec'

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 42

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 148

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 150

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 14

# Offense count: 4
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 35

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 153

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 16

# Offense count: 1
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'lib/atco/location.rb'

# Offense count: 1
Style/ClassVars:
Exclude:
- 'lib/atco.rb'

# Offense count: 4
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/atco.rb'
- 'lib/atco/journey.rb'
- 'lib/atco/location.rb'
- 'lib/atco/stop.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 159
11 changes: 7 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
gem 'rspec'
gem 'rspec-rails', '>= 2.0.0.beta.7'
gem 'autotest-rails'
gem 'autotest'
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

gem 'rubocop', require: false
113 changes: 57 additions & 56 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
PATH
remote: .
specs:
atco (1.0.0)

GEM
remote: https://rubygems.org/
specs:
ZenTest (4.4.2)
abstract (1.0.0)
actionpack (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
i18n (~> 0.4)
activesupport (3.0.4)
autotest (4.4.6)
ZenTest (>= 4.4.1)
autotest-rails (4.1.0)
ZenTest
builder (2.1.2)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.5.0)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
railties (3.0.4)
actionpack (= 3.0.4)
activesupport (= 3.0.4)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)
rspec-core (2.5.1)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
rspec-rails (2.5.0)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.5.0)
thor (0.14.6)
tzinfo (0.3.24)
ast (2.4.2)
diff-lcs (1.5.1)
json (2.7.2)
language_server-protocol (3.17.0.3)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
racc (1.7.3)
rainbow (3.1.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
ruby-progressbar (1.13.0)
unicode-display_width (2.5.0)

PLATFORMS
ruby
aarch64-linux
arm-linux
arm64-darwin
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
autotest
autotest-rails
atco!
rspec
rspec-rails (>= 2.0.0.beta.7)
rubocop

BUNDLED WITH
2.5.3
33 changes: 19 additions & 14 deletions README.mdown → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@

ATCO-CIF is the format of choice for UK public transport authorities. This is a ruby library that reads **.cif** files and gives you JSON back.

* ATCO (Association of Transport Coordinating Officers)
* CIF (Common Interface File)

* **Official spec:** [http://www.pti.org.uk/CIF/atco-cif-spec.pdf](http://www.pti.org.uk/CIF/atco-cif-spec.pdf)

### USAGE

Currently this library is under-development and has several things left to do before it is perfect (see the [todo.mdown](http://github.com/davidjrice/atco/blob/master/todo.mdown) list ).
Currently this library is under-development and has several things left to do before it is perfect (see the [todo.md](http://github.com/davidjrice/atco/blob/master/TODO.md) list ).

* clone this library
* start an irb session
* put the cif file in ./data (needs to change from being hardcoded)

Code example, for more detailed internal api usage see the spec files.

gem install atco
irb

```ruby
gem install atco
irb


require 'rubygems
require 'atco'

require 'rubygems
require 'atco'

result = Atco.parse('filename.cif')
result = Atco.parse('SVRTMAO009A-20091005.cif) # an example data file in the repo
result = Atco.parse('filename.cif')
result = Atco.parse('SVRTMAO009A-20091005.cif) # an example data file in the repo

=> {
:header => {...},
:locations => [...],
:journies => {...}
}
=> {
header: {…},
locations: […],
journies: {…}
}
```
22 changes: 10 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = "atco"
s.summary = "Simple and opinionated library for parsing ATCO-CIF files with Ruby."
s.email = "[email protected]"
s.homepage = "http://github.com/davidjrice/atco"
s.description = "Simple and opinionated library for parsing ATCO-CIF files with Ruby."
s.authors = ["David Rice"]
s.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
end
RSpec::Core::RakeTask.new(:spec)
rescue LoadError
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
end
puts 'RSpec, or one of its dependencies, is not available. Install it with: bundle install'
end

task default: :spec
Loading
Loading