rosa-build/app/controllers/rpc_controller.rb

41 lines
1.6 KiB
Ruby
Raw Normal View History

2011-10-24 02:59:16 +01:00
class RpcController < ApplicationController
exposes_xmlrpc_methods
before_filter :authenticate_user!
before_filter lambda { EventLog.current_controller = self }, :only => :xe_index # should be after auth callback
2011-10-24 02:59:16 +01:00
## Usage example:
#
# require 'xmlrpc/client'
# client = XMLRPC::Client.new("127.0.0.1", '/api/xmlrpc', 3000, nil, nil, 'user@email', 'password', false, 900)
# client.call("project_versions", 1)
def platforms
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список платформ')
Platform.select('name').where("platform_type = ?", 'main').map(&:name)
2011-10-24 02:59:16 +01:00
end
2011-10-24 02:59:16 +01:00
def user_projects
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'список пользовательских проектов')
current_user.projects.map{|p| { :id => p.id, :name => p.name } }
2011-10-24 02:59:16 +01:00
end
2011-10-24 02:59:16 +01:00
def project_versions id
p = Project.find_by_id(id)
ActiveSupport::Notifications.instrument("event_log.observer", :object => p, :message => "список версий")
2011-10-30 19:01:08 +00:00
p.project_versions.collect {|tag| tag.name.gsub(/^\w+\./, "")} rescue 'not found'
2011-10-24 02:59:16 +01:00
end
2011-10-24 02:59:16 +01:00
def build_status id
bl = BuildList.find_by_id(id)
ActiveSupport::Notifications.instrument("event_log.observer", :object => bl, :message => 'статус сборки')
bl.try(:status) || 'not found'
2011-10-24 02:59:16 +01:00
end
2011-10-24 02:59:16 +01:00
def build_packet project_id, repo_id
# p = Project.find_by_id(project_id); r = Repository.find_by_id(repo_id)
ActiveSupport::Notifications.instrument("event_log.observer", :message => 'сборка пакета')
'unknown' # TODO: build packet
2011-10-24 02:59:16 +01:00
end
end