smallcage 0.2.4 → 0.2.5
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/.gitignore +1 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +1 -1
- data/Gemfile +16 -5
- data/Guardfile +4 -0
- data/History.rdoc +9 -5
- data/README.rdoc +3 -3
- data/Rakefile +1 -1
- data/bin/smc +4 -12
- data/lib/smallcage.rb +4 -1
- data/lib/smallcage/anonymous_loader.rb +32 -0
- data/lib/smallcage/application.rb +4 -5
- data/lib/smallcage/commands/auto.rb +16 -17
- data/lib/smallcage/commands/base.rb +4 -5
- data/lib/smallcage/commands/clean.rb +5 -5
- data/lib/smallcage/commands/export.rb +5 -5
- data/lib/smallcage/commands/import.rb +25 -27
- data/lib/smallcage/commands/manifest.rb +4 -4
- data/lib/smallcage/commands/server.rb +4 -4
- data/lib/smallcage/commands/update.rb +4 -5
- data/lib/smallcage/commands/uri.rb +3 -5
- data/lib/smallcage/document_path.rb +6 -9
- data/lib/smallcage/http_server.rb +9 -10
- data/lib/smallcage/loader.rb +19 -49
- data/lib/smallcage/misc.rb +1 -1
- data/lib/smallcage/renderer.rb +1 -1
- data/lib/smallcage/resources/auto.html +7 -7
- data/lib/smallcage/runner.rb +6 -6
- data/lib/smallcage/update_list.rb +2 -3
- data/lib/smallcage/version.rb +1 -1
- data/project/base/_smc/helpers/base_helper.rb +8 -9
- data/project/bluecloth/_smc/helpers/blue_cloth_helper.rb +2 -3
- data/project/cache/_smc/filters/cache_filter.rb +10 -12
- data/project/cache/_smc/rakelib/cache.rake +7 -8
- data/project/gdata/_smc/rakelib/gdata.rake +3 -5
- data/project/lang/_smc/helpers/lang_helper.rb +3 -3
- data/project/news/_smc/helpers/news_helper.rb +3 -4
- data/project/nkf/_smc/filters/nkf_filter.rb +6 -6
- data/project/nkf/_smc/helpers/nkf_helper.rb +8 -9
- data/project/rake/_smc/rakelib/svn.rake +5 -6
- data/project/redcloth/_smc/helpers/red_cloth_helper.rb +3 -3
- data/project/standard/_smc/helpers/menu_helper.rb +4 -5
- data/project/standard/_smc/templates/redirect.rhtml +1 -1
- data/spec/data/anonymous_loader/1/error1.rb +1 -0
- data/spec/data/anonymous_loader/1/error2.rb +1 -0
- data/spec/data/anonymous_loader/1/test1.rb +1 -0
- data/spec/data/anonymous_loader/1/test2.rb +1 -0
- data/spec/lib/smallcage/anonymous_loader_spec.rb +37 -0
- data/spec/lib/smallcage/application_spec.rb +271 -0
- data/spec/{smallcage → lib/smallcage}/commands/auto_spec.rb +0 -0
- data/spec/{export_spec.rb → lib/smallcage/commands/export_spec.rb} +8 -10
- data/spec/{import_spec.rb → lib/smallcage/commands/import_spec.rb} +5 -6
- data/spec/{manifest_spec.rb → lib/smallcage/commands/manifest_spec.rb} +4 -3
- data/spec/{smallcage → lib/smallcage}/commands/server_spec.rb +0 -0
- data/spec/{update_spec.rb → lib/smallcage/commands/update_spec.rb} +15 -19
- data/spec/{uri_spec.rb → lib/smallcage/commands/uri_spec.rb} +3 -4
- data/spec/{document_path_spec.rb → lib/smallcage/document_path_spec.rb} +19 -31
- data/spec/{loader_spec.rb → lib/smallcage/loader_spec.rb} +16 -18
- data/spec/lib/smallcage/misc_spec.rb +18 -0
- data/spec/{update_list_spec.rb → lib/smallcage/update_list_spec.rb} +18 -21
- data/spec/{smallcage_spec.rb → lib/smallcage_spec.rb} +1 -1
- data/spec/spec_helper.rb +5 -4
- metadata +85 -55
- checksums.yaml +0 -7
- data/Gemfile.lock +0 -32
- data/spec/misc_spec.rb +0 -25
- data/spec/smallcage/application_spec.rb +0 -271
File without changes
|
@@ -2,18 +2,17 @@ require 'spec_helper.rb'
|
|
2
2
|
require 'smallcage'
|
3
3
|
|
4
4
|
describe "SmallCage::Commands::Export" do
|
5
|
+
docroot = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs2'))
|
6
|
+
outdir = Pathname.new(File.join(SPEC_DATA_DIR, 'out'))
|
5
7
|
|
6
|
-
docroot = Pathname.new(File.dirname(__FILE__) + "/data/htdocs2")
|
7
|
-
outdir = Pathname.new(File.dirname(__FILE__) + "/data/out")
|
8
|
-
|
9
8
|
it "should export not smc files" do
|
10
9
|
begin
|
11
|
-
opts = { :command => "export",
|
10
|
+
opts = { :command => "export",
|
12
11
|
:path => docroot.to_s,
|
13
12
|
:out => outdir.to_s,
|
14
13
|
:quiet => true }
|
15
14
|
SmallCage::Runner.run(opts)
|
16
|
-
|
15
|
+
|
17
16
|
(outdir + "./a/test.html.smc").exist?.should_not be_true
|
18
17
|
(outdir + "./a/test.html").exist?.should_not be_true
|
19
18
|
(outdir + "./a/b/test.html").exist?.should be_true
|
@@ -22,24 +21,23 @@ describe "SmallCage::Commands::Export" do
|
|
22
21
|
FileUtils.rm_r(outdir)
|
23
22
|
end
|
24
23
|
end
|
25
|
-
|
24
|
+
|
26
25
|
it "should export project subdirectory" do
|
27
26
|
begin
|
28
27
|
path = docroot + "a/b/c"
|
29
|
-
opts = { :command => "export",
|
28
|
+
opts = { :command => "export",
|
30
29
|
:path => path.to_s,
|
31
30
|
:out => outdir.to_s,
|
32
31
|
:quiet => true }
|
33
32
|
SmallCage::Runner.run(opts)
|
34
|
-
|
33
|
+
|
35
34
|
(outdir + "./a/test.html.smc").exist?.should_not be_true
|
36
35
|
(outdir + "./a/test.html").exist?.should_not be_true
|
37
36
|
(outdir + "./a/b/test.html").exist?.should_not be_true
|
38
|
-
|
37
|
+
|
39
38
|
(outdir + "./a/b/c/test.html").exist?.should be_true
|
40
39
|
ensure
|
41
40
|
FileUtils.rm_r(outdir)
|
42
41
|
end
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
@@ -2,19 +2,18 @@ require 'spec_helper.rb'
|
|
2
2
|
require 'smallcage'
|
3
3
|
|
4
4
|
describe "SmallCage::Commands::Import" do
|
5
|
-
root = Pathname.new(
|
6
|
-
|
5
|
+
root = Pathname.new(SPEC_DATA_DIR)
|
6
|
+
|
7
7
|
it "should import default project" do
|
8
8
|
tmpdir = root + "tmp"
|
9
9
|
Dir.mkdir(tmpdir) unless tmpdir.directory?
|
10
|
-
|
10
|
+
|
11
11
|
opts = { :command => "import", :from => "default", :to => tmpdir.to_s, :quiet => true }
|
12
12
|
SmallCage::Runner.run(opts)
|
13
|
-
|
13
|
+
|
14
14
|
(tmpdir + "_smc").directory?.should be_true
|
15
15
|
(tmpdir + "_smc/helpers/base_helper.rb").file?.should be_true
|
16
|
-
|
16
|
+
|
17
17
|
FileUtils.rm_r(tmpdir)
|
18
18
|
end
|
19
|
-
|
20
19
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper.rb'
|
2
2
|
require 'smallcage'
|
3
|
+
require 'smallcage/commands/manifest'
|
3
4
|
|
4
|
-
describe
|
5
|
+
describe SmallCage::Commands::Manifest do
|
5
6
|
|
6
7
|
before do
|
7
|
-
@docroot = Pathname.new(File.
|
8
|
+
@docroot = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs1'))
|
8
9
|
@opts = { :path => @docroot.to_s }
|
9
10
|
@manifest_file = @docroot + "Manifest.html"
|
10
11
|
end
|
@@ -32,7 +33,7 @@ EOT
|
|
32
33
|
contents.should include(line)
|
33
34
|
end
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
after do
|
37
38
|
SmallCage::Runner.run(@opts.merge(:command => "clean", :quiet => true))
|
38
39
|
@manifest_file.delete
|
File without changes
|
@@ -1,21 +1,22 @@
|
|
1
1
|
require 'spec_helper.rb'
|
2
2
|
require 'smallcage'
|
3
|
+
require 'smallcage/commands/update'
|
3
4
|
|
4
|
-
describe
|
5
|
+
describe SmallCage::Commands::Update do
|
5
6
|
|
6
7
|
it "should not update docroot directory" do
|
7
|
-
docroot = Pathname.new(File.
|
8
|
+
docroot = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs1'))
|
8
9
|
path = docroot + "a/b/"
|
9
10
|
|
10
11
|
opts = { :command => "update", :path => path.to_s, :quiet => true }
|
11
|
-
|
12
|
+
|
12
13
|
begin
|
13
14
|
SmallCage::Runner.run(opts)
|
14
|
-
|
15
|
+
|
15
16
|
out = docroot + "a/b/c/index.html"
|
16
17
|
out.file?.should be_true
|
17
18
|
out.delete
|
18
|
-
|
19
|
+
|
19
20
|
Dir.chdir(path) do
|
20
21
|
opts[:path] = "."
|
21
22
|
SmallCage::Runner.run(opts)
|
@@ -26,40 +27,38 @@ describe 'update' do
|
|
26
27
|
ensure
|
27
28
|
SmallCage::Runner.run({:command => "clean", :path => path.to_s, :quiet => true })
|
28
29
|
end
|
29
|
-
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "should not publish _dir.smc and _local.smc" do
|
33
|
-
root = Pathname.new(File.
|
33
|
+
root = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs3'))
|
34
34
|
|
35
35
|
opts = { :command => "update", :path => root.to_s, :quiet => true }
|
36
|
-
|
36
|
+
|
37
37
|
begin
|
38
38
|
SmallCage::Runner.run(opts)
|
39
|
-
|
39
|
+
|
40
40
|
out = root + "_dir"
|
41
41
|
out.file?.should be_false
|
42
|
-
|
42
|
+
|
43
43
|
out = root + "_local"
|
44
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
|
48
|
-
|
49
48
|
end
|
50
|
-
|
49
|
+
|
51
50
|
# http://github.com/bluemark/smallcage/issues/#issue/2
|
52
51
|
it "should not delete files under the common prefix directory" do
|
53
|
-
root = Pathname.new(File.
|
52
|
+
root = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs3'))
|
54
53
|
begin
|
55
54
|
SmallCage::Runner.run({ :command => "update", :path => root.to_s, :quiet => true })
|
56
|
-
|
55
|
+
|
57
56
|
(root + "a/index.html").file?.should be_true
|
58
57
|
(root + "ab/index.html").file?.should be_true
|
59
58
|
(root + "abc/index.html").file?.should be_true
|
60
59
|
|
61
60
|
SmallCage::Runner.run({ :command => "update", :path => (root + "a").to_s, :quiet => true })
|
62
|
-
|
61
|
+
|
63
62
|
(root + "a/index.html").file?.should be_true
|
64
63
|
(root + "ab/index.html").file?.should be_true
|
65
64
|
(root + "abc/index.html").file?.should be_true
|
@@ -72,8 +71,5 @@ describe 'update' do
|
|
72
71
|
ensure
|
73
72
|
SmallCage::Runner.run({:command => "clean", :path => root.to_s, :quiet => true })
|
74
73
|
end
|
75
|
-
|
76
74
|
end
|
77
|
-
|
78
|
-
|
79
75
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper.rb'
|
2
|
+
require 'smallcage'
|
2
3
|
require 'smallcage/commands/uri'
|
3
4
|
|
4
5
|
describe SmallCage::Commands::Uri do
|
5
6
|
it "should prints all uris" do
|
6
|
-
path = Pathname.new(File.
|
7
|
+
path = Pathname.new(File.join(SPEC_DATA_DIR, 'multifiles'))
|
7
8
|
|
8
9
|
old_stdout = $stdout
|
9
10
|
begin
|
@@ -26,7 +27,7 @@ EOT
|
|
26
27
|
end
|
27
28
|
|
28
29
|
it "should prints partial uris" do
|
29
|
-
path = Pathname.new(File.
|
30
|
+
path = Pathname.new(File.join(SPEC_DATA_DIR, 'multifiles'))
|
30
31
|
|
31
32
|
old_stdout = $stdout
|
32
33
|
begin
|
@@ -49,10 +50,8 @@ EOT
|
|
49
50
|
|
50
51
|
/items/items-after-emptyline.html
|
51
52
|
EOT
|
52
|
-
|
53
53
|
ensure
|
54
54
|
$stdout = old_stdout
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
@@ -2,47 +2,42 @@ require 'spec_helper.rb'
|
|
2
2
|
require 'smallcage'
|
3
3
|
|
4
4
|
describe SmallCage::DocumentPath do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@docpath = SmallCage::DocumentPath.new(@rootdir, @rootdir + "a/b/c/index.html.smc")
|
9
|
-
end
|
10
|
-
|
5
|
+
let(:rootdir) { Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs1')) }
|
6
|
+
let(:docpath) { SmallCage::DocumentPath.new(rootdir, rootdir + 'a/b/c/index.html.smc') }
|
7
|
+
|
11
8
|
it "should have uri property" do
|
12
|
-
|
9
|
+
docpath.uri.should == "/a/b/c/index.html.smc"
|
13
10
|
end
|
14
|
-
|
11
|
+
|
15
12
|
it "should return smc file or not" do
|
16
|
-
|
13
|
+
docpath.smc?.should be_true
|
17
14
|
end
|
18
|
-
|
15
|
+
|
19
16
|
it "should return output file" do
|
20
|
-
out =
|
17
|
+
out = docpath.outfile
|
21
18
|
out.should be_an_instance_of(SmallCage::DocumentPath)
|
22
|
-
out.path.basename.to_s.should ==
|
19
|
+
out.path.basename.to_s.should == 'index.html'
|
23
20
|
out.path.to_s.should match(%r{^/.+/a/b/c/index.html$})
|
24
|
-
|
21
|
+
docpath.path.to_s[0..-5].should == out.path.to_s
|
25
22
|
end
|
26
|
-
|
23
|
+
|
27
24
|
it "should return output file uri" do
|
28
|
-
out =
|
25
|
+
out = docpath.outuri
|
29
26
|
out.should == "/a/b/c/index.html"
|
30
27
|
end
|
31
|
-
|
28
|
+
|
32
29
|
it "should return root uri" do
|
33
|
-
docpath = SmallCage::DocumentPath.new(
|
30
|
+
docpath = SmallCage::DocumentPath.new(rootdir, rootdir)
|
34
31
|
docpath.uri.should == "/"
|
35
32
|
end
|
36
|
-
|
33
|
+
|
37
34
|
it "should return directory uri" do
|
38
|
-
docpath = SmallCage::DocumentPath.new(
|
39
|
-
docpath.uri.should ==
|
35
|
+
docpath = SmallCage::DocumentPath.new(rootdir, rootdir + 'a/b')
|
36
|
+
docpath.uri.should == '/a/b'
|
40
37
|
end
|
41
38
|
|
42
39
|
it "should raise Exception when the path doesn't exist under the root directory" do
|
43
|
-
rootdir = Pathname.new(File.dirname(__FILE__) + "/data/htdocs1")
|
44
40
|
path = Pathname.new(File.dirname(__FILE__))
|
45
|
-
|
46
41
|
ok = false
|
47
42
|
begin
|
48
43
|
docpath = SmallCage::DocumentPath.new(rootdir, path)
|
@@ -52,10 +47,7 @@ describe SmallCage::DocumentPath do
|
|
52
47
|
end
|
53
48
|
ok.should be_true
|
54
49
|
|
55
|
-
|
56
|
-
rootdir = Pathname.new(File.dirname(__FILE__) + "/data/htdocs1")
|
57
|
-
path = Pathname.new(File.dirname(__FILE__) + "/data/htdocs")
|
58
|
-
|
50
|
+
path = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs'))
|
59
51
|
ok = false
|
60
52
|
begin
|
61
53
|
docpath = SmallCage::DocumentPath.new(rootdir, path)
|
@@ -65,10 +57,7 @@ describe SmallCage::DocumentPath do
|
|
65
57
|
end
|
66
58
|
ok.should be_true
|
67
59
|
|
68
|
-
|
69
|
-
rootdir = Pathname.new(File.dirname(__FILE__) + "/data/htdocs1")
|
70
|
-
path = Pathname.new(File.dirname(__FILE__) + "/data/htdocs2")
|
71
|
-
|
60
|
+
path = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs2'))
|
72
61
|
ok = false
|
73
62
|
begin
|
74
63
|
docpath = SmallCage::DocumentPath.new(rootdir, path)
|
@@ -78,5 +67,4 @@ describe SmallCage::DocumentPath do
|
|
78
67
|
end
|
79
68
|
ok.should be_true
|
80
69
|
end
|
81
|
-
|
82
70
|
end
|
@@ -2,10 +2,9 @@ require 'spec_helper.rb'
|
|
2
2
|
require 'smallcage'
|
3
3
|
|
4
4
|
describe SmallCage::Loader do
|
5
|
-
|
6
5
|
before do
|
7
|
-
@docroot = Pathname.new(File.
|
8
|
-
@docroot3 = Pathname.new(File.
|
6
|
+
@docroot = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs1'))
|
7
|
+
@docroot3 = Pathname.new(File.join(SPEC_DATA_DIR, 'htdocs3'))
|
9
8
|
end
|
10
9
|
|
11
10
|
it "should load path value which is instance of Pathname" do
|
@@ -14,11 +13,11 @@ describe SmallCage::Loader do
|
|
14
13
|
|
15
14
|
obj["path"].should be_an_instance_of(Pathname)
|
16
15
|
obj["path"].smc.should be_an_instance_of(Pathname)
|
17
|
-
|
16
|
+
|
18
17
|
obj["path"].to_s.should =~ %r{^.+/a/b/c/index\.html$}
|
19
18
|
obj["path"].smc.to_s.should =~ %r{^.+/a/b/c/index\.html\.smc$}
|
20
19
|
end
|
21
|
-
|
20
|
+
|
22
21
|
it "should be able to omit smc extention" do
|
23
22
|
ldr = SmallCage::Loader.new(@docroot + "a/b/c/index.html")
|
24
23
|
objects = []
|
@@ -30,18 +29,18 @@ describe SmallCage::Loader do
|
|
30
29
|
obj["uri"].should == "/a/b/c/index.html"
|
31
30
|
obj["uri"].smc.should == "/a/b/c/index.html.smc"
|
32
31
|
end
|
33
|
-
|
32
|
+
|
34
33
|
it "should find smc root dir" do
|
35
34
|
path = @docroot + "a/b/c/index.html.smc"
|
36
|
-
|
35
|
+
|
37
36
|
depth = 5
|
38
37
|
root = SmallCage::Loader.find_root(path, depth)
|
39
38
|
root.to_s.should =~ %r{^.+/data/htdocs1$}
|
40
|
-
|
39
|
+
|
41
40
|
depth = 3
|
42
41
|
lambda { SmallCage::Loader.find_root(path, depth) }.should raise_error
|
43
42
|
end
|
44
|
-
|
43
|
+
|
45
44
|
it "should load strings" do
|
46
45
|
path = @docroot + "a/b/c/index.html.smc"
|
47
46
|
ldr = SmallCage::Loader.new(path)
|
@@ -53,14 +52,14 @@ describe SmallCage::Loader do
|
|
53
52
|
end
|
54
53
|
objects[0]["strings"][0].should == "abc\ndef\n\nghi"
|
55
54
|
end
|
56
|
-
|
55
|
+
|
57
56
|
it "should load body value which equals strings[0]" do
|
58
57
|
ldr = SmallCage::Loader.new(@docroot)
|
59
58
|
obj = ldr.load(@docroot + "a/b/c/index.html.smc")
|
60
|
-
|
61
|
-
obj["strings"][0].should == "abc\ndef\n\nghi"
|
59
|
+
|
60
|
+
obj["strings"][0].should == "abc\ndef\n\nghi"
|
62
61
|
obj["body"].should == obj["strings"][0]
|
63
|
-
|
62
|
+
|
64
63
|
# same String instance
|
65
64
|
obj["strings"][0].replace("XXX")
|
66
65
|
obj["body"].should == "XXX"
|
@@ -68,20 +67,20 @@ describe SmallCage::Loader do
|
|
68
67
|
obj["strings"][0] = "ABC"
|
69
68
|
obj["body"].should == "XXX"
|
70
69
|
end
|
71
|
-
|
70
|
+
|
72
71
|
it "should load dirs" do
|
73
72
|
ldr = SmallCage::Loader.new(@docroot)
|
74
73
|
obj = ldr.load(@docroot + "a/b/c/index.html.smc")
|
75
|
-
|
74
|
+
|
76
75
|
dirs = obj["dirs"]
|
77
76
|
dirs.length.should == 4
|
78
|
-
|
77
|
+
|
79
78
|
dirs[0]["uri"].should == "/"
|
80
79
|
dirs[1]["uri"].should == "/a/"
|
81
80
|
dirs[2]["uri"].should == "/a/b/"
|
82
81
|
dirs[3]["uri"].should == "/a/b/c/"
|
83
82
|
(dirs[3]["path"] + "index.html.smc").file?.should be_true
|
84
|
-
|
83
|
+
|
85
84
|
dirs[0]["var"].should == "xxx"
|
86
85
|
dirs[0]["strings"][0].should == "BODYBODYBODY"
|
87
86
|
dirs[0]["body"].should == "BODYBODYBODY"
|
@@ -107,5 +106,4 @@ describe SmallCage::Loader do
|
|
107
106
|
dirs[3]["body"].should == "strings"
|
108
107
|
|
109
108
|
end
|
110
|
-
|
111
109
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
require 'smallcage'
|
3
|
+
|
4
|
+
describe 'misc' do
|
5
|
+
it 'returns empty string' do
|
6
|
+
expect(''.camelize).to eq ''
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'camelize String' do
|
10
|
+
expect('smallcage'.camelize).to eq 'Smallcage'
|
11
|
+
expect('abc_def_ghi'.camelize).to eq 'AbcDefGhi'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'camelize with first character in lower case' do
|
15
|
+
expect('smallcage'.camelize(false)).to eq 'smallcage'
|
16
|
+
expect('abc_def_ghi'.camelize(false)).to eq 'abcDefGhi'
|
17
|
+
end
|
18
|
+
end
|
@@ -2,7 +2,7 @@ require 'spec_helper.rb'
|
|
2
2
|
require 'smallcage'
|
3
3
|
|
4
4
|
describe SmallCage::UpdateList do
|
5
|
-
root = Pathname.new(File.
|
5
|
+
root = Pathname.new(File.join(SPEC_DATA_DIR, 'updatelists'))
|
6
6
|
|
7
7
|
it "should create empty data" do
|
8
8
|
list = SmallCage::UpdateList.new(root + "dummy.yml", "/")
|
@@ -47,14 +47,14 @@ EOT
|
|
47
47
|
list = SmallCage::UpdateList.new(file, "/")
|
48
48
|
list.update("/index.html.smc", 1234567890, "/index.html")
|
49
49
|
list.save
|
50
|
-
|
50
|
+
|
51
51
|
list = SmallCage::UpdateList.new(file, "/")
|
52
52
|
list.mtime("/index.html.smc").should == 1234567890
|
53
|
-
|
53
|
+
|
54
54
|
# same dst file
|
55
55
|
list.update("/abc/index.html.smc", 1, "/index.html")
|
56
56
|
list.mtime("/abc/index.html.smc").should == 1
|
57
|
-
|
57
|
+
|
58
58
|
list.update("/abc/index.html.smc", 2, "/index.html")
|
59
59
|
list.mtime("/abc/index.html.smc").should == 2
|
60
60
|
list.mtime("/index.html.smc").should == 1234567890
|
@@ -62,10 +62,10 @@ EOT
|
|
62
62
|
list = SmallCage::UpdateList.new(file, "/")
|
63
63
|
list.mtime("/index.html.smc").should == 1234567890
|
64
64
|
list.mtime("/abc/index.html.smc").should == -1
|
65
|
-
|
65
|
+
|
66
66
|
list.update("/abc/index.html.smc", 1, "/index.html")
|
67
67
|
list.save
|
68
|
-
|
68
|
+
|
69
69
|
list = SmallCage::UpdateList.new(file, "/")
|
70
70
|
list.mtime("/index.html.smc").should == 1234567890
|
71
71
|
list.mtime("/abc/index.html.smc").should == 1
|
@@ -79,25 +79,25 @@ EOT
|
|
79
79
|
begin
|
80
80
|
list = SmallCage::UpdateList.new(file, "/")
|
81
81
|
list.update("/index.html.smc", 1, "/index.html")
|
82
|
-
|
82
|
+
|
83
83
|
e = list.expire
|
84
84
|
e.length.should == 0
|
85
|
-
|
85
|
+
|
86
86
|
list.save
|
87
87
|
list.update_count.should == 1
|
88
|
-
|
88
|
+
|
89
89
|
list = SmallCage::UpdateList.new(file, "/")
|
90
90
|
e = list.expire
|
91
91
|
e.length.should == 1
|
92
92
|
e[0].should == "/index.html"
|
93
93
|
list.update_count.should == 0
|
94
|
-
|
94
|
+
|
95
95
|
list = SmallCage::UpdateList.new(file, "/")
|
96
96
|
list.update("/index.html.smc", 1, "/index.html")
|
97
97
|
e = list.expire
|
98
98
|
e.length.should == 0
|
99
99
|
list.update_count.should == 1
|
100
|
-
|
100
|
+
|
101
101
|
list = SmallCage::UpdateList.new(file, "/")
|
102
102
|
list.update("/index.html.smc", 1, "/index.html")
|
103
103
|
list.update("/index.html.smc", 1, "/index2.html")
|
@@ -110,7 +110,7 @@ EOT
|
|
110
110
|
e = list.expire
|
111
111
|
e.length.should == 2
|
112
112
|
e.should =~ ["/index.html", "/index2.html"]
|
113
|
-
|
113
|
+
|
114
114
|
list = SmallCage::UpdateList.new(file, "/abc/")
|
115
115
|
list.update("/abc/index.html.smc", 2, "/abc/index.html")
|
116
116
|
list.update("/abc/index2.html.smc", 3, "/abc/index2.html")
|
@@ -124,7 +124,7 @@ EOT
|
|
124
124
|
e = list.expire
|
125
125
|
e.length.should == 1
|
126
126
|
e[0].should == "/abc/index.html"
|
127
|
-
|
127
|
+
|
128
128
|
list = SmallCage::UpdateList.new(file, "/a/")
|
129
129
|
list.update("/a/index.html.smc", 2, "/abc/a.html")
|
130
130
|
e = list.expire
|
@@ -139,13 +139,13 @@ EOT
|
|
139
139
|
e.length.should == 0
|
140
140
|
list.update_count.should == 2
|
141
141
|
list.save
|
142
|
-
|
142
|
+
|
143
143
|
list = SmallCage::UpdateList.new(file, "/a/")
|
144
144
|
list.update("/a/index.html.smc", 2, "/abc/b.html")
|
145
145
|
e = list.expire
|
146
146
|
e.length.should == 1
|
147
147
|
e[0] == "/abc/a.html"
|
148
|
-
|
148
|
+
|
149
149
|
list = SmallCage::UpdateList.new(file, "/")
|
150
150
|
e = list.expire
|
151
151
|
e.length.should == 5
|
@@ -155,14 +155,13 @@ EOT
|
|
155
155
|
e.should include("/abc/index2.html")
|
156
156
|
e.should include("/abc/a.html")
|
157
157
|
list.save
|
158
|
-
|
158
|
+
|
159
159
|
list = SmallCage::UpdateList.new(file, "/")
|
160
160
|
e = list.expire
|
161
161
|
e.length.should == 0
|
162
162
|
ensure
|
163
163
|
file.delete
|
164
164
|
end
|
165
|
-
|
166
165
|
end
|
167
166
|
|
168
167
|
it "should support single file target" do
|
@@ -203,7 +202,6 @@ EOT
|
|
203
202
|
end
|
204
203
|
end
|
205
204
|
|
206
|
-
|
207
205
|
it "should not expire file which other source published" do
|
208
206
|
file = root + "list-switch.yml"
|
209
207
|
begin
|
@@ -213,11 +211,11 @@ EOT
|
|
213
211
|
e = list.expire
|
214
212
|
e.length.should == 0
|
215
213
|
list.save
|
216
|
-
|
214
|
+
|
217
215
|
list = SmallCage::UpdateList.new(file, "/")
|
218
216
|
e = list.expire
|
219
217
|
e.length.should == 2
|
220
|
-
|
218
|
+
|
221
219
|
list = SmallCage::UpdateList.new(file, "/")
|
222
220
|
list.update("/other/file/1.smc", 2, "/aaa")
|
223
221
|
list.update("/other-file-2.smc", 2, "/bbb")
|
@@ -227,5 +225,4 @@ EOT
|
|
227
225
|
file.delete
|
228
226
|
end
|
229
227
|
end
|
230
|
-
|
231
228
|
end
|