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 CHANGED
@@ -21,7 +21,7 @@ spec = Gem::Specification.new do |s|
21
21
 
22
22
  # Change these as appropriate
23
23
  s.name = "soup"
24
- s.version = "1.0.4"
24
+ s.version = "1.0.5"
25
25
  s.summary = "A super-simple data store"
26
26
  s.author = "James Adam"
27
27
  s.email = "james@lazyatom.com"
@@ -10,11 +10,11 @@ class Soup
10
10
  end
11
11
 
12
12
  def names
13
- Dir[File.join(@base_path, "*")].map { |s| File.basename(s).split(".").first }
13
+ snip_paths.map { |s| File.basename(s).split(".").first }
14
14
  end
15
15
 
16
16
  def load_snip(name)
17
- path = Dir[File.join(@base_path, "*")].find { |s| File.basename(s).split(".").first == name }
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"))
@@ -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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soup
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 4
10
- version: 1.0.4
9
+ - 5
10
+ version: 1.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Adam