smallcage 0.2.6 → 0.2.7
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +3 -2
- data/lib/smallcage/application.rb +12 -236
- data/lib/smallcage/commands/auto.rb +46 -23
- data/lib/smallcage/commands/base.rb +5 -2
- data/lib/smallcage/commands/clean.rb +9 -8
- data/lib/smallcage/commands/export.rb +9 -14
- data/lib/smallcage/commands/import.rb +29 -29
- data/lib/smallcage/commands/manifest.rb +8 -10
- data/lib/smallcage/commands/server.rb +2 -2
- data/lib/smallcage/commands/update.rb +30 -17
- data/lib/smallcage/commands/uri.rb +6 -9
- data/lib/smallcage/document_path.rb +10 -12
- data/lib/smallcage/erb_base.rb +7 -3
- data/lib/smallcage/http_server.rb +10 -10
- data/lib/smallcage/loader.rb +57 -57
- data/lib/smallcage/misc.rb +1 -1
- data/lib/smallcage/options_parser.rb +251 -0
- data/lib/smallcage/renderer.rb +3 -4
- data/lib/smallcage/runner.rb +9 -9
- data/lib/smallcage/update_list.rb +50 -40
- data/lib/smallcage/version.rb +1 -1
- data/lib/smallcage.rb +1 -0
- data/spec/lib/smallcage/application_spec.rb +62 -43
- data/spec/lib/smallcage/commands/export_spec.rb +8 -8
- data/spec/lib/smallcage/commands/import_spec.rb +2 -2
- data/spec/lib/smallcage/commands/manifest_spec.rb +1 -1
- data/spec/lib/smallcage/commands/update_spec.rb +13 -13
- data/spec/lib/smallcage/document_path_spec.rb +4 -4
- data/spec/lib/smallcage/loader_spec.rb +3 -3
- data/spec/lib/smallcage/update_list_spec.rb +139 -118
- data/spec/spec_helper.rb +6 -0
- metadata +3 -2
@@ -2,225 +2,246 @@ require 'spec_helper.rb'
|
|
2
2
|
require 'smallcage'
|
3
3
|
|
4
4
|
describe SmallCage::UpdateList do
|
5
|
-
root
|
5
|
+
let(:root) { Pathname.new(File.join(SPEC_DATA_DIR, 'updatelists')) }
|
6
6
|
|
7
|
-
it
|
8
|
-
list = SmallCage::UpdateList.new(root +
|
7
|
+
it 'should create empty data' do
|
8
|
+
list = SmallCage::UpdateList.new(root + 'dummy.yml', '/')
|
9
9
|
result = YAML.load(list.to_yaml)
|
10
|
-
result[
|
11
|
-
result[
|
10
|
+
result['version'].should match(/\d\.\d\.\d/)
|
11
|
+
result['list'].should be_empty
|
12
12
|
|
13
|
-
list = SmallCage::UpdateList.new(root +
|
13
|
+
list = SmallCage::UpdateList.new(root + 'dummy.yml', '/')
|
14
14
|
list.expire
|
15
15
|
result = YAML.load(list.to_yaml)
|
16
|
-
result[
|
17
|
-
result[
|
16
|
+
result['version'].should match(/^\d\.\d\.\d$/)
|
17
|
+
result['list'].should be_empty
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
list = SmallCage::UpdateList.new(root +
|
22
|
-
|
23
|
-
list.update(
|
20
|
+
it 'should be update list items' do
|
21
|
+
list = SmallCage::UpdateList.new(root + 'dummy.yml', '/')
|
22
|
+
YAML.load(list.to_yaml)
|
23
|
+
list.update('/abc/index.html.smc', 100, '/abc/index.html')
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
27
|
-
file = root +
|
26
|
+
it 'should update version' do
|
27
|
+
file = root + 'list-version.yml'
|
28
28
|
begin
|
29
|
-
open(file,
|
29
|
+
open(file, 'w') do |io|
|
30
30
|
io << <<EOT
|
31
31
|
version: 0.0.0
|
32
32
|
EOT
|
33
33
|
end
|
34
|
-
list = SmallCage::UpdateList.new(file,
|
34
|
+
list = SmallCage::UpdateList.new(file, '/')
|
35
35
|
list.save
|
36
36
|
|
37
37
|
data = YAML.load_file(file)
|
38
|
-
data[
|
38
|
+
data['version'].should eq SmallCage::VERSION
|
39
39
|
ensure
|
40
40
|
file.delete
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
file = root +
|
44
|
+
it 'should save mtime' do
|
45
|
+
file = root + 'list-mtime.yml'
|
46
46
|
begin
|
47
|
-
list = SmallCage::UpdateList.new(file,
|
48
|
-
list.update(
|
47
|
+
list = SmallCage::UpdateList.new(file, '/')
|
48
|
+
list.update('/index.html.smc', 1_234_567_890, '/index.html')
|
49
49
|
list.save
|
50
50
|
|
51
|
-
list = SmallCage::UpdateList.new(file,
|
52
|
-
list.mtime(
|
51
|
+
list = SmallCage::UpdateList.new(file, '/')
|
52
|
+
list.mtime('/index.html.smc').should eq 1_234_567_890
|
53
53
|
|
54
54
|
# same dst file
|
55
|
-
list.update(
|
56
|
-
list.mtime(
|
55
|
+
list.update('/abc/index.html.smc', 1, '/index.html')
|
56
|
+
list.mtime('/abc/index.html.smc').should eq 1
|
57
57
|
|
58
|
-
list.update(
|
59
|
-
list.mtime(
|
60
|
-
list.mtime(
|
58
|
+
list.update('/abc/index.html.smc', 2, '/index.html')
|
59
|
+
list.mtime('/abc/index.html.smc').should eq 2
|
60
|
+
list.mtime('/index.html.smc').should eq 1_234_567_890
|
61
61
|
|
62
|
-
list = SmallCage::UpdateList.new(file,
|
63
|
-
list.mtime(
|
64
|
-
list.mtime(
|
62
|
+
list = SmallCage::UpdateList.new(file, '/')
|
63
|
+
list.mtime('/index.html.smc').should eq 1_234_567_890
|
64
|
+
list.mtime('/abc/index.html.smc').should eq(-1)
|
65
65
|
|
66
|
-
list.update(
|
66
|
+
list.update('/abc/index.html.smc', 1, '/index.html')
|
67
67
|
list.save
|
68
68
|
|
69
|
-
list = SmallCage::UpdateList.new(file,
|
70
|
-
list.mtime(
|
71
|
-
list.mtime(
|
69
|
+
list = SmallCage::UpdateList.new(file, '/')
|
70
|
+
list.mtime('/index.html.smc').should eq 1_234_567_890
|
71
|
+
list.mtime('/abc/index.html.smc').should eq 1
|
72
72
|
ensure
|
73
73
|
file.delete
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
|
78
|
-
file
|
77
|
+
describe '#mtimes' do
|
78
|
+
let(:file) { root + 'list-mtime.yml' }
|
79
|
+
|
80
|
+
it 'should return src uri to mtime map' do
|
81
|
+
begin
|
82
|
+
list = SmallCage::UpdateList.new(file, '/')
|
83
|
+
list.update('/abc/index.html.smc', 123, '/abc/index.html')
|
84
|
+
list.update('/xyz/index.html.smc', 987, '/xyz/index.html')
|
85
|
+
list.save
|
86
|
+
|
87
|
+
list = SmallCage::UpdateList.new(file, '/')
|
88
|
+
list.mtimes.should eq(
|
89
|
+
'/abc/index.html.smc' => 123,
|
90
|
+
'/xyz/index.html.smc' => 987
|
91
|
+
)
|
92
|
+
ensure
|
93
|
+
file.delete
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should return expired files' do
|
99
|
+
file = root + 'list-expire.yml'
|
79
100
|
begin
|
80
|
-
list = SmallCage::UpdateList.new(file,
|
81
|
-
list.update(
|
101
|
+
list = SmallCage::UpdateList.new(file, '/')
|
102
|
+
list.update('/index.html.smc', 1, '/index.html')
|
82
103
|
|
83
104
|
e = list.expire
|
84
|
-
e.length.should
|
105
|
+
e.length.should eq 0
|
85
106
|
|
86
107
|
list.save
|
87
|
-
list.update_count.should
|
108
|
+
list.update_count.should eq 1
|
88
109
|
|
89
|
-
list = SmallCage::UpdateList.new(file,
|
110
|
+
list = SmallCage::UpdateList.new(file, '/')
|
90
111
|
e = list.expire
|
91
|
-
e.length.should
|
92
|
-
e[0].should
|
93
|
-
list.update_count.should
|
112
|
+
e.length.should eq 1
|
113
|
+
e[0].should eq '/index.html'
|
114
|
+
list.update_count.should eq 0
|
94
115
|
|
95
|
-
list = SmallCage::UpdateList.new(file,
|
96
|
-
list.update(
|
116
|
+
list = SmallCage::UpdateList.new(file, '/')
|
117
|
+
list.update('/index.html.smc', 1, '/index.html')
|
97
118
|
e = list.expire
|
98
|
-
e.length.should
|
99
|
-
list.update_count.should
|
119
|
+
e.length.should eq 0
|
120
|
+
list.update_count.should eq 1
|
100
121
|
|
101
|
-
list = SmallCage::UpdateList.new(file,
|
102
|
-
list.update(
|
103
|
-
list.update(
|
122
|
+
list = SmallCage::UpdateList.new(file, '/')
|
123
|
+
list.update('/index.html.smc', 1, '/index.html')
|
124
|
+
list.update('/index.html.smc', 1, '/index2.html')
|
104
125
|
e = list.expire
|
105
|
-
e.length.should
|
106
|
-
list.update_count.should
|
126
|
+
e.length.should eq 0
|
127
|
+
list.update_count.should eq 2
|
107
128
|
list.save
|
108
129
|
|
109
|
-
list = SmallCage::UpdateList.new(file,
|
130
|
+
list = SmallCage::UpdateList.new(file, '/')
|
110
131
|
e = list.expire
|
111
|
-
e.length.should
|
112
|
-
e.should =~ [
|
132
|
+
e.length.should eq 2
|
133
|
+
e.should =~ ['/index.html', '/index2.html']
|
113
134
|
|
114
|
-
list = SmallCage::UpdateList.new(file,
|
115
|
-
list.update(
|
116
|
-
list.update(
|
135
|
+
list = SmallCage::UpdateList.new(file, '/abc/')
|
136
|
+
list.update('/abc/index.html.smc', 2, '/abc/index.html')
|
137
|
+
list.update('/abc/index2.html.smc', 3, '/abc/index2.html')
|
117
138
|
e = list.expire
|
118
|
-
e.length.should
|
119
|
-
list.update_count.should
|
139
|
+
e.length.should eq 0
|
140
|
+
list.update_count.should eq 2
|
120
141
|
list.save
|
121
142
|
|
122
|
-
list = SmallCage::UpdateList.new(file,
|
123
|
-
list.update(
|
143
|
+
list = SmallCage::UpdateList.new(file, '/abc/')
|
144
|
+
list.update('/abc/index.html.smc', 2, '/abc/index2.html')
|
124
145
|
e = list.expire
|
125
|
-
e.length.should
|
126
|
-
e[0].should
|
146
|
+
e.length.should eq 1
|
147
|
+
e[0].should eq '/abc/index.html'
|
127
148
|
|
128
|
-
list = SmallCage::UpdateList.new(file,
|
129
|
-
list.update(
|
149
|
+
list = SmallCage::UpdateList.new(file, '/a/')
|
150
|
+
list.update('/a/index.html.smc', 2, '/abc/a.html')
|
130
151
|
e = list.expire
|
131
|
-
e.length.should
|
132
|
-
list.update_count.should
|
152
|
+
e.length.should eq 0
|
153
|
+
list.update_count.should eq 1
|
133
154
|
list.save
|
134
155
|
|
135
|
-
list = SmallCage::UpdateList.new(file,
|
136
|
-
list.update(
|
137
|
-
list.update(
|
156
|
+
list = SmallCage::UpdateList.new(file, '/abc/')
|
157
|
+
list.update('/abc/index.html.smc', 2, '/abc/index.html')
|
158
|
+
list.update('/abc/index.html.smc', 2, '/abc/index2.html')
|
138
159
|
e = list.expire
|
139
|
-
e.length.should
|
140
|
-
list.update_count.should
|
160
|
+
e.length.should eq 0
|
161
|
+
list.update_count.should eq 2
|
141
162
|
list.save
|
142
163
|
|
143
|
-
list = SmallCage::UpdateList.new(file,
|
144
|
-
list.update(
|
164
|
+
list = SmallCage::UpdateList.new(file, '/a/')
|
165
|
+
list.update('/a/index.html.smc', 2, '/abc/b.html')
|
145
166
|
e = list.expire
|
146
|
-
e.length.should
|
147
|
-
e[0]
|
167
|
+
e.length.should eq 1
|
168
|
+
e[0].should eq '/abc/a.html'
|
148
169
|
|
149
|
-
list = SmallCage::UpdateList.new(file,
|
170
|
+
list = SmallCage::UpdateList.new(file, '/')
|
150
171
|
e = list.expire
|
151
|
-
e.length.should
|
152
|
-
e.should include(
|
153
|
-
e.should include(
|
154
|
-
e.should include(
|
155
|
-
e.should include(
|
156
|
-
e.should include(
|
172
|
+
e.length.should eq 5
|
173
|
+
e.should include('/index.html')
|
174
|
+
e.should include('/index2.html')
|
175
|
+
e.should include('/abc/index.html')
|
176
|
+
e.should include('/abc/index2.html')
|
177
|
+
e.should include('/abc/a.html')
|
157
178
|
list.save
|
158
179
|
|
159
|
-
list = SmallCage::UpdateList.new(file,
|
180
|
+
list = SmallCage::UpdateList.new(file, '/')
|
160
181
|
e = list.expire
|
161
|
-
e.length.should
|
182
|
+
e.length.should eq 0
|
162
183
|
ensure
|
163
184
|
file.delete
|
164
185
|
end
|
165
186
|
end
|
166
187
|
|
167
|
-
it
|
168
|
-
file = root +
|
188
|
+
it 'should support single file target' do
|
189
|
+
file = root + 'list-single.yml'
|
169
190
|
begin
|
170
|
-
list = SmallCage::UpdateList.new(file,
|
171
|
-
list.update(
|
191
|
+
list = SmallCage::UpdateList.new(file, '/index.html.smc')
|
192
|
+
list.update('/index.html.smc', 1, '/index.html')
|
172
193
|
e = list.expire
|
173
|
-
e.length.should
|
194
|
+
e.length.should eq 0
|
174
195
|
list.save
|
175
196
|
|
176
|
-
list = SmallCage::UpdateList.new(file,
|
197
|
+
list = SmallCage::UpdateList.new(file, '/index.html.smc')
|
177
198
|
e = list.expire
|
178
|
-
e.length.should
|
199
|
+
e.length.should eq 1
|
179
200
|
|
180
|
-
list = SmallCage::UpdateList.new(file,
|
201
|
+
list = SmallCage::UpdateList.new(file, '/index2.html.smc')
|
181
202
|
e = list.expire
|
182
|
-
e.length.should
|
203
|
+
e.length.should eq 0
|
183
204
|
|
184
|
-
list = SmallCage::UpdateList.new(file,
|
205
|
+
list = SmallCage::UpdateList.new(file, '/index.html.smc/')
|
185
206
|
e = list.expire
|
186
|
-
e.length.should
|
207
|
+
e.length.should eq 0
|
187
208
|
|
188
|
-
list = SmallCage::UpdateList.new(file,
|
189
|
-
list.update(
|
209
|
+
list = SmallCage::UpdateList.new(file, '/abc/index.html.smc')
|
210
|
+
list.update('/abc/index.html.smc', 2, '/abc/index.html')
|
190
211
|
e = list.expire
|
191
|
-
e.length.should
|
212
|
+
e.length.should eq 0
|
192
213
|
list.save
|
193
|
-
list = SmallCage::UpdateList.new(file,
|
214
|
+
list = SmallCage::UpdateList.new(file, '/ab/')
|
194
215
|
e = list.expire
|
195
|
-
e.length.should
|
216
|
+
e.length.should eq 0
|
196
217
|
|
197
|
-
list = SmallCage::UpdateList.new(file,
|
218
|
+
list = SmallCage::UpdateList.new(file, '/')
|
198
219
|
e = list.expire
|
199
|
-
e.length.should
|
220
|
+
e.length.should eq 2
|
200
221
|
ensure
|
201
222
|
file.delete
|
202
223
|
end
|
203
224
|
end
|
204
225
|
|
205
|
-
it
|
206
|
-
file = root +
|
226
|
+
it 'should not expire file which other source published' do
|
227
|
+
file = root + 'list-switch.yml'
|
207
228
|
begin
|
208
|
-
list = SmallCage::UpdateList.new(file,
|
209
|
-
list.update(
|
210
|
-
list.update(
|
229
|
+
list = SmallCage::UpdateList.new(file, '/')
|
230
|
+
list.update('/index.html.smc', 1, '/aaa')
|
231
|
+
list.update('/index.html.smc', 1, '/bbb')
|
211
232
|
e = list.expire
|
212
|
-
e.length.should
|
233
|
+
e.length.should eq 0
|
213
234
|
list.save
|
214
235
|
|
215
|
-
list = SmallCage::UpdateList.new(file,
|
236
|
+
list = SmallCage::UpdateList.new(file, '/')
|
216
237
|
e = list.expire
|
217
|
-
e.length.should
|
238
|
+
e.length.should eq 2
|
218
239
|
|
219
|
-
list = SmallCage::UpdateList.new(file,
|
220
|
-
list.update(
|
221
|
-
list.update(
|
240
|
+
list = SmallCage::UpdateList.new(file, '/')
|
241
|
+
list.update('/other/file/1.smc', 2, '/aaa')
|
242
|
+
list.update('/other-file-2.smc', 2, '/bbb')
|
222
243
|
e = list.expire
|
223
|
-
e.length.should
|
244
|
+
e.length.should eq 0
|
224
245
|
ensure
|
225
246
|
file.delete
|
226
247
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smallcage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SAITO Toshihiro
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: SmallCage is a simple, but powerful website generator. It converts content
|
16
16
|
and template files, which has common elements in a website, to a plain, static website.
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- lib/smallcage/http_server.rb
|
52
52
|
- lib/smallcage/loader.rb
|
53
53
|
- lib/smallcage/misc.rb
|
54
|
+
- lib/smallcage/options_parser.rb
|
54
55
|
- lib/smallcage/renderer.rb
|
55
56
|
- lib/smallcage/resources/Manifest.erb
|
56
57
|
- lib/smallcage/resources/auto.html
|