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
@@ -1,15 +1,17 @@
|
|
1
1
|
module SmallCage
|
2
|
-
|
2
|
+
#
|
3
3
|
# Updated files list model.
|
4
|
-
#
|
4
|
+
#
|
5
|
+
# UpdateList doesn't access file system except list.yml.
|
6
|
+
#
|
5
7
|
class UpdateList
|
6
|
-
attr_reader :update_count
|
8
|
+
attr_reader :update_count, :load_error
|
7
9
|
|
8
10
|
def self.create(root_path, target_path)
|
9
11
|
docpath = DocumentPath.new(root_path, target_path)
|
10
12
|
uri = docpath.uri
|
11
|
-
uri +=
|
12
|
-
|
13
|
+
uri += '/' if docpath.path.directory? && uri[-1, 1] != '/'
|
14
|
+
new(root_path + '_smc/tmp/list.yml', uri)
|
13
15
|
end
|
14
16
|
|
15
17
|
# target_uri must be ended with / when the target is a directory.
|
@@ -23,21 +25,27 @@ module SmallCage
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def load
|
28
|
+
@load_error = nil
|
26
29
|
if @list_file.exist?
|
27
|
-
|
30
|
+
begin
|
31
|
+
@yaml = YAML.load_file(@list_file)
|
32
|
+
rescue StandardError => e
|
33
|
+
@load_error = e
|
34
|
+
@yaml = {}
|
35
|
+
end
|
28
36
|
else
|
29
|
-
@
|
37
|
+
@yaml = {}
|
30
38
|
end
|
31
|
-
@
|
32
|
-
@
|
39
|
+
@yaml['version'] ||= VERSION
|
40
|
+
@yaml['list'] ||= []
|
33
41
|
|
34
|
-
@
|
35
|
-
@
|
36
|
-
src = item[
|
37
|
-
@
|
42
|
+
@src_item_map = {}
|
43
|
+
@yaml['list'].each do |item|
|
44
|
+
src = item['src']
|
45
|
+
@src_item_map[src] = item
|
38
46
|
if target?(src)
|
39
47
|
@expired_src[src] = true
|
40
|
-
item[
|
48
|
+
item['dst'].each do |d|
|
41
49
|
@expired_dst[d] = [true, src]
|
42
50
|
end
|
43
51
|
end
|
@@ -46,26 +54,31 @@ module SmallCage
|
|
46
54
|
private :load
|
47
55
|
|
48
56
|
def target?(uri)
|
49
|
-
|
57
|
+
uri[0...@target_uri.length] == @target_uri
|
50
58
|
end
|
51
59
|
private :target?
|
52
60
|
|
53
61
|
def save
|
54
62
|
FileUtils.mkpath(@list_file.parent)
|
55
|
-
@
|
56
|
-
open(@list_file,
|
63
|
+
@yaml['version'] = VERSION
|
64
|
+
open(@list_file, 'w') do |io|
|
57
65
|
io << to_yaml
|
58
66
|
end
|
59
67
|
end
|
60
68
|
|
61
69
|
def to_yaml
|
62
|
-
|
70
|
+
@yaml.to_yaml
|
71
|
+
end
|
72
|
+
|
73
|
+
# return src_uri => mtime hash.
|
74
|
+
def mtimes
|
75
|
+
Hash[@src_item_map.map { |k,v| [k, v['mtime'].to_i] }]
|
63
76
|
end
|
64
77
|
|
65
78
|
def mtime(srcuri)
|
66
|
-
item = @
|
79
|
+
item = @src_item_map[srcuri]
|
67
80
|
return -1 unless item
|
68
|
-
|
81
|
+
item['mtime'].to_i
|
69
82
|
end
|
70
83
|
|
71
84
|
def update(srcuri, mtime, dsturi)
|
@@ -75,25 +88,23 @@ module SmallCage
|
|
75
88
|
end
|
76
89
|
|
77
90
|
def update_list(srcuri, mtime, dsturi)
|
78
|
-
unless update_list_item(srcuri, mtime, dsturi)
|
79
|
-
add_list_item(srcuri, mtime, dsturi)
|
80
|
-
end
|
91
|
+
add_list_item(srcuri, mtime, dsturi) unless update_list_item(srcuri, mtime, dsturi)
|
81
92
|
end
|
82
93
|
private :update_list
|
83
94
|
|
84
95
|
def update_list_item(srcuri, mtime, dsturi)
|
85
|
-
return false unless @
|
86
|
-
item = @
|
87
|
-
item[
|
88
|
-
item[
|
89
|
-
|
96
|
+
return false unless @src_item_map[srcuri]
|
97
|
+
item = @src_item_map[srcuri]
|
98
|
+
item['mtime'] = mtime.to_i
|
99
|
+
item['dst'] << dsturi unless item['dst'].include?(dsturi)
|
100
|
+
true
|
90
101
|
end
|
91
102
|
private :update_list_item
|
92
103
|
|
93
104
|
def add_list_item(srcuri, mtime, dsturi)
|
94
|
-
item = {
|
95
|
-
@
|
96
|
-
@
|
105
|
+
item = { 'src' => srcuri, 'dst' => [dsturi], 'mtime' => mtime.to_i }
|
106
|
+
@src_item_map[srcuri] = item
|
107
|
+
@yaml['list'] << item
|
97
108
|
end
|
98
109
|
private :add_list_item
|
99
110
|
|
@@ -105,21 +116,20 @@ module SmallCage
|
|
105
116
|
|
106
117
|
def expire
|
107
118
|
expire_src
|
108
|
-
|
109
|
-
return result
|
119
|
+
expire_dst
|
110
120
|
end
|
111
121
|
|
112
122
|
def expire_src
|
113
|
-
@expired_src.each do |srcuri,v|
|
123
|
+
@expired_src.each do |srcuri, v|
|
114
124
|
mark_expired_src(srcuri)
|
115
125
|
end
|
116
|
-
@
|
126
|
+
@yaml['list'] = @yaml['list'].select { |item| !item['expired'] }
|
117
127
|
end
|
118
128
|
private :expire_src
|
119
129
|
|
120
130
|
def mark_expired_src(srcuri)
|
121
|
-
@
|
122
|
-
@
|
131
|
+
@src_item_map[srcuri]['expired'] = true
|
132
|
+
@src_item_map[srcuri]['dst'].each do |dsturi|
|
123
133
|
next if @expired_dst[dsturi] && ! @expired_dst[dsturi][0]
|
124
134
|
@expired_dst[dsturi] = [true, srcuri]
|
125
135
|
end
|
@@ -131,11 +141,11 @@ module SmallCage
|
|
131
141
|
@expired_dst.each do |dsturi, stat|
|
132
142
|
next unless stat[0]
|
133
143
|
srcuri = stat[1]
|
134
|
-
item = @
|
135
|
-
item[
|
144
|
+
item = @src_item_map[srcuri]
|
145
|
+
item['dst'].delete(dsturi)
|
136
146
|
result << dsturi
|
137
147
|
end
|
138
|
-
|
148
|
+
result
|
139
149
|
end
|
140
150
|
private :expire_dst
|
141
151
|
end
|
data/lib/smallcage/version.rb
CHANGED
data/lib/smallcage.rb
CHANGED
@@ -27,87 +27,101 @@ describe SmallCage::Application do
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
@target = SmallCage::Application.new
|
32
|
-
end
|
30
|
+
subject { SmallCage::Application.new }
|
33
31
|
|
34
32
|
it 'should parse update command' do
|
35
|
-
options =
|
36
|
-
options.should eq(:path => '.', :command => :update, :quiet => false)
|
33
|
+
options = subject.parse_options(['update', '.'])
|
34
|
+
options.should eq(:path => '.', :command => :update, :quiet => false, :fast => false)
|
35
|
+
end
|
37
36
|
|
38
|
-
|
39
|
-
options.
|
37
|
+
it 'should parse up command' do
|
38
|
+
options = subject.parse_options(['up', '.'])
|
39
|
+
options.should eq(:path => '.', :command => :update, :quiet => false, :fast => false)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should parse clean command' do
|
43
|
-
options =
|
43
|
+
options = subject.parse_options(['clean', '.'])
|
44
44
|
options.should eq(:path => '.', :command => :clean, :quiet => false)
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'should parse server command' do
|
48
|
-
options =
|
48
|
+
options = subject.parse_options(['server', '.'])
|
49
49
|
options.should eq(:path => '.', :command => :server, :quiet => false, :port => 8080) # num
|
50
50
|
|
51
|
-
options =
|
51
|
+
options = subject.parse_options(['sv', '.', '8080'])
|
52
52
|
options.should eq(:path => '.', :command => :server, :quiet => false, :port => 8080) # string
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should accept only number port' do
|
56
|
-
result = capture_result {
|
56
|
+
result = capture_result { subject.parse_options(['server', '.', 'pot']) }
|
57
57
|
result[:exit].should eq 1
|
58
58
|
result[:stdout].should be_empty
|
59
59
|
result[:stderr].should eq "illegal port number: pot\n"
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should not accept port 0' do
|
63
|
-
result = capture_result {
|
63
|
+
result = capture_result { subject.parse_options(['server', '.', '0']) }
|
64
64
|
result[:exit].should eq 1
|
65
65
|
result[:stdout].should be_empty
|
66
66
|
result[:stderr].should eq "illegal port number: 0\n"
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should parse auto command' do
|
70
|
-
options =
|
71
|
-
options.should eq(
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
options = subject.parse_options(['auto', '.'])
|
71
|
+
options.should eq(
|
72
|
+
:path => '.',
|
73
|
+
:command => :auto,
|
74
|
+
:port => nil,
|
75
|
+
:bell => false,
|
76
|
+
:fast => false,
|
77
|
+
:quiet => false
|
78
|
+
)
|
79
|
+
|
80
|
+
options = subject.parse_options(['au', '.', '8080'])
|
81
|
+
options.should eq(
|
82
|
+
:path => '.',
|
83
|
+
:command => :auto,
|
84
|
+
:port => 8080,
|
85
|
+
:bell => false,
|
86
|
+
:fast => false,
|
87
|
+
:quiet => false
|
88
|
+
)
|
75
89
|
end
|
76
90
|
|
77
91
|
it 'should parse import command' do
|
78
|
-
options =
|
92
|
+
options = subject.parse_options(['import', 'base', '.'])
|
79
93
|
options.should eq(:command => :import, :from => 'base', :to => '.', :quiet => false)
|
80
94
|
|
81
|
-
options =
|
95
|
+
options = subject.parse_options(['import'])
|
82
96
|
options.should eq(:command => :import, :from => 'default', :to => '.', :quiet => false)
|
83
97
|
end
|
84
98
|
|
85
99
|
it 'should parse export command' do
|
86
|
-
options =
|
100
|
+
options = subject.parse_options(['export', '.', 'path'])
|
87
101
|
options.should eq(:command => :export, :path => '.', :out => 'path', :quiet => false)
|
88
102
|
|
89
|
-
options =
|
103
|
+
options = subject.parse_options(['export'])
|
90
104
|
options.should eq(:command => :export, :path => '.', :out => nil, :quiet => false)
|
91
105
|
end
|
92
106
|
|
93
107
|
it 'should parse uri command' do
|
94
|
-
options =
|
108
|
+
options = subject.parse_options(['uri', './path/to/target'])
|
95
109
|
options.should eq(:command => :uri, :path => './path/to/target', :quiet => false)
|
96
110
|
|
97
|
-
options =
|
111
|
+
options = subject.parse_options(['uri'])
|
98
112
|
options.should eq(:command => :uri, :path => '.', :quiet => false)
|
99
113
|
end
|
100
114
|
|
101
115
|
it 'should parse manifest command' do
|
102
|
-
options =
|
116
|
+
options = subject.parse_options(['manifest', './path/to/target'])
|
103
117
|
options.should eq(:command => :manifest, :path => './path/to/target', :quiet => false)
|
104
118
|
|
105
|
-
options =
|
119
|
+
options = subject.parse_options(['manifest'])
|
106
120
|
options.should eq( :command => :manifest, :path => '.', :quiet => false )
|
107
121
|
end
|
108
122
|
|
109
123
|
it 'should exit 1 if command is empty' do
|
110
|
-
result = capture_result {
|
124
|
+
result = capture_result { subject.parse_options([]) }
|
111
125
|
result[:exit].should eq 1
|
112
126
|
result[:stdout].should =~ /\AUsage:/
|
113
127
|
result[:stdout].should =~ /^Subcommands are:/
|
@@ -115,7 +129,7 @@ describe SmallCage::Application do
|
|
115
129
|
end
|
116
130
|
|
117
131
|
it 'should show help' do
|
118
|
-
result = capture_result {
|
132
|
+
result = capture_result { subject.parse_options(['help']) }
|
119
133
|
result[:exit].should eq 0
|
120
134
|
result[:stdout].should =~ /\AUsage:/
|
121
135
|
result[:stdout].should =~ /^Subcommands are:/
|
@@ -123,7 +137,7 @@ describe SmallCage::Application do
|
|
123
137
|
end
|
124
138
|
|
125
139
|
it 'should show help if the arguments include --help' do
|
126
|
-
result = capture_result {
|
140
|
+
result = capture_result { subject.parse_options(['--help', 'update']) }
|
127
141
|
result[:exit].should eq 0
|
128
142
|
result[:stdout].should =~ /\AUsage:/
|
129
143
|
result[:stdout].should =~ /^Subcommands are:/
|
@@ -131,28 +145,28 @@ describe SmallCage::Application do
|
|
131
145
|
end
|
132
146
|
|
133
147
|
it 'should show subcommand help' do
|
134
|
-
result = capture_result {
|
148
|
+
result = capture_result { subject.parse_options(['help', 'update']) }
|
135
149
|
result[:exit].should eq 0
|
136
150
|
result[:stdout].should =~ /\AUsage: smc update \[path\]/
|
137
151
|
result[:stderr].should be_empty
|
138
152
|
end
|
139
153
|
|
140
154
|
it 'should exit if the command is unknown' do
|
141
|
-
result = capture_result {
|
155
|
+
result = capture_result { subject.parse_options(['xxxx']) }
|
142
156
|
result[:exit].should eq 1
|
143
157
|
result[:stdout].should be_empty
|
144
158
|
result[:stderr].should eq "no such subcommand: xxxx\n"
|
145
159
|
end
|
146
160
|
|
147
161
|
it 'should show version' do
|
148
|
-
result = capture_result {
|
162
|
+
result = capture_result { subject.parse_options(['--version', 'update']) }
|
149
163
|
result[:exit].should eq 0
|
150
164
|
result[:stdout].should =~ /\ASmallCage \d+\.\d+\.\d+ - /
|
151
165
|
result[:stderr].should be_empty
|
152
166
|
end
|
153
167
|
|
154
168
|
it 'should exit when subcommand is empty' do
|
155
|
-
result = capture_result {
|
169
|
+
result = capture_result { subject.parse_options(['', '--version']) }
|
156
170
|
result[:exit].should eq 1
|
157
171
|
result[:stdout].should =~ /\AUsage:/
|
158
172
|
result[:stdout].should =~ /^Subcommands are:/
|
@@ -160,49 +174,49 @@ describe SmallCage::Application do
|
|
160
174
|
end
|
161
175
|
|
162
176
|
it 'should ignore subcommand with --version option' do
|
163
|
-
result = capture_result {
|
177
|
+
result = capture_result { subject.parse_options(['help', '--version']) }
|
164
178
|
result[:exit].should eq 0
|
165
179
|
result[:stdout].should =~ /\ASmallCage \d+\.\d+\.\d+ - /
|
166
180
|
result[:stderr].should be_empty
|
167
181
|
end
|
168
182
|
|
169
183
|
it 'should ignore subcommand with -v option' do
|
170
|
-
result = capture_result {
|
184
|
+
result = capture_result { subject.parse_options(['help', '-v']) }
|
171
185
|
result[:exit].should eq 0
|
172
186
|
result[:stdout].should =~ /\ASmallCage \d+\.\d+\.\d+ - /
|
173
187
|
result[:stderr].should be_empty
|
174
188
|
end
|
175
189
|
|
176
190
|
it 'should ignore subcommand with --help option' do
|
177
|
-
result = capture_result {
|
191
|
+
result = capture_result { subject.parse_options(['update', '--help']) }
|
178
192
|
result[:exit].should eq 0
|
179
193
|
result[:stdout].should =~ /\AUsage: smc update \[path\] \[options\]/
|
180
194
|
result[:stderr].should be_empty
|
181
195
|
end
|
182
196
|
|
183
197
|
it 'should ignore subcommand with -h option' do
|
184
|
-
result = capture_result {
|
198
|
+
result = capture_result { subject.parse_options(['update', '-h']) }
|
185
199
|
result[:exit].should eq 0
|
186
200
|
result[:stdout].should =~ /\AUsage: smc update \[path\] \[options\]/
|
187
201
|
result[:stderr].should be_empty
|
188
202
|
end
|
189
203
|
|
190
204
|
it 'should exit with unknown main option --QQQ' do
|
191
|
-
result = capture_result {
|
205
|
+
result = capture_result { subject.parse_options(['--QQQ']) }
|
192
206
|
result[:exit].should eq 1
|
193
207
|
result[:stdout].should be_empty
|
194
208
|
result[:stderr].should eq "invalid option: --QQQ\n"
|
195
209
|
end
|
196
210
|
|
197
211
|
it 'should exit with unknown sub option --QQQ' do
|
198
|
-
result = capture_result {
|
212
|
+
result = capture_result { subject.parse_options(['update', '--QQQ']) }
|
199
213
|
result[:exit].should eq 1
|
200
214
|
result[:stdout].should be_empty
|
201
215
|
result[:stderr].should eq "invalid option: --QQQ\n"
|
202
216
|
end
|
203
217
|
|
204
218
|
it 'should accept auto command --bell option' do
|
205
|
-
result = capture_result {
|
219
|
+
result = capture_result { subject.parse_options(['auto', '--bell']) }
|
206
220
|
result[:exit].should be_nil
|
207
221
|
result[:stdout].should be_empty
|
208
222
|
result[:stderr].should be_empty
|
@@ -211,12 +225,13 @@ describe SmallCage::Application do
|
|
211
225
|
:port => nil,
|
212
226
|
:path => '.',
|
213
227
|
:bell => true,
|
228
|
+
:fast => false,
|
214
229
|
:quiet => false
|
215
230
|
)
|
216
231
|
end
|
217
232
|
|
218
233
|
it 'should set bell option false as default' do
|
219
|
-
result = capture_result {
|
234
|
+
result = capture_result { subject.parse_options(['auto']) }
|
220
235
|
result[:exit].should be_nil
|
221
236
|
result[:stdout].should be_empty
|
222
237
|
result[:stderr].should be_empty
|
@@ -225,37 +240,40 @@ describe SmallCage::Application do
|
|
225
240
|
:port => nil,
|
226
241
|
:path => '.',
|
227
242
|
:bell => false,
|
243
|
+
:fast => false,
|
228
244
|
:quiet => false
|
229
245
|
)
|
230
246
|
end
|
231
247
|
|
232
248
|
it 'should accept --quiet option' do
|
233
|
-
result = capture_result {
|
249
|
+
result = capture_result { subject.parse_options(['--quiet', 'update']) }
|
234
250
|
result[:exit].should be_nil
|
235
251
|
result[:stdout].should be_empty
|
236
252
|
result[:stderr].should be_empty
|
237
253
|
result[:result].should eq(
|
238
254
|
:command => :update,
|
239
255
|
:path => '.',
|
256
|
+
:fast => false,
|
240
257
|
:quiet => true
|
241
258
|
)
|
242
259
|
end
|
243
260
|
|
244
261
|
it 'should accept --quiet option after subcommand' do
|
245
|
-
result = capture_result {
|
262
|
+
result = capture_result { subject.parse_options(['update', '--quiet']) }
|
246
263
|
result[:exit].should be_nil
|
247
264
|
result[:stdout].should be_empty
|
248
265
|
result[:stderr].should be_empty
|
249
266
|
result[:result].should eq(
|
250
267
|
:command => :update,
|
251
268
|
:path => '.',
|
269
|
+
:fast => false,
|
252
270
|
:quiet => true
|
253
271
|
)
|
254
272
|
end
|
255
273
|
|
256
274
|
it 'should accept --quiet option before and after subcommand' do
|
257
275
|
opts = %w{--quiet auto --quiet path --bell 80}
|
258
|
-
result = capture_result {
|
276
|
+
result = capture_result { subject.parse_options(opts) }
|
259
277
|
result[:exit].should be_nil
|
260
278
|
result[:stdout].should be_empty
|
261
279
|
result[:stderr].should be_empty
|
@@ -264,6 +282,7 @@ describe SmallCage::Application do
|
|
264
282
|
:path => 'path',
|
265
283
|
:port => 80,
|
266
284
|
:bell => true,
|
285
|
+
:fast => false,
|
267
286
|
:quiet => true
|
268
287
|
)
|
269
288
|
end
|
@@ -13,10 +13,10 @@ describe "SmallCage::Commands::Export" do
|
|
13
13
|
:quiet => true }
|
14
14
|
SmallCage::Runner.run(opts)
|
15
15
|
|
16
|
-
(outdir + "./a/test.html.smc").exist?.
|
17
|
-
(outdir + "./a/test.html").exist?.
|
18
|
-
(outdir + "./a/b/test.html").exist?.should
|
19
|
-
(outdir + "./a/b/c/test.html").exist?.should
|
16
|
+
(outdir + "./a/test.html.smc").exist?.should be false
|
17
|
+
(outdir + "./a/test.html").exist?.should be false
|
18
|
+
(outdir + "./a/b/test.html").exist?.should be true
|
19
|
+
(outdir + "./a/b/c/test.html").exist?.should be true
|
20
20
|
ensure
|
21
21
|
FileUtils.rm_r(outdir)
|
22
22
|
end
|
@@ -31,11 +31,11 @@ describe "SmallCage::Commands::Export" do
|
|
31
31
|
:quiet => true }
|
32
32
|
SmallCage::Runner.run(opts)
|
33
33
|
|
34
|
-
(outdir + "./a/test.html.smc").exist?.
|
35
|
-
(outdir + "./a/test.html").exist?.
|
36
|
-
(outdir + "./a/b/test.html").exist?.
|
34
|
+
(outdir + "./a/test.html.smc").exist?.should be false
|
35
|
+
(outdir + "./a/test.html").exist?.should be false
|
36
|
+
(outdir + "./a/b/test.html").exist?.should be false
|
37
37
|
|
38
|
-
(outdir + "./a/b/c/test.html").exist?.should
|
38
|
+
(outdir + "./a/b/c/test.html").exist?.should be true
|
39
39
|
ensure
|
40
40
|
FileUtils.rm_r(outdir)
|
41
41
|
end
|
@@ -11,8 +11,8 @@ describe "SmallCage::Commands::Import" do
|
|
11
11
|
opts = { :command => "import", :from => "default", :to => tmpdir.to_s, :quiet => true }
|
12
12
|
SmallCage::Runner.run(opts)
|
13
13
|
|
14
|
-
(tmpdir + "_smc").directory?.should
|
15
|
-
(tmpdir + "_smc/helpers/base_helper.rb").file?.should
|
14
|
+
(tmpdir + "_smc").directory?.should be true
|
15
|
+
(tmpdir + "_smc/helpers/base_helper.rb").file?.should be true
|
16
16
|
|
17
17
|
FileUtils.rm_r(tmpdir)
|
18
18
|
end
|
@@ -13,7 +13,7 @@ describe SmallCage::Commands::Manifest do
|
|
13
13
|
it "should create Manifest.html" do
|
14
14
|
|
15
15
|
SmallCage::Runner.run(@opts.merge(:command => "manifest"))
|
16
|
-
@manifest_file.file?.should
|
16
|
+
@manifest_file.file?.should be true
|
17
17
|
|
18
18
|
source = @manifest_file.read
|
19
19
|
source = source.match(%r{<ul class="files">\n(.+?)\n</ul>}m)[1].split(/\n/)
|
@@ -14,7 +14,7 @@ describe SmallCage::Commands::Update do
|
|
14
14
|
SmallCage::Runner.run(opts)
|
15
15
|
|
16
16
|
out = docroot + "a/b/c/index.html"
|
17
|
-
out.file?.should
|
17
|
+
out.file?.should be true
|
18
18
|
out.delete
|
19
19
|
|
20
20
|
Dir.chdir(path) do
|
@@ -22,7 +22,7 @@ describe SmallCage::Commands::Update do
|
|
22
22
|
SmallCage::Runner.run(opts)
|
23
23
|
end
|
24
24
|
|
25
|
-
out.file?.should
|
25
|
+
out.file?.should be true
|
26
26
|
out.delete
|
27
27
|
ensure
|
28
28
|
SmallCage::Runner.run({:command => "clean", :path => path.to_s, :quiet => true })
|
@@ -38,10 +38,10 @@ describe SmallCage::Commands::Update do
|
|
38
38
|
SmallCage::Runner.run(opts)
|
39
39
|
|
40
40
|
out = root + "_dir"
|
41
|
-
out.file?.should
|
41
|
+
out.file?.should be false
|
42
42
|
|
43
43
|
out = root + "_local"
|
44
|
-
out.file?.should
|
44
|
+
out.file?.should be false
|
45
45
|
ensure
|
46
46
|
SmallCage::Runner.run({:command => "clean", :path => root.to_s, :quiet => true })
|
47
47
|
end
|
@@ -53,21 +53,21 @@ describe SmallCage::Commands::Update do
|
|
53
53
|
begin
|
54
54
|
SmallCage::Runner.run({ :command => "update", :path => root.to_s, :quiet => true })
|
55
55
|
|
56
|
-
(root + "a/index.html").file?.should
|
57
|
-
(root + "ab/index.html").file?.should
|
58
|
-
(root + "abc/index.html").file?.should
|
56
|
+
(root + "a/index.html").file?.should be true
|
57
|
+
(root + "ab/index.html").file?.should be true
|
58
|
+
(root + "abc/index.html").file?.should be true
|
59
59
|
|
60
60
|
SmallCage::Runner.run({ :command => "update", :path => (root + "a").to_s, :quiet => true })
|
61
61
|
|
62
|
-
(root + "a/index.html").file?.should
|
63
|
-
(root + "ab/index.html").file?.should
|
64
|
-
(root + "abc/index.html").file?.should
|
62
|
+
(root + "a/index.html").file?.should be true
|
63
|
+
(root + "ab/index.html").file?.should be true
|
64
|
+
(root + "abc/index.html").file?.should be true
|
65
65
|
|
66
66
|
SmallCage::Runner.run({ :command => "update", :path => (root + "ab").to_s, :quiet => true })
|
67
67
|
|
68
|
-
(root + "a/index.html").file?.should
|
69
|
-
(root + "ab/index.html").file?.should
|
70
|
-
(root + "abc/index.html").file?.should
|
68
|
+
(root + "a/index.html").file?.should be true
|
69
|
+
(root + "ab/index.html").file?.should be true
|
70
|
+
(root + "abc/index.html").file?.should be true
|
71
71
|
ensure
|
72
72
|
SmallCage::Runner.run({:command => "clean", :path => root.to_s, :quiet => true })
|
73
73
|
end
|
@@ -10,7 +10,7 @@ describe SmallCage::DocumentPath do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should return smc file or not" do
|
13
|
-
docpath.smc?.should
|
13
|
+
docpath.smc?.should be true
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return output file" do
|
@@ -45,7 +45,7 @@ describe SmallCage::DocumentPath do
|
|
45
45
|
e.message.should =~ /\AIllegal path: /
|
46
46
|
ok = true
|
47
47
|
end
|
48
|
-
ok.should
|
48
|
+
ok.should be true
|
49
49
|
|
50
50
|
path = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs'))
|
51
51
|
ok = false
|
@@ -55,7 +55,7 @@ describe SmallCage::DocumentPath do
|
|
55
55
|
e.message.should =~ /\AIllegal path: /
|
56
56
|
ok = true
|
57
57
|
end
|
58
|
-
ok.should
|
58
|
+
ok.should be true
|
59
59
|
|
60
60
|
path = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs2'))
|
61
61
|
ok = false
|
@@ -65,6 +65,6 @@ describe SmallCage::DocumentPath do
|
|
65
65
|
e.message.should =~ /\AIllegal path: /
|
66
66
|
ok = true
|
67
67
|
end
|
68
|
-
ok.should
|
68
|
+
ok.should be true
|
69
69
|
end
|
70
70
|
end
|
@@ -38,7 +38,7 @@ describe SmallCage::Loader do
|
|
38
38
|
root.to_s.should =~ %r{^.+/data/htdocs1$}
|
39
39
|
|
40
40
|
depth = 3
|
41
|
-
lambda { SmallCage::Loader.find_root(path, depth) }.should raise_error
|
41
|
+
lambda { SmallCage::Loader.find_root(path, depth) }.should raise_error(RuntimeError)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should load strings" do
|
@@ -79,7 +79,7 @@ describe SmallCage::Loader do
|
|
79
79
|
dirs[1]["uri"].should == "/a/"
|
80
80
|
dirs[2]["uri"].should == "/a/b/"
|
81
81
|
dirs[3]["uri"].should == "/a/b/c/"
|
82
|
-
(dirs[3]["path"] + "index.html.smc").file?.should
|
82
|
+
(dirs[3]["path"] + "index.html.smc").file?.should be true
|
83
83
|
|
84
84
|
dirs[0]["var"].should == "xxx"
|
85
85
|
dirs[0]["strings"][0].should == "BODYBODYBODY"
|
@@ -101,7 +101,7 @@ describe SmallCage::Loader do
|
|
101
101
|
dirs[2]["z"].should == 999
|
102
102
|
dirs[2]["body"].should == "dirsmc"
|
103
103
|
|
104
|
-
dirs[3]["only_local_smc"].should
|
104
|
+
dirs[3]["only_local_smc"].should be true
|
105
105
|
dirs[3]["arrays"][0][2].should == "smc"
|
106
106
|
dirs[3]["body"].should == "strings"
|
107
107
|
|