rubypress 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2Y1NTQ2Zjg5ZTc2ZmE5MjhhNTVkM2IxYTVmOThjNTI1ZjU0ZmI2Ng==
5
+ data.tar.gz: !binary |-
6
+ MGNkNDM0NzNjZDliNGU1ZWZkYjlkOGRiNTkyM2JiMWZiZjIyYzQ2Ng==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ODBlMDZmYmFmMzVmMGI4MWUyNzg0YzBjZGJjMWNlMWIzZTRkMjBlNzgzNGNh
10
+ YmViZWQzZTQxMmFiOTUxNzY0Njk2ZmJkNjlkZTYyNWNiZTk4MjY0MTJjOWI1
11
+ MWUwYzJlMTZmZDFlYTNjM2ZkZjRkZGY1ODA1MDcwN2MwNzlmYTQ=
12
+ data.tar.gz: !binary |-
13
+ MTJjODhlNThmMDQ5N2Q3ZTZhZmI5ZmNlOTBkZGI5MjRhZTAwZGM3OWYxMjk1
14
+ YzZiMjU2N2RiYzNkYThmOWE5NzllY2ExMDg3MGMxZTMyMTNmZGZjNTg1MzQ1
15
+ MzY2ZmM3YjYwOWQ3Y2Q1MzVmNDExYzI5Y2RlNzY1MzdhZTRiOWE=
@@ -0,0 +1,29 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))
2
+
3
+ require 'xmlrpc/client'
4
+ require 'rubypress/client'
5
+
6
+ class Hash
7
+
8
+ def deep_merge!(other_hash)
9
+ other_hash.each_pair do |k,v|
10
+ tv = self[k]
11
+ self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
12
+ end
13
+ self
14
+ end
15
+
16
+ def deep_merge(other_hash)
17
+ dup.deep_merge!(other_hash)
18
+ end
19
+
20
+ end
21
+
22
+
23
+ require 'pp'
24
+
25
+ class XMLRPC::Client
26
+ def set_debug
27
+ @http.set_debug_output($stderr);
28
+ end
29
+ end
@@ -0,0 +1,66 @@
1
+ require 'yaml'
2
+ require 'erb'
3
+ require_relative "posts"
4
+ require_relative "taxonomies"
5
+ require_relative "media"
6
+ require_relative "comments"
7
+ require_relative "options"
8
+ require_relative "users"
9
+
10
+ module Rubypress
11
+
12
+ class Client
13
+
14
+ attr_reader :connection
15
+ attr_accessor :port, :host, :path, :username, :password, :use_ssl, :default_post_fields, :debug
16
+
17
+ def initialize(options = {})
18
+ {
19
+ :port => 80,
20
+ :use_ssl => false,
21
+ :host => nil,
22
+ :path => '/xmlrpc.php',
23
+ :username => nil,
24
+ :password => nil,
25
+ :default_post_fields => ['post','terms','custom_fields'],
26
+ :debug => false
27
+ }.merge(options).each{ |opt| self.send("#{opt[0]}=", opt[1]) }
28
+ self
29
+ end
30
+
31
+ def connection
32
+ @connection = XMLRPC::Client.new(self.host, self.path, self.port,nil,nil,nil,nil,self.use_ssl,nil)
33
+ end
34
+
35
+ def self.default
36
+ self.new(:host => ENV['WORDPRESS_HOST'], :port => 80, :username => ENV['WORDPRESS_USERNAME'], :password => ENV['WORDPRESS_PASSWORD'], :use_ssl => false)
37
+ end
38
+
39
+ def execute(method, options)
40
+ args = []
41
+ options_final = {
42
+ :blog_id => 0,
43
+ :username => self.username,
44
+ :password => self.password
45
+ }
46
+ options_final.deep_merge!(options).each{|option| args.push(option[1]) if !option[1].nil?}
47
+ if self.debug
48
+ connection.set_debug
49
+ server = self.connection.call("wp.#{method}", args)
50
+ pp server
51
+ else
52
+ self.connection.call("wp.#{method}", args)
53
+ end
54
+ end
55
+
56
+ include Posts
57
+ include Taxonomies
58
+ include Media
59
+ include Comments
60
+ include Options
61
+ include Users
62
+
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,51 @@
1
+ module Comments
2
+
3
+ def getCommentCount(options = {})
4
+ default_options = {
5
+ :post_id => nil
6
+ }.deep_merge!(options)
7
+ execute("getCommentCount", default_options)
8
+ end
9
+
10
+ def getComment(options = {})
11
+ default_options = {
12
+ :comment_id => nil
13
+ }.deep_merge!(options)
14
+ execute("getComment", default_options)
15
+ end
16
+
17
+ def getComments(options = {})
18
+ default_options = {
19
+ :filter => {}
20
+ }.deep_merge!(options)
21
+ execute("getComments", default_options)
22
+ end
23
+
24
+ def newComment(options = {})
25
+ default_options = {
26
+ :post_id => nil,
27
+ :comment => {}
28
+ }.deep_merge!(options)
29
+ execute("newComment", default_options)
30
+ end
31
+
32
+ def editComment(options = {})
33
+ default_options = {
34
+ :comment_id => nil,
35
+ :comment => {}
36
+ }.deep_merge!(options)
37
+ execute("editComment", default_options)
38
+ end
39
+
40
+ def deleteComment(options = {})
41
+ default_options = {
42
+ :comment_id => nil
43
+ }.deep_merge!(options)
44
+ execute("deleteComment", default_options)
45
+ end
46
+
47
+ def getCommentStatusList(options = {})
48
+ execute("getCommentStatusList", options)
49
+ end
50
+
51
+ end
@@ -0,0 +1,24 @@
1
+ module Media
2
+
3
+ def getMediaItem(options = {})
4
+ default_options = {
5
+ :attachment_id => nil
6
+ }.deep_merge!(options)
7
+ execute("getMediaItem", default_options)
8
+ end
9
+
10
+ def getMediaLibrary(options = {})
11
+ default_options = {
12
+ :filter => {}
13
+ }.deep_merge!(options)
14
+ execute("getMediaLibrary", default_options)
15
+ end
16
+
17
+ def uploadFile(options = {})
18
+ default_options = {
19
+ :data => {}
20
+ }.deep_merge!(options)
21
+ execute("uploadFile", default_options)
22
+ end
23
+
24
+ end
@@ -0,0 +1,17 @@
1
+ module Options
2
+
3
+ def getOptions(options = {})
4
+ default_options = {
5
+ :options => []
6
+ }.deep_merge!(options)
7
+ execute("getOptions", default_options)
8
+ end
9
+
10
+ def setOptions(options = {})
11
+ default_options = {
12
+ :options => []
13
+ }.deep_merge!(options)
14
+ execute("setOptions", default_options)
15
+ end
16
+
17
+ end
@@ -0,0 +1,72 @@
1
+ module Posts
2
+
3
+ def getPost(options = {})
4
+ default_options = {
5
+ :post_id => nil,
6
+ :fields => self.default_post_fields
7
+ }.deep_merge!(options)
8
+ execute("getPost", default_options)
9
+ end
10
+
11
+ def getPosts(options = {})
12
+ default_options = {
13
+ :filter => {
14
+ :post_type => 'post',
15
+ :orderby => 'post_date',
16
+ :order => 'asc',
17
+ :fields => self.default_post_fields
18
+ }
19
+ }.deep_merge!(options)
20
+ execute("getPosts", default_options)
21
+ end
22
+
23
+ def newPost(options = {})
24
+ default_options = {
25
+ :content => {}
26
+ }.deep_merge!(options)
27
+ execute("newPost", default_options)
28
+ end
29
+
30
+ def editPost(options = {})
31
+ default_options = {
32
+ :post_id => nil,
33
+ :content => {}
34
+ }.deep_merge!(options)
35
+ execute("editPost", default_options)
36
+ end
37
+
38
+ def deletePost(options = {})
39
+ default_options = {
40
+ :post_id => nil
41
+ }.deep_merge!(options)
42
+ execute("deletePost", default_options)
43
+ end
44
+
45
+ def getPostType(options = {})
46
+ default_options = {
47
+ :post_type_name => nil,
48
+ :fields => []
49
+ }.deep_merge!(options)
50
+ execute("getPostType", default_options)
51
+ end
52
+
53
+ def getPostTypes(options = {})
54
+ default_options = {
55
+ :filter => {},
56
+ :fields => []
57
+ }.deep_merge!(options)
58
+ execute("getPostTypes", default_options)
59
+ end
60
+
61
+ def getPostFormats(options = {})
62
+ default_options = {
63
+ :filter => {}
64
+ }.deep_merge!(options)
65
+ execute("getPostFormats", default_options)
66
+ end
67
+
68
+ def getPostStatusList(options = {})
69
+ execute("getPostFormats", options)
70
+ end
71
+
72
+ end
@@ -0,0 +1,53 @@
1
+ module Taxonomies
2
+
3
+ def getTaxonomy(options = {})
4
+ default_options = {
5
+ :taxonomy => "category"
6
+ }.deep_merge!(options)
7
+ execute("getTaxonomy", default_options)
8
+ end
9
+
10
+ def getTaxonomies(options = {})
11
+ execute("getTaxonomies", options)
12
+ end
13
+
14
+ def getTerm(options = {})
15
+ default_options = {
16
+ :taxonomy => "category",
17
+ :term_id => nil
18
+ }.deep_merge!(options)
19
+ execute("getTerm", default_options)
20
+ end
21
+
22
+ def getTerms(options = {})
23
+ default_options = {
24
+ :taxonomy => "category",
25
+ :filter => {}
26
+ }.deep_merge!(options)
27
+ execute("getTerms", default_options)
28
+ end
29
+
30
+ def newTerm(options = {})
31
+ default_options = {
32
+ :content => {}
33
+ }.deep_merge!(options)
34
+ execute("newTerm", default_options)
35
+ end
36
+
37
+ def editTerm(options = {})
38
+ default_options = {
39
+ :term_id => nil,
40
+ :content => {}
41
+ }.deep_merge!(options)
42
+ execute("editTerm", default_options)
43
+ end
44
+
45
+ def deleteTerm(options = {})
46
+ default_options = {
47
+ :taxonomy => nil,
48
+ :term_id => nil
49
+ }.deep_merge!(options)
50
+ execute("deleteTerm", default_options)
51
+ end
52
+
53
+ end
@@ -0,0 +1,40 @@
1
+ module Users
2
+
3
+ def getUsersBlogs
4
+ self.connection.call("wp.getUsersBlogs", self.username, self.password)
5
+ end
6
+
7
+ def getUser(options = {})
8
+ default_options = {
9
+ :user_id => nil,
10
+ :fields => []
11
+ }.deep_merge!(options)
12
+ execute("getUser", default_options)
13
+ end
14
+
15
+ def getUsers(options = {})
16
+ default_options = {
17
+ :filter => {}
18
+ }.deep_merge!(options)
19
+ execute("getUsers", default_options)
20
+ end
21
+
22
+ def getProfile(options = {})
23
+ default_options = {
24
+ :fields => []
25
+ }.deep_merge!(options)
26
+ execute("getProfile", default_options)
27
+ end
28
+
29
+ def editProfile(options = {})
30
+ default_options = {
31
+ :content => {}
32
+ }.deep_merge!(options)
33
+ execute("editProfile", default_options)
34
+ end
35
+
36
+ def getAuthors(options = {})
37
+ execute("getAuthors", options)
38
+ end
39
+
40
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubypress
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Zach Feldman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Easily push to WordPress installations through the WordPress XML-RPC
14
+ API. This gem exactly mirrors the functionality provided by the WordPress XML-RPC
15
+ API.
16
+ email:
17
+ - zachfeldman@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/rubypress.rb
23
+ - lib/rubypress/client.rb
24
+ - lib/rubypress/comments.rb
25
+ - lib/rubypress/media.rb
26
+ - lib/rubypress/options.rb
27
+ - lib/rubypress/posts.rb
28
+ - lib/rubypress/taxonomies.rb
29
+ - lib/rubypress/users.rb
30
+ homepage: https://github.com/zachfeldman/ruby-wordpress-api
31
+ licenses: []
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: 1.9.2
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.0.3
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Easily access WordPress installations through the WordPress XML-RPC API.
53
+ test_files: []