spandex 0.0.3 → 0.0.4
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/.gitignore +2 -1
- data/lib/spandex/finder.rb +1 -1
- data/lib/spandex/page.rb +4 -3
- data/lib/spandex/version.rb +1 -1
- data/spec/finder_spec.rb +15 -0
- metadata +1 -1
data/.gitignore
CHANGED
data/lib/spandex/finder.rb
CHANGED
@@ -28,7 +28,7 @@ module Spandex
|
|
28
28
|
roots = []
|
29
29
|
@pages ||= CaseInsensitiveHash.new
|
30
30
|
Dir.glob(File.join(@base_dir, "**/*"))
|
31
|
-
.map{|path|
|
31
|
+
.map{|path| Page.pathify(path)}
|
32
32
|
.select{|path| Page.registered?(path)}
|
33
33
|
.each{|path| load(path)}
|
34
34
|
@pages.values
|
data/lib/spandex/page.rb
CHANGED
@@ -24,8 +24,8 @@ module Spandex
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.path_from_file(pathname, base_path)
|
27
|
-
pathname = pathify
|
28
|
-
pathname.relative_path_from(pathify(base_path)).sub_ext('')
|
27
|
+
pathname = pathify pathname
|
28
|
+
pathify pathname.relative_path_from(pathify(base_path)).sub_ext('')
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.registered?(pathname)
|
@@ -83,7 +83,7 @@ module Spandex
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def self.pathify(path_or_string)
|
86
|
-
path_or_string.is_a?(String) ? Pathname.new(
|
86
|
+
fix_path path_or_string.is_a?(String) ? Pathname.new(path_or_string) : path_or_string
|
87
87
|
end
|
88
88
|
|
89
89
|
def self.parse_file(filename)
|
@@ -106,6 +106,7 @@ module Spandex
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def self.fix_path(path)
|
109
|
+
path = "/#{path}" unless path.to_s.match(/^\//)
|
109
110
|
path.sub(/\/$/, '')
|
110
111
|
end
|
111
112
|
|
data/lib/spandex/version.rb
CHANGED
data/spec/finder_spec.rb
CHANGED
@@ -134,6 +134,13 @@ describe Spandex::Finder do
|
|
134
134
|
page.should_not be_nil
|
135
135
|
end
|
136
136
|
|
137
|
+
it "can have a leading /" do
|
138
|
+
create_file("stuff.md")
|
139
|
+
page = make_finder.get("/stuff")
|
140
|
+
page.should_not be_nil
|
141
|
+
end
|
142
|
+
|
143
|
+
|
137
144
|
it "finds the first file tilt knows" do
|
138
145
|
create_file("stuff.snoogledoobers")
|
139
146
|
create_file("stuff.md")
|
@@ -174,9 +181,17 @@ describe Spandex::Finder do
|
|
174
181
|
finder = make_finder
|
175
182
|
finder.all_pages
|
176
183
|
finder.get("stuff/")
|
184
|
+
finder.all_pages.size.should == 1
|
185
|
+
end
|
177
186
|
|
187
|
+
it "doesn't create a separate cache entry for leading slashes" do
|
188
|
+
create_file("stuff.md")
|
189
|
+
finder = make_finder
|
190
|
+
finder.get("stuff")
|
191
|
+
finder.get("/stuff")
|
178
192
|
finder.all_pages.size.should == 1
|
179
193
|
end
|
194
|
+
|
180
195
|
|
181
196
|
end
|
182
197
|
|