webby 0.9.3-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/History.txt +206 -0
  2. data/Manifest.txt +228 -0
  3. data/README.txt +92 -0
  4. data/Rakefile +49 -0
  5. data/bin/webby +41 -0
  6. data/bin/webby-gen +41 -0
  7. data/examples/blog/Sitefile +7 -0
  8. data/examples/blog/tasks/blog.rake +72 -0
  9. data/examples/blog/templates/atom_feed.erb +40 -0
  10. data/examples/blog/templates/blog/month.erb +22 -0
  11. data/examples/blog/templates/blog/post.erb +16 -0
  12. data/examples/blog/templates/blog/year.erb +22 -0
  13. data/examples/presentation/Sitefile +10 -0
  14. data/examples/presentation/content/css/uv/twilight.css +137 -0
  15. data/examples/presentation/content/presentation/_sample_code.txt +10 -0
  16. data/examples/presentation/content/presentation/index.txt +63 -0
  17. data/examples/presentation/content/presentation/s5/blank.gif +0 -0
  18. data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
  19. data/examples/presentation/content/presentation/s5/framing.css +23 -0
  20. data/examples/presentation/content/presentation/s5/iepngfix.htc +42 -0
  21. data/examples/presentation/content/presentation/s5/opera.css +7 -0
  22. data/examples/presentation/content/presentation/s5/outline.css +15 -0
  23. data/examples/presentation/content/presentation/s5/pretty.css +86 -0
  24. data/examples/presentation/content/presentation/s5/print.css +25 -0
  25. data/examples/presentation/content/presentation/s5/s5-core.css +9 -0
  26. data/examples/presentation/content/presentation/s5/slides.css +3 -0
  27. data/examples/presentation/content/presentation/s5/slides.js +553 -0
  28. data/examples/presentation/layouts/presentation.txt +43 -0
  29. data/examples/presentation/templates/_code_partial.erb +13 -0
  30. data/examples/presentation/templates/presentation.erb +40 -0
  31. data/examples/tumblog/Sitefile +9 -0
  32. data/examples/tumblog/content/css/tumblog.css +308 -0
  33. data/examples/tumblog/content/images/tumblog/permalink.gif +0 -0
  34. data/examples/tumblog/content/images/tumblog/rss.gif +0 -0
  35. data/examples/tumblog/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  36. data/examples/tumblog/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  37. data/examples/tumblog/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  38. data/examples/tumblog/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  39. data/examples/tumblog/content/tumblog/200807/up-a-tree/index.txt +13 -0
  40. data/examples/tumblog/content/tumblog/index.txt +37 -0
  41. data/examples/tumblog/content/tumblog/rss.txt +37 -0
  42. data/examples/tumblog/layouts/tumblog/default.txt +44 -0
  43. data/examples/tumblog/layouts/tumblog/post.txt +15 -0
  44. data/examples/tumblog/lib/tumblog_helper.rb +32 -0
  45. data/examples/tumblog/tasks/tumblog.rake +30 -0
  46. data/examples/tumblog/templates/atom_feed.erb +40 -0
  47. data/examples/tumblog/templates/tumblog/conversation.erb +12 -0
  48. data/examples/tumblog/templates/tumblog/link.erb +10 -0
  49. data/examples/tumblog/templates/tumblog/photo.erb +13 -0
  50. data/examples/tumblog/templates/tumblog/post.erb +12 -0
  51. data/examples/tumblog/templates/tumblog/quote.erb +11 -0
  52. data/examples/webby/Sitefile +19 -0
  53. data/examples/webby/content/communicate/index.txt +28 -0
  54. data/examples/webby/content/css/background.gif +0 -0
  55. data/examples/webby/content/css/blueprint/print.css +76 -0
  56. data/examples/webby/content/css/blueprint/screen.css +696 -0
  57. data/examples/webby/content/css/coderay.css +96 -0
  58. data/examples/webby/content/css/site.css +196 -0
  59. data/examples/webby/content/css/uv/twilight.css +137 -0
  60. data/examples/webby/content/index.txt +37 -0
  61. data/examples/webby/content/learn/index.txt +28 -0
  62. data/examples/webby/content/reference/index.txt +204 -0
  63. data/examples/webby/content/release-notes/index.txt +21 -0
  64. data/examples/webby/content/release-notes/rel-0-9-0/index.txt +74 -0
  65. data/examples/webby/content/release-notes/rel-0-9-1/index.txt +93 -0
  66. data/examples/webby/content/release-notes/rel-0-9-2/index.txt +14 -0
  67. data/examples/webby/content/release-notes/rel-0-9-3/index.txt +49 -0
  68. data/examples/webby/content/robots.txt +6 -0
  69. data/examples/webby/content/script/jquery.corner.js +152 -0
  70. data/examples/webby/content/script/jquery.js +31 -0
  71. data/examples/webby/content/sitemap.txt +31 -0
  72. data/examples/webby/content/tips_and_tricks/index.txt +97 -0
  73. data/examples/webby/content/tutorial/index.txt +135 -0
  74. data/examples/webby/content/user-manual/index.txt +419 -0
  75. data/examples/webby/layouts/default.txt +49 -0
  76. data/examples/webby/templates/page.erb +10 -0
  77. data/examples/website/Sitefile +7 -0
  78. data/examples/website/content/css/blueprint/License.txt +21 -0
  79. data/examples/website/content/css/blueprint/Readme.txt +100 -0
  80. data/examples/website/content/css/blueprint/compressed/print.css +76 -0
  81. data/examples/website/content/css/blueprint/compressed/screen.css +696 -0
  82. data/examples/website/content/css/blueprint/lib/forms.css +45 -0
  83. data/examples/website/content/css/blueprint/lib/grid.css +193 -0
  84. data/examples/website/content/css/blueprint/lib/grid.png +0 -0
  85. data/examples/website/content/css/blueprint/lib/ie.css +30 -0
  86. data/examples/website/content/css/blueprint/lib/reset.css +39 -0
  87. data/examples/website/content/css/blueprint/lib/typography.css +116 -0
  88. data/examples/website/content/css/blueprint/plugins/buttons/Readme +31 -0
  89. data/examples/website/content/css/blueprint/plugins/buttons/buttons.css +97 -0
  90. data/examples/website/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  91. data/examples/website/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
  92. data/examples/website/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  93. data/examples/website/content/css/blueprint/plugins/css-classes/Readme +14 -0
  94. data/examples/website/content/css/blueprint/plugins/css-classes/css-classes.css +24 -0
  95. data/examples/website/content/css/blueprint/plugins/fancy-type/Readme +22 -0
  96. data/examples/website/content/css/blueprint/plugins/fancy-type/fancy-type-compressed.css +5 -0
  97. data/examples/website/content/css/blueprint/plugins/fancy-type/fancy-type.css +74 -0
  98. data/examples/website/content/css/blueprint/print.css +68 -0
  99. data/examples/website/content/css/blueprint/screen.css +22 -0
  100. data/examples/website/content/css/coderay.css +111 -0
  101. data/examples/website/content/css/site.css +67 -0
  102. data/examples/website/content/index.txt +19 -0
  103. data/examples/website/layouts/default.txt +58 -0
  104. data/examples/website/lib/breadcrumbs.rb +28 -0
  105. data/examples/website/templates/_partial.erb +10 -0
  106. data/examples/website/templates/page.erb +18 -0
  107. data/lib/webby.rb +221 -0
  108. data/lib/webby/apps.rb +12 -0
  109. data/lib/webby/apps/generator.rb +276 -0
  110. data/lib/webby/apps/main.rb +255 -0
  111. data/lib/webby/auto_builder.rb +157 -0
  112. data/lib/webby/builder.rb +180 -0
  113. data/lib/webby/core_ext/enumerable.rb +11 -0
  114. data/lib/webby/core_ext/hash.rb +28 -0
  115. data/lib/webby/core_ext/kernel.rb +26 -0
  116. data/lib/webby/core_ext/string.rb +163 -0
  117. data/lib/webby/core_ext/time.rb +9 -0
  118. data/lib/webby/filters.rb +83 -0
  119. data/lib/webby/filters/basepath.rb +97 -0
  120. data/lib/webby/filters/erb.rb +9 -0
  121. data/lib/webby/filters/haml.rb +18 -0
  122. data/lib/webby/filters/markdown.rb +16 -0
  123. data/lib/webby/filters/outline.rb +309 -0
  124. data/lib/webby/filters/sass.rb +17 -0
  125. data/lib/webby/filters/slides.rb +56 -0
  126. data/lib/webby/filters/textile.rb +16 -0
  127. data/lib/webby/filters/tidy.rb +76 -0
  128. data/lib/webby/filters/wiki_words.rb +14 -0
  129. data/lib/webby/helpers.rb +30 -0
  130. data/lib/webby/helpers/capture_helper.rb +141 -0
  131. data/lib/webby/helpers/coderay_helper.rb +69 -0
  132. data/lib/webby/helpers/graphviz_helper.rb +136 -0
  133. data/lib/webby/helpers/tag_helper.rb +65 -0
  134. data/lib/webby/helpers/tex_img_helper.rb +133 -0
  135. data/lib/webby/helpers/ultraviolet_helper.rb +63 -0
  136. data/lib/webby/helpers/url_helper.rb +241 -0
  137. data/lib/webby/journal.rb +126 -0
  138. data/lib/webby/link_validator.rb +152 -0
  139. data/lib/webby/renderer.rb +386 -0
  140. data/lib/webby/resources.rb +136 -0
  141. data/lib/webby/resources/db.rb +251 -0
  142. data/lib/webby/resources/layout.rb +54 -0
  143. data/lib/webby/resources/meta_file.rb +211 -0
  144. data/lib/webby/resources/page.rb +81 -0
  145. data/lib/webby/resources/partial.rb +85 -0
  146. data/lib/webby/resources/resource.rb +201 -0
  147. data/lib/webby/resources/static.rb +36 -0
  148. data/lib/webby/stelan/mktemp.rb +135 -0
  149. data/lib/webby/stelan/paginator.rb +165 -0
  150. data/lib/webby/stelan/spawner.rb +339 -0
  151. data/lib/webby/tasks/build.rake +27 -0
  152. data/lib/webby/tasks/create.rake +22 -0
  153. data/lib/webby/tasks/deploy.rake +22 -0
  154. data/lib/webby/tasks/growl.rake +16 -0
  155. data/lib/webby/tasks/validate.rake +19 -0
  156. data/spec/core_ext/hash_spec.rb +47 -0
  157. data/spec/core_ext/string_spec.rb +110 -0
  158. data/spec/core_ext/time_spec.rb +19 -0
  159. data/spec/data/hooligans/bad_meta_data_1.txt +34 -0
  160. data/spec/data/hooligans/bad_meta_data_2.txt +34 -0
  161. data/spec/data/outline/basic.out +81 -0
  162. data/spec/data/outline/basic.txt +25 -0
  163. data/spec/data/outline/no_clobber.out +86 -0
  164. data/spec/data/outline/numbering.out +81 -0
  165. data/spec/data/outline/numbering_only.out +21 -0
  166. data/spec/data/outline/toc_range_1.out +66 -0
  167. data/spec/data/outline/toc_range_2.out +55 -0
  168. data/spec/data/outline/toc_style.out +81 -0
  169. data/spec/data/site/Sitefile +9 -0
  170. data/spec/data/site/content/_partial.txt +10 -0
  171. data/spec/data/site/content/css/coderay.css +111 -0
  172. data/spec/data/site/content/css/site.css +67 -0
  173. data/spec/data/site/content/css/tumblog.css +308 -0
  174. data/spec/data/site/content/images/tumblog/permalink.gif +0 -0
  175. data/spec/data/site/content/images/tumblog/rss.gif +0 -0
  176. data/spec/data/site/content/index.txt +19 -0
  177. data/spec/data/site/content/photos.txt +21 -0
  178. data/spec/data/site/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  179. data/spec/data/site/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  180. data/spec/data/site/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  181. data/spec/data/site/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  182. data/spec/data/site/content/tumblog/200807/up-a-tree/index.txt +13 -0
  183. data/spec/data/site/content/tumblog/index.txt +37 -0
  184. data/spec/data/site/content/tumblog/rss.txt +37 -0
  185. data/spec/data/site/layouts/default.txt +58 -0
  186. data/spec/data/site/layouts/tumblog/default.txt +44 -0
  187. data/spec/data/site/layouts/tumblog/post.txt +15 -0
  188. data/spec/data/site/lib/breadcrumbs.rb +28 -0
  189. data/spec/data/site/lib/tumblog_helper.rb +32 -0
  190. data/spec/data/site/tasks/tumblog.rake +30 -0
  191. data/spec/data/site/templates/_partial.erb +10 -0
  192. data/spec/data/site/templates/atom_feed.erb +40 -0
  193. data/spec/data/site/templates/page.erb +18 -0
  194. data/spec/data/site/templates/presentation.erb +40 -0
  195. data/spec/data/site/templates/tumblog/conversation.erb +12 -0
  196. data/spec/data/site/templates/tumblog/link.erb +10 -0
  197. data/spec/data/site/templates/tumblog/photo.erb +13 -0
  198. data/spec/data/site/templates/tumblog/post.erb +12 -0
  199. data/spec/data/site/templates/tumblog/quote.erb +11 -0
  200. data/spec/spec.opts +1 -0
  201. data/spec/spec_helper.rb +51 -0
  202. data/spec/webby/apps/generator_spec.rb +116 -0
  203. data/spec/webby/apps/main_spec.rb +88 -0
  204. data/spec/webby/filters/basepath_spec.rb +167 -0
  205. data/spec/webby/filters/outline_spec.rb +92 -0
  206. data/spec/webby/filters/textile_spec.rb +20 -0
  207. data/spec/webby/helpers/capture_helper_spec.rb +56 -0
  208. data/spec/webby/renderer_spec.rb +139 -0
  209. data/spec/webby/resources/db_spec.rb +250 -0
  210. data/spec/webby/resources/layout_spec.rb +83 -0
  211. data/spec/webby/resources/meta_file_spec.rb +171 -0
  212. data/spec/webby/resources/page_spec.rb +111 -0
  213. data/spec/webby/resources/partial_spec.rb +58 -0
  214. data/spec/webby/resources/resource_spec.rb +219 -0
  215. data/spec/webby/resources/static_spec.rb +49 -0
  216. data/spec/webby/resources_spec.rb +69 -0
  217. data/tasks/ann.rake +81 -0
  218. data/tasks/bones.rake +21 -0
  219. data/tasks/gem.rake +187 -0
  220. data/tasks/git.rake +41 -0
  221. data/tasks/manifest.rake +48 -0
  222. data/tasks/notes.rake +28 -0
  223. data/tasks/post_load.rake +39 -0
  224. data/tasks/rdoc.rake +51 -0
  225. data/tasks/rubyforge.rake +55 -0
  226. data/tasks/setup.rb +268 -0
  227. data/tasks/spec.rake +55 -0
  228. data/tasks/website.rake +38 -0
  229. metadata +365 -0
@@ -0,0 +1,49 @@
1
+
2
+ require File.expand_path(
3
+ File.join(File.dirname(__FILE__), %w[.. .. spec_helper]))
4
+
5
+ # -------------------------------------------------------------------------
6
+ describe Webby::Resources::Static do
7
+ before :all do
8
+ @filename = File.join %w[content css coderay.css]
9
+ @static = Webby::Resources::Static.new(@filename)
10
+ end
11
+
12
+ it 'contains no meta-data' do
13
+ @static._meta_data.should be_empty
14
+ end
15
+
16
+ it 'uses the path remounted to the output directory as the destination' do
17
+ @static.destination.should == 'output/css/coderay.css'
18
+ end
19
+
20
+ it 'returns destination without the output directory as the url' do
21
+ @static.url.should == '/css/coderay.css'
22
+ end
23
+
24
+ it 'reads the contents of the file' do
25
+ str = @static._read
26
+ str.split($/).first.should == '.CodeRay {'
27
+ end
28
+
29
+ it 'uses the file extension as the extension' do
30
+ @static.extension.should equal(@static.ext)
31
+ end
32
+
33
+ # -----------------------------------------------------------------------
34
+ describe '.dirty?' do
35
+ it 'returns true if the output file is missing' do
36
+ @static.dirty?.should == true
37
+ end
38
+
39
+ it 'returns false if the output file is present' do
40
+ dest = @static.destination
41
+ FileUtils.mkdir_p File.dirname(dest)
42
+ FileUtils.touch dest
43
+ @static.dirty?.should == false
44
+ end
45
+ end
46
+
47
+ end # describe Webby::Resources::Static
48
+
49
+ # EOF
@@ -0,0 +1,69 @@
1
+
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. spec_helper]))
5
+
6
+ # --------------------------------------------------------------------------
7
+ describe Webby::Resources do
8
+ before :each do
9
+ Webby::Resources.clear
10
+ end
11
+
12
+ it "should raise a useful error if there are no layouts" do
13
+ layouts = mock("Layouts")
14
+ Webby::Resources.stub!(:layouts).and_return(layouts)
15
+ layouts.should_receive(:find).and_raise RuntimeError
16
+
17
+ lambda do
18
+ Webby::Resources.find_layout("default")
19
+ end.should raise_error(Webby::Error, 'could not find layout "default"')
20
+ end
21
+
22
+ it "should return the directory name for a file" do
23
+ Webby::Resources.dirname('content').should == './'
24
+ Webby::Resources.dirname('layouts').should == './'
25
+
26
+ Webby::Resources.dirname('content/index.txt').should == ''
27
+ Webby::Resources.dirname('layouts/default.txt').should == ''
28
+
29
+ Webby::Resources.dirname('content/tumblog/index.txt').should == 'tumblog'
30
+ Webby::Resources.dirname('layouts/tumblog/post.txt').should == 'tumblog'
31
+
32
+ Webby::Resources.dirname('output/tumblog/index.html').should == 'output/tumblog'
33
+ Webby::Resources.dirname('templates/tumblog/post.erb').should == 'templates/tumblog'
34
+ end
35
+
36
+ it "should normalize the path for a filename" do
37
+ Webby::Resources.path('content').should == 'content'
38
+ Webby::Resources.path('/content').should == 'content'
39
+ Webby::Resources.path('./content').should == 'content'
40
+
41
+ Webby::Resources.path('./').should == ''
42
+ Webby::Resources.path('/').should == ''
43
+ Webby::Resources.path('').should == ''
44
+ end
45
+
46
+ # ------------------------------------------------------------------------
47
+ describe "#new" do
48
+ before :each do
49
+ layout = Webby::Resources::Layout.
50
+ new(Webby.datapath %w[site layouts default.txt])
51
+ Webby::Resources.stub!(:find_layout).and_return(layout)
52
+ end
53
+
54
+ it "creates multiple pages for files with multiple YAML sections" do
55
+ pages = Webby::Resources.pages
56
+
57
+ fn = File.join %w[content photos.txt]
58
+ Webby::Resources.new(fn)
59
+
60
+ ary = pages.find(:all, :in_directory => 'photos')
61
+ ary.map {|page| page.title}.should == [
62
+ 'First Photo', 'Second Photo', 'Third Photo'
63
+ ]
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ # EOF
@@ -0,0 +1,81 @@
1
+ # $Id$
2
+
3
+ begin
4
+ require 'bones/smtp_tls'
5
+ rescue LoadError
6
+ require 'net/smtp'
7
+ end
8
+ require 'time'
9
+
10
+ namespace :ann do
11
+
12
+ # A prerequisites task that all other tasks depend upon
13
+ task :prereqs
14
+
15
+ file PROJ.ann.file do
16
+ ann = PROJ.ann
17
+ puts "Generating #{ann.file}"
18
+ File.open(ann.file,'w') do |fd|
19
+ fd.puts("#{PROJ.name} version #{PROJ.version}")
20
+ fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
21
+ fd.puts(" #{PROJ.url}") if PROJ.url.valid?
22
+ fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
23
+ fd.puts
24
+ fd.puts("== DESCRIPTION")
25
+ fd.puts
26
+ fd.puts(PROJ.description)
27
+ fd.puts
28
+ fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
29
+ fd.puts
30
+ ann.paragraphs.each do |p|
31
+ fd.puts "== #{p.upcase}"
32
+ fd.puts
33
+ fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
34
+ fd.puts
35
+ end
36
+ fd.puts ann.text if ann.text
37
+ end
38
+ end
39
+
40
+ desc "Create an announcement file"
41
+ task :announcement => ['ann:prereqs', PROJ.ann.file]
42
+
43
+ desc "Send an email announcement"
44
+ task :email => ['ann:prereqs', PROJ.ann.file] do
45
+ ann = PROJ.ann
46
+ from = ann.email[:from] || PROJ.email
47
+ to = Array(ann.email[:to])
48
+
49
+ ### build a mail header for RFC 822
50
+ rfc822msg = "From: #{from}\n"
51
+ rfc822msg << "To: #{to.join(',')}\n"
52
+ rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
53
+ rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
54
+ rfc822msg << "\n"
55
+ rfc822msg << "Date: #{Time.new.rfc822}\n"
56
+ rfc822msg << "Message-Id: "
57
+ rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
58
+ rfc822msg << File.read(ann.file)
59
+
60
+ params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
61
+ ann.email[key]
62
+ end
63
+
64
+ params[3] = PROJ.email if params[3].nil?
65
+
66
+ if params[4].nil?
67
+ STDOUT.write "Please enter your e-mail password (#{params[3]}): "
68
+ params[4] = STDIN.gets.chomp
69
+ end
70
+
71
+ ### send email
72
+ Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
73
+ end
74
+ end # namespace :ann
75
+
76
+ desc 'Alias to ann:announcement'
77
+ task :ann => 'ann:announcement'
78
+
79
+ CLOBBER << PROJ.ann.file
80
+
81
+ # EOF
@@ -0,0 +1,21 @@
1
+ # $Id$
2
+
3
+ if HAVE_BONES
4
+
5
+ namespace :bones do
6
+
7
+ desc 'Show the PROJ open struct'
8
+ task :debug do |t|
9
+ atr = if t.application.top_level_tasks.length == 2
10
+ t.application.top_level_tasks.pop
11
+ end
12
+
13
+ if atr then Bones::Debug.show_attr(PROJ, atr)
14
+ else Bones::Debug.show PROJ end
15
+ end
16
+
17
+ end # namespace :bones
18
+
19
+ end # HAVE_BONES
20
+
21
+ # EOF
@@ -0,0 +1,187 @@
1
+
2
+ require 'find'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/user_interaction'
5
+ require 'rubygems/builder'
6
+
7
+ class Bones::GemPackageTask < Rake::PackageTask
8
+ # Ruby GEM spec containing the metadata for this package. The
9
+ # name, version and package_files are automatically determined
10
+ # from the GEM spec and don't need to be explicitly provided.
11
+ #
12
+ attr_accessor :gem_spec
13
+
14
+ # Create a GEM Package task library. Automatically define the gem
15
+ # if a block is given. If no block is supplied, then +define+
16
+ # needs to be called to define the task.
17
+ #
18
+ def initialize(gem_spec)
19
+ init(gem_spec)
20
+ yield self if block_given?
21
+ define if block_given?
22
+ end
23
+
24
+ # Initialization tasks without the "yield self" or define
25
+ # operations.
26
+ #
27
+ def init(gem)
28
+ super(gem.name, gem.version)
29
+ @gem_spec = gem
30
+ @package_files += gem_spec.files if gem_spec.files
31
+ end
32
+
33
+ # Create the Rake tasks and actions specified by this
34
+ # GemPackageTask. (+define+ is automatically called if a block is
35
+ # given to +new+).
36
+ #
37
+ def define
38
+ super
39
+ task :prereqs
40
+ task :package => ['gem:prereqs', "#{package_dir_path}/#{gem_file}"]
41
+ file "#{package_dir_path}/#{gem_file}" => [package_dir_path] + package_files do
42
+ when_writing("Creating GEM") {
43
+ chdir(package_dir_path) do
44
+ Gem::Builder.new(gem_spec).build
45
+ verbose(true) {
46
+ mv gem_file, "../#{gem_file}"
47
+ }
48
+ end
49
+ }
50
+ end
51
+ end
52
+
53
+ def gem_file
54
+ if @gem_spec.platform == Gem::Platform::RUBY
55
+ "#{package_name}.gem"
56
+ else
57
+ "#{package_name}-#{@gem_spec.platform}.gem"
58
+ end
59
+ end
60
+ end # class Bones::GemPackageTask
61
+
62
+ namespace :gem do
63
+
64
+ PROJ.gem._spec = Gem::Specification.new do |s|
65
+ s.name = PROJ.name
66
+ s.version = PROJ.version
67
+ s.summary = PROJ.summary
68
+ s.authors = Array(PROJ.authors)
69
+ s.email = PROJ.email
70
+ s.homepage = Array(PROJ.url).first
71
+ s.rubyforge_project = PROJ.rubyforge.name
72
+
73
+ s.description = PROJ.description
74
+
75
+ PROJ.gem.dependencies.each do |dep|
76
+ s.add_dependency(*dep)
77
+ end
78
+
79
+ s.files = PROJ.gem.files
80
+ s.executables = PROJ.gem.executables.map {|fn| File.basename(fn)}
81
+ s.extensions = PROJ.gem.files.grep %r/extconf\.rb$/
82
+
83
+ s.bindir = 'bin'
84
+ dirs = Dir["{#{PROJ.libs.join(',')}}"]
85
+ s.require_paths = dirs unless dirs.empty?
86
+
87
+ incl = Regexp.new(PROJ.rdoc.include.join('|'))
88
+ excl = PROJ.rdoc.exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
89
+ excl = Regexp.new(excl.join('|'))
90
+ rdoc_files = PROJ.gem.files.find_all do |fn|
91
+ case fn
92
+ when excl; false
93
+ when incl; true
94
+ else false end
95
+ end
96
+ s.rdoc_options = PROJ.rdoc.opts + ['--main', PROJ.rdoc.main]
97
+ s.extra_rdoc_files = rdoc_files
98
+ s.has_rdoc = true
99
+
100
+ if test ?f, PROJ.test.file
101
+ s.test_file = PROJ.test.file
102
+ else
103
+ s.test_files = PROJ.test.files.to_a
104
+ end
105
+
106
+ # Do any extra stuff the user wants
107
+ PROJ.gem.extras.each do |msg, val|
108
+ case val
109
+ when Proc
110
+ val.call(s.send(msg))
111
+ else
112
+ s.send "#{msg}=", val
113
+ end
114
+ end
115
+ end # Gem::Specification.new
116
+
117
+ Bones::GemPackageTask.new(PROJ.gem._spec) do |pkg|
118
+ pkg.need_tar = PROJ.gem.need_tar
119
+ pkg.need_zip = PROJ.gem.need_zip
120
+ end
121
+
122
+ desc 'Show information about the gem'
123
+ task :debug => 'gem:prereqs' do
124
+ puts PROJ.gem._spec.to_ruby
125
+ end
126
+
127
+ desc 'Install the gem'
128
+ task :install => [:clobber, 'gem:package'] do
129
+ sh "#{SUDO} #{GEM} install --local pkg/#{PROJ.gem._spec.full_name}"
130
+
131
+ # use this version of the command for rubygems > 1.0.0
132
+ #sh "#{SUDO} #{GEM} install --no-update-sources pkg/#{PROJ.gem._spec.full_name}"
133
+ end
134
+
135
+ desc 'Uninstall the gem'
136
+ task :uninstall do
137
+ installed_list = Gem.source_index.find_name(PROJ.name)
138
+ if installed_list and installed_list.collect { |s| s.version.to_s}.include?(PROJ.version) then
139
+ sh "#{SUDO} #{GEM} uninstall --version '#{PROJ.version}' --ignore-dependencies --executables #{PROJ.name}"
140
+ end
141
+ end
142
+
143
+ desc 'Reinstall the gem'
144
+ task :reinstall => [:uninstall, :install]
145
+
146
+ desc 'Cleanup the gem'
147
+ task :cleanup do
148
+ sh "#{SUDO} #{GEM} cleanup #{PROJ.gem._spec.name}"
149
+ end
150
+
151
+ namespace :mswin32 do
152
+ win32_spec = PROJ.gem._spec.dup
153
+ win32_spec.platform = 'x86-mswin32'
154
+
155
+ pkg = Bones::GemPackageTask.new(win32_spec)
156
+ class << pkg
157
+ def package_dir_path() "#{package_dir}/#{package_name}-x86-mswin32"; end
158
+ end
159
+ pkg.define
160
+
161
+ file "#{pkg.package_dir_path}/#{pkg.gem_file}" => :unix2dos
162
+
163
+ task :unix2dos do
164
+ reject = %w[.gif .jpg .jpeg]
165
+ Find.find(File.join(pkg.package_dir_path, 'examples')) do |fn|
166
+ next unless test(?f, fn)
167
+ next if reject.include?(File.extname(fn))
168
+ sh %{unix2dos #{fn}}
169
+ end
170
+ end
171
+ end # namespace :mswin32
172
+ end # namespace :gem
173
+
174
+
175
+ desc 'Alias to gem:package'
176
+ task :gem => ['gem:package', 'gem:mswin32:package']
177
+
178
+ task :clobber => ['gem:clobber_package', 'gem:mswin32:clobber_package']
179
+
180
+ %w[
181
+ gem:clobber_package
182
+ gem:mswin32:clobber_package
183
+ gem:mswin32:package
184
+ gem:mswin32:repackage
185
+ ].each {|name| remove_desc_for_task name}
186
+
187
+ # EOF
@@ -0,0 +1,41 @@
1
+ # $Id$
2
+
3
+ if HAVE_GIT
4
+
5
+ namespace :git do
6
+
7
+ # A prerequisites task that all other tasks depend upon
8
+ task :prereqs
9
+
10
+ desc 'Show tags from the Git repository'
11
+ task :show_tags => 'git:prereqs' do |t|
12
+ puts %x/git tag/
13
+ end
14
+
15
+ desc 'Create a new tag in the Git repository'
16
+ task :create_tag => 'git:prereqs' do |t|
17
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
18
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
19
+
20
+ tag = "%s-%s" % [PROJ.name, PROJ.version]
21
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
22
+
23
+ puts "Creating Git tag '#{tag}'"
24
+ unless system "git tag -a -m '#{msg}' #{tag}"
25
+ abort "Tag creation failed"
26
+ end
27
+
28
+ if %x/git remote/ =~ %r/^origin\s*$/
29
+ unless system "git push origin #{tag}"
30
+ abort "Could not push tag to remote Git repository"
31
+ end
32
+ end
33
+ end
34
+
35
+ end # namespace :git
36
+
37
+ task 'gem:release' => 'git:create_tag'
38
+
39
+ end # if HAVE_GIT
40
+
41
+ # EOF