jpbuilder 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{Gemfile → Users/jwebb/src/bigjason/jpbuilder/Gemfile} +0 -0
- data/Users/jwebb/src/bigjason/jpbuilder/Gemfile.lock +24 -0
- data/{LICENSE → Users/jwebb/src/bigjason/jpbuilder/LICENSE} +0 -0
- data/Users/jwebb/src/bigjason/jpbuilder/README.md +58 -0
- data/Users/jwebb/src/bigjason/jpbuilder/Rakefile +8 -0
- data/Users/jwebb/src/bigjason/jpbuilder/jpbuilder-0.1.0.gem +0 -0
- data/{jpbuilder.gemspec → Users/jwebb/src/bigjason/jpbuilder/jpbuilder.gemspec} +1 -1
- data/{lib → Users/jwebb/src/bigjason/jpbuilder/lib}/jpbuilder-handler.rb +4 -2
- data/{lib → Users/jwebb/src/bigjason/jpbuilder/lib}/jpbuilder.rb +0 -0
- metadata +19 -10
- data/README.md +0 -29
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jpbuilder (0.2.1)
|
5
|
+
jbuilder
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (3.2.6)
|
11
|
+
i18n (~> 0.6)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
blankslate (2.1.2.4)
|
14
|
+
i18n (0.6.0)
|
15
|
+
jbuilder (0.4.0)
|
16
|
+
activesupport (>= 3.0.0)
|
17
|
+
blankslate (>= 2.1.2.4)
|
18
|
+
multi_json (1.3.6)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
jpbuilder!
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# jpbuilder
|
2
|
+
|
3
|
+
A small extension to the excellent [jbuilder](https://github.com/rails/jbuilder)
|
4
|
+
library that outputs JSONP using a specified callback.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'jpbuilder'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install jpbuilder
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Install in your gem file and then just create templates with the extension
|
23
|
+
`.jpbuilder` and use the normal Jbuilder DSL. The template will use the
|
24
|
+
callback as specified in the "callback" url parameter. If none is provided then
|
25
|
+
the regular JSON format will be returned.
|
26
|
+
|
27
|
+
### Setting a default callback
|
28
|
+
|
29
|
+
You can set a global callback to be used in the absence of a callback listed in
|
30
|
+
the `params` hash, by setting the `JPbuilderHandler.default_callback` variable
|
31
|
+
in an initializer:
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
# config/initilizers/jpbuilder.rb
|
35
|
+
JPbuilderHandler.default_callback = "myJsCallback"
|
36
|
+
```
|
37
|
+
|
38
|
+
To disable the auto callback simply set `JPbuilderHandler.default_callback` to
|
39
|
+
`null` or `""`.
|
40
|
+
|
41
|
+
``` ruby
|
42
|
+
# config/initilizers/jpbuilder.rb
|
43
|
+
JPbuilderHandler.default_callback = nil
|
44
|
+
```
|
45
|
+
|
46
|
+
**Note**: `nil` is the default value.
|
47
|
+
|
48
|
+
## TODO
|
49
|
+
|
50
|
+
* Find a decent way to test.
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
1. Fork it
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
+
5. Create new Pull Request
|
Binary file
|
@@ -4,7 +4,7 @@ Gem::Specification.new do |gem|
|
|
4
4
|
gem.authors = ["Jason Webb"]
|
5
5
|
gem.email = ["bigjasonwebb@gmail.com"]
|
6
6
|
gem.summary = "A small template extension to add JSONP support to Jbuilder."
|
7
|
-
gem.version = "0.1
|
7
|
+
gem.version = "0.2.1"
|
8
8
|
gem.homepage = "https://github.com/bigjason/jpbuilder"
|
9
9
|
gem.files = Dir["#{File.dirname(__FILE__)}/**/*"]
|
10
10
|
gem.name = "jpbuilder"
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require "jbuilder"
|
2
2
|
|
3
3
|
class JPbuilderHandler
|
4
|
-
cattr_accessor :default_format
|
4
|
+
cattr_accessor :default_format, :default_callback
|
5
5
|
self.default_format = Mime::JSON
|
6
|
+
self.default_callback = nil
|
6
7
|
|
7
8
|
def self.call(template)
|
8
9
|
%{
|
@@ -12,7 +13,8 @@ class JPbuilderHandler
|
|
12
13
|
result = JbuilderTemplate.encode(self) do |json|
|
13
14
|
#{template.source}
|
14
15
|
end
|
15
|
-
|
16
|
+
callback = params[:callback] || JPbuilderHandler.default_callback
|
17
|
+
if callback.present?
|
16
18
|
"\#{callback}(\#{result});"
|
17
19
|
else
|
18
20
|
result
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jpbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jbuilder
|
16
|
-
requirement: &
|
16
|
+
requirement: &70181545303820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70181545303820
|
25
25
|
description:
|
26
26
|
email:
|
27
27
|
- bigjasonwebb@gmail.com
|
@@ -29,12 +29,15 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
|
-
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
32
|
+
- /Users/jwebb/src/bigjason/jpbuilder/Gemfile
|
33
|
+
- /Users/jwebb/src/bigjason/jpbuilder/Gemfile.lock
|
34
|
+
- /Users/jwebb/src/bigjason/jpbuilder/jpbuilder-0.1.0.gem
|
35
|
+
- /Users/jwebb/src/bigjason/jpbuilder/jpbuilder.gemspec
|
36
|
+
- /Users/jwebb/src/bigjason/jpbuilder/lib/jpbuilder-handler.rb
|
37
|
+
- /Users/jwebb/src/bigjason/jpbuilder/lib/jpbuilder.rb
|
38
|
+
- /Users/jwebb/src/bigjason/jpbuilder/LICENSE
|
39
|
+
- /Users/jwebb/src/bigjason/jpbuilder/Rakefile
|
40
|
+
- /Users/jwebb/src/bigjason/jpbuilder/README.md
|
38
41
|
homepage: https://github.com/bigjason/jpbuilder
|
39
42
|
licenses: []
|
40
43
|
post_install_message:
|
@@ -47,12 +50,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
50
|
- - ! '>='
|
48
51
|
- !ruby/object:Gem::Version
|
49
52
|
version: '0'
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
hash: -3969643636571762822
|
50
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
57
|
none: false
|
52
58
|
requirements:
|
53
59
|
- - ! '>='
|
54
60
|
- !ruby/object:Gem::Version
|
55
61
|
version: '0'
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
hash: -3969643636571762822
|
56
65
|
requirements: []
|
57
66
|
rubyforge_project:
|
58
67
|
rubygems_version: 1.8.10
|
data/README.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Jpbuilder
|
2
|
-
|
3
|
-
A small extension to the excellent Jbuilder library that outputs JSONP using a specified callback.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'jpbuilder'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install jpbuilder
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
Install in your gem file and then just create templates with the extension `.jpbuilder`. The template will use name the callback whatever is specified in the "callback" url parameter.
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|