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.
@@ -2,225 +2,246 @@ require 'spec_helper.rb'
2
2
  require 'smallcage'
3
3
 
4
4
  describe SmallCage::UpdateList do
5
- root = Pathname.new(File.join(SPEC_DATA_DIR, 'updatelists'))
5
+ let(:root) { Pathname.new(File.join(SPEC_DATA_DIR, 'updatelists')) }
6
6
 
7
- it "should create empty data" do
8
- list = SmallCage::UpdateList.new(root + "dummy.yml", "/")
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["version"].should match(/\d\.\d\.\d/)
11
- result["list"].should be_empty
10
+ result['version'].should match(/\d\.\d\.\d/)
11
+ result['list'].should be_empty
12
12
 
13
- list = SmallCage::UpdateList.new(root + "dummy.yml", "/")
13
+ list = SmallCage::UpdateList.new(root + 'dummy.yml', '/')
14
14
  list.expire
15
15
  result = YAML.load(list.to_yaml)
16
- result["version"].should match(/^\d\.\d\.\d$/)
17
- result["list"].should be_empty
16
+ result['version'].should match(/^\d\.\d\.\d$/)
17
+ result['list'].should be_empty
18
18
  end
19
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")
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 "should update version" do
27
- file = root + "list-version.yml"
26
+ it 'should update version' do
27
+ file = root + 'list-version.yml'
28
28
  begin
29
- open(file, "w") do |io|
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["version"].should == SmallCage::VERSION
38
+ data['version'].should eq SmallCage::VERSION
39
39
  ensure
40
40
  file.delete
41
41
  end
42
42
  end
43
43
 
44
- it "should save mtime" do
45
- file = root + "list-mtime.yml"
44
+ it 'should save mtime' do
45
+ file = root + 'list-mtime.yml'
46
46
  begin
47
- list = SmallCage::UpdateList.new(file, "/")
48
- list.update("/index.html.smc", 1234567890, "/index.html")
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("/index.html.smc").should == 1234567890
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("/abc/index.html.smc", 1, "/index.html")
56
- list.mtime("/abc/index.html.smc").should == 1
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("/abc/index.html.smc", 2, "/index.html")
59
- list.mtime("/abc/index.html.smc").should == 2
60
- list.mtime("/index.html.smc").should == 1234567890
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("/index.html.smc").should == 1234567890
64
- list.mtime("/abc/index.html.smc").should == -1
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("/abc/index.html.smc", 1, "/index.html")
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("/index.html.smc").should == 1234567890
71
- list.mtime("/abc/index.html.smc").should == 1
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
- it "should return expired files" do
78
- file = root + "list-expire.yml"
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("/index.html.smc", 1, "/index.html")
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 == 0
105
+ e.length.should eq 0
85
106
 
86
107
  list.save
87
- list.update_count.should == 1
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 == 1
92
- e[0].should == "/index.html"
93
- list.update_count.should == 0
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("/index.html.smc", 1, "/index.html")
116
+ list = SmallCage::UpdateList.new(file, '/')
117
+ list.update('/index.html.smc', 1, '/index.html')
97
118
  e = list.expire
98
- e.length.should == 0
99
- list.update_count.should == 1
119
+ e.length.should eq 0
120
+ list.update_count.should eq 1
100
121
 
101
- list = SmallCage::UpdateList.new(file, "/")
102
- list.update("/index.html.smc", 1, "/index.html")
103
- list.update("/index.html.smc", 1, "/index2.html")
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 == 0
106
- list.update_count.should == 2
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 == 2
112
- e.should =~ ["/index.html", "/index2.html"]
132
+ e.length.should eq 2
133
+ e.should =~ ['/index.html', '/index2.html']
113
134
 
114
- list = SmallCage::UpdateList.new(file, "/abc/")
115
- list.update("/abc/index.html.smc", 2, "/abc/index.html")
116
- list.update("/abc/index2.html.smc", 3, "/abc/index2.html")
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 == 0
119
- list.update_count.should == 2
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, "/abc/")
123
- list.update("/abc/index.html.smc", 2, "/abc/index2.html")
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 == 1
126
- e[0].should == "/abc/index.html"
146
+ e.length.should eq 1
147
+ e[0].should eq '/abc/index.html'
127
148
 
128
- list = SmallCage::UpdateList.new(file, "/a/")
129
- list.update("/a/index.html.smc", 2, "/abc/a.html")
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 == 0
132
- list.update_count.should == 1
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, "/abc/")
136
- list.update("/abc/index.html.smc", 2, "/abc/index.html")
137
- list.update("/abc/index.html.smc", 2, "/abc/index2.html")
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 == 0
140
- list.update_count.should == 2
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, "/a/")
144
- list.update("/a/index.html.smc", 2, "/abc/b.html")
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 == 1
147
- e[0] == "/abc/a.html"
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 == 5
152
- e.should include("/index.html")
153
- e.should include("/index2.html")
154
- e.should include("/abc/index.html")
155
- e.should include("/abc/index2.html")
156
- e.should include("/abc/a.html")
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 == 0
182
+ e.length.should eq 0
162
183
  ensure
163
184
  file.delete
164
185
  end
165
186
  end
166
187
 
167
- it "should support single file target" do
168
- file = root + "list-single.yml"
188
+ it 'should support single file target' do
189
+ file = root + 'list-single.yml'
169
190
  begin
170
- list = SmallCage::UpdateList.new(file, "/index.html.smc")
171
- list.update("/index.html.smc", 1, "/index.html")
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 == 0
194
+ e.length.should eq 0
174
195
  list.save
175
196
 
176
- list = SmallCage::UpdateList.new(file, "/index.html.smc")
197
+ list = SmallCage::UpdateList.new(file, '/index.html.smc')
177
198
  e = list.expire
178
- e.length.should == 1
199
+ e.length.should eq 1
179
200
 
180
- list = SmallCage::UpdateList.new(file, "/index2.html.smc")
201
+ list = SmallCage::UpdateList.new(file, '/index2.html.smc')
181
202
  e = list.expire
182
- e.length.should == 0
203
+ e.length.should eq 0
183
204
 
184
- list = SmallCage::UpdateList.new(file, "/index.html.smc/")
205
+ list = SmallCage::UpdateList.new(file, '/index.html.smc/')
185
206
  e = list.expire
186
- e.length.should == 0
207
+ e.length.should eq 0
187
208
 
188
- list = SmallCage::UpdateList.new(file, "/abc/index.html.smc")
189
- list.update("/abc/index.html.smc", 2, "/abc/index.html")
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 == 0
212
+ e.length.should eq 0
192
213
  list.save
193
- list = SmallCage::UpdateList.new(file, "/ab/")
214
+ list = SmallCage::UpdateList.new(file, '/ab/')
194
215
  e = list.expire
195
- e.length.should == 0
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 == 2
220
+ e.length.should eq 2
200
221
  ensure
201
222
  file.delete
202
223
  end
203
224
  end
204
225
 
205
- it "should not expire file which other source published" do
206
- file = root + "list-switch.yml"
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("/index.html.smc", 1, "/aaa")
210
- list.update("/index.html.smc", 1, "/bbb")
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 == 0
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 == 2
238
+ e.length.should eq 2
218
239
 
219
- list = SmallCage::UpdateList.new(file, "/")
220
- list.update("/other/file/1.smc", 2, "/aaa")
221
- list.update("/other-file-2.smc", 2, "/bbb")
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 == 0
244
+ e.length.should eq 0
224
245
  ensure
225
246
  file.delete
226
247
  end
data/spec/spec_helper.rb CHANGED
@@ -9,3 +9,9 @@ SPEC_DATA_DIR = File.join(File.dirname(__FILE__), 'data')
9
9
 
10
10
  # required to execute rcov rake task.
11
11
  require 'rspec/core'
12
+
13
+ RSpec.configure do |config|
14
+ config.expect_with :rspec do |c|
15
+ c.syntax = [:should, :expect]
16
+ end
17
+ end
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.6
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: 2014-03-13 00:00:00.000000000 Z
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