yamlrpc 0.2.3 → 1.0.0

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 (75) hide show
  1. data/Manifest.txt +107 -6
  2. data/README.txt +39 -10
  3. data/Rakefile +31 -23
  4. data/examples/README.txt +8 -0
  5. data/examples/examples_helper.rb +5 -0
  6. data/examples/girlfriend.jpg +0 -0
  7. data/examples/rails_basic_add_foo_bar.rb +6 -0
  8. data/examples/rails_basic_hello_world.rb +6 -0
  9. data/examples/rails_basic_hello_world_with_status.rb +8 -0
  10. data/examples/rails_basic_redirect_to_hello_world.rb +6 -0
  11. data/examples/rails_basic_redirect_twice_to_hello_world.rb +6 -0
  12. data/examples/rails_basic_unnamed_arguments.rb +6 -0
  13. data/examples/rails_basic_upload_image.rb +9 -0
  14. data/examples/rails_example/README +203 -0
  15. data/examples/rails_example/Rakefile +10 -0
  16. data/examples/rails_example/app/controllers/api/authenticated_controller.rb +2 -0
  17. data/examples/rails_example/app/controllers/api/basic_controller.rb +68 -0
  18. data/examples/rails_example/app/controllers/application.rb +10 -0
  19. data/examples/rails_example/app/helpers/api/authenticated_helper.rb +2 -0
  20. data/examples/rails_example/app/helpers/api/basic_helper.rb +2 -0
  21. data/examples/rails_example/app/helpers/application_helper.rb +3 -0
  22. data/examples/rails_example/config/boot.rb +109 -0
  23. data/examples/rails_example/config/database.yml +19 -0
  24. data/examples/rails_example/config/environment.rb +61 -0
  25. data/examples/rails_example/config/environments/development.rb +21 -0
  26. data/examples/rails_example/config/environments/production.rb +19 -0
  27. data/examples/rails_example/config/environments/test.rb +22 -0
  28. data/examples/rails_example/config/initializers/inflections.rb +10 -0
  29. data/examples/rails_example/config/initializers/mime_types.rb +5 -0
  30. data/examples/rails_example/config/routes.rb +35 -0
  31. data/examples/rails_example/db/development.sqlite3 +0 -0
  32. data/examples/rails_example/doc/README_FOR_APP +4 -0
  33. data/examples/rails_example/log/development.log +6 -0
  34. data/examples/rails_example/log/test.log +1 -0
  35. data/examples/rails_example/public/.htaccess +40 -0
  36. data/examples/rails_example/public/404.html +30 -0
  37. data/examples/rails_example/public/422.html +30 -0
  38. data/examples/rails_example/public/500.html +30 -0
  39. data/examples/rails_example/public/dispatch.cgi +10 -0
  40. data/examples/rails_example/public/dispatch.fcgi +24 -0
  41. data/examples/rails_example/public/dispatch.rb +10 -0
  42. data/examples/rails_example/public/favicon.ico +0 -0
  43. data/examples/rails_example/public/images/rails.png +0 -0
  44. data/examples/rails_example/public/index.html +277 -0
  45. data/examples/rails_example/public/javascripts/application.js +2 -0
  46. data/examples/rails_example/public/javascripts/controls.js +963 -0
  47. data/examples/rails_example/public/javascripts/dragdrop.js +972 -0
  48. data/examples/rails_example/public/javascripts/effects.js +1120 -0
  49. data/examples/rails_example/public/javascripts/prototype.js +4225 -0
  50. data/examples/rails_example/public/robots.txt +5 -0
  51. data/examples/rails_example/script/about +3 -0
  52. data/examples/rails_example/script/console +3 -0
  53. data/examples/rails_example/script/destroy +3 -0
  54. data/examples/rails_example/script/generate +3 -0
  55. data/examples/rails_example/script/performance/benchmarker +3 -0
  56. data/examples/rails_example/script/performance/profiler +3 -0
  57. data/examples/rails_example/script/performance/request +3 -0
  58. data/examples/rails_example/script/plugin +3 -0
  59. data/examples/rails_example/script/process/inspector +3 -0
  60. data/examples/rails_example/script/process/reaper +3 -0
  61. data/examples/rails_example/script/process/spawner +3 -0
  62. data/examples/rails_example/script/runner +3 -0
  63. data/examples/rails_example/script/server +3 -0
  64. data/examples/rails_example/test/functional/api/authenticated_controller_test.rb +8 -0
  65. data/examples/rails_example/test/functional/api/basic_controller_test.rb +8 -0
  66. data/examples/rails_example/test/test_helper.rb +38 -0
  67. data/lib/yamlrpc/client.rb +59 -32
  68. data/lib/yamlrpc.rb +1 -1
  69. metadata +110 -7
  70. data/examples/common_root_example.rb +0 -13
  71. data/examples/helper.rb +0 -3
  72. data/examples/image_example.rb +0 -15
  73. data/examples/pdf_example.pdf +0 -0
  74. data/examples/pdf_example.rb +0 -26
  75. data/examples/simple_example.rb +0 -13
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/about'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/console'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/destroy'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/generate'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/benchmarker'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/profiler'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/request'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/plugin'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/process/inspector'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/process/reaper'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/process/spawner'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/runner'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/server'
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class Api::AuthenticatedControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class Api::BasicControllerTest < ActionController::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
+ require 'test_help'
4
+
5
+ class Test::Unit::TestCase
6
+ # Transactional fixtures accelerate your tests by wrapping each test method
7
+ # in a transaction that's rolled back on completion. This ensures that the
8
+ # test database remains unchanged so your fixtures don't have to be reloaded
9
+ # between every test method. Fewer database queries means faster tests.
10
+ #
11
+ # Read Mike Clark's excellent walkthrough at
12
+ # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
13
+ #
14
+ # Every Active Record database supports transactions except MyISAM tables
15
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
16
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
17
+ # is recommended.
18
+ #
19
+ # The only drawback to using transactional fixtures is when you actually
20
+ # need to test transactions. Since your test is bracketed by a transaction,
21
+ # any transactions started in your code will be automatically rolled back.
22
+ self.use_transactional_fixtures = true
23
+
24
+ # Instantiated fixtures are slow, but give you @david where otherwise you
25
+ # would need people(:david). If you don't want to migrate your existing
26
+ # test cases which use the @david style and don't mind the speed hit (each
27
+ # instantiated fixtures translates to a database query per test method),
28
+ # then set this back to true.
29
+ self.use_instantiated_fixtures = false
30
+
31
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
32
+ #
33
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
34
+ # -- they do not yet inherit this setting
35
+ fixtures :all
36
+
37
+ # Add more helper methods to be used by all tests here...
38
+ end
@@ -2,8 +2,8 @@
2
2
  #
3
3
  # Example usage:
4
4
  #
5
- # yaml_rpc = YamlRpc.new('http://rubyforge.org/projects/yamlrpc/')
6
- # yaml_rpc.foo({
5
+ # yamlrpc = YamlRpc.new('http://rubyforge.org/projects/yamlrpc/')
6
+ # yamlrpc.foo({
7
7
  # :bar => 'foo-bar'
8
8
  # )
9
9
  #
@@ -17,11 +17,11 @@
17
17
  #
18
18
  # On the server side you can use (Ruby on Rails):
19
19
  #
20
- # YAML::load(params[:yaml_rpc])[:foo]
20
+ # YAML::load(params[:yamlrpc])[:foo]
21
21
  #
22
22
  # or in PHP:
23
23
  #
24
- # $data = syck_load($_POST['yaml_rpc']);
24
+ # $data = syck_load($_POST['yamlrpc']);
25
25
  # $data['foo']
26
26
  #
27
27
  # See examples in /examples directory
@@ -29,62 +29,89 @@ module YamlRpc
29
29
 
30
30
  class Client
31
31
 
32
- DEFAULT_FORM_DATA_ROOT = :yaml_rpc
32
+ DEFAULT_FORM_DATA_ROOT = :yamlrpc
33
33
  DEFAULT_OPEN_TIMEOUT = 120 # 2 minutes
34
34
  DEFAULT_READ_TIMEOUT = 120 # 2 minutes
35
35
 
36
- attr_accessor :url
36
+ attr_accessor :uri
37
37
  attr_accessor :form_data_root
38
38
  attr_accessor :open_timeout
39
39
  attr_accessor :read_timeout
40
+ attr_accessor :user
41
+ attr_accessor :password
42
+ attr_accessor :permanent_data
40
43
 
41
- # * <tt>url</tt> Root url, ie. "http://my.com/something/"; YamlRpc#some_method(:foo => 'bar') will POST to http://my.com/something/some_method with { :foo => 'bar' } params
44
+ # * <tt>uri</tt> Root url, ie. "http://my.com/something/"; YamlRpc#some_method(:foo => 'bar') will POST to http://my.com/something/some_method with { :foo => 'bar' } params
42
45
  # * <tt>options</tt>
43
46
  # * <tt>:form_data_root</tt> Default to :yamlrpc, meaning all params are passed inside :yamlrpc form field
44
- def initialize(url, options = {})
45
- @open_timeout = options[:open_timeout]
46
- @read_timeout = options[:read_timeout]
47
- @url = url
48
- @form_data_root = options.has_key?(:form_data_root) ? options[:form_data_root] : DEFAULT_FORM_DATA_ROOT
47
+ # * <tt>:open_timeout</tt> Open timeout
48
+ # * <tt>:read_timeout</tt> Read timeout
49
+ # * <tt>:user</tt> Basic http auth, user name
50
+ # * <tt>:password</tt> Basic http auth, password
51
+ def initialize(uri, options = {})
52
+ @open_timeout = options[:open_timeout]
53
+ @read_timeout = options[:read_timeout]
54
+ @user = options[:user]
55
+ @password = options[:password]
56
+ @permanent_data = options[:permanent_data]
57
+ @uri = URI.parse(uri.to_s)
58
+ @form_data_root = options[:form_data_root] || DEFAULT_FORM_DATA_ROOT
49
59
  end
50
60
 
51
- # * <tt>method</tt> Method name
61
+ # * <tt>uri</tt> Method name (mainly) or full uri (to support redirects to other domains)
52
62
  # * <tt>args</tt> Arguments, nil or Hash of values
53
- def method_missing(method, args = {})
54
- post(method, args)
63
+ def method_missing(uri, *args)
64
+ args = args.first if args.size == 1 && args.first.is_a?(Hash)
65
+ uri = URI.parse(uri.to_s)
66
+ if uri.host.nil?
67
+ uri.host = @uri.host
68
+ uri.port = @uri.port
69
+ end
70
+ uri.path = "#{@uri.path}#{uri.path}" unless uri.path =~ /^\//
71
+ post(uri, args)
55
72
  end
56
73
 
57
74
  protected
58
75
 
59
- # * <tt>add_url</tt> Path to be added to the YamlRpc#url (usually it's the method name), ie :invoice)
60
- # * <tt>args</tt> Data to be passed as POST fields, ie: { :status => 'SUCCESS', :message => 'All ok' }
61
- def post(add_url, args = {})
62
- url = URI.parse("#{@url}#{add_url}")
63
- req = Net::HTTP::Post.new(url.path)
64
- req.set_form_data(args_to_form_data(args), ';')
65
- http = Net::HTTP.new(url.host, url.port)
76
+ # * <tt>uri</tt> URI instance
77
+ # * <tt>args</tt> Optional data to be passed as POST fields, ie: { :status => 'SUCCESS', :message => 'All ok' }
78
+ def post(uri, args = nil)
79
+ req = Net::HTTP::Post.new(uri.path)
80
+ req.set_form_data(args_to_form_data(args) || {}, ';')
81
+ #req.basic_auth @user, @password if @user && @password
82
+ http = Net::HTTP.new(uri.host, uri.port)
66
83
  http.open_timeout = @open_timeout
67
84
  http.read_timeout = @read_timeout
68
85
  res = http.start { |http| http.request(req) }
69
86
  case res
70
87
  when Net::HTTPSuccess
71
88
  YAML::load(res.body)
89
+ when Net::HTTPRedirection
90
+ redirect_uri = URI.parse(res['location'])
91
+ if redirect_uri.host.nil?
92
+ redirect_uri.host = uri.host
93
+ redirect_uri.port = uri.port
94
+ end
95
+ post(redirect_uri, args)
72
96
  else
73
97
  res.error!
74
98
  end
75
99
  end
76
100
 
77
- # POST form data can be passed in two ways:
78
- # 1) with common root (set YamlRpc#form_data_root to ie. :my_root)
79
- # 2) without common root, each key is at the root of POST
80
- def args_to_form_data(args)
81
- r = {}
82
- if @form_data_root
83
- r[@form_data_root.to_sym] = YAML::dump(args)
84
- else
85
- args.each { |k, v| r[k.to_sym] = YAML::dump(v) }
101
+ # POST form data is always passed in YamlRpc#form_data_root variable name
102
+ # * <tt>args</tt>
103
+ def args_to_form_data(args = nil)
104
+ args = @permanent_data if args.nil? # HACK: this is hack as hell but logically ok for merging to work for nil args
105
+ unless @permanent_data.nil?
106
+ if @permanent_data.respond_to?('merge')
107
+ args = @permanent_data.merge(args)
108
+ elsif @permanent_data.respond_to?('+')
109
+ args = @permanent_data + args
110
+ else
111
+ raise ArgumentError.new("Can't merge #{@permanent_data.class} and #{args.class}")
112
+ end
86
113
  end
87
- r
114
+ { @form_data_root.to_sym => YAML::dump(args) }
88
115
  end
89
116
 
90
117
  end
data/lib/yamlrpc.rb CHANGED
@@ -28,5 +28,5 @@ require 'yamlrpc/helpers'
28
28
  require 'yamlrpc/client'
29
29
 
30
30
  module YamlRpc
31
- VERSION = '0.2.3'
31
+ VERSION = '1.0.0'
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamlrpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mirek Rusin
@@ -32,6 +32,8 @@ extra_rdoc_files:
32
32
  - History.txt
33
33
  - Manifest.txt
34
34
  - README.txt
35
+ - examples/rails_example/public/robots.txt
36
+ - examples/README.txt
35
37
  files:
36
38
  - History.txt
37
39
  - Manifest.txt
@@ -40,12 +42,113 @@ files:
40
42
  - lib/yamlrpc/client.rb
41
43
  - lib/yamlrpc/helpers.rb
42
44
  - lib/yamlrpc.rb
43
- - examples/common_root_example.rb
44
- - examples/helper.rb
45
- - examples/image_example.rb
46
- - examples/pdf_example.pdf
47
- - examples/pdf_example.rb
48
- - examples/simple_example.rb
45
+ - examples
46
+ - examples/examples_helper.rb
47
+ - examples/girlfriend.jpg
48
+ - examples/rails_basic_add_foo_bar.rb
49
+ - examples/rails_basic_hello_world.rb
50
+ - examples/rails_basic_hello_world_with_status.rb
51
+ - examples/rails_basic_redirect_to_hello_world.rb
52
+ - examples/rails_basic_redirect_twice_to_hello_world.rb
53
+ - examples/rails_basic_unnamed_arguments.rb
54
+ - examples/rails_basic_upload_image.rb
55
+ - examples/rails_example
56
+ - examples/rails_example/app
57
+ - examples/rails_example/app/controllers
58
+ - examples/rails_example/app/controllers/api
59
+ - examples/rails_example/app/controllers/api/authenticated_controller.rb
60
+ - examples/rails_example/app/controllers/api/basic_controller.rb
61
+ - examples/rails_example/app/controllers/application.rb
62
+ - examples/rails_example/app/helpers
63
+ - examples/rails_example/app/helpers/api
64
+ - examples/rails_example/app/helpers/api/authenticated_helper.rb
65
+ - examples/rails_example/app/helpers/api/basic_helper.rb
66
+ - examples/rails_example/app/helpers/application_helper.rb
67
+ - examples/rails_example/app/models
68
+ - examples/rails_example/app/views
69
+ - examples/rails_example/app/views/api
70
+ - examples/rails_example/app/views/api/authenticated
71
+ - examples/rails_example/app/views/api/basic
72
+ - examples/rails_example/app/views/layouts
73
+ - examples/rails_example/config
74
+ - examples/rails_example/config/boot.rb
75
+ - examples/rails_example/config/database.yml
76
+ - examples/rails_example/config/environment.rb
77
+ - examples/rails_example/config/environments
78
+ - examples/rails_example/config/environments/development.rb
79
+ - examples/rails_example/config/environments/production.rb
80
+ - examples/rails_example/config/environments/test.rb
81
+ - examples/rails_example/config/initializers
82
+ - examples/rails_example/config/initializers/inflections.rb
83
+ - examples/rails_example/config/initializers/mime_types.rb
84
+ - examples/rails_example/config/routes.rb
85
+ - examples/rails_example/db
86
+ - examples/rails_example/db/development.sqlite3
87
+ - examples/rails_example/doc
88
+ - examples/rails_example/doc/README_FOR_APP
89
+ - examples/rails_example/lib
90
+ - examples/rails_example/lib/tasks
91
+ - examples/rails_example/log
92
+ - examples/rails_example/log/development.log
93
+ - examples/rails_example/log/test.log
94
+ - examples/rails_example/public
95
+ - examples/rails_example/public/.htaccess
96
+ - examples/rails_example/public/404.html
97
+ - examples/rails_example/public/422.html
98
+ - examples/rails_example/public/500.html
99
+ - examples/rails_example/public/dispatch.cgi
100
+ - examples/rails_example/public/dispatch.fcgi
101
+ - examples/rails_example/public/dispatch.rb
102
+ - examples/rails_example/public/favicon.ico
103
+ - examples/rails_example/public/images
104
+ - examples/rails_example/public/images/rails.png
105
+ - examples/rails_example/public/index.html
106
+ - examples/rails_example/public/javascripts
107
+ - examples/rails_example/public/javascripts/application.js
108
+ - examples/rails_example/public/javascripts/controls.js
109
+ - examples/rails_example/public/javascripts/dragdrop.js
110
+ - examples/rails_example/public/javascripts/effects.js
111
+ - examples/rails_example/public/javascripts/prototype.js
112
+ - examples/rails_example/public/robots.txt
113
+ - examples/rails_example/public/stylesheets
114
+ - examples/rails_example/Rakefile
115
+ - examples/rails_example/README
116
+ - examples/rails_example/script
117
+ - examples/rails_example/script/about
118
+ - examples/rails_example/script/console
119
+ - examples/rails_example/script/destroy
120
+ - examples/rails_example/script/generate
121
+ - examples/rails_example/script/performance
122
+ - examples/rails_example/script/performance/benchmarker
123
+ - examples/rails_example/script/performance/profiler
124
+ - examples/rails_example/script/performance/request
125
+ - examples/rails_example/script/plugin
126
+ - examples/rails_example/script/process
127
+ - examples/rails_example/script/process/inspector
128
+ - examples/rails_example/script/process/reaper
129
+ - examples/rails_example/script/process/spawner
130
+ - examples/rails_example/script/runner
131
+ - examples/rails_example/script/server
132
+ - examples/rails_example/test
133
+ - examples/rails_example/test/fixtures
134
+ - examples/rails_example/test/functional
135
+ - examples/rails_example/test/functional/api
136
+ - examples/rails_example/test/functional/api/authenticated_controller_test.rb
137
+ - examples/rails_example/test/functional/api/basic_controller_test.rb
138
+ - examples/rails_example/test/integration
139
+ - examples/rails_example/test/mocks
140
+ - examples/rails_example/test/mocks/development
141
+ - examples/rails_example/test/mocks/test
142
+ - examples/rails_example/test/test_helper.rb
143
+ - examples/rails_example/test/unit
144
+ - examples/rails_example/tmp
145
+ - examples/rails_example/tmp/cache
146
+ - examples/rails_example/tmp/pids
147
+ - examples/rails_example/tmp/sessions
148
+ - examples/rails_example/tmp/sockets
149
+ - examples/rails_example/vendor
150
+ - examples/rails_example/vendor/plugins
151
+ - examples/README.txt
49
152
  has_rdoc: true
50
153
  homepage: http://rubyforge.com/projects/yamlrpc
51
154
  post_install_message:
@@ -1,13 +0,0 @@
1
-
2
- require 'helper'
3
-
4
- client = YamlRpc::Client.new('http://localhost:3000/site/', :form_data_root => :yaml_rpc)
5
-
6
- pp client.create_online_sales_order( :test => 'My test', :test2 => 'My test2' )[:response]
7
-
8
- # On the server side, if you're using Ruby on Rails you may want to:
9
- #
10
- # def create_online_sales_order
11
- # rpc_params = YamlRpc.decode(params[:yaml_rpc])
12
- # render => YAML::dump({ :response => "Got your #{rpc_params.inspect}!" })
13
- # end
data/examples/helper.rb DELETED
@@ -1,3 +0,0 @@
1
- $:.unshift '../lib'
2
- require 'yamlrpc'
3
- require 'pp'
@@ -1,15 +0,0 @@
1
-
2
- require 'helper'
3
- require 'open-uri'
4
-
5
- client = YamlRpc::Client.new('http://localhost:3000/site/')
6
-
7
- image = open('http://www.google.co.uk/intl/en_uk/images/logo.gif').read
8
-
9
- pp client.send_image( :image => image )
10
-
11
- # On the server side, if you're using Ruby on Rails you may want to:
12
- #
13
- # rpc_params = YamlRpc.decode(params, [:image])
14
- # send_data rpc_params[:image],
15
- # :content_type => 'image/gif'
Binary file
@@ -1,26 +0,0 @@
1
-
2
- require 'helper'
3
- require 'open-uri'
4
-
5
- client = YamlRpc::Client.new('http://www.pdfonrails.com/api/yaml_rpc/')
6
-
7
- params = {
8
- :layout => 'basic',
9
- :html => <<END
10
- <h1>Hello world!</h1>
11
- <p>
12
- Hello <b>PDF</b> world!
13
- </p>
14
- <p>
15
- <ul>
16
- <li>Hello
17
- <li><i>World</i>
18
- <li>!!!
19
- </ul>
20
- </p>
21
- END
22
- }
23
-
24
- pdf = open('pdf_example.pdf', 'wb')
25
- pdf.write(client.pdf(params)[:pdf])
26
- pdf.close
@@ -1,13 +0,0 @@
1
-
2
- require 'helper'
3
-
4
- client = YamlRpc::Client.new('http://localhost:3000/site/')
5
-
6
- pp client.create_online_sales_order( :test => 'My test' )[:response]
7
-
8
- # On the server side, if you're using Ruby on Rails you may want to:
9
- #
10
- # def create_online_sales_order
11
- # rpc_params = YamlRpc.decode(params, [:test])
12
- # render => YAML::dump({ :response => "Got your #{rpc_params[:test]}!" })
13
- # end