1 # -*- encoding: binary -*-
2 autoload :Gem, 'rubygems'
3 autoload :Tempfile, 'tempfile'
6 cgit_url = Wrongdoc.config[:cgit_url]
7 git_url = Wrongdoc.config[:git_url]
9 desc "read news article from STDIN and post to rubyforge"
12 spec = Gem::Specification.load('rainbows.gemspec')
13 tmp = Tempfile.new('rf-news')
14 _, subject, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
17 tmp.puts spec.description.strip
19 tmp.puts "* #{spec.homepage}"
20 tmp.puts "* #{spec.email}"
21 tmp.puts "* #{git_url}"
22 tmp.print "\nChanges:\n\n"
25 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
26 msg = File.readlines(tmp.path)
29 blank == "\n" or abort "no newline after subject!"
31 body = msg.join("").strip!
33 rf = RubyForge.new.configure
35 rf.post_news('rainbows', subject, body)
42 rc = Net::Netrc.locate('rainbows-raa') or abort "~/.netrc not found"
43 password = rc.password
45 s = Gem::Specification.load('rainbows.gemspec')
46 desc = [ s.description.strip ]
48 desc << "* #{s.email}"
49 desc << "* #{git_url}"
50 desc << "* #{cgit_url}"
51 desc = desc.join("\n")
52 uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
55 :short_description => s.summary,
56 :version => s.version.to_s,
57 :status => 'experimental',
58 :owner => s.authors.first,
60 :category_major => 'Library',
61 :category_minor => 'Web',
63 :download => "http://rubyforge.org/frs/?group_id=8977",
65 :description_style => 'Plain',
70 res = Net::HTTP.post_form(uri, form)
80 version = ENV['VERSION'] or abort "VERSION= needed"
81 uri = URI.parse('https://freecode.com/projects/rainbows/releases.json')
82 rc = Net::Netrc.locate('rainbows-fm') or abort "~/.netrc not found"
83 api_token = rc.password
84 _, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3)
85 tmp = Tempfile.new('fm-changelog')
90 system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
91 changelog = File.read(tmp.path).strip
94 "auth_code" => api_token,
96 "tag_list" => "Stable",
98 "changelog" => changelog,
101 if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z}
102 Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
103 p http.post(uri.path, req, {'Content-Type'=>'application/json'})
106 warn "not updating freshmeat for v#{version}"