@@ -4,14 +4,15 @@ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base) and !$LOAD_PATH.includ
4
4
5
5
require 'spec/rake/spectask'
6
6
require 'spec/rake/verify_rcov'
7
- require 'rake/rdoctask'
7
+ require 'hanna/rdoctask'
8
+ require 'garlic/tasks'
8
9
9
- plugin_name = File . basename ( File . dirname ( __FILE__ ) )
10
+ plugin_name = "truncate_html"
10
11
11
12
task :default => :spec
12
13
13
- task :cruise do
14
- sh "garlic all "
14
+ task :cruise => [ 'garlic:all' , 'doc:push' ] do
15
+ puts "The build is GOOD "
15
16
end
16
17
17
18
desc "Run the specs for #{ plugin_name } "
@@ -20,53 +21,66 @@ Spec::Rake::SpecTask.new(:spec) do |t|
20
21
t . spec_opts = [ "--colour" ]
21
22
end
22
23
23
- namespace :spec do
24
- desc "Generate RCov report for #{ plugin_name } "
25
- Spec ::Rake ::SpecTask . new ( :rcov ) do |t |
26
- t . spec_files = FileList [ 'spec/**/*_spec.rb' ]
27
- t . rcov = true
28
- t . rcov_dir = 'doc/coverage'
29
- t . rcov_opts = [ '--text-report' , '--exclude' , "spec/,rcov.rb,#{ File . expand_path ( File . join ( File . dirname ( __FILE__ ) , '../../..' ) ) } " ]
30
- end
31
-
32
- namespace :rcov do
33
- desc "Verify RCov threshold for #{ plugin_name } "
34
- RCov ::VerifyTask . new ( :verify => "spec:rcov" ) do |t |
35
- t . threshold = 100.0
36
- t . index_html = File . join ( File . dirname ( __FILE__ ) , 'doc/coverage/index.html' )
37
- end
38
- end
39
-
40
- desc "Generate specdoc for #{ plugin_name } "
41
- Spec ::Rake ::SpecTask . new ( :doc ) do |t |
42
- t . spec_files = FileList [ 'spec/**/*_spec.rb' ]
43
- t . spec_opts = [ "--format" , "specdoc:SPECDOC" ]
44
- end
24
+ desc "Generate RCov report for #{ plugin_name } "
25
+ Spec ::Rake ::SpecTask . new ( :rcov ) do |t |
26
+ t . spec_files = FileList [ 'spec/**/*_spec.rb' ]
27
+ t . rcov = true
28
+ t . rcov_dir = 'doc/coverage'
29
+ t . rcov_opts = [ '--text-report' , '--exclude' , "spec/,rcov.rb,#{ File . expand_path ( File . join ( File . dirname ( __FILE__ ) , '../../..' ) ) } " ]
30
+ end
45
31
46
- namespace :doc do
47
- desc "Generate html specdoc for #{ plugin_name } "
48
- Spec ::Rake ::SpecTask . new ( :html => :rdoc ) do |t |
49
- t . spec_files = FileList [ 'spec/**/*_spec.rb' ]
50
- t . spec_opts = [ "--format" , "html:doc/rspec_report.html" , "--diff" ]
51
- end
32
+ namespace :rcov do
33
+ desc "Verify RCov threshold for #{ plugin_name } "
34
+ RCov ::VerifyTask . new ( :verify => "spec:rcov" ) do |t |
35
+ t . threshold = 100.0
36
+ t . index_html = File . join ( File . dirname ( __FILE__ ) , 'doc/coverage/index.html' )
52
37
end
53
38
end
54
39
55
- task :rdoc => :doc
56
- task "SPECDOC" => "spec:doc"
40
+ task :doc => 'doc:build'
57
41
58
- desc "Generate rdoc for #{ plugin_name } "
59
- Rake ::RDocTask . new ( :doc ) do |t |
60
- t . rdoc_dir = 'doc'
61
- t . main = 'README'
62
- t . title = "#{ plugin_name } "
63
- t . template = ENV [ 'RDOC_TEMPLATE' ]
64
- t . options = [ '--line-numbers' , '--inline-source' , '--all' ]
65
- t . rdoc_files . include ( 'README' , 'SPECDOC' , 'MIT-LICENSE' , 'CHANGELOG' )
66
- t . rdoc_files . include ( 'lib/**/*.rb' )
42
+ namespace :doc do
43
+ def sha
44
+ `git log -1 --pretty=format:"%h"`
45
+ end
46
+
47
+ Rake ::RDocTask . new ( :build ) do |d |
48
+ d . rdoc_dir = 'doc'
49
+ d . main = 'README.rdoc'
50
+ d . title = "#{ plugin_name } API Docs (#{ sha } )"
51
+ d . rdoc_files . include ( 'README.rdoc' , 'History.txt' , 'License.txt' , 'Todo.txt' , 'lib/**/*.rb' )
52
+ end
53
+
54
+ task :push => 'doc:build' do
55
+ # if sha != `cat`
56
+ #
57
+ # mv 'doc', 'newdoc'
58
+ # on_gh_pages do
59
+ # if doc_changed_sha?('newdoc', 'doc')
60
+ # puts "doc has changed, pushing to gh-pages"
61
+ # `rm -rf doc && mv newdoc doc`
62
+ # `git add doc`
63
+ # `git commit -a -m "Update API docs"`
64
+ # `git push`
65
+ # else
66
+ # puts "doc is unchanged"
67
+ # rm_rf 'newdoc'
68
+ # end
69
+ # end
70
+ end
71
+
72
+ def doc_changed_sha? ( docpath1 , docpath2 )
73
+ `cat #{ docpath1 } /index.html | grep "<title>"` != `cat #{ docpath2 } /index.html | grep "<title>"`
74
+ end
75
+
76
+ def on_gh_pages ( &block )
77
+ `git branch -m gh-pages orig-gh-pages > /dev/null 2>&1`
78
+ `git checkout -b gh-pages origin/gh-pages`
79
+ `git pull`
80
+ yield
81
+ ensure
82
+ `git checkout master`
83
+ `git branch -D gh-pages`
84
+ `git branch -m orig-gh-pages gh-pages > /dev/null 2>&1`
85
+ end
67
86
end
68
-
69
- namespace :doc do
70
- desc "Generate all documentation (rdoc, specdoc, specdoc html and rcov) for #{ plugin_name } "
71
- task :all => [ "spec:doc:html" , "spec:doc" , "spec:rcov" , "doc" ]
72
- end
0 commit comments