template-inheritance 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/template-inheritance.rb +12 -4
- data/template-inheritance.gemspec +1 -1
- metadata +2 -2
data/lib/template-inheritance.rb
CHANGED
@@ -67,7 +67,7 @@ module TemplateInheritance
|
|
67
67
|
def fullpath
|
68
68
|
@fullpath ||= begin
|
69
69
|
if self.path.match(/^(\/|\.)/) # /foo or ./foo
|
70
|
-
|
70
|
+
find_file(self.path, "#{self.path}.*")
|
71
71
|
else
|
72
72
|
self.find_in_paths
|
73
73
|
end
|
@@ -104,12 +104,20 @@ module TemplateInheritance
|
|
104
104
|
|
105
105
|
protected
|
106
106
|
def find_in_paths
|
107
|
-
self.class.paths.
|
108
|
-
|
109
|
-
|
107
|
+
self.class.paths.inject(nil) do |real, directory|
|
108
|
+
if real.nil?
|
109
|
+
path = File.join(directory, self.path)
|
110
|
+
find_file(path, "#{path}.*")
|
111
|
+
else
|
112
|
+
real
|
113
|
+
end
|
110
114
|
end
|
111
115
|
end
|
112
116
|
|
117
|
+
def find_file(one, other)
|
118
|
+
alternatives.find { |file| File.file?(file) }
|
119
|
+
end
|
120
|
+
|
113
121
|
def snake_case(string)
|
114
122
|
return string.downcase if string =~ /^[A-Z]+$/
|
115
123
|
string.gsub(/([A-Z]+)(?=[A-Z][a-z]?)|\B[A-Z]/, '_\&') =~ /_*(.*)/
|