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.
@@ -67,7 +67,7 @@ module TemplateInheritance
67
67
  def fullpath
68
68
  @fullpath ||= begin
69
69
  if self.path.match(/^(\/|\.)/) # /foo or ./foo
70
- Dir[self.path, "#{self.path}.*"].find {|file| !File.directory?(file)}
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.each do |directory|
108
- path = File.join(directory, self.path)
109
- return Dir[path, "#{path}.*"].find {|file| !File.directory?(file)}
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]/, '_\&') =~ /_*(.*)/
@@ -5,7 +5,7 @@ require "base64"
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "template-inheritance"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
  s.authors = ["Jakub Šťastný aka Botanicus"]
10
10
  s.homepage = "http://github.com/botanicus/template-inheritance"
11
11
  s.summary = ""
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"