Skip to content

Commit

Permalink
Merge pull request #11 from ekohl/rewrite-functions
Browse files Browse the repository at this point in the history
Rewrite methods to be more expressive
  • Loading branch information
jaynetics authored Dec 22, 2024
2 parents 288d252 + d484ce1 commit 8d65a20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/taro/rails/generators/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Taro::Rails::Generators::InstallGenerator < ::Rails::Generators::Base
def create_type_files
Dir["#{self.class.source_root}/**/*.erb"].each do |tmpl|
dest_dir = options[:dir].chomp('/')
template tmpl, "#{dest_dir}/#{File.basename(tmpl).sub('erb', 'rb')}"
template tmpl, "#{dest_dir}/#{File.basename(tmpl, '.erb')}.rb"
end
end
# :nocov:
Expand Down
12 changes: 5 additions & 7 deletions lib/taro/rails/route_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ def cache

def build_cache
# Build a Hash like
# { 'users#show' } => [#<NormalizedRoute>, #<NormalizedRoute>] }
rails_routes.each_with_object({}) do |rails_route, hash|
route = Taro::Rails::NormalizedRoute.new(rails_route)
next if route.ignored?

(hash[route.endpoint] ||= []) << route
end
# { 'users#show' => [#<NormalizedRoute>, #<NormalizedRoute>] }
rails_routes
.map { |r| Taro::Rails::NormalizedRoute.new(r) }
.reject(&:ignored?)
.group_by(&:endpoint)
end

def rails_routes
Expand Down

0 comments on commit 8d65a20

Please sign in to comment.