spandex 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -10,4 +10,5 @@ tmp/**/*
10
10
  bin/**
11
11
  .sass-cache/**
12
12
  Gemfile.lock
13
- pkg
13
+ pkg
14
+ *.gem
@@ -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| Pathname.new(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(pathname)
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(fix_path path_or_string) : path_or_string
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
 
@@ -1,3 +1,3 @@
1
1
  module Spandex
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: spandex
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Isaac Cambron