Skip to content

Commit af49bfb

Browse files
committed
Fix bug with generated routes and precompile engine assets
1 parent 7012f95 commit af49bfb

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Unreleased
2+
3+
- Bug fix: Update generated routes so that resource root path does not override existing applciation routes
4+
- Add initializer to precompile assets so that main app can load views with Todoro's layout
5+
16
### 0.1.5 - 2025-02-16
27

38
- Automatic route generation for any model that includes `acts_as_taskable`, eliminating the need for manual route configuration.

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Todoro.taskable_models.each do |model|
33
resource_name = model.underscore.pluralize.to_sym
44

5-
resources resource_name, defaults: { taskable_type: model.downcase }, constraints: TaskableModelsConstraint.new do
5+
resources resource_name, defaults: { taskable_type: model.downcase }, only: [], constraints: TaskableModelsConstraint.new do
66
resources :task_lists do
77
resources :tasks, only: [ :new, :edit, :create, :update, :destroy ] do
88
patch :complete, on: :member

lib/tasks/version.rake

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace :version do
2+
desc "Bump the gem version, update changelog, build and release the gem"
3+
task :bump, [:version] => :environment do |t, args|
4+
version = args[:version]
5+
raise "Please specify a version. Usage: rake version:bump[0.1.5]" unless version
6+
7+
gemspec_file = Dir.glob("*.gemspec").first
8+
raise "No gemspec file found" unless gemspec_file
9+
10+
# Update the gemspec version
11+
gemspec_content = File.read(gemspec_file)
12+
new_gemspec_content = gemspec_content.gsub(/(spec\.version\s*=\s*")\d+\.\d+\.\d+("?)/, "\\1#{version}\\2")
13+
File.write(gemspec_file, new_gemspec_content)
14+
puts "Updated gemspec version to #{version}"
15+
16+
# Update the changelog
17+
changelog_file = "CHANGELOG.md"
18+
raise "CHANGELOG.md not found" unless File.exist?(changelog_file)
19+
20+
changelog_content = File.read(changelog_file)
21+
new_changelog_content = changelog_content.sub("## [Unreleased]", "## [Unreleased]\n\n## [#{version}] - #{Time.now.strftime('%Y-%m-%d')}")
22+
File.write(changelog_file, new_changelog_content)
23+
puts "Updated CHANGELOG.md with version #{version}"
24+
25+
# Commit changes and create a git tag
26+
`git add #{gemspec_file} #{changelog_file}`
27+
`git commit -m "Bump version to #{version}"`
28+
`git tag -a v#{version} -m "Version #{version}"`
29+
puts "Committed and tagged version #{version}"
30+
31+
# Build the gem
32+
`gem build #{gemspec_file}`
33+
puts "Built gem version #{version}"
34+
35+
# Release the gem
36+
gem_file = Dir.glob("*.gem").max_by { |f| File.mtime(f) }
37+
raise "No gem file found" unless gem_file
38+
`gem push #{gem_file}`
39+
puts "Released gem #{gem_file}"
40+
end
41+
end

lib/todoro/engine.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ class Engine < ::Rails::Engine
77
extend Todoro::Taskable::ClassMethods
88
end
99
end
10+
11+
initializer "todoro.assets.precompile" do |app|
12+
app.config.assets.precompile += %w[todoro/application.css todoro/application.js]
13+
end
1014
end
1115
end

0 commit comments

Comments
 (0)