smallcage 0.1.7 → 0.1.8

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.
File without changes
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,3 @@
1
+ xxx: 1
2
+ yyy: 2
3
+ zzz: 3
@@ -0,0 +1,6 @@
1
+ --- default ---
2
+
3
+ <%= uri %>
4
+ <%= uri.smc %>
5
+ <%= path %>
6
+ <%= path.smc %>
@@ -0,0 +1,8 @@
1
+ <%= cursor %>
2
+
3
+ <%= uri %>
4
+ <%= uri.smc %>
5
+ <%= path %>
6
+ <%= path.smc %>
7
+
8
+ <%= uris.join("\n") %>
@@ -0,0 +1,5 @@
1
+ <%- 10.times do |i| -%>
2
+ items-<%= "%03d" % i %>.html
3
+ <%- end -%>
4
+
5
+ items-after-emptyline.html
@@ -0,0 +1 @@
1
+ template: items
@@ -0,0 +1,13 @@
1
+ ---
2
+ version: 0.0.1
3
+ list:
4
+ - mtime: 1250000000
5
+ src: /index.html.smc
6
+ dst:
7
+ - /index.html
8
+ - mtime: 1250000001
9
+ src: /items/items.smc
10
+ dst:
11
+ - /items/item-001.html
12
+ - /items/item-002.html
13
+ - /items/item-003.html
@@ -34,8 +34,8 @@ EOT
34
34
  end
35
35
 
36
36
  after do
37
- SmallCage::Runner.run(@opts.merge(:command => "clean"))
37
+ SmallCage::Runner.run(@opts.merge(:command => "clean", :quiet => true))
38
38
  @manifest_file.delete
39
39
  end
40
40
 
41
- end
41
+ end
@@ -7,79 +7,4 @@ describe "smallcage" do
7
7
  # puts "------- version:" + SmallCage::VERSION::STRING
8
8
  end
9
9
 
10
- it "should update not docroot directory" do
11
- docroot = Pathname.new(File.dirname(__FILE__) + "/data/htdocs1")
12
- path = docroot + "a/b/"
13
-
14
- opts = { :command => "update", :path => path.to_s, :quiet => true }
15
-
16
- begin
17
- SmallCage::Runner.run(opts)
18
-
19
- out = docroot + "a/b/c/index.html"
20
- out.file?.should be_true
21
- out.delete
22
-
23
- pwd = Dir.pwd
24
- Dir.chdir(path)
25
-
26
- opts[:path] = "."
27
- SmallCage::Runner.run(opts)
28
-
29
- Dir.chdir(pwd)
30
-
31
- out.file?.should be_true
32
- out.delete
33
- ensure
34
- SmallCage::Runner.run({:command => "clean", :path => path.to_s, :quiet => true })
35
- end
36
-
37
- end
38
-
39
- it "should not publish _dir.smc and _local.smc" do
40
- root = Pathname.new(File.dirname(__FILE__) + "/data/htdocs3")
41
-
42
- opts = { :command => "update", :path => root.to_s, :quiet => true }
43
-
44
- begin
45
- SmallCage::Runner.run(opts)
46
-
47
- out = root + "_dir"
48
- out.file?.should be_false
49
-
50
- out = root + "_local"
51
- out.file?.should be_false
52
- ensure
53
- SmallCage::Runner.run({:command => "clean", :path => root.to_s, :quiet => true })
54
- end
55
-
56
- end
57
-
58
- # http://github.com/bluemark/smallcage/issues/#issue/2
59
- it "should not delete files under the common prefix directory" do
60
- root = Pathname.new(File.dirname(__FILE__) + "/data/htdocs3")
61
- begin
62
- SmallCage::Runner.run({ :command => "update", :path => root.to_s, :quiet => true })
63
-
64
- (root + "a/index.html").file?.should be_true
65
- (root + "ab/index.html").file?.should be_true
66
- (root + "abc/index.html").file?.should be_true
67
-
68
- SmallCage::Runner.run({ :command => "update", :path => (root + "a").to_s, :quiet => true })
69
-
70
- (root + "a/index.html").file?.should be_true
71
- (root + "ab/index.html").file?.should be_true
72
- (root + "abc/index.html").file?.should be_true
73
-
74
- SmallCage::Runner.run({ :command => "update", :path => (root + "ab").to_s, :quiet => true })
75
-
76
- (root + "a/index.html").file?.should be_true
77
- (root + "ab/index.html").file?.should be_true
78
- (root + "abc/index.html").file?.should be_true
79
- ensure
80
- SmallCage::Runner.run({:command => "clean", :path => root.to_s, :quiet => true })
81
- end
82
-
83
- end
84
-
85
- end
10
+ end
@@ -0,0 +1,232 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+ require 'smallcage'
3
+
4
+ describe SmallCage::UpdateList do
5
+ root = Pathname.new(File.dirname(__FILE__) + "/data/updatelists")
6
+
7
+ it "should create empty data" do
8
+ list = SmallCage::UpdateList.new(root + "dummy.yml", "/")
9
+ result = YAML.load(list.to_yaml)
10
+ result["version"].should match(/\d\.\d\.\d/)
11
+ result["list"].should be_empty
12
+
13
+ list = SmallCage::UpdateList.new(root + "dummy.yml", "/")
14
+ list.expire
15
+ result = YAML.load(list.to_yaml)
16
+ result["version"].should match(/^\d\.\d\.\d$/)
17
+ result["list"].should be_empty
18
+ end
19
+
20
+ it "should be update list items" do
21
+ list = SmallCage::UpdateList.new(root + "dummy.yml", "/")
22
+ result = YAML.load(list.to_yaml)
23
+ list.update("/abc/index.html.smc", 100, "/abc/index.html")
24
+ end
25
+
26
+ it "should update version" do
27
+ file = root + "list-version.yml"
28
+ begin
29
+ open(file, "w") do |io|
30
+ io << <<EOT
31
+ version: 0.0.0
32
+ EOT
33
+ end
34
+ list = SmallCage::UpdateList.new(file, "/")
35
+ list.save
36
+
37
+ data = YAML.load_file(file)
38
+ data["version"].should == SmallCage::VERSION::STRING
39
+ ensure
40
+ file.delete
41
+ end
42
+ end
43
+
44
+ it "should save mtime" do
45
+ file = root + "list-mtime.yml"
46
+ begin
47
+ list = SmallCage::UpdateList.new(file, "/")
48
+ list.update("/index.html.smc", 1234567890, "/index.html")
49
+ list.save
50
+
51
+ list = SmallCage::UpdateList.new(file, "/")
52
+ list.mtime("/index.html.smc").should == 1234567890
53
+
54
+ # same dst file
55
+ list.update("/abc/index.html.smc", 1, "/index.html")
56
+ list.mtime("/abc/index.html.smc").should == 1
57
+
58
+ list.update("/abc/index.html.smc", 2, "/index.html")
59
+ list.mtime("/abc/index.html.smc").should == 2
60
+ list.mtime("/index.html.smc").should == 1234567890
61
+
62
+ list = SmallCage::UpdateList.new(file, "/")
63
+ list.mtime("/index.html.smc").should == 1234567890
64
+ list.mtime("/abc/index.html.smc").should == -1
65
+
66
+ list.update("/abc/index.html.smc", 1, "/index.html")
67
+ list.save
68
+
69
+ list = SmallCage::UpdateList.new(file, "/")
70
+ list.mtime("/index.html.smc").should == 1234567890
71
+ list.mtime("/abc/index.html.smc").should == 1
72
+ ensure
73
+ file.delete
74
+ end
75
+ end
76
+
77
+ it "should return expired files" do
78
+ file = root + "list-expire.yml"
79
+ begin
80
+ list = SmallCage::UpdateList.new(file, "/")
81
+ list.update("/index.html.smc", 1, "/index.html")
82
+
83
+ e = list.expire
84
+ e.length.should == 0
85
+
86
+ list.save
87
+ list.update_count.should == 1
88
+
89
+ list = SmallCage::UpdateList.new(file, "/")
90
+ e = list.expire
91
+ e.length.should == 1
92
+ e[0].should == "/index.html"
93
+ list.update_count.should == 0
94
+
95
+ list = SmallCage::UpdateList.new(file, "/")
96
+ list.update("/index.html.smc", 1, "/index.html")
97
+ e = list.expire
98
+ e.length.should == 0
99
+ list.update_count.should == 1
100
+
101
+ list = SmallCage::UpdateList.new(file, "/")
102
+ list.update("/index.html.smc", 1, "/index.html")
103
+ list.update("/index.html.smc", 1, "/index2.html")
104
+ e = list.expire
105
+ e.length.should == 0
106
+ list.update_count.should == 2
107
+ list.save
108
+
109
+ list = SmallCage::UpdateList.new(file, "/")
110
+ e = list.expire
111
+ e.length.should == 2
112
+ e[0].should == "/index.html"
113
+ e[1].should == "/index2.html"
114
+
115
+ list = SmallCage::UpdateList.new(file, "/abc/")
116
+ list.update("/abc/index.html.smc", 2, "/abc/index.html")
117
+ list.update("/abc/index2.html.smc", 3, "/abc/index2.html")
118
+ e = list.expire
119
+ e.length.should == 0
120
+ list.update_count.should == 2
121
+ list.save
122
+
123
+ list = SmallCage::UpdateList.new(file, "/abc/")
124
+ list.update("/abc/index.html.smc", 2, "/abc/index2.html")
125
+ e = list.expire
126
+ e.length.should == 1
127
+ e[0].should == "/abc/index.html"
128
+
129
+ list = SmallCage::UpdateList.new(file, "/a/")
130
+ list.update("/a/index.html.smc", 2, "/abc/a.html")
131
+ e = list.expire
132
+ e.length.should == 0
133
+ list.update_count.should == 1
134
+ list.save
135
+
136
+ list = SmallCage::UpdateList.new(file, "/abc/")
137
+ list.update("/abc/index.html.smc", 2, "/abc/index.html")
138
+ list.update("/abc/index.html.smc", 2, "/abc/index2.html")
139
+ e = list.expire
140
+ e.length.should == 0
141
+ list.update_count.should == 2
142
+ list.save
143
+
144
+ list = SmallCage::UpdateList.new(file, "/a/")
145
+ list.update("/a/index.html.smc", 2, "/abc/b.html")
146
+ e = list.expire
147
+ e.length.should == 1
148
+ e[0] == "/abc/a.html"
149
+
150
+ list = SmallCage::UpdateList.new(file, "/")
151
+ e = list.expire
152
+ e.length.should == 5
153
+ e.should include("/index.html")
154
+ e.should include("/index2.html")
155
+ e.should include("/abc/index.html")
156
+ e.should include("/abc/index2.html")
157
+ e.should include("/abc/a.html")
158
+ list.save
159
+
160
+ list = SmallCage::UpdateList.new(file, "/")
161
+ e = list.expire
162
+ e.length.should == 0
163
+ ensure
164
+ file.delete
165
+ end
166
+
167
+ end
168
+
169
+ it "should support single file target" do
170
+ file = root + "list-single.yml"
171
+ begin
172
+ list = SmallCage::UpdateList.new(file, "/index.html.smc")
173
+ list.update("/index.html.smc", 1, "/index.html")
174
+ e = list.expire
175
+ e.length.should == 0
176
+ list.save
177
+
178
+ list = SmallCage::UpdateList.new(file, "/index.html.smc")
179
+ e = list.expire
180
+ e.length.should == 1
181
+
182
+ list = SmallCage::UpdateList.new(file, "/index2.html.smc")
183
+ e = list.expire
184
+ e.length.should == 0
185
+
186
+ list = SmallCage::UpdateList.new(file, "/index.html.smc/")
187
+ e = list.expire
188
+ e.length.should == 0
189
+
190
+ list = SmallCage::UpdateList.new(file, "/abc/index.html.smc")
191
+ list.update("/abc/index.html.smc", 2, "/abc/index.html")
192
+ e = list.expire
193
+ e.length.should == 0
194
+ list.save
195
+ list = SmallCage::UpdateList.new(file, "/ab/")
196
+ e = list.expire
197
+ e.length.should == 0
198
+
199
+ list = SmallCage::UpdateList.new(file, "/")
200
+ e = list.expire
201
+ e.length.should == 2
202
+ ensure
203
+ file.delete
204
+ end
205
+ end
206
+
207
+
208
+ it "should not expire file which other source published" do
209
+ file = root + "list-switch.yml"
210
+ begin
211
+ list = SmallCage::UpdateList.new(file, "/")
212
+ list.update("/index.html.smc", 1, "/aaa")
213
+ list.update("/index.html.smc", 1, "/bbb")
214
+ e = list.expire
215
+ e.length.should == 0
216
+ list.save
217
+
218
+ list = SmallCage::UpdateList.new(file, "/")
219
+ e = list.expire
220
+ e.length.should == 2
221
+
222
+ list = SmallCage::UpdateList.new(file, "/")
223
+ list.update("/other/file/1.smc", 2, "/aaa")
224
+ list.update("/other-file-2.smc", 2, "/bbb")
225
+ e = list.expire
226
+ e.length.should == 0
227
+ ensure
228
+ file.delete
229
+ end
230
+ end
231
+
232
+ end
@@ -0,0 +1,79 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+ require 'smallcage'
3
+
4
+ describe 'update' do
5
+
6
+ it "should update not docroot directory" do
7
+ docroot = Pathname.new(File.dirname(__FILE__) + "/data/htdocs1")
8
+ path = docroot + "a/b/"
9
+
10
+ opts = { :command => "update", :path => path.to_s, :quiet => true }
11
+
12
+ begin
13
+ SmallCage::Runner.run(opts)
14
+
15
+ out = docroot + "a/b/c/index.html"
16
+ out.file?.should be_true
17
+ out.delete
18
+
19
+ Dir.chdir(path) do
20
+ opts[:path] = "."
21
+ SmallCage::Runner.run(opts)
22
+ end
23
+
24
+ out.file?.should be_true
25
+ out.delete
26
+ ensure
27
+ SmallCage::Runner.run({:command => "clean", :path => path.to_s, :quiet => true })
28
+ end
29
+
30
+ end
31
+
32
+ it "should not publish _dir.smc and _local.smc" do
33
+ root = Pathname.new(File.dirname(__FILE__) + "/data/htdocs3")
34
+
35
+ opts = { :command => "update", :path => root.to_s, :quiet => true }
36
+
37
+ begin
38
+ SmallCage::Runner.run(opts)
39
+
40
+ out = root + "_dir"
41
+ out.file?.should be_false
42
+
43
+ out = root + "_local"
44
+ out.file?.should be_false
45
+ ensure
46
+ SmallCage::Runner.run({:command => "clean", :path => root.to_s, :quiet => true })
47
+ end
48
+
49
+ end
50
+
51
+ # http://github.com/bluemark/smallcage/issues/#issue/2
52
+ it "should not delete files under the common prefix directory" do
53
+ root = Pathname.new(File.dirname(__FILE__) + "/data/htdocs3")
54
+ begin
55
+ SmallCage::Runner.run({ :command => "update", :path => root.to_s, :quiet => true })
56
+
57
+ (root + "a/index.html").file?.should be_true
58
+ (root + "ab/index.html").file?.should be_true
59
+ (root + "abc/index.html").file?.should be_true
60
+
61
+ SmallCage::Runner.run({ :command => "update", :path => (root + "a").to_s, :quiet => true })
62
+
63
+ (root + "a/index.html").file?.should be_true
64
+ (root + "ab/index.html").file?.should be_true
65
+ (root + "abc/index.html").file?.should be_true
66
+
67
+ SmallCage::Runner.run({ :command => "update", :path => (root + "ab").to_s, :quiet => true })
68
+
69
+ (root + "a/index.html").file?.should be_true
70
+ (root + "ab/index.html").file?.should be_true
71
+ (root + "abc/index.html").file?.should be_true
72
+ ensure
73
+ SmallCage::Runner.run({:command => "clean", :path => root.to_s, :quiet => true })
74
+ end
75
+
76
+ end
77
+
78
+
79
+ end