sdoc_all 1.0.4 → 1.0.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/Rakefile +7 -0
- data/VERSION +1 -1
- data/lib/sdoc_all/base.rb +3 -3
- data/lib/sdoc_all/parts/gems.rb +1 -2
- data/lib/sdoc_all/parts/paths.rb +2 -3
- data/lib/sdoc_all/parts/plugins.rb +1 -5
- data/lib/sdoc_all/parts/rails.rb +1 -2
- data/lib/sdoc_all/parts/ruby.rb +2 -3
- data/lib/sdoc_all.rb +4 -3
- data/sdoc_all.gemspec +2 -2
- data/spec/sdoc_all/file_list_spec.rb +28 -30
- data/spec/sdoc_all/gems_spec.rb +50 -52
- data/spec/sdoc_all/paths_spec.rb +96 -98
- data/spec/sdoc_all/plugins_spec.rb +61 -62
- data/spec/sdoc_all/rails_spec.rb +43 -45
- data/spec/sdoc_all/ruby_spec.rb +156 -158
- data/spec/sdoc_all_spec.rb +1 -1
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -34,3 +34,10 @@ begin
|
|
34
34
|
rescue LoadError
|
35
35
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
36
36
|
end
|
37
|
+
|
38
|
+
require 'spec/rake/spectask'
|
39
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
40
|
+
spec.libs << 'lib' << 'spec'
|
41
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
42
|
+
end
|
43
|
+
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.5
|
data/lib/sdoc_all/base.rb
CHANGED
@@ -30,7 +30,7 @@ class SdocAll
|
|
30
30
|
self.class.sources_path
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
class << self
|
34
34
|
BASE_PATH = Pathname.new(Dir.pwd).expand_path
|
35
35
|
DOCS_PATH = BASE_PATH + 'docs'
|
36
36
|
PUBLIC_PATH = BASE_PATH + 'public'
|
@@ -42,7 +42,7 @@ class SdocAll
|
|
42
42
|
defined?(@@dry_run) && @@dry_run
|
43
43
|
end
|
44
44
|
def verbose_level=(val)
|
45
|
-
@@verbose_level = val
|
45
|
+
@@verbose_level = val.to_i
|
46
46
|
end
|
47
47
|
def verbose_level
|
48
48
|
defined?(@@verbose_level) ? @@verbose_level : 0
|
@@ -130,6 +130,7 @@ class SdocAll
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def system(*args)
|
133
|
+
args = args.map(&:to_s)
|
133
134
|
command = args.length == 1 ? args.first : ShellEscape.command(*args)
|
134
135
|
if verbose_level >= 1
|
135
136
|
puts [dirs.last && "cd #{dirs.last}", command].compact.join('; ').shrink(250).blue
|
@@ -212,6 +213,5 @@ class SdocAll
|
|
212
213
|
end
|
213
214
|
end
|
214
215
|
end
|
215
|
-
extend ClassMethods
|
216
216
|
end
|
217
217
|
end
|
data/lib/sdoc_all/parts/gems.rb
CHANGED
data/lib/sdoc_all/parts/paths.rb
CHANGED
@@ -91,14 +91,14 @@ class SdocAll
|
|
91
91
|
@entries ||= []
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
class << self
|
95
95
|
def common_path(paths)
|
96
96
|
common = nil
|
97
97
|
paths.each do |path|
|
98
98
|
if common ||= path
|
99
99
|
unless path.to_s.starts_with?(common.to_s)
|
100
100
|
path.ascend do |path_part|
|
101
|
-
if common.to_s.starts_with?(path_part)
|
101
|
+
if common.to_s.starts_with?(path_part.to_s)
|
102
102
|
common = path_part
|
103
103
|
break
|
104
104
|
end
|
@@ -109,6 +109,5 @@ class SdocAll
|
|
109
109
|
common = common.parent if common
|
110
110
|
end
|
111
111
|
end
|
112
|
-
extend ClassMethods
|
113
112
|
end
|
114
113
|
end
|
@@ -21,11 +21,7 @@ class SdocAll
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def add_tasks(options = {})
|
24
|
-
plugins =
|
25
|
-
Pathname.glob('*').map do |path|
|
26
|
-
config[:path] + path if path.directory?
|
27
|
-
end.compact
|
28
|
-
end
|
24
|
+
plugins = config[:path].children.select(&:directory?)
|
29
25
|
|
30
26
|
plugins.delete_if{ |plugin| !config[:only].include?(plugin.basename.to_s.downcase) } if config[:only]
|
31
27
|
plugins.delete_if{ |plugin| config[:exclude].include?(plugin.basename.to_s.downcase) }
|
data/lib/sdoc_all/parts/rails.rb
CHANGED
@@ -56,7 +56,7 @@ class SdocAll
|
|
56
56
|
)
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
class << self
|
60
60
|
def versions
|
61
61
|
[].tap do |versions|
|
62
62
|
Gem.source_index.search(Gem::Dependency.new('rails', :all)).each do |spec|
|
@@ -65,6 +65,5 @@ class SdocAll
|
|
65
65
|
end.sort.map(&:to_s)
|
66
66
|
end
|
67
67
|
end
|
68
|
-
extend ClassMethods
|
69
68
|
end
|
70
69
|
end
|
data/lib/sdoc_all/parts/ruby.rb
CHANGED
@@ -178,7 +178,7 @@ class SdocAll
|
|
178
178
|
end
|
179
179
|
|
180
180
|
ArchiveInfo = Struct.new(:path, :name, :full_version, :extension, :version)
|
181
|
-
|
181
|
+
class << self
|
182
182
|
def match_ruby_archive(path)
|
183
183
|
name = File.basename(path)
|
184
184
|
if match = /^ruby-((\d+\.\d+\.\d+)-p(\d+))(?:\.(tar\.(?:gz|bz2)|zip))$/.match(name)
|
@@ -225,7 +225,7 @@ class SdocAll
|
|
225
225
|
|
226
226
|
tar_bz2_matcher = /(^|\/)ruby-.*\.tar\.bz2$/
|
227
227
|
|
228
|
-
unless tar = last_matching_ruby_archive(version, files.
|
228
|
+
unless tar = last_matching_ruby_archive(version, files.select{ |file| tar_bz2_matcher === file.to_s }) || last_matching_ruby_archive(version, files)
|
229
229
|
dirs = dirs.sort_by{ |dir| s = dir.basename.to_s; v = s.to_f; [v, s] }.reverse.
|
230
230
|
select{ |dir| dir.basename.to_s[/^\d/] && dir.basename.to_s.starts_with?(version[0, 3]) }
|
231
231
|
dirs.each do |dir|
|
@@ -255,6 +255,5 @@ class SdocAll
|
|
255
255
|
archive
|
256
256
|
end
|
257
257
|
end
|
258
|
-
extend ClassMethods
|
259
258
|
end
|
260
259
|
end
|
data/lib/sdoc_all.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
require 'fileutils'
|
3
5
|
require 'find'
|
4
6
|
require 'digest'
|
5
7
|
|
6
8
|
require 'rubygems'
|
7
|
-
require '
|
9
|
+
require 'active_support'
|
8
10
|
require 'rake'
|
9
11
|
require 'progress'
|
10
12
|
require 'colored'
|
@@ -37,7 +39,7 @@ class String
|
|
37
39
|
end
|
38
40
|
|
39
41
|
class SdocAll
|
40
|
-
|
42
|
+
class << self
|
41
43
|
def update?
|
42
44
|
@update.nil? || @update
|
43
45
|
end
|
@@ -175,7 +177,6 @@ class SdocAll
|
|
175
177
|
end
|
176
178
|
end
|
177
179
|
end
|
178
|
-
extend ClassMethods
|
179
180
|
end
|
180
181
|
|
181
182
|
require 'sdoc_all/base'
|
data/sdoc_all.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sdoc_all}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Boba Fat"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-01-03}
|
13
13
|
s.default_executable = %q{sdoc-all}
|
14
14
|
s.description = %q{Command line tool to get documentation for ruby, rails, gems and plugins in one place}
|
15
15
|
s.executables = ["sdoc-all"]
|
@@ -1,40 +1,38 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
3
|
+
describe SdocAll::FileList do
|
4
|
+
before do
|
5
|
+
@list = SdocAll::FileList.new
|
6
|
+
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
it "should include well" do
|
9
|
+
@list.include('R*')
|
10
|
+
@list.should == %w(Rakefile README.rdoc)
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
it "should exclude well" do
|
14
|
+
@list.include('R*')
|
15
|
+
@list.exclude('Rake*')
|
16
|
+
@list.should == %w(README.rdoc)
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
it "should exclude non existing files from list" do
|
20
|
+
@list.include('R*')
|
21
|
+
@list.include('non existing')
|
22
|
+
@list.should == %w(Rakefile README.rdoc)
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
it "should exclude duplicates" do
|
26
|
+
@list.include('R*')
|
27
|
+
@list.include('R*')
|
28
|
+
@list.should == %w(Rakefile README.rdoc)
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
31
|
+
it "should not fail if directory changes after resolve" do
|
32
|
+
@list.include('R*')
|
33
|
+
@list.resolve
|
34
|
+
Dir.original_chdir('lib') do
|
35
|
+
@list.should == %w(Rakefile README.rdoc)
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
data/spec/sdoc_all/gems_spec.rb
CHANGED
@@ -1,66 +1,64 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
3
|
+
describe SdocAll::Gems do
|
4
|
+
def gem_mock(name, version)
|
5
|
+
mock(:gem, {
|
6
|
+
:name => name,
|
7
|
+
:version => version,
|
8
|
+
:full_name => "#{name}-#{version.join('.')}",
|
9
|
+
:sort_obj => [name, version],
|
10
|
+
:rdoc_options => [],
|
11
|
+
:full_gem_path => name,
|
12
|
+
:require_paths => [],
|
13
|
+
:extra_rdoc_files => []
|
14
|
+
})
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
before do
|
18
|
+
one_1 = gem_mock('one', [1])
|
19
|
+
one_2 = gem_mock('one', [2])
|
20
|
+
two_1 = gem_mock('two', [1])
|
21
|
+
two_2 = gem_mock('two', [2])
|
22
|
+
two_3 = gem_mock('two', [3])
|
23
|
+
three = gem_mock('three', [1])
|
24
|
+
four = gem_mock('four', [1])
|
25
|
+
five = gem_mock('five', [1])
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
@all_specs = [one_1, one_2, two_1, two_2, two_3, three, four, five]
|
28
|
+
@latest_specs = [one_2, two_3, three, four, five]
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
SdocAll::Gems.stub!(:latest_specs).and_return(@latest_specs)
|
31
|
+
SdocAll::Gems.stub!(:all_specs).and_return(@all_specs)
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
it "should add one selected tasks" do
|
35
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'gems.one-2'))
|
36
|
+
SdocAll::Gems.new('one').add_tasks
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
it "should add two selected tasks" do
|
40
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'gems.one-2'))
|
41
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'gems.two-3'))
|
42
|
+
SdocAll::Gems.new(['one', 'two']).add_tasks
|
43
|
+
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
it "should add tasks except excluded" do
|
46
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'gems.four-1'))
|
47
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'gems.five-1'))
|
48
|
+
SdocAll::Gems.new(:exclude => ['one', 'two', 'three']).add_tasks
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
Gems.new({}).add_tasks
|
51
|
+
it "should add tasks for latest gems" do
|
52
|
+
@latest_specs.each do |gem_spec|
|
53
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => "gems.#{gem_spec.full_name}"))
|
57
54
|
end
|
55
|
+
SdocAll::Gems.new({}).add_tasks
|
56
|
+
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
Gems.new(:versions => 'all').add_tasks
|
58
|
+
it "should add tasks for all gems" do
|
59
|
+
@all_specs.each do |gem_spec|
|
60
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => "gems.#{gem_spec.full_name}"))
|
64
61
|
end
|
62
|
+
SdocAll::Gems.new(:versions => 'all').add_tasks
|
65
63
|
end
|
66
64
|
end
|
data/spec/sdoc_all/paths_spec.rb
CHANGED
@@ -1,117 +1,115 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe SdocAll::Paths do
|
4
|
+
it "should determine common path part" do
|
5
|
+
paths = %w(/aaa/bbb/ccc/ddd/a.rb /aaa/bbb/ccc/ddd/b.rb /aaa/bbb/ccc/readme).map{ |path| Pathname.new(path) }
|
6
|
+
SdocAll::Paths.common_path(paths).should == Pathname.new('/aaa/bbb')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should add task for string config" do
|
10
|
+
@roots = {}
|
11
|
+
[:a, :b, :c].each do |sym|
|
12
|
+
@roots[sym] = mock(sym, :expand_path => mock("#{sym}_exp".to_sym, :exist? => true, :relative_path_from => "lala/#{sym}_exp"))
|
13
|
+
Pathname.should_receive(:new).with("#{sym}").and_return(@roots[sym])
|
14
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lala.#{sym}_exp", :src_path => @roots[sym].expand_path, :title => "paths: lala/#{sym}_exp")
|
15
|
+
end
|
16
|
+
SdocAll::Paths.should_receive(:common_path).with(@roots.values_at(:a, :b, :c).map(&:expand_path)).and_return('/common')
|
17
|
+
|
18
|
+
File.should_receive(:expand_path).with('*').and_return('/common/lala/*')
|
19
|
+
Dir.should_receive(:[]).with('/common/lala/*').and_return(['a', 'b', 'c'])
|
20
|
+
SdocAll::Paths.new('*').add_tasks
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should add task for array of strings config" do
|
24
|
+
@roots = {}
|
25
|
+
[:a, :b, :d, :e].each do |sym|
|
26
|
+
@roots[sym] = mock(sym, :expand_path => mock("#{sym}_exp".to_sym, :exist? => true, :relative_path_from => "lala/#{sym}_exp"))
|
27
|
+
Pathname.should_receive(:new).with("#{sym}").and_return(@roots[sym])
|
28
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lala.#{sym}_exp", :src_path => @roots[sym].expand_path, :title => "paths: lala/#{sym}_exp")
|
29
|
+
end
|
30
|
+
SdocAll::Paths.should_receive(:common_path).with(@roots.values_at(:a, :b, :d, :e).map(&:expand_path)).and_return('/common')
|
31
|
+
|
32
|
+
File.should_receive(:expand_path).with('*').and_return('/common/lala/*')
|
33
|
+
File.should_receive(:expand_path).with('**').and_return('/common/common/lala/*')
|
34
|
+
Dir.should_receive(:[]).with('/common/lala/*').and_return(['a', 'b'])
|
35
|
+
Dir.should_receive(:[]).with('/common/common/lala/*').and_return(['d', 'e'])
|
36
|
+
SdocAll::Paths.new(['*', '**']).add_tasks
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "for hash config" do
|
40
|
+
before do
|
41
|
+
@root = mock(:root, :expand_path => mock(:root_exp, :exist? => true, :relative_path_from => "lala/root"))
|
42
|
+
Pathname.should_receive(:new).with('/lalala/lala/root').and_return(@root)
|
43
|
+
SdocAll::Paths.should_receive(:common_path).with([@root.expand_path]).and_return('/common')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should add task" do
|
47
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :title => 'paths: lala/root')
|
48
|
+
SdocAll::Paths.new({:root => '/lalala/lala/root'}).add_tasks
|
8
49
|
end
|
9
50
|
|
10
|
-
it "should add task
|
11
|
-
@
|
12
|
-
|
13
|
-
@roots[sym] = mock(sym, :expand_path => mock("#{sym}_exp".to_sym, :exist? => true, :relative_path_from => "lala/#{sym}_exp"))
|
14
|
-
Pathname.should_receive(:new).with("#{sym}").and_return(@roots[sym])
|
15
|
-
Base.should_receive(:add_task).with(:doc_path => "paths.lala.#{sym}_exp", :src_path => @roots[sym].expand_path, :title => "paths: lala/#{sym}_exp")
|
16
|
-
end
|
17
|
-
Paths.should_receive(:common_path).with(@roots.values_at(:a, :b, :c).map(&:expand_path)).and_return('/common')
|
18
|
-
|
19
|
-
File.should_receive(:expand_path).with('*').and_return('/common/lala/*')
|
20
|
-
Dir.should_receive(:[]).with('/common/lala/*').and_return(['a', 'b', 'c'])
|
21
|
-
Paths.new('*').add_tasks
|
51
|
+
it "should add task with main" do
|
52
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :main => 'special_readme', :title => 'paths: lala/root')
|
53
|
+
SdocAll::Paths.new({:root => '/lalala/lala/root', :main => 'special_readme'}).add_tasks
|
22
54
|
end
|
23
55
|
|
24
|
-
it "should add task
|
25
|
-
@
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
File.should_receive(:expand_path).with('*').and_return('/common/lala/*')
|
34
|
-
File.should_receive(:expand_path).with('**').and_return('/common/common/lala/*')
|
35
|
-
Dir.should_receive(:[]).with('/common/lala/*').and_return(['a', 'b'])
|
36
|
-
Dir.should_receive(:[]).with('/common/common/lala/*').and_return(['d', 'e'])
|
37
|
-
Paths.new(['*', '**']).add_tasks
|
56
|
+
it "should add task with with one include" do
|
57
|
+
@file_list = mock(:file_list, :resolve => true)
|
58
|
+
SdocAll::FileList.stub!(:new).and_return(@file_list)
|
59
|
+
SdocAll::Base.should_receive(:chdir).with(@root.expand_path).and_yield
|
60
|
+
@file_list.should_receive(:include).with('*.rb')
|
61
|
+
@file_list.should_receive(:to_a).and_return(['a.rb', 'b.rb'])
|
62
|
+
|
63
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :paths => ['a.rb', 'b.rb'], :title => 'paths: lala/root')
|
64
|
+
SdocAll::Paths.new({:root => '/lalala/lala/root', :paths => '*.rb'}).add_tasks
|
38
65
|
end
|
39
66
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :main => 'special_readme', :title => 'paths: lala/root')
|
54
|
-
Paths.new({:root => '/lalala/lala/root', :main => 'special_readme'}).add_tasks
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should add task with with one include" do
|
58
|
-
@file_list = mock(:file_list, :resolve => true)
|
59
|
-
FileList.stub!(:new).and_return(@file_list)
|
60
|
-
Dir.should_receive(:chdir).with(@root.expand_path).and_yield
|
61
|
-
@file_list.should_receive(:include).with('*.rb')
|
62
|
-
@file_list.should_receive(:to_a).and_return(['a.rb', 'b.rb'])
|
63
|
-
|
64
|
-
Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :paths => ['a.rb', 'b.rb'], :title => 'paths: lala/root')
|
65
|
-
Paths.new({:root => '/lalala/lala/root', :paths => '*.rb'}).add_tasks
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should add task with with array of includes and excludes" do
|
69
|
-
@file_list = mock(:file_list, :resolve => true)
|
70
|
-
FileList.stub!(:new).and_return(@file_list)
|
71
|
-
Dir.should_receive(:chdir).with(@root.expand_path).and_yield
|
72
|
-
@file_list.should_receive(:include).ordered.with('*.*')
|
73
|
-
@file_list.should_receive(:exclude).ordered.with('*.cgi')
|
74
|
-
@file_list.should_receive(:include).ordered.with('README')
|
75
|
-
@file_list.should_receive(:include).ordered.with('README_*')
|
76
|
-
@file_list.should_receive(:exclude).ordered.with('*.tmp')
|
77
|
-
@file_list.should_receive(:to_a).and_return(['a.rb', 'b.rb', 'README', 'README_en'])
|
78
|
-
|
79
|
-
Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :paths => ['a.rb', 'b.rb', 'README', 'README_en'], :title => 'paths: lala/root')
|
80
|
-
Paths.new({:root => '/lalala/lala/root', :paths => ['*.*', '-*.cgi', '+README', '+README_*', '-*.tmp']}).add_tasks
|
81
|
-
end
|
67
|
+
it "should add task with with array of includes and excludes" do
|
68
|
+
@file_list = mock(:file_list, :resolve => true)
|
69
|
+
SdocAll::FileList.stub!(:new).and_return(@file_list)
|
70
|
+
SdocAll::Base.should_receive(:chdir).with(@root.expand_path).and_yield
|
71
|
+
@file_list.should_receive(:include).ordered.with('*.*')
|
72
|
+
@file_list.should_receive(:exclude).ordered.with('*.cgi')
|
73
|
+
@file_list.should_receive(:include).ordered.with('README')
|
74
|
+
@file_list.should_receive(:include).ordered.with('README_*')
|
75
|
+
@file_list.should_receive(:exclude).ordered.with('*.tmp')
|
76
|
+
@file_list.should_receive(:to_a).and_return(['a.rb', 'b.rb', 'README', 'README_en'])
|
77
|
+
|
78
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :paths => ['a.rb', 'b.rb', 'README', 'README_en'], :title => 'paths: lala/root')
|
79
|
+
SdocAll::Paths.new({:root => '/lalala/lala/root', :paths => ['*.*', '-*.cgi', '+README', '+README_*', '-*.tmp']}).add_tasks
|
82
80
|
end
|
81
|
+
end
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
describe "for array of hashes config" do
|
84
|
+
it "should add task" do
|
85
|
+
@root = mock(:root, :expand_path => mock(:root_exp, :exist? => true, :relative_path_from => "lala/root"))
|
86
|
+
Pathname.should_receive(:new).with('/lalala/lala/root').and_return(@root)
|
88
87
|
|
89
|
-
|
90
|
-
|
88
|
+
@other = mock(:other, :expand_path => mock(:other_exp, :exist? => true, :relative_path_from => "lolo/other"))
|
89
|
+
Pathname.should_receive(:new).with('/lalala/lolo/other').and_return(@other)
|
91
90
|
|
92
|
-
|
91
|
+
SdocAll::Paths.should_receive(:common_path).with([@root, @other].map(&:expand_path)).and_return('/common')
|
93
92
|
|
94
|
-
|
95
|
-
|
93
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :title => 'paths: lala/root')
|
94
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lolo.other", :src_path => @other.expand_path, :title => 'paths: lolo/other')
|
96
95
|
|
97
|
-
|
98
|
-
end
|
96
|
+
SdocAll::Paths.new([{:root => '/lalala/lala/root'}, {:root => '/lalala/lolo/other'}]).add_tasks
|
99
97
|
end
|
98
|
+
end
|
100
99
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
108
|
-
Paths.should_receive(:common_path).with(@roots.values_at(:a, :b, :c, :d, :e, :f, :g).map(&:expand_path)).and_return('/common')
|
109
|
-
|
110
|
-
File.should_receive(:expand_path).with('*').and_return('/common/lala/*')
|
111
|
-
Dir.should_receive(:[]).with('/common/lala/*').and_return(['b', 'c'])
|
112
|
-
File.should_receive(:expand_path).with('**').and_return('/common/lala/**')
|
113
|
-
Dir.should_receive(:[]).with('/common/lala/**').and_return(['e', 'f'])
|
114
|
-
Paths.new([{:root => 'a'}, '*', {:root => 'd'}, '**', {:root => 'g'}]).add_tasks
|
100
|
+
it "should add task for mixed config" do
|
101
|
+
@roots = {}
|
102
|
+
[:a, :b, :c, :d, :e, :f, :g].each do |sym|
|
103
|
+
@roots[sym] = mock(sym, :expand_path => mock("#{sym}_exp".to_sym, :exist? => true, :relative_path_from => "lala/#{sym}_exp"))
|
104
|
+
Pathname.should_receive(:new).with("#{sym}").and_return(@roots[sym])
|
105
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "paths.lala.#{sym}_exp", :src_path => @roots[sym].expand_path, :title => "paths: lala/#{sym}_exp")
|
115
106
|
end
|
107
|
+
SdocAll::Paths.should_receive(:common_path).with(@roots.values_at(:a, :b, :c, :d, :e, :f, :g).map(&:expand_path)).and_return('/common')
|
108
|
+
|
109
|
+
File.should_receive(:expand_path).with('*').and_return('/common/lala/*')
|
110
|
+
Dir.should_receive(:[]).with('/common/lala/*').and_return(['b', 'c'])
|
111
|
+
File.should_receive(:expand_path).with('**').and_return('/common/lala/**')
|
112
|
+
Dir.should_receive(:[]).with('/common/lala/**').and_return(['e', 'f'])
|
113
|
+
SdocAll::Paths.new([{:root => 'a'}, '*', {:root => 'd'}, '**', {:root => 'g'}]).add_tasks
|
116
114
|
end
|
117
115
|
end
|
@@ -1,81 +1,80 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe SdocAll::Plugins do
|
4
|
+
def plugin_mock(name, options = {})
|
5
|
+
mock(:plugin, :basename => name, :directory? => !options[:not_directory], :+ => mock(:git_dir, :directory? => !options[:no_git]))
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@one = mock(:one, :expand_path => mock(:one_expanded, :directory? => true))
|
10
|
+
SdocAll::Base.stub!(:chdir).and_yield
|
11
|
+
end
|
8
12
|
|
13
|
+
describe "path" do
|
9
14
|
before do
|
10
|
-
@one
|
15
|
+
@one.stub!(:mkpath)
|
16
|
+
@one.expand_path.stub!(:children).and_return([])
|
11
17
|
end
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
it "should set default path if none given" do
|
20
|
-
Plugins.stub!(:sources_path).and_return('sources/plugins')
|
21
|
-
Pathname.should_receive(:new).with('sources/plugins').and_return(@one)
|
22
|
-
Plugins.new(nil).add_tasks
|
23
|
-
end
|
19
|
+
it "should set default path if none given" do
|
20
|
+
SdocAll::Plugins.stub!(:sources_path).and_return('sources/plugins')
|
21
|
+
Pathname.should_receive(:new).with('sources/plugins').and_return(@one)
|
22
|
+
SdocAll::Plugins.new(nil)
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
25
|
+
it "should asume that lone argument is path" do
|
26
|
+
Pathname.should_receive(:new).with('one').and_return(@one)
|
27
|
+
SdocAll::Plugins.new('one')
|
29
28
|
end
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
describe "update" do
|
32
|
+
before do
|
33
|
+
@a = plugin_mock('a')
|
34
|
+
@b = plugin_mock('b', :no_git => true)
|
35
|
+
@c = plugin_mock('c', :not_directory => true)
|
36
|
+
@one.expand_path.should_receive(:children).and_return([@a, @b, @c])
|
37
|
+
Pathname.should_receive(:new).with('one').and_return(@one)
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
it "should update plugins using git" do
|
41
|
+
SdocAll::Base.should_receive(:system).once.with("git fetch origin && git reset --hard origin")
|
42
|
+
SdocAll::Base.stub!(:add_task)
|
43
|
+
SdocAll::Plugins.new(:path => 'one').add_tasks(:update => true)
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
46
|
+
it "should not update plugins when config disables it" do
|
47
|
+
SdocAll::Base.should_not_receive(:system)
|
48
|
+
SdocAll::Base.stub!(:add_task)
|
49
|
+
SdocAll::Plugins.new(:path => 'one', :update => false).add_tasks
|
51
50
|
end
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
describe "adding" do
|
54
|
+
before do
|
55
|
+
@a = plugin_mock('a')
|
56
|
+
@b = plugin_mock('b')
|
57
|
+
@c = plugin_mock('c')
|
58
|
+
@one.expand_path.should_receive(:children).and_return([@a, @b, @c])
|
59
|
+
Pathname.should_receive(:new).with('one').and_return(@one)
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
it "should add tasks" do
|
63
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'plugins.a'))
|
64
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'plugins.b'))
|
65
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'plugins.c'))
|
66
|
+
SdocAll::Plugins.new(:path => 'one').add_tasks
|
67
|
+
end
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
it "should add only selected tasks" do
|
70
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'plugins.a'))
|
71
|
+
SdocAll::Plugins.new(:path => 'one', :only => 'a').add_tasks
|
72
|
+
end
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
74
|
+
it "should add not excluded tasks" do
|
75
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'plugins.a'))
|
76
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'plugins.c'))
|
77
|
+
SdocAll::Plugins.new(:path => 'one', :exclude => 'b').add_tasks
|
79
78
|
end
|
80
79
|
end
|
81
80
|
end
|
data/spec/sdoc_all/rails_spec.rb
CHANGED
@@ -1,57 +1,55 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
describe SdocAll::Rails do
|
4
|
+
before do
|
5
|
+
SdocAll::Rails.stub!(:versions).and_return(['1.2.3', '1.3.5', '1.5.9'])
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "adding task" do
|
5
9
|
before do
|
6
|
-
|
10
|
+
File.should_receive(:open).with('vendor/rails/railties/lib/tasks/documentation.rake')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should add task" do
|
14
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'rails-1.3.5'))
|
15
|
+
SdocAll::Rails.new(:version => '1.3.5').add_tasks
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should use latest version if none given" do
|
19
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'rails-1.5.9'))
|
20
|
+
SdocAll::Rails.new(nil).add_tasks
|
7
21
|
end
|
8
22
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
Base.should_receive(:add_task).with(hash_including(:doc_path => 'rails-1.3.5'))
|
26
|
-
Rails.new('1.3.5').add_tasks
|
27
|
-
end
|
23
|
+
it "should use lone argument as version" do
|
24
|
+
SdocAll::Base.should_receive(:add_task).with(hash_including(:doc_path => 'rails-1.3.5'))
|
25
|
+
SdocAll::Rails.new('1.3.5').add_tasks
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should raise for wrong version" do
|
30
|
+
proc{
|
31
|
+
SdocAll::Rails.new('1.1.1').add_tasks
|
32
|
+
}.should raise_error(SdocAll::ConfigError)
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "creating app" do
|
36
|
+
before do
|
37
|
+
SdocAll::Base.stub!(:add_task)
|
38
|
+
File.stub!(:open)
|
28
39
|
end
|
29
40
|
|
30
|
-
it "should
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
it "should create rails app" do
|
42
|
+
FileTest.should_receive(:directory?).with("sources/rails/1.3.5").and_return(false)
|
43
|
+
SdocAll::Base.should_receive(:remove_if_present).with(Pathname.new("sources/rails/1.3.5"))
|
44
|
+
SdocAll::Base.should_receive(:system).with("rails", Pathname.new("sources/rails/1.3.5"), "--freeze")
|
45
|
+
SdocAll::Rails.new('1.3.5').add_tasks
|
34
46
|
end
|
35
47
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
it "should create rails app" do
|
43
|
-
FileTest.should_receive(:directory?).with("sources/rails/1.3.5").and_return(false)
|
44
|
-
Base.should_receive(:remove_if_present).with(Pathname.new("sources/rails/1.3.5"))
|
45
|
-
Base.should_receive(:system).with("rails", Pathname.new("sources/rails/1.3.5"), "--freeze")
|
46
|
-
Rails.new('1.3.5').add_tasks
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should not create rails app if it already exists" do
|
50
|
-
FileTest.should_receive(:directory?).with("sources/rails/1.3.5").and_return(true)
|
51
|
-
Base.should_not_receive(:remove_if_present)
|
52
|
-
Base.should_not_receive(:system)
|
53
|
-
Rails.new('1.3.5').add_tasks
|
54
|
-
end
|
48
|
+
it "should not create rails app if it already exists" do
|
49
|
+
FileTest.should_receive(:directory?).with("sources/rails/1.3.5").and_return(true)
|
50
|
+
SdocAll::Base.should_not_receive(:remove_if_present)
|
51
|
+
SdocAll::Base.should_not_receive(:system)
|
52
|
+
SdocAll::Rails.new('1.3.5').add_tasks
|
55
53
|
end
|
56
54
|
end
|
57
55
|
end
|
data/spec/sdoc_all/ruby_spec.rb
CHANGED
@@ -1,203 +1,201 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
describe "
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
3
|
+
describe SdocAll::Ruby do
|
4
|
+
describe "subroutines" do
|
5
|
+
describe "match_ruby_archive" do
|
6
|
+
it "should return nil if does not match" do
|
7
|
+
SdocAll::Ruby.match_ruby_archive('').should be_nil
|
8
|
+
SdocAll::Ruby.match_ruby_archive('ruby').should be_nil
|
9
|
+
SdocAll::Ruby.match_ruby_archive('ruby-1.2.3-p666.tar').should be_nil
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
12
|
+
%w(tar.bz2 tar.gz zip).each do |ext|
|
13
|
+
it "should return info if match" do
|
14
|
+
@archive = SdocAll::Ruby.match_ruby_archive("path/ruby-1.2.3-p666.#{ext}")
|
15
|
+
@archive.should be_an(SdocAll::Ruby::ArchiveInfo)
|
16
|
+
@archive.path.should == "path/ruby-1.2.3-p666.#{ext}"
|
17
|
+
@archive.name.should == "ruby-1.2.3-p666.#{ext}"
|
18
|
+
@archive.full_version.should == "1.2.3-p666"
|
19
|
+
@archive.extension.should == ext
|
20
|
+
@archive.version.should == [1, 2, 3, 666]
|
23
21
|
end
|
24
22
|
end
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
describe "last_matching_ruby_archive" do
|
26
|
+
it "should return nil if could nothing match" do
|
27
|
+
SdocAll::Ruby.last_matching_ruby_archive('2.0.0', %w(path/ruby-1.2.3-p666.zip .DS_Store)).should be_nil
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
30
|
+
it "should return latest matching" do
|
31
|
+
@archive = SdocAll::Ruby.last_matching_ruby_archive('2.0.0', %w(
|
32
|
+
path/ruby-1.0.0-p333.zip
|
33
|
+
path/ruby-2.0.0-p444.zip
|
34
|
+
path/ruby-3.0.0-p444.zip
|
35
|
+
path/ruby-2.0.0-p666.zip
|
36
|
+
path/ruby-3.0.0-p666.zip
|
37
|
+
path/ruby-2.0.0-p555.zip
|
38
|
+
path/ruby-3.0.0-p777.zip
|
39
|
+
.DS_Store
|
40
|
+
))
|
41
|
+
@archive.should be_an(SdocAll::Ruby::ArchiveInfo)
|
42
|
+
@archive.path.should == "path/ruby-2.0.0-p666.zip"
|
45
43
|
end
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
46
|
+
describe "find_matching_archive" do
|
47
|
+
it "should call last_matching_ruby_archive for all files in sources" do
|
48
|
+
@files = mock(:files)
|
49
|
+
@children = mock(:children)
|
50
|
+
@children.should_receive(:select).and_return(@files)
|
51
|
+
@sources_path = mock(:sources_path, :parent => mock(:parent, :children => @children))
|
52
|
+
SdocAll::Ruby.stub!(:sources_path).and_return(@sources_path)
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
54
|
+
SdocAll::Ruby.should_receive(:last_matching_ruby_archive).with('1.2.3', @files)
|
55
|
+
SdocAll::Ruby.find_matching_archive('1.2.3')
|
58
56
|
end
|
57
|
+
end
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
it "should not download anything if no matces" do
|
75
|
-
@ftp.should_not_receive(:size)
|
76
|
-
@ftp.should_not_receive(:getbinaryfile)
|
59
|
+
describe "download_matching_archive" do
|
60
|
+
before do
|
61
|
+
@ftp = mock(:ftp, :debug_mode= => nil, :passive= => nil, :login => nil)
|
62
|
+
@ftp.should_receive(:chdir).with(Pathname('/pub/ruby'))
|
63
|
+
@list = ['mode user ... ruby-1.2.3.tar.bz2', 'mode user ... ruby-1.2.4.tar.bz2', 'mode user ... ruby-1.2.5.tar.bz2']
|
64
|
+
@paths = [Pathname('/pub/ruby/ruby-1.2.3.tar.bz2'), Pathname('/pub/ruby/ruby-1.2.4.tar.bz2'), Pathname('/pub/ruby/ruby-1.2.5.tar.bz2')]
|
65
|
+
@ftp.should_receive(:list).with('*').and_return(@list)
|
66
|
+
Net::FTP.should_receive(:open).with('ftp.ruby-lang.org').and_yield(@ftp)
|
67
|
+
|
68
|
+
@dest = mock(:dest)
|
69
|
+
@sources_path = mock(:sources_path, :parent => mock(:parent, :children => @children, :+ => @dest))
|
70
|
+
SdocAll::Ruby.stub!(:sources_path).and_return(@sources_path)
|
71
|
+
end
|
77
72
|
|
78
|
-
|
79
|
-
|
80
|
-
|
73
|
+
it "should not download anything if no matches" do
|
74
|
+
@ftp.should_not_receive(:size)
|
75
|
+
@ftp.should_not_receive(:getbinaryfile)
|
81
76
|
|
82
|
-
|
83
|
-
|
84
|
-
@tar = mock(:tar, :name => 'abc', :path => '/path')
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should download if it does not exist locally" do
|
88
|
-
@dest.stub!(:exist?).and_return(false)
|
89
|
-
@ftp.should_receive(:getbinaryfile)
|
90
|
-
|
91
|
-
Ruby.should_receive(:last_matching_ruby_archive).with('1.2.3', @paths).and_return(@tar)
|
92
|
-
Ruby.download_matching_archive('1.2.3')
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should download if local file size is not equal to remote" do
|
96
|
-
@dest.stub!(:exist?).and_return(true)
|
97
|
-
@dest.stub!(:size).and_return(1000)
|
98
|
-
@ftp.stub!(:size).and_return(2000)
|
99
|
-
@ftp.should_receive(:getbinaryfile)
|
100
|
-
|
101
|
-
Ruby.should_receive(:last_matching_ruby_archive).with('1.2.3', @paths).and_return(@tar)
|
102
|
-
Ruby.download_matching_archive('1.2.3')
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should not download if local file size is equal to remote" do
|
106
|
-
@dest.stub!(:exist?).and_return(true)
|
107
|
-
@dest.stub!(:size).and_return(2000)
|
108
|
-
@ftp.stub!(:size).and_return(2000)
|
109
|
-
@ftp.should_not_receive(:getbinaryfile)
|
110
|
-
|
111
|
-
Ruby.should_receive(:last_matching_ruby_archive).with('1.2.3', @paths).and_return(@tar)
|
112
|
-
Ruby.download_matching_archive('1.2.3')
|
113
|
-
end
|
114
|
-
end
|
77
|
+
SdocAll::Ruby.should_receive(:last_matching_ruby_archive).with('1.2.3', @paths).any_number_of_times.and_return(nil)
|
78
|
+
SdocAll::Ruby.download_matching_archive('1.2.3')
|
115
79
|
end
|
116
80
|
|
117
|
-
describe "
|
81
|
+
describe "when match" do
|
118
82
|
before do
|
119
|
-
@
|
83
|
+
@tar = mock(:tar, :name => 'abc', :path => '/path')
|
120
84
|
end
|
121
85
|
|
122
|
-
it "should
|
123
|
-
|
124
|
-
|
86
|
+
it "should download if it does not exist locally" do
|
87
|
+
@dest.stub!(:exist?).and_return(false)
|
88
|
+
@ftp.should_receive(:getbinaryfile)
|
125
89
|
|
126
|
-
Ruby.
|
90
|
+
SdocAll::Ruby.should_receive(:last_matching_ruby_archive).with('1.2.3', @paths).and_return(@tar)
|
91
|
+
SdocAll::Ruby.download_matching_archive('1.2.3')
|
127
92
|
end
|
128
93
|
|
129
|
-
it "should
|
130
|
-
|
131
|
-
|
94
|
+
it "should download if local file size is not equal to remote" do
|
95
|
+
@dest.stub!(:exist?).and_return(true)
|
96
|
+
@dest.stub!(:size).and_return(1000)
|
97
|
+
@ftp.stub!(:size).and_return(2000)
|
98
|
+
@ftp.should_receive(:getbinaryfile)
|
132
99
|
|
133
|
-
Ruby.
|
100
|
+
SdocAll::Ruby.should_receive(:last_matching_ruby_archive).with('1.2.3', @paths).and_return(@tar)
|
101
|
+
SdocAll::Ruby.download_matching_archive('1.2.3')
|
134
102
|
end
|
135
103
|
|
136
|
-
it "should
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should raise if can not find local or downlaod archive" do
|
144
|
-
Ruby.should_receive(:find_matching_archive).with('1.2.3').once.ordered.and_return(nil, nil)
|
145
|
-
Ruby.should_receive(:download_matching_archive).with('1.2.3').once.ordered
|
104
|
+
it "should not download if local file size is equal to remote" do
|
105
|
+
@dest.stub!(:exist?).and_return(true)
|
106
|
+
@dest.stub!(:size).and_return(2000)
|
107
|
+
@ftp.stub!(:size).and_return(2000)
|
108
|
+
@ftp.should_not_receive(:getbinaryfile)
|
146
109
|
|
147
|
-
|
148
|
-
|
149
|
-
}.should raise_error(SdocAll::ConfigError)
|
110
|
+
SdocAll::Ruby.should_receive(:last_matching_ruby_archive).with('1.2.3', @paths).and_return(@tar)
|
111
|
+
SdocAll::Ruby.download_matching_archive('1.2.3')
|
150
112
|
end
|
151
113
|
end
|
152
114
|
end
|
153
115
|
|
154
|
-
|
155
|
-
|
156
|
-
|
116
|
+
describe "find_or_download_matching_archive" do
|
117
|
+
before do
|
118
|
+
@archive = mock(:archive)
|
119
|
+
end
|
157
120
|
|
158
|
-
|
159
|
-
|
160
|
-
|
121
|
+
it "should immediately return match if update not allowed" do
|
122
|
+
SdocAll::Ruby.should_receive(:find_matching_archive).with('1.2.3').once.and_return(@archive)
|
123
|
+
SdocAll::Ruby.should_not_receive(:download_matching_archive)
|
161
124
|
|
162
|
-
|
163
|
-
before do
|
164
|
-
@path = mock(:path)
|
165
|
-
@sources_path = mock(:sources_path)
|
166
|
-
@archive = mock(:archive, :full_version => '1.2.3-p666', :extension => 'tar.bz2', :path => 'sources/ruby-1.2.3-p666.tar.bz2')
|
167
|
-
@sources_path.should_receive(:+).with('1.2.3-p666').and_return(@path)
|
168
|
-
Ruby.stub!(:sources_path).and_return(@sources_path)
|
169
|
-
Ruby.should_receive(:find_or_download_matching_archive).with('1.2.3')
|
170
|
-
Ruby.should_receive(:find_or_download_matching_archive).with('1.2.3', :update => true).and_return(@archive)
|
171
|
-
Base.stub!(:add_task)
|
125
|
+
SdocAll::Ruby.find_or_download_matching_archive('1.2.3', :update => false).should == @archive
|
172
126
|
end
|
173
127
|
|
174
|
-
it "should
|
175
|
-
|
176
|
-
|
177
|
-
Base.should_not_receive(:system)
|
128
|
+
it "should downlaod and return match if update allowed" do
|
129
|
+
SdocAll::Ruby.should_receive(:download_matching_archive).with('1.2.3').once.ordered
|
130
|
+
SdocAll::Ruby.should_receive(:find_matching_archive).with('1.2.3').once.ordered.and_return(@archive)
|
178
131
|
|
179
|
-
Ruby.
|
132
|
+
SdocAll::Ruby.find_or_download_matching_archive('1.2.3', :update => true).should == @archive
|
180
133
|
end
|
181
134
|
|
182
|
-
it "should
|
183
|
-
|
184
|
-
|
185
|
-
Base.should_receive(:system).with("tar", "-xjf", "sources/ruby-1.2.3-p666.tar.bz2", "-C", @sources_path)
|
186
|
-
@path2 = mock(:path2)
|
187
|
-
@sources_path.should_receive(:+).with('ruby-1.2.3-p666').and_return(@path2)
|
188
|
-
File.should_receive(:rename).with(@path2, @path)
|
135
|
+
it "should downlaod and return match if not found local" do
|
136
|
+
SdocAll::Ruby.should_receive(:find_matching_archive).with('1.2.3').once.ordered.and_return(nil, @archive)
|
137
|
+
SdocAll::Ruby.should_receive(:download_matching_archive).with('1.2.3').once.ordered
|
189
138
|
|
190
|
-
Ruby.
|
139
|
+
SdocAll::Ruby.find_or_download_matching_archive('1.2.3').should == @archive
|
191
140
|
end
|
192
141
|
|
193
|
-
it "should
|
194
|
-
|
195
|
-
|
196
|
-
Base.should_not_receive(:system)
|
197
|
-
Base.should_receive(:add_task).with(:doc_path => "ruby-1.2.3-p666", :src_path => @path, :title => 'ruby-1.2.3-p666')
|
142
|
+
it "should raise if can not find local or downlaod archive" do
|
143
|
+
SdocAll::Ruby.should_receive(:find_matching_archive).with('1.2.3').once.ordered.and_return(nil, nil)
|
144
|
+
SdocAll::Ruby.should_receive(:download_matching_archive).with('1.2.3').once.ordered
|
198
145
|
|
199
|
-
|
146
|
+
proc{
|
147
|
+
SdocAll::Ruby.find_or_download_matching_archive('1.2.3').should == @archive
|
148
|
+
}.should raise_error(SdocAll::ConfigError)
|
200
149
|
end
|
201
150
|
end
|
202
151
|
end
|
152
|
+
|
153
|
+
it "should raise error if version not specified" do
|
154
|
+
proc{ SdocAll::Ruby.new(nil).add_tasks }.should raise_error(SdocAll::ConfigError)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should raise error if version is blank" do
|
158
|
+
proc{ SdocAll::Ruby.new(:version => ' ').add_tasks }.should raise_error(SdocAll::ConfigError)
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "extracting archive and adding task" do
|
162
|
+
before do
|
163
|
+
@path = mock(:path)
|
164
|
+
@sources_path = mock(:sources_path)
|
165
|
+
@archive = mock(:archive, :full_version => '1.2.3-p666', :extension => 'tar.bz2', :path => 'sources/ruby-1.2.3-p666.tar.bz2')
|
166
|
+
@sources_path.should_receive(:+).with('1.2.3-p666').and_return(@path)
|
167
|
+
SdocAll::Ruby.stub!(:sources_path).and_return(@sources_path)
|
168
|
+
SdocAll::Ruby.should_receive(:find_or_download_matching_archive).with('1.2.3')
|
169
|
+
SdocAll::Ruby.should_receive(:find_or_download_matching_archive).with('1.2.3', :update => true).and_return(@archive)
|
170
|
+
SdocAll::Base.stub!(:add_task)
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should not extract archive if matching directory already exists" do
|
174
|
+
@path.stub!(:directory?).and_return(true)
|
175
|
+
SdocAll::Base.should_not_receive(:remove_if_present)
|
176
|
+
SdocAll::Base.should_not_receive(:system)
|
177
|
+
|
178
|
+
SdocAll::Ruby.new(:version => '1.2.3').add_tasks(:update => true)
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should extract archive if matching directory does not exist" do
|
182
|
+
@path.stub!(:directory?).and_return(false)
|
183
|
+
SdocAll::Base.should_receive(:remove_if_present).with(@path)
|
184
|
+
SdocAll::Base.should_receive(:system).with("tar", "-xjf", "sources/ruby-1.2.3-p666.tar.bz2", "-C", @sources_path)
|
185
|
+
@path2 = mock(:path2)
|
186
|
+
@sources_path.should_receive(:+).with('ruby-1.2.3-p666').and_return(@path2)
|
187
|
+
File.should_receive(:rename).with(@path2, @path)
|
188
|
+
|
189
|
+
SdocAll::Ruby.new(:version => '1.2.3').add_tasks(:update => true)
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should finally add task" do
|
193
|
+
@path.stub!(:directory?).and_return(true)
|
194
|
+
SdocAll::Base.should_not_receive(:remove_if_present)
|
195
|
+
SdocAll::Base.should_not_receive(:system)
|
196
|
+
SdocAll::Base.should_receive(:add_task).with(:doc_path => "ruby-1.2.3-p666", :src_path => @path, :title => 'ruby-1.2.3-p666')
|
197
|
+
|
198
|
+
SdocAll::Ruby.new(:version => '1.2.3').add_tasks(:update => true)
|
199
|
+
end
|
200
|
+
end
|
203
201
|
end
|
data/spec/sdoc_all_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe SdocAll do
|
|
22
22
|
SdocAll::Base.stub!(:public_path).and_return(Pathname.new('/public'))
|
23
23
|
|
24
24
|
@tasks = []
|
25
|
-
@each = @tasks.should_receive(:
|
25
|
+
@each = @tasks.should_receive(:each).twice
|
26
26
|
%w(a b c).each do |c|
|
27
27
|
task = mock(c, :doc_path => "#{c}", :src_path => "/sources/#{c}", :title => "<#{c}>", :config_hash => 'abc')
|
28
28
|
task.should_receive(:run)
|
data/spec/spec.opts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--colour
|
1
|
+
--colour -b
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
gem 'rspec'
|
3
3
|
require 'spec'
|
4
|
+
require 'stringio'
|
4
5
|
|
5
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
7
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -16,6 +17,8 @@ Spec::Runner.configure do |config|
|
|
16
17
|
Dir.stub!(:chdir).and_yield
|
17
18
|
Net::FTP.stub!(:open)
|
18
19
|
File.stub!(:symlink)
|
20
|
+
@progress_io = StringIO.new
|
21
|
+
Progress.stub!(:io).and_return(@progress_io)
|
19
22
|
|
20
23
|
SdocAll.constants.each do |constant|
|
21
24
|
klass = SdocAll.const_get(constant)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdoc_all
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boba Fat
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-03 00:00:00 +03:00
|
13
13
|
default_executable: sdoc-all
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|