simple_rest 0.0.5 → 0.0.6
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.
- data/Gemfile +4 -0
- data/Gemfile.lock +76 -0
- data/README.rdoc +4 -3
- data/lib/simple_rest/action_controller_responder_methods.rb +28 -24
- data/lib/simple_rest.rb +2 -2
- metadata +35 -50
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.11)
|
6
|
+
actionpack (= 3.0.11)
|
7
|
+
mail (~> 2.2.19)
|
8
|
+
actionpack (3.0.11)
|
9
|
+
activemodel (= 3.0.11)
|
10
|
+
activesupport (= 3.0.11)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.11)
|
19
|
+
activesupport (= 3.0.11)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.11)
|
23
|
+
activemodel (= 3.0.11)
|
24
|
+
activesupport (= 3.0.11)
|
25
|
+
arel (~> 2.0.10)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.11)
|
28
|
+
activemodel (= 3.0.11)
|
29
|
+
activesupport (= 3.0.11)
|
30
|
+
activesupport (3.0.11)
|
31
|
+
arel (2.0.10)
|
32
|
+
builder (2.1.2)
|
33
|
+
erubis (2.6.6)
|
34
|
+
abstract (>= 1.0.0)
|
35
|
+
i18n (0.5.0)
|
36
|
+
json (1.6.1)
|
37
|
+
mail (2.2.19)
|
38
|
+
activesupport (>= 2.3.6)
|
39
|
+
i18n (>= 0.4.0)
|
40
|
+
mime-types (~> 1.16)
|
41
|
+
treetop (~> 1.4.8)
|
42
|
+
mime-types (1.17.2)
|
43
|
+
polyglot (0.3.3)
|
44
|
+
rack (1.2.5)
|
45
|
+
rack-mount (0.6.14)
|
46
|
+
rack (>= 1.0.0)
|
47
|
+
rack-test (0.5.7)
|
48
|
+
rack (>= 1.0)
|
49
|
+
rails (3.0.11)
|
50
|
+
actionmailer (= 3.0.11)
|
51
|
+
actionpack (= 3.0.11)
|
52
|
+
activerecord (= 3.0.11)
|
53
|
+
activeresource (= 3.0.11)
|
54
|
+
activesupport (= 3.0.11)
|
55
|
+
bundler (~> 1.0)
|
56
|
+
railties (= 3.0.11)
|
57
|
+
railties (3.0.11)
|
58
|
+
actionpack (= 3.0.11)
|
59
|
+
activesupport (= 3.0.11)
|
60
|
+
rake (>= 0.8.7)
|
61
|
+
rdoc (~> 3.4)
|
62
|
+
thor (~> 0.14.4)
|
63
|
+
rake (0.9.2.2)
|
64
|
+
rdoc (3.12)
|
65
|
+
json (~> 1.4)
|
66
|
+
thor (0.14.6)
|
67
|
+
treetop (1.4.10)
|
68
|
+
polyglot
|
69
|
+
polyglot (>= 0.3.1)
|
70
|
+
tzinfo (0.3.31)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
rails (<= 3.1)
|
data/README.rdoc
CHANGED
@@ -34,15 +34,16 @@ Example:
|
|
34
34
|
def action
|
35
35
|
#fetch result
|
36
36
|
options = {:status=>:ok,:serialize_opts=>some options will be passed to to_json or to_xml}
|
37
|
-
|
37
|
+
respond_with result,options
|
38
38
|
end
|
39
39
|
|
40
40
|
|
41
41
|
== CHANGE LOG
|
42
42
|
|
43
|
-
* 0.0.
|
44
|
-
* 0.0.3 propogate opts to render method if html
|
43
|
+
* 0.0.6 upgrade to Rails 3.1
|
45
44
|
* 0.0.4 upgrade to Rails 3 (no backward compatibility)
|
45
|
+
* 0.0.3 propogate opts to render method if html
|
46
|
+
* 0.0.2 add json request magic parameter support
|
46
47
|
|
47
48
|
== MORE
|
48
49
|
|
@@ -1,28 +1,35 @@
|
|
1
1
|
module SimpleRest
|
2
2
|
module ActionControllerResponderMethods
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
alias_method :default_to_html, :to_html
|
7
|
+
|
8
|
+
def to_html
|
6
9
|
begin
|
7
|
-
|
10
|
+
simple_to_html
|
8
11
|
rescue ActionView::MissingTemplate
|
9
|
-
default_to_html
|
12
|
+
default_to_html
|
10
13
|
end
|
11
14
|
end
|
15
|
+
|
16
|
+
def to_js
|
17
|
+
simple_to_js
|
18
|
+
end
|
12
19
|
end
|
13
20
|
|
14
|
-
def
|
21
|
+
def simple_to_js
|
15
22
|
status = options[:status] || :ok
|
16
23
|
render :json => resource.to_json(options[:serialize_opts] || {}), :status => status
|
17
24
|
end
|
18
25
|
|
19
26
|
def to_yaml
|
20
27
|
status = options[:status] || :ok
|
21
|
-
render :partial=> 'shared/inspect', :content_type =>'text/html', :locals => {:data => resource}, :status=> status
|
28
|
+
render :partial => 'shared/inspect', :content_type => 'text/html', :locals => {:data => resource}, :status => status
|
22
29
|
end
|
23
30
|
|
24
31
|
def to_pdf
|
25
|
-
render (options[:pdf_opts] || {}).merge(:layout=>false)
|
32
|
+
render (options[:pdf_opts] || {}).merge(:layout => false)
|
26
33
|
end
|
27
34
|
|
28
35
|
def to_xml
|
@@ -32,29 +39,26 @@ module SimpleRest
|
|
32
39
|
|
33
40
|
def to_jsonp
|
34
41
|
text = build_jsonp_message(resource, options)
|
35
|
-
render ({:content_type => :js, :text => text}.merge(options.merge(:status
|
42
|
+
render ({:content_type => :js, :text => text}.merge(options.merge(:status => :ok)))
|
36
43
|
end
|
37
44
|
|
38
|
-
def
|
45
|
+
def simple_to_html
|
39
46
|
render options
|
40
47
|
end
|
41
48
|
|
42
49
|
def build_jsonp_message(data, options)
|
43
|
-
message = {:status=>options[:status] || 200, :data=>data}
|
44
|
-
json
|
50
|
+
message = {:status => options[:status] || 200, :data => data}
|
51
|
+
json = message.to_json(options)
|
45
52
|
callback, variable = controller.params[:callback], controller.params[:variable]
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
json
|
56
|
-
end
|
57
|
-
end
|
53
|
+
if callback && variable
|
54
|
+
"var #{variable} = #{json};\n#{callback}(#{variable});"
|
55
|
+
elsif variable
|
56
|
+
"var #{variable} = #{json};"
|
57
|
+
elsif callback
|
58
|
+
"#{callback}(#{json});"
|
59
|
+
else
|
60
|
+
json
|
61
|
+
end
|
58
62
|
end
|
59
63
|
end
|
60
64
|
end
|
data/lib/simple_rest.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
module SimpleRest
|
4
|
-
VERSION = '0.0.
|
4
|
+
VERSION = '0.0.6'
|
5
5
|
autoload :ActionControllerMethods, 'simple_rest/action_controller_methods'
|
6
6
|
autoload :ActionControllerResponderMethods, 'simple_rest/action_controller_responder_methods'
|
7
7
|
class << self
|
@@ -22,5 +22,5 @@ module SimpleRest
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
require "rails/railtie"
|
25
|
+
require "rails/railtie"
|
26
26
|
require "simple_rest/railtie"
|
metadata
CHANGED
@@ -1,85 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_rest
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
version: 0.0.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- niquola,smecsia,mirasrael
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rails
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &13691780 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 3
|
30
|
-
- 0
|
31
|
-
version: "3.0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
32
22
|
type: :runtime
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *13691780
|
34
25
|
description:
|
35
26
|
email: niquola@gmail.com,smecsia@gmail.com,alexander.i.bondarev@gmail.com
|
36
27
|
executables: []
|
37
|
-
|
38
28
|
extensions: []
|
39
|
-
|
40
|
-
extra_rdoc_files:
|
29
|
+
extra_rdoc_files:
|
41
30
|
- README.rdoc
|
42
|
-
files:
|
31
|
+
files:
|
43
32
|
- README.rdoc
|
44
33
|
- Rakefile
|
34
|
+
- Gemfile
|
35
|
+
- Gemfile.lock
|
36
|
+
- lib/simple_rest.rb
|
45
37
|
- lib/simple_rest/railtie.rb
|
46
38
|
- lib/simple_rest/action_controller_methods.rb
|
47
39
|
- lib/simple_rest/action_controller_responder_methods.rb
|
48
|
-
- lib/simple_rest.rb
|
49
|
-
- test/simple_rest_test.rb
|
50
40
|
- test/log/development.log
|
41
|
+
- test/simple_rest_test.rb
|
51
42
|
- test/test_helper.rb
|
52
|
-
has_rdoc: true
|
53
43
|
homepage:
|
54
44
|
licenses: []
|
55
|
-
|
56
45
|
post_install_message:
|
57
46
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
47
|
+
require_paths:
|
60
48
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
50
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
segments:
|
67
56
|
- 0
|
68
|
-
|
69
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
hash: 347343492354608195
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
59
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
- 0
|
76
|
-
version: "0"
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
77
64
|
requirements: []
|
78
|
-
|
79
65
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.8.10
|
81
67
|
signing_key:
|
82
68
|
specification_version: 3
|
83
69
|
summary: ActionControllers helpers for restful rails
|
84
70
|
test_files: []
|
85
|
-
|