metaweblog 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ..gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tatsuya Sato
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # metaweblog - Ruby client for metaWeblog API
2
+
3
+ This gem makes it easier for you to talk with your blog apps via metaWeblog API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your Gemfile:
8
+
9
+ gem 'metaweblog'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install metaweblog
18
+
19
+ ## Usage
20
+
21
+ ### Setup a client
22
+
23
+ ```ruby
24
+ client = MetaWeblog::Client.new('http://yourblog.example.com/xmlrpc.rb', # XML-RPC endpoint
25
+ 'your_blog_id', # Blog ID
26
+ 'username', # username
27
+ 'password', # password
28
+ 'proxy.example.com') # (Optional) proxy
29
+ ```
30
+
31
+ ### Post new entry
32
+
33
+ ```ruby
34
+ require 'metaweblog'
35
+
36
+ post = MetaWeblog::Post.new('Title', 'Body')
37
+ client.post(post)
38
+ ```
39
+
40
+ `MetaWeblog::Client#post` returns `post_id` of new entry if the entry is posted successfully.
41
+
42
+ ### Edit an existing entry
43
+
44
+ ```ruby
45
+ modified_entry = MetaWeblog::Post.new('Fixed Title', 'Fixed Contents')
46
+ client.edit(post_id, modified_entry)
47
+ ```
48
+
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
57
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ require 'xmlrpc/client'
4
+
5
+ module MetaWeblog
6
+ POST_MEMBERS = [:title, :link, :description]
7
+ Post = Struct.new(*POST_MEMBERS)
8
+
9
+ class Client
10
+ attr_reader :uri, :proxy, :blog_id, :username, :password, :client
11
+
12
+ def initialize(uri, blog_id, username, password, proxy = nil)
13
+ @uri = uri
14
+ @proxy = proxy
15
+ @blog_id = blog_id
16
+ @username = username
17
+ @password = password
18
+ @client = XMLRPC::Client.new2(@uri, @proxy)
19
+ end
20
+
21
+ def post(post, publish=true)
22
+ client.call('metaWeblog.newPost', blog_id, username, password, post, publish)
23
+ end
24
+
25
+ def edit(post_id, post, publish=true)
26
+ client.call('metaWeblog.editPost', post_id, username, password, post, publish)
27
+ end
28
+
29
+ def recent_posts(n=10)
30
+ client.call('metaWeblog.getRecentPosts', blog_id, username, password, n)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module MetaWeblog
2
+ VERSION = "0.0.1"
3
+ end
data/lib/metaweblog.rb ADDED
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+
3
+ require 'metaweblog/version'
4
+ require 'metaweblog/cilent'
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'metaweblog/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "metaweblog"
8
+ spec.version = MetaWeblog::VERSION
9
+ spec.authors = ["Tatsuya Sato"]
10
+ spec.email = ["satoryu.1981@gmail.com"]
11
+ spec.description = <<-DESC
12
+ Ruby client for metaWeblog API.
13
+ This gem makes it easier for developers to talk with your Blog supporting
14
+ metaWeblog API.
15
+ This gem only depends on REXML provided as one of Ruby's standard lib.
16
+ DESC
17
+ spec.summary = %q{Ruby client for metaWeblog API.}
18
+ spec.homepage = "http://github.com/satoryu/metaweblog"
19
+ spec.license = "MIT"
20
+ spec.required_ruby_version = '>= 1.9.3'
21
+
22
+ spec.files = `git ls-files`.split($/)
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.3"
28
+ spec.add_development_dependency "rspec", "~> 2.0"
29
+ spec.add_development_dependency "rake"
30
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metaweblog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tatsuya Sato
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: ! " Ruby client for metaWeblog API.\n This gem makes it easier
63
+ for developers to talk with your Blog supporting\n metaWeblog API. \n This
64
+ gem only depends on REXML provided as one of Ruby's standard lib. \n"
65
+ email:
66
+ - satoryu.1981@gmail.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - .gitignore
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - lib/metaweblog.rb
77
+ - lib/metaweblog/client.rb
78
+ - lib/metaweblog/version.rb
79
+ - metaweblog.gemspec
80
+ homepage: http://github.com/satoryu/metaweblog
81
+ licenses:
82
+ - MIT
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: 1.9.3
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ segments:
100
+ - 0
101
+ hash: 182703639642257521
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 1.8.25
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Ruby client for metaWeblog API.
108
+ test_files: []