rmetaweblog 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ #require the Class
2
+ require 'rmetaweblog'
3
+
4
+ #This is an example to interact with the Apache Roller java based blogging application:
5
+
6
+ #Initialize RMetaWebLog with: host, path, port(optional), {options}
7
+
8
+ blog = RMetaWebLog.new("hostname", "/roller/roller-services/xmlrpc", {
9
+ :blog_url => "http://hostname:8080/roller/blogname",
10
+ :blog_id => "blogid",
11
+ :api_user => "username",
12
+ :api_pass => "password"
13
+ })
14
+
15
+ #Upload an image
16
+
17
+ img_url = blog.new_media_object("filename.jpg", "image/jpeg", "/location/of/filename.jpg")
18
+
19
+ #img_url in now in this case: http://hostname:8080/roller/blogname/resource/filename.jpg
20
+
21
+ #Create a new post to blog
22
+
23
+ blog.new_post("title","content")
24
+
25
+ #Most of class methods work in the same manner, just look at the class if you want to do anything else.
data/README ADDED
@@ -0,0 +1,3 @@
1
+ rmetaweblog is a tiny ruby class for interacting with the MetaWebLog API supported by many blog applications.
2
+
3
+ see EXAMPLES
@@ -0,0 +1,89 @@
1
+ require 'xmlrpc/client'
2
+ class RMetaWebLog < XMLRPC::Client
3
+ # Initialize RMetaWebLog with: host, path, port(optional), {options}
4
+ #
5
+ # RMetaWebLog.new("hostname", "/path/to/xmlrpc", {
6
+ # :blog_url => "http://path/to/blog",
7
+ # :blog_id => "blogid",
8
+ # :api_user => "username",
9
+ # :api_pass => "password"
10
+ # })
11
+ #
12
+ # Optional parameters are:
13
+ # +blog_url+ =
14
+ # +blog_id+ =
15
+ # +api_user+ =
16
+ # +api_pass+ =
17
+ # +proxy_host+ =
18
+ # +proxy_port+ =
19
+ # +user+ =
20
+ # +password+ =
21
+ # +use_ssl+ =
22
+ # +timeout+ =
23
+
24
+ def initialize(*args)
25
+ options = extract_hash_from_args!(args)
26
+ args[2] ||= 80
27
+ @blog_url = options[:blog_url]
28
+ @blog_id = options[:blog_id]
29
+ @api_user = options[:api_user]
30
+ @api_pass = options[:api_pass]
31
+ super(args[0], args[1], args[2], options[:proxy_host], options[:proxy_port], options[:user], options[:password], options[:use_ssl], options[:timeout])
32
+ end
33
+
34
+ #Returns Hash.
35
+ def post(postid)
36
+ call('metaWeblog.getPost', postid, @api_user, @api_pass)
37
+ end
38
+
39
+ #Returns Hash.
40
+ def posts(count = 5)
41
+ call('metaWeblog.getRecentPosts', @blog_id, @api_user, @api_pass, count)
42
+ end
43
+
44
+ #Returns True.
45
+ def delete_post!(postid)
46
+ call('metaWeblog.deletePost', "appkey", postid, @api_user, @api_pass, true)
47
+ end
48
+
49
+
50
+ #Returns String (postid).
51
+ def new_post(title, content)
52
+ object = { 'title' => title, 'link' => @blog_url, 'description' => content }
53
+ call('metaWeblog.newPost', @blog_id, @api_user, @api_pass, object, true)
54
+ end
55
+
56
+ #Returns True.
57
+ def edit_post(postid, title, content)
58
+ object = { 'title' => title, 'link' => @blog_url, 'description' => content }
59
+ call('metaWeblog.editPost', postid, @api_user, @api_pass, object, true)
60
+ end
61
+
62
+ #Returns Hash.
63
+ def new_media_object(name, type, filename)
64
+ require 'base64'
65
+ object = {
66
+ 'name' => name,
67
+ 'type' => type,
68
+ 'bits' => XMLRPC::Base64.new(File.read(filename))
69
+ }
70
+ call('metaWeblog.newMediaObject', @blog_id, @api_user, @api_pass, object)
71
+ end
72
+
73
+ #Returns Hash.
74
+ def categories
75
+ call('metaWeblog.getCategories', @blog_id, @api_user, @api_pass)
76
+ end
77
+
78
+ #Returns array of hashes.
79
+ def recent_posts(number = 5)
80
+ call('metaWeblog.getRecentPosts', @blog_id, @api_user, @api_pass, number)
81
+ end
82
+
83
+ private
84
+
85
+ def extract_hash_from_args!(args)
86
+ args.last.is_a?(Hash) ? args.pop : {}
87
+ end
88
+
89
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'rmetaweblog'
4
+
5
+ class TestRMetaweblog < Test::Unit::TestCase
6
+
7
+ def test_should_pass
8
+ assert true
9
+ end
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rmetaweblog
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.0"
5
+ platform: ruby
6
+ authors:
7
+ - Pieter Steyn and Jae Hess
8
+ autorequire: rmetaweblog
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-02-13 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: pieterste@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ files:
25
+ - lib/rmetaweblog.rb
26
+ - test/test_rmetaweblog.rb
27
+ - EXAMPLES
28
+ - README
29
+ has_rdoc: true
30
+ homepage: http://rmetaweblog.rubyforge.org
31
+ post_install_message:
32
+ rdoc_options: []
33
+
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ requirements: []
49
+
50
+ rubyforge_project: rmetaweblog
51
+ rubygems_version: 1.0.1
52
+ signing_key:
53
+ specification_version: 2
54
+ summary: A ruby class for interacting with the MetaWebLog API used by many blogging systems.
55
+ test_files:
56
+ - test/test_rmetaweblog.rb