amos 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +58 -5
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -3,12 +3,15 @@
|
|
3
3
|
AMOS is a rails plugin that provides a simple server that uses the url to decide which model to deliver. It is intended for
|
4
4
|
front-end applications that use something like javascriptMVC.
|
5
5
|
|
6
|
-
E.g. If the incoming request is /recipe it executes the index action which does a find(:all)
|
6
|
+
E.g. If the incoming request is /recipe it executes the index action which does a find(:all) on the Recipe model.
|
7
7
|
|
8
8
|
== Supported actions
|
9
9
|
|
10
10
|
:get => "/user" returns array of all users
|
11
|
+
:get => "/user?fields=name,email" returns only the name and email attributes
|
11
12
|
:get => "/users/1" returns record for user 1
|
13
|
+
:get => "/users/1?fields=name,email" returns only the name and email attributes for user 1
|
14
|
+
:get => "/users/1?associations=posts" returns the record for user plus any post
|
12
15
|
:delete => "/users/1" deletes record 1 from users, returns success => true / false
|
13
16
|
:put => "/users/1" + form data. Updates user record 1. Returns success => true / false
|
14
17
|
:post => "/users" + form data. Returns details of new record on success, or errors array on failure
|
@@ -17,8 +20,58 @@ E.g. If the incoming request is /recipe it executes the index action which does
|
|
17
20
|
|
18
21
|
Distributed under the MIT License, all rights reserved 2011 Geoff Drake
|
19
22
|
|
23
|
+
== Installation
|
24
|
+
Create a rails application as normal using:
|
25
|
+
|
26
|
+
rails create MyApp
|
27
|
+
|
28
|
+
Add the following line to your Gemfile
|
29
|
+
|
30
|
+
gem 'amos'
|
31
|
+
|
32
|
+
Run
|
33
|
+
bundle install
|
34
|
+
|
35
|
+
Amos uses cancan[https://github.com/ryanb/cancan] for its security checking so you need to add the following class in *app/models/ability.rb*
|
36
|
+
|
37
|
+
class Ability
|
38
|
+
include CanCan::Ability
|
39
|
+
|
40
|
+
def initialize(user)
|
41
|
+
can :manage, :all
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Replace the code inside the initialize with your requirements. There is a skeleton class in lib/app/models/ability.rb, so
|
46
|
+
if you are getting authorisation errors you have not overridden that version.
|
47
|
+
|
48
|
+
Cancan also needs access to a method called current_user in the controllers. If you are using devise or similar
|
49
|
+
this should automatically be available.
|
50
|
+
|
51
|
+
If not you will need to define the following in your Applicationcontroller class:
|
52
|
+
|
53
|
+
class ApplicationController < ActionController::Base
|
54
|
+
def current_user
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
If you are using user authentication replace the nil return with the current user record.
|
60
|
+
|
61
|
+
Finally create some models that match the code you have on the front-end.
|
62
|
+
|
63
|
+
rails g model recipes name:string description:string
|
64
|
+
|
65
|
+
And start the server
|
66
|
+
|
67
|
+
rails s
|
68
|
+
|
69
|
+
Your models should now be available on /recipe etc.
|
70
|
+
|
71
|
+
Take a look at spec/controllers/amos_controller_spec.rb and test/dummy/features/amos.feature for some examples of accessing
|
72
|
+
the data and what is returned.
|
73
|
+
|
74
|
+
|
20
75
|
== Thing to to
|
21
|
-
*
|
22
|
-
* Add
|
23
|
-
* Add security
|
24
|
-
* More tests against a javascriptMVC application
|
76
|
+
* More tests against a javascriptMVC application
|
77
|
+
* Add code to support rails dynamic finders.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Geoff Drake
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-05 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -49,7 +49,7 @@ files:
|
|
49
49
|
- Rakefile
|
50
50
|
- README.rdoc
|
51
51
|
has_rdoc: true
|
52
|
-
homepage:
|
52
|
+
homepage: http://rubygems.org/gems/amos
|
53
53
|
licenses: []
|
54
54
|
|
55
55
|
post_install_message:
|