Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 150 lines (127 sloc) 3.586 kB
509ddba @jimweirich Initial commit for rspec-given
authored
1 #!/usr/bin/ruby -wKU
2
3 require 'rake/clean'
68c3c0b @jimweirich Better README generation.
authored
4 require './lib/rspec/given/version'
509ddba @jimweirich Initial commit for rspec-given
authored
5
68c3c0b @jimweirich Better README generation.
authored
6 CLOBBER.include("*.gemspec", "html", "README", "README.old")
e35c229 @jimweirich Added a readme.
authored
7
8 # README Formatting --------------------------------------------------
9
ccb60e0 @jimweirich Updated the README examples to reflect the current state of the code.
authored
10 begin
11 require 'bluecloth'
12 rescue LoadError => ex
13 puts "WARNING: BlueCloth not available"
14 end
b953c58 @jimweirich Updated README
authored
15
16 task :default => :examples
17
18 # Running examples ---------------------------------------------------
19
68c3c0b @jimweirich Better README generation.
authored
20 desc "Run all the examples"
21 task :examples => [:examples1, :examples2]
22
23 desc "Run the examples in RSpec 1"
24 task :examples1 do
25 sh "spec examples/stack/stack_spec1.rb"
26 end
27
28 desc "Run the examples in RSpec 2"
29 task :examples2 do
b953c58 @jimweirich Updated README
authored
30 sh "rspec examples"
31 end
32
33 # Formatting the README ----------------------------------------------
34
e35c229 @jimweirich Added a readme.
authored
35 directory 'html'
36
37 desc "Display the README file"
38 task :readme => "html/README.html" do
39 sh "open html/README.html"
40 end
41
42 desc "format the README file"
43 task "html/README.html" => ['html', 'README.md'] do
44 open("README.md") do |source|
45 open('html/README.html', 'w') do |out|
46 out.write(BlueCloth.new(source.read).to_html)
47 end
48 end
49 end
09bb60e @jimweirich added rdoc task
authored
50
68c3c0b @jimweirich Better README generation.
authored
51 desc "Generate an RDoc README"
52 file "README.md" => ["examples/stack/stack_spec.rb", "lib/rspec/given/version.rb"] do
53 open("README.md") do |ins|
54 open("README.tmp", "w") do |outs|
55 state = :copy
56 while line = ins.gets
57 case state
58 when :copy
59 if line =~ /version +\d+\.\d+\.\d+/
60 line.gsub!(/version +\d+\.\d+\.\d+/, "version #{RSpec::Given::VERSION}")
61 outs.puts line
62 elsif line =~ /^<pre>/
63 state = :insert
64 else
65 outs.puts line
66 end
67 when :insert
68 outs.puts "<pre>"
69 outs.puts open("examples/stack/stack_spec.rb") { |codes| codes.read }
70 outs.puts "</pre>"
71 state = :skip
72 when :skip
73 state = :copy2 if line =~ /^<\/pre>/
74 when :copy2
75 outs.puts line
76 end
77 end
78 end
79 end
80 mv "README.md", "README.old"
81 mv "README.tmp", "README.md"
82 end
83
84
09bb60e @jimweirich added rdoc task
authored
85 # RDoc ---------------------------------------------------------------
68c3c0b @jimweirich Better README generation.
authored
86 gem "rdoc"
88de7fb @jimweirich Rakefile and tasks cleanup
authored
87 require 'rdoc/task'
09bb60e @jimweirich added rdoc task
authored
88
89 begin
90 require 'darkfish-rdoc'
91 DARKFISH_ENABLED = true
92 rescue LoadError => ex
93 DARKFISH_ENABLED = false
94 end
95
68c3c0b @jimweirich Better README generation.
authored
96 def md_to_rdoc(infile, outfile)
97 open(infile) do |ins|
98 open(outfile, "w") do |outs|
99 state = :copy
100 while line = ins.gets
101 case state
102 when :ignore
103 if line =~ /^-->/
104 state = :copy
105 end
106 when :pre
107 if line =~ /^<\/pre>/
108 state = :copy
109 else
110 outs.puts " #{line}"
111 end
112 when :copy
113 if line =~ /^<!--/
114 state = :ignore
115 elsif line =~ /^<pre>/
116 state = :pre
117 else
118 line.gsub!(/^####/, '====')
119 line.gsub!(/^###/, '===')
120 line.gsub!(/^##/, '==')
121 line.gsub!(/^#/, '=')
122 outs.puts line
123 end
124 end
125 end
126 end
127 end
128 end
09bb60e @jimweirich added rdoc task
authored
129
68c3c0b @jimweirich Better README generation.
authored
130 file "README" => ["README.md"] do
131 md_to_rdoc("README.md", "README")
132 end
133
134 RDoc::Task.new("rdoc") do |rdoc|
09bb60e @jimweirich added rdoc task
authored
135 rdoc.rdoc_dir = 'html'
68c3c0b @jimweirich Better README generation.
authored
136 rdoc.title = "RSpec/Given -- A Given/When/Then extension for RSpec"
137 rdoc.options = [
138 '--line-numbers',
139 '--main' , 'README',
140 '--title', 'RSpec::Given - Given/When/Then Extensions for RSpec'
141 ]
09bb60e @jimweirich added rdoc task
authored
142 rdoc.options << '-SHN' << '-f' << 'darkfish' if DARKFISH_ENABLED
143
68c3c0b @jimweirich Better README generation.
authored
144 rdoc.rdoc_files.include('README')
145 rdoc.rdoc_files.include('MIT-LICENSE')
09bb60e @jimweirich added rdoc task
authored
146 rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
147 end
68c3c0b @jimweirich Better README generation.
authored
148
149 task :rdoc => "README"
Something went wrong with that request. Please try again.