soup 1.0.0 → 1.0.1
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 +1 -1
- data/test/file_backend_test.rb +15 -5
- metadata +11 -4
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ class Soup
|
|
18
18
|
if File.exist?(path)
|
19
19
|
file = File.new(path)
|
20
20
|
data = file.read
|
21
|
-
default_attributes = {:name => name, :updated_at => file.mtime}
|
21
|
+
default_attributes = {:name => name, :updated_at => file.mtime, :created_at => file.mtime}
|
22
22
|
if attribute_start = data.index("\n:")
|
23
23
|
content = data[0, attribute_start].strip
|
24
24
|
attributes = default_attributes.merge(YAML.load(data[attribute_start, data.length]).merge(:content => content))
|
data/test/file_backend_test.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
require "ftools"
|
3
|
+
require "time"
|
3
4
|
|
4
5
|
class FileBackendTest < Test::Unit::TestCase
|
5
6
|
context "The file-based backend" do
|
@@ -37,13 +38,22 @@ of the snip
|
|
37
38
|
assert_equal "blahface", @soup["blahface"].name
|
38
39
|
end
|
39
40
|
|
40
|
-
should "take updated_at from file timestamps if not supplied" do
|
41
|
-
|
42
|
-
|
43
|
-
File.utime(
|
41
|
+
should "take updated_at and created_at from file timestamps if not supplied" do
|
42
|
+
@soup << {:name => "snip", :content => "whatever"}
|
43
|
+
time = Time.parse("2010-11-04 14:56")
|
44
|
+
File.utime(time, time, path_for("snip"))
|
44
45
|
|
45
46
|
snip = @soup["snip"]
|
46
|
-
assert_equal
|
47
|
+
assert_equal time, snip.updated_at
|
48
|
+
assert_equal time, snip.created_at
|
49
|
+
end
|
50
|
+
|
51
|
+
should "take created_at from attributes if supplied" do
|
52
|
+
created_at = Time.parse("2010-11-04 14:56")
|
53
|
+
@soup << {:name => "snip", :content => "whatever", :created_at => created_at}
|
54
|
+
|
55
|
+
snip = @soup["snip"]
|
56
|
+
assert_equal created_at.to_i, snip.created_at.to_i
|
47
57
|
end
|
48
58
|
end
|
49
59
|
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- James Adam
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-11-19 00:00:00 +00:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: shoulda
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -65,23 +68,27 @@ rdoc_options:
|
|
65
68
|
require_paths:
|
66
69
|
- lib
|
67
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
68
72
|
requirements:
|
69
73
|
- - ">="
|
70
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
71
76
|
segments:
|
72
77
|
- 0
|
73
78
|
version: "0"
|
74
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
75
81
|
requirements:
|
76
82
|
- - ">="
|
77
83
|
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
78
85
|
segments:
|
79
86
|
- 0
|
80
87
|
version: "0"
|
81
88
|
requirements: []
|
82
89
|
|
83
90
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.3.
|
91
|
+
rubygems_version: 1.3.7
|
85
92
|
signing_key:
|
86
93
|
specification_version: 3
|
87
94
|
summary: A super-simple data store
|