Skip to content

Commit

Permalink
Add PagyApps::INDEX
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Nov 9, 2024
1 parent 0adb448 commit 22ed550
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
7 changes: 7 additions & 0 deletions gem/apps/index.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

# PagyApp module
module PagyApps
# Return the hash of app name/path
INDEX = Dir[File.expand_path('./*.ru', __dir__)].to_h { |f| [File.basename(f, '.ru'), f] }.freeze
end
4 changes: 2 additions & 2 deletions gem/bin/pagy
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ HOST = '0.0.0.0'
PORT = '8000'

require_relative '../lib/optimist'

apps = Dir[File.expand_path('../apps/*.ru', __dir__)].to_h { |f| [File.basename(f, '.ru'), f] }
require_relative '../apps/index'
apps = PagyApps::INDEX
opts = Optimist.options do
text <<~HEAD
Pagy #{VERSION} (https://ddnexus.github.io/pagy/playground)
Expand Down
24 changes: 10 additions & 14 deletions scripts/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

require 'tempfile'
require_relative 'scripty'
require_relative '../gem/apps/index'
include Scripty # rubocop:disable Style/MixinUsage

# Abort if the working tree is dirty
Expand Down Expand Up @@ -65,20 +66,15 @@
replace_string_in_file('CHANGELOG.md', /<hr>\n/, "<hr>\n\n## Version #{new_version}\n\n#{changes}")

# Bump the version in files
%w[retype.yml
.github/ISSUE_TEMPLATE/Code.yml
.github/latest_release_body.md
gem/apps/calendar.ru
gem/apps/demo.ru
gem/apps/keyset_ar.ru
gem/apps/keyset_s.ru
gem/apps/rails.ru
gem/apps/repro.ru
gem/bin/pagy
gem/config/pagy.rb
gem/lib/pagy.rb
gem/pagy.gemspec
src/pagy.ts].each do |path|
(%w[retype.yml
.github/ISSUE_TEMPLATE/Code.yml
.github/latest_release_body.md
gem/bin/pagy
gem/config/pagy.rb
gem/lib/pagy.rb
gem/pagy.gemspec
src/pagy.ts] +
PagyApps::INDEX.values).each do |path|
replace_string_in_file(path, old_version, new_version)
end

Expand Down
5 changes: 3 additions & 2 deletions test/pagy/version_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../gem/apps/index'

describe 'Version match' do
it 'has version' do
Expand All @@ -19,8 +20,8 @@
_(Pagy.root.join('bin', 'pagy').read).must_match "VERSION = '#{Pagy::VERSION}'"
end
it 'defines the same version in apps/*.ru' do
%w[calendar demo rails repro].each do |app|
_(Pagy.root.join('apps', "#{app}.ru").read).must_match "VERSION = '#{Pagy::VERSION}'"
PagyApps::INDEX.each_value do |path|
_(File.read(path)).must_match "VERSION = '#{Pagy::VERSION}'"
end
end
it 'defines the same version in javascripts/pagy.min.js' do
Expand Down

0 comments on commit 22ed550

Please sign in to comment.