Last active
December 19, 2015 13:29
-
-
Save parndt/5962394 to your computer and use it in GitHub Desktop.
Who wants to make this nicer? :(
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extension_path_for_nested_extension(path, apply_tmp) | |
if File.exist?(path.gsub(/\.erb$/, "")) | |
if %r{/(locales/.*\.yml)|((routes|#{gem_name})\.rb\.erb)$} === path | |
# put new translations into a tmp directory | |
path = path.split(File::SEPARATOR).insert(-2, "tmp").join(File::SEPARATOR) if apply_tmp | |
elsif %r{/readme.md$} === path || %r{/#{plural_name}.rb$} === path | |
path = nil | |
end | |
elsif %r{lib\/#{plural_name}.rb$} === path | |
path = nil | |
end | |
path | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extension_path_for_nested_extension(path, apply_tmp) | |
return nil if !File.exist?(path.gsub(/\.erb$/, '')) && | |
%r{readme.md|(lib/)?#{plural_name}.rb$} === path | |
if apply_tmp && %r{(locales/.*\.yml)|((config/routes|#{gem_name})\.rb\.erb)$} === path | |
return path.split(File::SEPARATOR).insert(-2, "tmp").join(File::SEPARATOR) | |
end | |
path | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You've done a reasonable job with
final.rb
. 😺The only change I'd make is to change
if !condition &&
tounless condition ||
for readability/explicitness. 👴