gon_responder 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +102 -0
- data/Rakefile +2 -0
- data/gon_responder.gemspec +26 -0
- data/lib/gon_responder/version.rb +3 -0
- data/lib/gon_responder.rb +28 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 992c5b9ca21c3acc174a2712e44d6f78038f99e1
|
4
|
+
data.tar.gz: 45abff58c3aef3d9a7e7eeaf780da75865917ee7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32a7e5c2ee7f3dab4f32cf1aee64f0db78e2904f626a70e7cd626441a573772fb709bd19a95b901ae60ba6572c5724d7652ea7f546428557c52040a9e2dffc13
|
7
|
+
data.tar.gz: efb5bcd27d3622e152bd254c103349ec8553b16aef77ebeea8752d8b92a690e37e6b2c9f9d83d348929575c9cf3a37dbf3b76554601cc31cf6a84004acc86b55
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 kr3ssh
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# GonResponder
|
2
|
+
|
3
|
+
GonResponder module for responders gem
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'gon_responder'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install gon_responder
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Add GonResponder module to your ApplicationResponder like this:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
class ApplicationResponder < ActionController::Responder
|
27
|
+
|
28
|
+
include Responders::FlashResponder
|
29
|
+
include Responders::HttpCacheResponder
|
30
|
+
include Responders::GonResponder
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Now you're ready to respond_with gon:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
class PostsController < ApplicationController
|
38
|
+
respond_to :html, :json
|
39
|
+
|
40
|
+
def index
|
41
|
+
@posts = Post.all
|
42
|
+
respond_with @posts, gon: { rabl: { as: :posts }}
|
43
|
+
end
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
You should add `gon` options hash to respond_with.
|
48
|
+
|
49
|
+
#### Example
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
respond_with @posts, gon: { :posts= => @posts }
|
53
|
+
```
|
54
|
+
Which equals to
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
gon.posts = @posts
|
58
|
+
```
|
59
|
+
|
60
|
+
#### Another example
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
respond_with @posts, gon: { push: { user_id: 1, user_role: "admin" } }
|
64
|
+
```
|
65
|
+
|
66
|
+
Which equals to
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
gon.push({ :user_id => 1, :user_role => "admin" })
|
70
|
+
```
|
71
|
+
|
72
|
+
#### RablRails example
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
respond_with @posts, gon: { rabl: {} }
|
76
|
+
```
|
77
|
+
|
78
|
+
Which equals to
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
gon.rabl
|
82
|
+
```
|
83
|
+
|
84
|
+
#### Another RablRails example
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
respond_with @posts, gon: { rabl: { template: 'app/views/posts/index.json.rabl', as: :posts } }
|
88
|
+
```
|
89
|
+
|
90
|
+
Which equals to
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
gon.rabl template: 'app/views/posts/index.json.rabl', as: :posts
|
94
|
+
```
|
95
|
+
|
96
|
+
## Contributing
|
97
|
+
|
98
|
+
1. Fork it ( https://github.com/kressh/gon_responder/fork )
|
99
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
100
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
101
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
102
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gon_responder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gon_responder"
|
8
|
+
spec.version = GonResponder::VERSION
|
9
|
+
spec.authors = ["Sergey Besedin"]
|
10
|
+
spec.email = ["kr3ssh@gmail.com"]
|
11
|
+
spec.summary = %q{GonResponder for responders gem}
|
12
|
+
spec.description = %q{respond_with gon}
|
13
|
+
spec.homepage = "https://github.com/kressh/gon_responder"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'responders', '~> 2.0'
|
22
|
+
spec.add_dependency 'gon', '~> 5.0'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "gon_responder/version"
|
2
|
+
|
3
|
+
module Responders
|
4
|
+
module GonResponder
|
5
|
+
def initialize(controller, resources, options={})
|
6
|
+
super
|
7
|
+
@gon = options.delete(:gon)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_html
|
11
|
+
set_gon! if @gon
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def set_gon!
|
18
|
+
case @gon
|
19
|
+
when Symbol, String
|
20
|
+
controller.gon.send(@gon)
|
21
|
+
when Hash
|
22
|
+
@gon.each do |meth, opts|
|
23
|
+
controller.gon.send(meth, opts)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gon_responder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergey Besedin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: responders
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gon
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: respond_with gon
|
70
|
+
email:
|
71
|
+
- kr3ssh@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- gon_responder.gemspec
|
82
|
+
- lib/gon_responder.rb
|
83
|
+
- lib/gon_responder/version.rb
|
84
|
+
homepage: https://github.com/kressh/gon_responder
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.2.2
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: GonResponder for responders gem
|
108
|
+
test_files: []
|