soup 1.0.4 → 1.0.5
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/Rakefile +1 -1
- data/lib/soup/backends/file_backend.rb +6 -2
- data/test/file_backend_test.rb +6 -0
- metadata +3 -3
data/Rakefile
CHANGED
@@ -10,11 +10,11 @@ class Soup
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def names
|
13
|
-
|
13
|
+
snip_paths.map { |s| File.basename(s).split(".").first }
|
14
14
|
end
|
15
15
|
|
16
16
|
def load_snip(name)
|
17
|
-
path =
|
17
|
+
path = snip_paths.find { |s| File.basename(s).split(".").first == name }
|
18
18
|
if path
|
19
19
|
file = File.new(path)
|
20
20
|
data = file.read
|
@@ -62,6 +62,10 @@ class Soup
|
|
62
62
|
File.join(@base_path, name + snip_extension)
|
63
63
|
end
|
64
64
|
|
65
|
+
def snip_paths
|
66
|
+
Dir[File.join(@base_path, "*")].select { |s| File.file?(s) }
|
67
|
+
end
|
68
|
+
|
65
69
|
def all_snips
|
66
70
|
Dir[File.join(@base_path, "*")].map do |key|
|
67
71
|
load_snip(File.basename(key, ".snip"))
|
data/test/file_backend_test.rb
CHANGED
@@ -70,6 +70,12 @@ of the snip
|
|
70
70
|
assert_equal "markdown", snip.extension
|
71
71
|
end
|
72
72
|
|
73
|
+
should "not ignore directories" do
|
74
|
+
FileUtils.mkdir(File.join(@base_path, "test"))
|
75
|
+
write_snip("test", "content")
|
76
|
+
assert_equal "content", @soup["test"].content
|
77
|
+
end
|
78
|
+
|
73
79
|
def path_for(name)
|
74
80
|
File.join(@base_path, name + ".snip")
|
75
81
|
end
|
metadata
CHANGED