Class: DevTools::Freshmeat::FreshmeatService

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_project/release/freshmeat.rb

Overview

Provides access to the Freshmeat XML-RPC API via a nice interface. API reference at freshmeat.net/faq/view/49/

Example:

fm = DevTools::FreshmeatService.new( username, password )
fm.get_project_list.each do |p|
  puts p
  branches = fm.get_branch_list( p.shortName )
  puts branches.inspect
  release = fm.get_release( p.shortName, branches[0], p.version )
  puts release
end
puts fm.logout

Constant Summary collapse

RPCURL =

The URL for the Freshmeat RPC service

'http://freshmeat.net/xmlrpc/'
API_VERSION_MAJOR =

The major version of the freshmeat API with which this library works

'1'
API_VERSION_MINOR =

The minor version of the freshmeat API with which this library works

'03'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ FreshmeatService

Use username and password to log into Freshmeat service.



206
207
208
209
210
211
212
213
214
# File 'lib/meta_project/release/freshmeat.rb', line 206

def initialize( username, password )
  @session = XMLRPC::Client.new2( RPCURL )
  ret = @session.call( :login, :username=>username, :password=>password )
  @sid = ret['SID']
  major, minor = ret['API Version'].split( '.' )
  if major != API_VERSION_MAJOR or minor < API_VERSION_MINOR
    raise FreshmeatException, 'Incompatible API versions'
  end
end

Class Method Details

.get_licensesObject

Returns all available licenses



217
218
219
# File 'lib/meta_project/release/freshmeat.rb', line 217

def self.get_licenses
  XMLRPC::Client.new2( RPCURL ).call( :fetch_available_licenses )
end

.get_release_focus_typesObject

Returns all available release focus types



222
223
224
# File 'lib/meta_project/release/freshmeat.rb', line 222

def self.get_release_focus_types
  XMLRPC::Client.new2( RPCURL ).call( :fetch_available_release_foci )
end

Instance Method Details

#get_branch_list(project) ⇒ Object

Returns an array of branch names for the project project.



233
234
235
# File 'lib/meta_project/release/freshmeat.rb', line 233

def get_branch_list( project )
  @session.call( :fetch_branch_list, :SID=>@sid, :project_name=>project )
end

#get_project_listObject

Returns an array of Project objects which are assigned to the logged in user



227
228
229
230
# File 'lib/meta_project/release/freshmeat.rb', line 227

def get_project_list
  ret = @session.call( :fetch_project_list, :SID=>@sid )
  ret.collect! {|p| Project.new( p['projectname_short'], p['projectname_full'], p['project_status'], p['project_version'] ) }
end

#get_release(project, branch, version) ⇒ Object

Returns a ReleaseInfo object which has the information about the requested release.



238
239
240
241
242
243
# File 'lib/meta_project/release/freshmeat.rb', line 238

def get_release( project, branch, version )
  ret = @session.call( :fetch_release, :SID=>@sid, :project_name=>project, :branch_name=>branch, :version=>version )
  releaseFocus = ret['release_focus'].split( ' - ' )[0].to_i
  hidden = (ret['hide_from_frontpage'] == 'Y' )
  ReleaseInfo.new( ret['version'], ret['changes'], releaseFocus, hidden )
end

#logoutObject

Logs out from the Freshmeat service.



258
259
260
261
# File 'lib/meta_project/release/freshmeat.rb', line 258

def logout
  ok, ret = @session.call2( :logout, :SID=>@sid )
  ok && ret['OK'] == 'Logout successful.'
end

#publish_release(release) ⇒ Object

Publishes a new release of a project. The parameter release has to be a Release object!



246
247
248
249
# File 'lib/meta_project/release/freshmeat.rb', line 246

def publish_release( release )
  ret = @session.call( :publish_release, {:SID=>@sid}.update( release.to_rpc_data ) )
  ret['OK'] == 'submission successful'
end

#withdraw_release(project, branch, version) ⇒ Object

Withdraws the specified release.



252
253
254
255
# File 'lib/meta_project/release/freshmeat.rb', line 252

def withdraw_release( project, branch, version )
  ret = @session.call( :withdraw_release, :SID=>@sid, :project_name=>project, :branch_name=>branch, :version=>version )
  ret['OK'] == 'Withdraw successful.'
end