Thor::RPC generates RPC endpoints for executing thor tasks. It uses rack-rpc to generate the RPC endpoints.
Add this line to your application's Gemfile:
gem "thor-rpc", :git => "git://github.com/drachenfels-gmbh/thor-rpc.git"
And then execute:
$ bundle
Please have a look at the config.ru in the example folder.
Thor::RPC and the thor files have to be loaded in the config.ru:
require 'thor-rpc' load 'simple.thor'
The RPC server classes are dynamically generated but must be manually registered:
# register servers created from thor classes Thor::RPC::SERVERS.each_pair do |key, server| puts "Register endpoint #{server}: /#{key.downcase}" use Rack::RPC::Endpoint, server.new, :path => "/#{key.downcase}" end
Currently there are no specs and unit tests, because it was just a simple prove of concept. But you can test the code by running rackup in the example directory and execute the curl test script afterwards.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- tests, tests, tests
- concept for providing thor method options
- better logging
- warn when a method is registered more than once
- API browsing page similar to thor commandline help
- client stubs