Skip to content
This repository
Newer
Older
100644 114 lines (93 sloc) 3.087 kb
81272808 »
2009-10-27 Use some time Thor tasks for gem management (on Gemcutter) -- no more…
1 module GemHelpers
2
3 def generate_gemspec
4 $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
5 require "rack/bug"
6
7 Gem::Specification.new do |s|
8 s.name = "rack-bug"
9 s.version = Rack::Bug::VERSION
10 s.author = "Bryan Helmkamp"
11 s.email = "bryan@brynary.com"
12 s.homepage = "http://github.com/brynary/rack-bug"
13 s.summary = "Debugging toolbar for Rack applications implemented as middleware"
14 # s.description = "TODO"
15 s.rubyforge_project = "rack-bug"
16
17 require "git"
18 repo = Git.open(".")
19
20 s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files)
21 s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files)
22
23 s.has_rdoc = true
8f7404d9 »
2010-05-28 Prep for 0.3.0 release
24 s.extra_rdoc_files = %w[README.md MIT-LICENSE.txt]
81272808 »
2009-10-27 Use some time Thor tasks for gem management (on Gemcutter) -- no more…
25
26 s.add_dependency "rack", ">= 1.0"
87014e0b »
2010-09-04 Update gemspec
27 s.add_development_dependency "webrat"
28 s.add_development_dependency "rspec"
29 s.add_development_dependency "sinatra"
30 s.add_development_dependency "git"
81272808 »
2009-10-27 Use some time Thor tasks for gem management (on Gemcutter) -- no more…
31 end
32 end
33
34 def normalize_files(array)
35 # only keep files, no directories, and sort
36 array.select do |path|
37 File.file?(path)
38 end.sort
39 end
40
41 # Adds extra space when outputting an array. This helps create better version
42 # control diffs, because otherwise it is all on the same line.
43 def prettyify_array(gemspec_ruby, array_name)
44 gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
45 leadin, files = match[0..-2].split("[")
46 leadin + "[\n #{files.split(",").join(",\n ")}\n ]"
47 end
48 end
49
50 def read_gemspec
51 @read_gemspec ||= eval(File.read("rack-bug.gemspec"))
52 end
53
54 def sh(command)
55 puts command
56 system command
57 end
58 end
59
60 class Default < Thor
61 include GemHelpers
62
63 desc "gemspec", "Regenerate rack-bug.gemspec"
64 def gemspec
65 File.open("rack-bug.gemspec", "w") do |file|
66 gemspec_ruby = generate_gemspec.to_ruby
67 gemspec_ruby = prettyify_array(gemspec_ruby, :files)
68 gemspec_ruby = prettyify_array(gemspec_ruby, :test_files)
69 gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
70
71 file.write gemspec_ruby
72 end
73
74 puts "Wrote gemspec to rack-bug.gemspec"
75 read_gemspec.validate
76 end
77
78 desc "build", "Build a rack-bug gem"
79 def build
80 sh "gem build rack-bug.gemspec"
81 FileUtils.mkdir_p "pkg"
82 FileUtils.mv read_gemspec.file_name, "pkg"
83 end
84
85 desc "install", "Install the latest built gem"
86 def install
87 sh "gem install --local pkg/#{read_gemspec.file_name}"
88 end
89
90 desc "release", "Release the current branch to GitHub and Gemcutter"
91 def release
92 gemspec
93 build
94 Release.new.tag
95 Release.new.gem
96 end
97 end
98
99 class Release < Thor
100 include GemHelpers
101
102 desc "tag", "Tag the gem on the origin server"
103 def tag
104 release_tag = "v#{read_gemspec.version}"
105 sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'"
106 sh "git push origin #{release_tag}"
107 end
108
109 desc "gem", "Push the gem to Gemcutter"
110 def gem
111 sh "gem push pkg/#{read_gemspec.file_name}"
112 end
0200a43f »
2010-05-28 Whitespace fixes
113 end
Something went wrong with that request. Please try again.