Skip to content

Instantly share code, notes, and snippets.

@nbqx
Created January 11, 2012 08:34
Show Gist options
  • Save nbqx/1593724 to your computer and use it in GitHub Desktop.
Save nbqx/1593724 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
Earthquake.init do
command %r|^:create_shindanmaker_plugin\s+(.+)\s(.+)$|, :as => :create_shindanmaker_plugin do |m|
name = m[1]
url = m[2]
dir = File.dirname(__FILE__)
tmpl = <<TMPL
# -*- coding: utf-8 -*-
require 'httpclient'
Earthquake.init do
command :#{name} do |m|
url = "#{url}"
html = HTTPClient.new.post(url, { :u => m[1], :from => ""} )
r = nil
html.body.split("\\n").detect{|e| r = e.match(/>\s+?(.+)\#\{url\}/)}
input(r[1]) if r
end
end
TMPL
if confirm "create #{name} plugin?"
open(dir+"/#{name}.rb","w") do |f|
f.print tmpl
end
puts "Created. You have to reboot earthquake.gem"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment