yamlrpc 0.1.080624130617

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/README +29 -0
  2. data/lib/yamlrpc/client.rb +36 -0
  3. data/lib/yamlrpc.rb +4 -0
  4. metadata +56 -0
data/README ADDED
@@ -0,0 +1,29 @@
1
+ = YamlRpc -- simple RPC client
2
+
3
+ client = YamlRpc::Client.new('http://localhost:3000/somewhere/')
4
+ # Invokes http://localhost:3000/somewhere/my_method passing POST data { :test => 'My test' } as YAML
5
+ result = client.my_method( :test => 'My test' )
6
+
7
+ # Result is YAML which is loaded and returned as object
8
+ puts result['my_response_message']
9
+
10
+ == Download
11
+
12
+ The latest version of Csv2sql can be found at
13
+
14
+ * http://mirekrusin.com/ruby/yamlrpc
15
+
16
+ == Installation
17
+
18
+ gem install yamlrpc
19
+
20
+ == License
21
+
22
+ Csv2sql is released under the LGPL license.
23
+
24
+ == Support
25
+
26
+ The Csv2sql homepage is http://mirekrusin.com/ruby/yamlrpc
27
+
28
+ For other information, feel free to ask on the ruby-talk mailing list
29
+ (which is mirrored to comp.lang.ruby) or contact mailto:ruby@mirekrusin.com
@@ -0,0 +1,36 @@
1
+
2
+ # Simple RPC client on YAML.
3
+ module YamlRpc
4
+
5
+ class Client
6
+
7
+ attr_accessor :url
8
+
9
+ def initialize(url)
10
+ @url = url
11
+ end
12
+
13
+ def method_missing(method, args)
14
+ post(method, args)
15
+ end
16
+
17
+ protected
18
+
19
+ # * <tt>url</tt> Url
20
+ # * <tt>data</tt> Data to be passed as POST form field 'yaml', ie: { :status => 'SUCCESS', :message => 'All ok' }
21
+ def post(url, data = {})
22
+ url = URI.parse("#{@url}#{url}")
23
+ req = Net::HTTP::Post.new(url.path)
24
+ req.set_form_data({ :yaml => YAML::dump(data) }, ';')
25
+ res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
26
+ case res
27
+ when Net::HTTPSuccess
28
+ YAML::load(res.body)
29
+ else
30
+ res.error!
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ end
data/lib/yamlrpc.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'yaml'
2
+ require 'net/http'
3
+
4
+ require 'yamlrpc/client'
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yamlrpc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.080624130617
5
+ platform: ruby
6
+ authors:
7
+ - Mirek Rusin
8
+ autorequire: yamlrpc
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-24 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: ruby@mirekrusin.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ files:
25
+ - lib/yamlrpc
26
+ - lib/yamlrpc/client.rb
27
+ - lib/yamlrpc.rb
28
+ - README
29
+ has_rdoc: true
30
+ homepage: http://mirekrusin.com/ruby/yamlrpc
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:
51
+ rubygems_version: 1.0.1
52
+ signing_key:
53
+ specification_version: 2
54
+ summary: YamlRpc is a simple RPC client based on YAML
55
+ test_files: []
56
+