Skip to content

Upgrade to support Rails <= 7.1 and Ruby <= 3.2 #4

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

Merged
merged 4 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
41 changes: 41 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby

on:
push:
branches: ['master']
pull_request:
branches: ['master']
schedule:
- cron: '0 0 * * 0'

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2']
activerecord: ['6.0', '6.1', '7.0', '7.1']
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.activerecord }}.gemfile
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ test/dummy/.sass-cache
vendor/bundle
Gemfile.lock
.ruby-version
gemfiles/*.gemfile.lock
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

15 changes: 15 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appraise "rails-6.0" do
gem 'rails', '6.0.6.1'
end

appraise "rails-6.1" do
gem 'rails', '~> 6.1'
end

appraise "rails-7.0" do
gem 'rails', '7.0.8.4'
end

appraise "rails-7.1" do
gem 'rails', '~> 7.1'
end
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

### Unreleased

### Version 6.0.0

- Furthermore support Rails 7.0
- Removing the dependencies for sprocket-rails as a consequences of that gem no longer needed in Rails 7

### Version 5.0.0

- Add dependencies to support Rails 6.1
- parent_name is deprecated in rails 6 and gone in 6.1
- Update I18n translation function
- Change assertion function in spec
- Bump ruby version to be at least 3.0

### Version 4.0.0

- [Pull Request 28](https://github.com/winston/rails_utils/pull/28) - [Development] remove `.ruby-version` file - by @JuanitoFatas
Expand Down
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
Rails helpers based on opinionated project practices. Useful for structuring CSS and JavaScript,
display title of the page, and flash messages with Bootstrap.

## Forkception

This repo is a fork of:

- The [fonglh](https://github.com/fonglh/rails_utils) gem
- which is the fork of the original gem maintained by [Winston](https://github.com/winston/rails_utils)

## Requirements

- Ruby >= 3.0, <= 3.2
- Rails >= 6.0, <= 7.1

The library might work for the higher version, however it's only tested for the specs mentioned above.

## Installation

Add rails_utils to your application's Gemfile:
Expand Down Expand Up @@ -36,7 +50,7 @@ you can use `page_class` to include the controller name and action name as CSS c
becomes

```html
<body class='animes show'>
<body class="animes show">
...
</body>
```
Expand Down Expand Up @@ -79,9 +93,7 @@ When controller and action is `animes#show` you can easily use `page_title` like
becomes

```html
<div class="page-title">
Animes Show
</div>
<div class="page-title">Animes Show</div>
```

Besides, it supports I18n and interpolation:
Expand All @@ -104,9 +116,7 @@ Pass in `anime_name`:
becomes

```html
<div class="page-title">
Showing anime of: Frozen
</div>
<div class="page-title">Showing anime of: Frozen</div>
```

### #`javascript_initialization`
Expand All @@ -130,13 +140,17 @@ compiles to:

```html
<script type="text/javascript">
//<![CDATA[
MyApp.init();
if(MyApp.animes) {
if(MyApp.animes.init) { MyApp.animes.init(); }
if(MyApp.animes.show && MyApp.animes.show.init) { MyApp.animes.show.init(); }
}
//]]>
//<![CDATA[
MyApp.init();
if (MyApp.animes) {
if (MyApp.animes.init) {
MyApp.animes.init();
}
if (MyApp.animes.show && MyApp.animes.show.init) {
MyApp.animes.show.init();
}
}
//]]>
</script>
```

Expand Down Expand Up @@ -196,16 +210,13 @@ Minitest-ed. To run all tests, just run `rake` or `rake test`.

## Author

Rails Utils is maintained by [Winston Teo](mailto:winstonyw+rails_utils@gmail.com).
Rails Utils is originally maintained by [Winston Teo](mailto:winstonyw+rails_utils@gmail.com).

[You should follow Winston on Twitter](https://www.twitter.com/winstonyw), or find out more on [WinstonYW](http://www.winstonyw.com) and [LinkedIn](http://sg.linkedin.com/in/winstonyw).

## License

Copyright © 2013-2016 Winston Teo Yong Wei. Free software, released under the MIT license.


[version-badge]: https://badge.fury.io/rb/rails_utils.svg
[rubygems]: https://rubygems.org/gems/rails_utils
[travis-badge]: https://travis-ci.org/winston/rails_utils.svg
[travis]: https://travis-ci.org/winston/rails_utils
7 changes: 7 additions & 0 deletions gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "6.0.6.1"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.1"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "7.0.8.4"

gemspec path: "../"
7 changes: 7 additions & 0 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 7.1"

gemspec path: "../"
4 changes: 2 additions & 2 deletions lib/rails_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def page_title(options={})
@page_title ||= begin
default_page_title = "#{page_controller_class.capitalize} #{page_action_class.capitalize}"
i18n_options = { default: default_page_title }.merge!(options)
I18n.t("#{page_controller_class}.#{page_action_class}.title", i18n_options)
I18n.t("#{page_controller_class}.#{page_action_class}.title", **i18n_options)
end
end

def javascript_initialization(options = {})
application_name = Rails.application.class.parent_name
application_name = Rails.application.class.module_parent_name
js_namespace_name = page_controller_class_underscored
js_function_name = page_action_class

Expand Down
2 changes: 1 addition & 1 deletion lib/rails_utils/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RailsUtils
VERSION = "4.0.0"
VERSION = "6.0.0"
end
11 changes: 7 additions & 4 deletions rails_utils.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ require "rails_utils/version"
Gem::Specification.new do |s|
s.name = "rails_utils"
s.version = RailsUtils::VERSION
s.authors = ["Winston Teo"]
s.email = ["winston.yongwei+rails_utils@gmail.com"]
s.homepage = "https://github.com/winston/rails_utils"
s.authors = ["Bivan Alzacky Harmanto"]
s.email = ["bivan.alzacky@gmail.com"]
s.homepage = "https://github.com/Coursemology/rails_utils"
s.summary = "Rails helpers based on opinionated project practices."
s.description = "Rails helpers based on opinionated project practices. Currently useful for structuring CSS and JS."

s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]

s.add_dependency "rails", ">=3.2"
s.required_ruby_version = ">= 3.0"

s.add_dependency "rails", ">= 6"

s.add_development_dependency "minitest" , ">= 4.7.5"
s.add_development_dependency "appraisal", "~> 2.1"
s.add_development_dependency "mocha"

s.license = 'MIT'
Expand Down
6 changes: 2 additions & 4 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
require File.expand_path('../boot', __FILE__)

# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"

Bundler.require(*Rails.groups)
Expand Down Expand Up @@ -55,10 +53,10 @@ class Application < Rails::Application
# config.active_record.whitelist_attributes = true

# Enable the asset pipeline
config.assets.enabled = true
# config.assets.enabled = true

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
# config.assets.version = '1.0'
end
end

Loading
Loading