sdoc_all 0.2.0.1 → 0.2.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ Echoe.new('sdoc_all', version) do |p|
15
15
  p.url = "http://github.com/toy/sdoc_all"
16
16
  p.runtime_dependencies << 'activesupport'
17
17
  p.runtime_dependencies << 'rake'
18
- p.runtime_dependencies << 'progress >= 0.0.8'
18
+ p.runtime_dependencies << 'progress >=0.0.8'
19
19
  # TODO: sdoc or voloko-sdoc
20
20
  p.project = 'toytoy'
21
21
  end
data/VERSION.yml CHANGED
@@ -1 +1 @@
1
- [0, 2, 0, 1]
1
+ [0, 2, 0, 6]
@@ -46,8 +46,8 @@ class SdocAll
46
46
  task_options = {
47
47
  :src_path => path,
48
48
  :doc_path => "paths.#{path.relative_path_from(common_path).to_s.gsub('/', '.')}",
49
+ :title => "paths: #{path.relative_path_from(common_path)}"
49
50
  }
50
- task_options[:title] = task_options[:doc_path].sub('.', ': ')
51
51
  task_options[:main] = entry[:main] if entry[:main]
52
52
 
53
53
  if entry[:paths]
@@ -44,6 +44,22 @@ class SdocAll
44
44
  paths.include('lib/**/*.rb')
45
45
  paths.include('README*')
46
46
  paths.include('CHANGELOG*')
47
+
48
+ begin
49
+ File.open('Rakefile') do |f|
50
+ true until f.readline['Rake::RDocTask']
51
+ until ['end', '}'].include?(line = f.readline.strip)
52
+ globs = line.scan(/'([^']*)'/).map{ |match| match[0] }
53
+ if line['include(']
54
+ paths.include(*globs)
55
+ elsif line['exclude(']
56
+ paths.exclude(*globs)
57
+ end
58
+ end
59
+ end
60
+ rescue
61
+ end
62
+
47
63
  paths.resolve
48
64
  end
49
65
  Base.add_task(
data/lib/sdoc_all/task.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'digest'
2
+
1
3
  class SdocAll
2
4
  class Task
3
5
  attr_reader :src_path, :doc_path, :paths, :main, :title
@@ -10,19 +12,64 @@ class SdocAll
10
12
  end
11
13
 
12
14
  def run(options = {})
13
- cmd = %w(sdoc)
14
- cmd << '-o' << Base.docs_path + doc_path
15
- cmd << '-t' << title
16
- cmd << '-T' << 'direct'
17
-
18
- if src_path.directory?
19
- Dir.chdir(src_path) do
20
- cmd << '-m' << main if main
21
- Base.system(*cmd + paths)
15
+ if clobber?
16
+ Base.remove_if_present(Base.docs_path + doc_path)
17
+
18
+ cmd = %w(sdoc)
19
+ cmd << '-o' << Base.docs_path + doc_path
20
+ cmd << '-t' << title
21
+ cmd << '-T' << 'direct'
22
+
23
+ if src_path.directory?
24
+ Dir.chdir(src_path) do
25
+ cmd << '-m' << main if main
26
+ Base.system(*cmd + paths)
27
+ end
28
+ else
29
+ Base.system(*cmd + [src_path])
30
+ end
31
+
32
+ if (Base.docs_path + doc_path).directory?
33
+ config_hash_path.open('w') do |f|
34
+ f.write(hash)
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ def hash
41
+ Digest::SHA1.hexdigest([src_path.to_s, doc_path.to_s, paths, main, title, last_build_time].inspect)
42
+ end
43
+
44
+ def config_hash_path
45
+ Base.docs_path + doc_path + 'config.hash'
46
+ end
47
+
48
+ def created_rid_path
49
+ Base.docs_path + doc_path + 'created.rid'
50
+ end
51
+
52
+ def last_build_time
53
+ Time.parse(created_rid_path.read) rescue nil
54
+ end
55
+
56
+ def clobber?
57
+ full_doc_path = Base.docs_path + doc_path
58
+ return true unless full_doc_path.exist?
59
+
60
+ created_hash = config_hash_path.read rescue nil
61
+ return true if created_hash != hash
62
+
63
+ latest = [src_path.mtime, src_path.ctime].max
64
+ created = last_build_time
65
+ if created && latest < created
66
+ src_path.find do |path|
67
+ Find.prune if path.directory? && path.basename.to_s[0] == ?.
68
+ latest = [latest, src_path.mtime, src_path.ctime].max
69
+ break unless latest < created
22
70
  end
23
- else
24
- Base.system(*cmd + [src_path])
25
71
  end
72
+ created.nil? || latest >= created
26
73
  end
27
74
  end
28
75
  end
data/lib/sdoc_all.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'fileutils'
4
4
  require 'find'
5
+ require 'digest'
5
6
 
6
7
  require 'rubygems'
7
8
  require 'activesupport'
@@ -35,10 +36,8 @@ class SdocAll
35
36
  Gem.searcher.find('sdoc').version.to_s
36
37
  end
37
38
 
38
- def store_current_sdoc_version
39
- last_build_sdoc_version_path.open('w') do |f|
40
- f.write(current_sdoc_version)
41
- end
39
+ def config_hash_path
40
+ Base.public_path + 'config.hash'
42
41
  end
43
42
 
44
43
  def run(options = {})
@@ -58,38 +57,16 @@ class SdocAll
58
57
  Base.remove_if_present(path)
59
58
  end
60
59
  end
61
-
62
- tasks.each do |task|
63
- doc_path = Base.docs_path + task.doc_path
64
- src_path = task.src_path
65
- if doc_path.exist?
66
- latest = [src_path.mtime, src_path.ctime].max
67
-
68
- created = Time.parse(File.read(doc_path + 'created.rid')) rescue nil
69
- if created && latest < created
70
- src_path.find do |path|
71
- Find.prune if path.directory? && path.basename.to_s[0] == ?.
72
- latest = [latest, src_path.mtime, src_path.ctime].max
73
- break unless latest < created
74
- end
75
- end
76
- if created.nil? || latest >= created
77
- Base.remove_if_present(doc_path)
78
- end
79
- end
80
- end
81
60
  end
82
61
 
83
- merge = false
84
62
  tasks.each_with_progress('docs') do |task|
85
- unless (Base.docs_path + task.doc_path).directory?
86
- puts
87
- merge = true
88
- task.run(options)
89
- end
63
+ task.run(options)
90
64
  end
91
65
 
92
- if merge || !Base.public_path.exist?
66
+ hash = Digest::SHA1.hexdigest(tasks.map(&:hash).inspect)
67
+ created_hash = config_hash_path.read rescue nil
68
+
69
+ if hash != created_hash
93
70
  Dir.chdir(Base.docs_path) do
94
71
  paths = []
95
72
  titles = []
@@ -113,11 +90,18 @@ class SdocAll
113
90
  cmd << '-u' << urls.join(' ')
114
91
  Base.system(*cmd + paths)
115
92
 
116
- File.symlink(Base.docs_path, Base.public_path + 'docs')
93
+ if Base.public_path.directory?
94
+ File.symlink(Base.docs_path, Base.public_path + 'docs')
95
+ config_hash_path.open('w') do |f|
96
+ f.write(hash)
97
+ end
98
+ last_build_sdoc_version_path.open('w') do |f|
99
+ f.write(current_sdoc_version)
100
+ end
101
+ end
117
102
  end
118
103
  end
119
104
  end
120
- store_current_sdoc_version
121
105
  rescue ConfigError => e
122
106
  STDERR.puts e.to_s
123
107
  end
@@ -7,9 +7,15 @@ task :run do
7
7
  SdocAll.run
8
8
  end
9
9
 
10
+ desc "Clobber documentation"
11
+ task :clobber do
12
+ rm_rf 'docs' rescue nil
13
+ rm_rf 'public' rescue nil
14
+ end
15
+
10
16
  namespace :run do
11
17
  desc "Force update sources, before building/updating"
12
- task :force do
18
+ task :update do
13
19
  SdocAll.run(:update => true)
14
20
  end
15
21
  end
data/sdoc_all.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{sdoc_all}
5
- s.version = "0.2.0.1"
5
+ s.version = "0.2.0.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["toy"]
9
- s.date = %q{2009-04-27}
9
+ s.date = %q{2009-05-02}
10
10
  s.default_executable = %q{sdoc-all}
11
11
  s.description = %q{Command line tool to get documentation for ruby, rails, gems and plugins in one place}
12
12
  s.email = %q{ivan@workisfun.ru}
@@ -28,15 +28,15 @@ Gem::Specification.new do |s|
28
28
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
29
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
30
30
  s.add_runtime_dependency(%q<rake>, [">= 0"])
31
- s.add_runtime_dependency(%q<progress>, [">= 0", "= 0.0.8"])
31
+ s.add_runtime_dependency(%q<progress>, [">= 0.0.8"])
32
32
  else
33
33
  s.add_dependency(%q<activesupport>, [">= 0"])
34
34
  s.add_dependency(%q<rake>, [">= 0"])
35
- s.add_dependency(%q<progress>, [">= 0", "= 0.0.8"])
35
+ s.add_dependency(%q<progress>, [">= 0.0.8"])
36
36
  end
37
37
  else
38
38
  s.add_dependency(%q<activesupport>, [">= 0"])
39
39
  s.add_dependency(%q<rake>, [">= 0"])
40
- s.add_dependency(%q<progress>, [">= 0", "= 0.0.8"])
40
+ s.add_dependency(%q<progress>, [">= 0.0.8"])
41
41
  end
42
42
  end
@@ -12,7 +12,7 @@ class SdocAll
12
12
  [:a, :b, :c].each do |sym|
13
13
  @roots[sym] = mock(sym, :expand_path => mock("#{sym}_exp".to_sym, :exist? => true, :relative_path_from => "lala/#{sym}_exp"))
14
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)
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
16
  end
17
17
  Paths.should_receive(:common_path).with([@roots[:a], @roots[:b], @roots[:c]].map(&:expand_path)).and_return('/common')
18
18
 
@@ -26,7 +26,7 @@ class SdocAll
26
26
  [:a, :b, :d, :e].each do |sym|
27
27
  @roots[sym] = mock(sym, :expand_path => mock("#{sym}_exp".to_sym, :exist? => true, :relative_path_from => "lala/#{sym}_exp"))
28
28
  Pathname.should_receive(:new).with("#{sym}").and_return(@roots[sym])
29
- Base.should_receive(:add_task).with(:doc_path => "paths.lala/#{sym}_exp", :src_path => @roots[sym].expand_path)
29
+ Base.should_receive(:add_task).with(:doc_path => "paths.lala.#{sym}_exp", :src_path => @roots[sym].expand_path, :title => "paths: lala/#{sym}_exp")
30
30
  end
31
31
  Paths.should_receive(:common_path).with([@roots[:a], @roots[:b], @roots[:d], @roots[:e]].map(&:expand_path)).and_return('/common')
32
32
 
@@ -45,12 +45,12 @@ class SdocAll
45
45
  end
46
46
 
47
47
  it "should add task" do
48
- Base.should_receive(:add_task).with(:doc_path => "paths.lala/root", :src_path => @root.expand_path)
48
+ Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :title => 'paths: lala/root')
49
49
  Paths.new({:root => '/lalala/lala/root'}).add_tasks
50
50
  end
51
51
 
52
52
  it "should add task with main" do
53
- Base.should_receive(:add_task).with(:doc_path => "paths.lala/root", :src_path => @root.expand_path, :main => 'special_readme')
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
54
  Paths.new({:root => '/lalala/lala/root', :main => 'special_readme'}).add_tasks
55
55
  end
56
56
 
@@ -61,7 +61,7 @@ class SdocAll
61
61
  @file_list.should_receive(:include).with('*.rb')
62
62
  @file_list.should_receive(:to_a).and_return(['a.rb', 'b.rb'])
63
63
 
64
- Base.should_receive(:add_task).with(:doc_path => "paths.lala/root", :src_path => @root.expand_path, :paths => ['a.rb', 'b.rb'])
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
65
  Paths.new({:root => '/lalala/lala/root', :paths => '*.rb'}).add_tasks
66
66
  end
67
67
 
@@ -76,7 +76,7 @@ class SdocAll
76
76
  @file_list.should_receive(:exclude).ordered.with('*.tmp')
77
77
  @file_list.should_receive(:to_a).and_return(['a.rb', 'b.rb', 'README', 'README_en'])
78
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'])
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
80
  Paths.new({:root => '/lalala/lala/root', :paths => ['*.*', '-*.cgi', '+README', '+README_*', '-*.tmp']}).add_tasks
81
81
  end
82
82
  end
@@ -91,8 +91,8 @@ class SdocAll
91
91
 
92
92
  Paths.should_receive(:common_path).with([@root, @other].map(&:expand_path)).and_return('/common')
93
93
 
94
- Base.should_receive(:add_task).with(:doc_path => "paths.lala/root", :src_path => @root.expand_path)
95
- Base.should_receive(:add_task).with(:doc_path => "paths.lolo/other", :src_path => @other.expand_path)
94
+ Base.should_receive(:add_task).with(:doc_path => "paths.lala.root", :src_path => @root.expand_path, :title => 'paths: lala/root')
95
+ Base.should_receive(:add_task).with(:doc_path => "paths.lolo.other", :src_path => @other.expand_path, :title => 'paths: lolo/other')
96
96
 
97
97
  Paths.new([{:root => '/lalala/lala/root'}, {:root => '/lalala/lolo/other'}]).add_tasks
98
98
  end
@@ -190,7 +190,7 @@ class SdocAll
190
190
  @path.stub!(:directory?).and_return(true)
191
191
  Base.should_not_receive(:remove_if_present)
192
192
  Base.should_not_receive(:system)
193
- Base.should_receive(:add_task).with(:doc_path => "ruby-1.2.3-p666", :src_path => @path)
193
+ Base.should_receive(:add_task).with(:doc_path => "ruby-1.2.3-p666", :src_path => @path, :title => 'ruby-1.2.3-p666')
194
194
 
195
195
  Ruby.new(:version => '1.2.3').add_tasks(:update => true)
196
196
  end
@@ -34,7 +34,6 @@ describe SdocAll do
34
34
  SdocAll.should_receive(:read_config)
35
35
  SdocAll::Base.should_receive(:tasks).and_return(@tasks)
36
36
  SdocAll::Base.should_receive(:system).with('sdoc-merge', '-o', Pathname.new('/public'), '-t', 'all', '-n', '<a>,<b>,<c>', '-u', '/docs/a /docs/b /docs/c', 'a', 'b', 'c')
37
- SdocAll.should_receive(:store_current_sdoc_version)
38
37
  SdocAll.run
39
38
  end
40
39
  end
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: 0.2.0.1
4
+ version: 0.2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - toy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-27 00:00:00 +04:00
12
+ date: 2009-05-02 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,9 +39,6 @@ dependencies:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- - - "="
45
42
  - !ruby/object:Gem::Version
46
43
  version: 0.0.8
47
44
  version: