yamlrpc 0.2.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/Manifest.txt CHANGED
@@ -5,9 +5,110 @@ Rakefile
5
5
  lib/yamlrpc/client.rb
6
6
  lib/yamlrpc/helpers.rb
7
7
  lib/yamlrpc.rb
8
- examples/common_root_example.rb
9
- examples/helper.rb
10
- examples/image_example.rb
11
- examples/pdf_example.pdf
12
- examples/pdf_example.rb
13
- examples/simple_example.rb
8
+ examples
9
+ examples/examples_helper.rb
10
+ examples/girlfriend.jpg
11
+ examples/rails_basic_add_foo_bar.rb
12
+ examples/rails_basic_hello_world.rb
13
+ examples/rails_basic_hello_world_with_status.rb
14
+ examples/rails_basic_redirect_to_hello_world.rb
15
+ examples/rails_basic_redirect_twice_to_hello_world.rb
16
+ examples/rails_basic_unnamed_arguments.rb
17
+ examples/rails_basic_upload_image.rb
18
+ examples/rails_example
19
+ examples/rails_example/app
20
+ examples/rails_example/app/controllers
21
+ examples/rails_example/app/controllers/api
22
+ examples/rails_example/app/controllers/api/authenticated_controller.rb
23
+ examples/rails_example/app/controllers/api/basic_controller.rb
24
+ examples/rails_example/app/controllers/application.rb
25
+ examples/rails_example/app/helpers
26
+ examples/rails_example/app/helpers/api
27
+ examples/rails_example/app/helpers/api/authenticated_helper.rb
28
+ examples/rails_example/app/helpers/api/basic_helper.rb
29
+ examples/rails_example/app/helpers/application_helper.rb
30
+ examples/rails_example/app/models
31
+ examples/rails_example/app/views
32
+ examples/rails_example/app/views/api
33
+ examples/rails_example/app/views/api/authenticated
34
+ examples/rails_example/app/views/api/basic
35
+ examples/rails_example/app/views/layouts
36
+ examples/rails_example/config
37
+ examples/rails_example/config/boot.rb
38
+ examples/rails_example/config/database.yml
39
+ examples/rails_example/config/environment.rb
40
+ examples/rails_example/config/environments
41
+ examples/rails_example/config/environments/development.rb
42
+ examples/rails_example/config/environments/production.rb
43
+ examples/rails_example/config/environments/test.rb
44
+ examples/rails_example/config/initializers
45
+ examples/rails_example/config/initializers/inflections.rb
46
+ examples/rails_example/config/initializers/mime_types.rb
47
+ examples/rails_example/config/routes.rb
48
+ examples/rails_example/db
49
+ examples/rails_example/db/development.sqlite3
50
+ examples/rails_example/doc
51
+ examples/rails_example/doc/README_FOR_APP
52
+ examples/rails_example/lib
53
+ examples/rails_example/lib/tasks
54
+ examples/rails_example/log
55
+ examples/rails_example/log/development.log
56
+ examples/rails_example/log/test.log
57
+ examples/rails_example/public
58
+ examples/rails_example/public/.htaccess
59
+ examples/rails_example/public/404.html
60
+ examples/rails_example/public/422.html
61
+ examples/rails_example/public/500.html
62
+ examples/rails_example/public/dispatch.cgi
63
+ examples/rails_example/public/dispatch.fcgi
64
+ examples/rails_example/public/dispatch.rb
65
+ examples/rails_example/public/favicon.ico
66
+ examples/rails_example/public/images
67
+ examples/rails_example/public/images/rails.png
68
+ examples/rails_example/public/index.html
69
+ examples/rails_example/public/javascripts
70
+ examples/rails_example/public/javascripts/application.js
71
+ examples/rails_example/public/javascripts/controls.js
72
+ examples/rails_example/public/javascripts/dragdrop.js
73
+ examples/rails_example/public/javascripts/effects.js
74
+ examples/rails_example/public/javascripts/prototype.js
75
+ examples/rails_example/public/robots.txt
76
+ examples/rails_example/public/stylesheets
77
+ examples/rails_example/Rakefile
78
+ examples/rails_example/README
79
+ examples/rails_example/script
80
+ examples/rails_example/script/about
81
+ examples/rails_example/script/console
82
+ examples/rails_example/script/destroy
83
+ examples/rails_example/script/generate
84
+ examples/rails_example/script/performance
85
+ examples/rails_example/script/performance/benchmarker
86
+ examples/rails_example/script/performance/profiler
87
+ examples/rails_example/script/performance/request
88
+ examples/rails_example/script/plugin
89
+ examples/rails_example/script/process
90
+ examples/rails_example/script/process/inspector
91
+ examples/rails_example/script/process/reaper
92
+ examples/rails_example/script/process/spawner
93
+ examples/rails_example/script/runner
94
+ examples/rails_example/script/server
95
+ examples/rails_example/test
96
+ examples/rails_example/test/fixtures
97
+ examples/rails_example/test/functional
98
+ examples/rails_example/test/functional/api
99
+ examples/rails_example/test/functional/api/authenticated_controller_test.rb
100
+ examples/rails_example/test/functional/api/basic_controller_test.rb
101
+ examples/rails_example/test/integration
102
+ examples/rails_example/test/mocks
103
+ examples/rails_example/test/mocks/development
104
+ examples/rails_example/test/mocks/test
105
+ examples/rails_example/test/test_helper.rb
106
+ examples/rails_example/test/unit
107
+ examples/rails_example/tmp
108
+ examples/rails_example/tmp/cache
109
+ examples/rails_example/tmp/pids
110
+ examples/rails_example/tmp/sessions
111
+ examples/rails_example/tmp/sockets
112
+ examples/rails_example/vendor
113
+ examples/rails_example/vendor/plugins
114
+ examples/README.txt
data/README.txt CHANGED
@@ -1,17 +1,46 @@
1
- = YamlRpc -- simple RPC client
1
+ = YamlRpc -- advanced RPC client on YAML
2
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' )
3
+ Supports:
6
4
 
7
- # Result is YAML which is loaded and returned as object
8
- puts result['my_response_message']
5
+ * Data types (String, Regexp, Arrays, Hashes etc.)
6
+ * Passing images, PDFs and other binary data so easy you don't even think about it
7
+ * HTTP redirects
8
+ * HTTP Authentication
9
+
10
+ Simple to use:
11
+
12
+ client = YamlRpc::Client.new('http://localhost:3000/api/basic')
13
+
14
+ client.add_foo_bar( :foo => 3, :bar => 5 ) # -> { :result => 8 }
15
+ client.add(7, 11) # -> 18
16
+ client.upload(:image => open('image.gif', 'rb').read) # -> uploads image
17
+
18
+ Example add_foo_bar POSTs:
19
+
20
+ http://localhost:3000/api/basic/add_foo_bar
21
+
22
+ passing POST data:
23
+
24
+ yamlrpc=---%20%0A:foo:%203%0A:bar:%205%0A
25
+
26
+ which can be captured in any language like PHP, Java or Ruby, ie. Ruby on Rails:
27
+
28
+ class Api::BasicController < ApplicationController
29
+ def add_foo_bar
30
+ @yamlrpc = YAML.load(params[:yamlrpc])
31
+ render :text => (@yamlrpc[:foo] + @yamlrpc[:bar]).to_yaml
32
+ end
33
+ end
34
+
35
+ Result is returned as YAML as well and automatically decoded.
36
+
37
+ See /examples dir for more examples.
9
38
 
10
39
  == Download
11
40
 
12
- The latest version of Csv2sql can be found at
41
+ The latest version:
13
42
 
14
- * http://mirekrusin.com/ruby/yamlrpc
43
+ * http://svn.mirekrusin.com/ruby/yamlrpc/trunk
15
44
 
16
45
  == Installation
17
46
 
@@ -19,11 +48,11 @@ gem install yamlrpc
19
48
 
20
49
  == License
21
50
 
22
- Csv2sql is released under the LGPL license.
51
+ This library is released under the LGPL license.
23
52
 
24
53
  == Support
25
54
 
26
- The Csv2sql homepage is http://mirekrusin.com/ruby/yamlrpc
55
+ The homepage is located under http://www.rubyforge/projects/yamlrpc
27
56
 
28
57
  For other information, feel free to ask on the ruby-talk mailing list
29
58
  (which is mirrored to comp.lang.ruby) or contact mailto:ruby@mirekrusin.com
data/Rakefile CHANGED
@@ -1,23 +1,31 @@
1
-
2
- require 'rubygems'
3
- require 'hoe'
4
-
5
- $:.unshift(File.dirname(__FILE__) + "/lib")
6
- require 'yamlrpc'
7
-
8
- Hoe.new('YamlRpc', YamlRpc::VERSION) do |p|
9
- p.name = "yamlrpc"
10
- p.author = "Mirek Rusin"
11
- p.email = 'ruby@mirekrusin.com'
12
- p.summary = "YamlRpc is a simple RPC client based on YAML"
13
- p.description = "YamlRpc is a simple RPC client based on YAML"
14
- p.url = "http://rubyforge.com/projects/yamlrpc"
15
- p.clean_globs = ['test/actual'] # Remove this directory on "rake clean"
16
- p.remote_rdoc_dir = '' # Release to root
17
- p.changes = p.paragraphs_of('CHANGELOG', 0..1).join("\n\n")
18
- p.rsync_args << ' --exclude=statsvn/'
19
- # * extra_deps - An array of rubygem dependencies.
20
- end
21
-
22
- desc "Release and publish documentation"
23
- task :default => [:release, :publish_docs]
1
+
2
+ require 'rubygems'
3
+ require 'hoe'
4
+
5
+ $:.unshift(File.dirname(__FILE__) + "/lib")
6
+ require 'yamlrpc'
7
+
8
+ RUBYFORGE_PROJECT = 'yamlrpc'
9
+
10
+ Hoe.new('YamlRpc', YamlRpc::VERSION) do |p|
11
+ p.name = RUBYFORGE_PROJECT
12
+ p.author = "Mirek Rusin"
13
+ p.email = 'ruby@mirekrusin.com'
14
+ p.summary = "YamlRpc is a simple RPC client based on YAML"
15
+ p.description = "YamlRpc is a simple RPC client based on YAML"
16
+ p.url = "http://rubyforge.com/projects/#{RUBYFORGE_PROJECT}"
17
+ p.clean_globs = ['test/actual'] # Remove this directory on "rake clean"
18
+ p.remote_rdoc_dir = '' # Release to root
19
+ p.changes = p.paragraphs_of('CHANGELOG', 0..1).join("\n\n")
20
+ #p.rsync_args << ' --exclude=statsvn/'
21
+ # * extra_deps - An array of rubygem dependencies.
22
+ end
23
+
24
+ desc 'Publish RDoc to RubyForge via pscp'
25
+ task :publish_docs_via_pscp => [:clean, :docs] do
26
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
27
+ sh %{pscp -r doc/* #{config["username"]}@rubyforge.org:/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/}
28
+ end
29
+
30
+ desc "Release and publish documentation"
31
+ task :default => [:release, :publish_docs_via_pscp]
@@ -0,0 +1,8 @@
1
+
2
+ To launch rails_* tests run rails_test Ruby on Rails server first.
3
+
4
+ Make sure you've got sqlite3:
5
+
6
+ gem install sqlite3-ruby
7
+
8
+ and on Windows download http://www.sqlite.org/sqlitedll-3_5_9.zip and extrace to c:\Windows\System32
@@ -0,0 +1,5 @@
1
+
2
+ require 'pp'
3
+
4
+ $:.unshift "#{File.dirname(__FILE__)}/../lib"
5
+ require 'yamlrpc'
Binary file
@@ -0,0 +1,6 @@
1
+
2
+ require 'examples_helper'
3
+
4
+ client = YamlRpc::Client.new('http://localhost:3000/api/basic/')
5
+
6
+ puts client.add_foo_bar(:foo => 3, :bar => 5)
@@ -0,0 +1,6 @@
1
+
2
+ require 'examples_helper'
3
+
4
+ client = YamlRpc::Client.new('http://localhost:3000/api/basic/')
5
+
6
+ pp client.hello_world
@@ -0,0 +1,8 @@
1
+
2
+ require 'examples_helper'
3
+
4
+ client = YamlRpc::Client.new('http://localhost:3000/api/basic/')
5
+
6
+ response = client.hello_world_with_status
7
+ puts response[:status]
8
+ puts response[:message]
@@ -0,0 +1,6 @@
1
+
2
+ require 'examples_helper'
3
+
4
+ client = YamlRpc::Client.new('http://localhost:3000/api/basic/')
5
+
6
+ puts client.redirect_to_hello_world
@@ -0,0 +1,6 @@
1
+
2
+ require 'examples_helper'
3
+
4
+ client = YamlRpc::Client.new('http://localhost:3000/api/basic/')
5
+
6
+ puts client.redirect_twice_to_hello_world
@@ -0,0 +1,6 @@
1
+
2
+ require 'examples_helper'
3
+
4
+ client = YamlRpc::Client.new('http://localhost:3000/api/basic/')
5
+
6
+ pp client.unnamed_arguments(1, 2, :foo, 'bar')
@@ -0,0 +1,9 @@
1
+
2
+ require 'examples_helper'
3
+
4
+ client = YamlRpc::Client.new('http://localhost:3000/api/basic/')
5
+
6
+ pp client.upload_image({
7
+ :image => open('girlfriend.jpg', 'rb').read,
8
+ :save_as => 'julie.jpg'
9
+ })
@@ -0,0 +1,203 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application and persistence framework that includes everything
4
+ needed to create database-backed web-applications according to the
5
+ Model-View-Control pattern of separation. This pattern splits the view (also
6
+ called the presentation) into "dumb" templates that are primarily responsible
7
+ for inserting pre-built data in between HTML tags. The model contains the
8
+ "smart" domain objects (such as Account, Product, Person, Post) that holds all
9
+ the business logic and knows how to persist themselves to a database. The
10
+ controller handles the incoming requests (such as Save New Account, Update
11
+ Product, Show Post) by manipulating the model and directing data to the view.
12
+
13
+ In Rails, the model is handled by what's called an object-relational mapping
14
+ layer entitled Active Record. This layer allows you to present the data from
15
+ database rows as objects and embellish these data objects with business logic
16
+ methods. You can read more about Active Record in
17
+ link:files/vendor/rails/activerecord/README.html.
18
+
19
+ The controller and view are handled by the Action Pack, which handles both
20
+ layers by its two parts: Action View and Action Controller. These two layers
21
+ are bundled in a single package due to their heavy interdependence. This is
22
+ unlike the relationship between the Active Record and Action Pack that is much
23
+ more separate. Each of these packages can be used independently outside of
24
+ Rails. You can read more about Action Pack in
25
+ link:files/vendor/rails/actionpack/README.html.
26
+
27
+
28
+ == Getting Started
29
+
30
+ 1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
31
+ and your application name. Ex: rails myapp
32
+ (If you've downloaded Rails in a complete tgz or zip, this step is already done)
33
+ 2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
34
+ 3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
35
+ 4. Follow the guidelines to start developing your application
36
+
37
+
38
+ == Web Servers
39
+
40
+ By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
41
+ Rails will use WEBrick, the webserver that ships with Ruby. When you run script/server,
42
+ Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
43
+ that you can always get up and running quickly.
44
+
45
+ Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
46
+ suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
47
+ getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
48
+ More info at: http://mongrel.rubyforge.org
49
+
50
+ If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
51
+ Mongrel and WEBrick and also suited for production use, but requires additional
52
+ installation and currently only works well on OS X/Unix (Windows users are encouraged
53
+ to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
54
+ http://www.lighttpd.net.
55
+
56
+ And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
57
+ web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
58
+ for production.
59
+
60
+ But of course its also possible to run Rails on any platform that supports FCGI.
61
+ Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
62
+ please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
63
+
64
+
65
+ == Debugging Rails
66
+
67
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
68
+ will help you debug it and get it back on the rails.
69
+
70
+ First area to check is the application log files. Have "tail -f" commands running
71
+ on the server.log and development.log. Rails will automatically display debugging
72
+ and runtime information to these files. Debugging info will also be shown in the
73
+ browser on requests from 127.0.0.1.
74
+
75
+ You can also log your own messages directly into the log file from your code using
76
+ the Ruby logger class from inside your controllers. Example:
77
+
78
+ class WeblogController < ActionController::Base
79
+ def destroy
80
+ @weblog = Weblog.find(params[:id])
81
+ @weblog.destroy
82
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
83
+ end
84
+ end
85
+
86
+ The result will be a message in your log file along the lines of:
87
+
88
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
89
+
90
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
91
+
92
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
93
+
94
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
95
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
96
+
97
+ These two online (and free) books will bring you up to speed on the Ruby language
98
+ and also on programming in general.
99
+
100
+
101
+ == Debugger
102
+
103
+ Debugger support is available through the debugger command when you start your Mongrel or
104
+ Webrick server with --debugger. This means that you can break out of execution at any point
105
+ in the code, investigate and change the model, AND then resume execution! Example:
106
+
107
+ class WeblogController < ActionController::Base
108
+ def index
109
+ @posts = Post.find(:all)
110
+ debugger
111
+ end
112
+ end
113
+
114
+ So the controller will accept the action, run the first line, then present you
115
+ with a IRB prompt in the server window. Here you can do things like:
116
+
117
+ >> @posts.inspect
118
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
119
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
120
+ >> @posts.first.title = "hello from a debugger"
121
+ => "hello from a debugger"
122
+
123
+ ...and even better is that you can examine how your runtime objects actually work:
124
+
125
+ >> f = @posts.first
126
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
127
+ >> f.
128
+ Display all 152 possibilities? (y or n)
129
+
130
+ Finally, when you're ready to resume execution, you enter "cont"
131
+
132
+
133
+ == Console
134
+
135
+ You can interact with the domain model by starting the console through <tt>script/console</tt>.
136
+ Here you'll have all parts of the application configured, just like it is when the
137
+ application is running. You can inspect domain models, change values, and save to the
138
+ database. Starting the script without arguments will launch it in the development environment.
139
+ Passing an argument will specify a different environment, like <tt>script/console production</tt>.
140
+
141
+ To reload your controllers and models after launching the console run <tt>reload!</tt>
142
+
143
+
144
+ == Description of Contents
145
+
146
+ app
147
+ Holds all the code that's specific to this particular application.
148
+
149
+ app/controllers
150
+ Holds controllers that should be named like weblogs_controller.rb for
151
+ automated URL mapping. All controllers should descend from ApplicationController
152
+ which itself descends from ActionController::Base.
153
+
154
+ app/models
155
+ Holds models that should be named like post.rb.
156
+ Most models will descend from ActiveRecord::Base.
157
+
158
+ app/views
159
+ Holds the template files for the view that should be named like
160
+ weblogs/index.erb for the WeblogsController#index action. All views use eRuby
161
+ syntax.
162
+
163
+ app/views/layouts
164
+ Holds the template files for layouts to be used with views. This models the common
165
+ header/footer method of wrapping views. In your views, define a layout using the
166
+ <tt>layout :default</tt> and create a file named default.erb. Inside default.erb,
167
+ call <% yield %> to render the view using this layout.
168
+
169
+ app/helpers
170
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
171
+ for you automatically when using script/generate for controllers. Helpers can be used to
172
+ wrap functionality for your views into methods.
173
+
174
+ config
175
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
176
+
177
+ db
178
+ Contains the database schema in schema.rb. db/migrate contains all
179
+ the sequence of Migrations for your schema.
180
+
181
+ doc
182
+ This directory is where your application documentation will be stored when generated
183
+ using <tt>rake doc:app</tt>
184
+
185
+ lib
186
+ Application specific libraries. Basically, any kind of custom code that doesn't
187
+ belong under controllers, models, or helpers. This directory is in the load path.
188
+
189
+ public
190
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
191
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
192
+ set as the DOCUMENT_ROOT of your web server.
193
+
194
+ script
195
+ Helper scripts for automation and generation.
196
+
197
+ test
198
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
199
+ test files will be generated for you and placed in this directory.
200
+
201
+ vendor
202
+ External libraries that the application depends on. Also includes the plugins subdirectory.
203
+ This directory is in the load path.
@@ -0,0 +1,10 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ require 'tasks/rails'
@@ -0,0 +1,2 @@
1
+ class Api::AuthenticatedController < ApplicationController
2
+ end
@@ -0,0 +1,68 @@
1
+ class Api::BasicController < ApplicationController
2
+
3
+ before_filter :set_yamlrpc
4
+
5
+ # Simple hellow world example
6
+ def hello_world
7
+ render :text => 'Hello World!'.to_yaml
8
+ end
9
+
10
+ # Hello world example with status and message response
11
+ def hello_world_with_status
12
+ render :text => {
13
+ :status => :ok,
14
+ :message => 'Hello World!'
15
+ }.to_yaml
16
+ end
17
+
18
+ # Unnamed arguments example, ie: client.unnamed_arguments(1, 2, 'foo', 'bar')
19
+ def unnamed_arguments
20
+ render :text => {
21
+ :response => @yamlrpc.map { |e| "#{e.to_s} in response!" }
22
+ }.to_yaml
23
+ end
24
+
25
+ # Add two arguments and return result example
26
+ def add_foo_bar
27
+ render :text => (@yamlrpc[:foo] + @yamlrpc[:bar]).to_yaml
28
+ end
29
+
30
+ # Upload binary image example
31
+ # Uploaded image is saved to #{RAILS_ROOT}/public/images/#{@yamlrpc[:save_as]}
32
+ # Returns:
33
+ # * <tt>:status</tt> :ok on success, :error on error
34
+ # * <tt>:message</tt> Descriptive response message
35
+ def upload_image
36
+ begin
37
+ file = open("#{RAILS_ROOT}/public/images/#{@yamlrpc[:save_as]}", "wb")
38
+ file.write @yamlrpc[:image]
39
+ file.close
40
+ status = :ok
41
+ message = 'Image uploaded successfully'
42
+ rescue StandardError => ex
43
+ status = :error
44
+ message = ex.message
45
+ end
46
+ render :text => {
47
+ :status => status,
48
+ :message => message
49
+ }.to_yaml
50
+ end
51
+
52
+ def redirect_to_hello_world
53
+ redirect_to :action => 'hello_world'
54
+ end
55
+
56
+ def redirect_twice_to_hello_world
57
+ redirect_to :action => 'redirect_to_hello_world'
58
+ end
59
+
60
+ protected
61
+
62
+ def set_yamlrpc
63
+ if request.post? && params[:yamlrpc]
64
+ @yamlrpc = YAML.load(params[:yamlrpc] || "--- \n")
65
+ end
66
+ end
67
+
68
+ end
@@ -0,0 +1,10 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+
7
+ # See ActionController::RequestForgeryProtection for details
8
+ # Uncomment the :secret if you're not using the cookie session store
9
+ protect_from_forgery # :secret => '49596d8b57f7619503bc50f5331b44bd'
10
+ end
@@ -0,0 +1,2 @@
1
+ module Api::AuthenticatedHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module Api::BasicHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end