jpbuilder 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jpbuilder.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jason Webb
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
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
data/jpbuilder.gemspec ADDED
@@ -0,0 +1,14 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Jason Webb"]
5
+ gem.email = ["bigjasonwebb@gmail.com"]
6
+ gem.summary = "A small template extension to add JSONP support to Jbuilder."
7
+ gem.version = "0.1.0"
8
+ gem.homepage = "https://github.com/bigjason/jpbuilder"
9
+ gem.files = Dir["#{File.dirname(__FILE__)}/**/*"]
10
+ gem.name = "jpbuilder"
11
+ gem.require_paths = ["lib"]
12
+
13
+ gem.add_dependency "jbuilder"
14
+ end
@@ -0,0 +1,25 @@
1
+ require "jbuilder"
2
+
3
+ class JPbuilderHandler
4
+ cattr_accessor :default_format
5
+ self.default_format = Mime::JSON
6
+
7
+ def self.call(template)
8
+ %{
9
+ if defined?(json)
10
+ #{template.source}
11
+ else
12
+ result = JbuilderTemplate.encode(self) do |json|
13
+ #{template.source}
14
+ end
15
+ if callback = params[:callback]
16
+ "\#{callback}(\#{result});"
17
+ else
18
+ result
19
+ end
20
+ end
21
+ }
22
+ end
23
+ end
24
+
25
+ ActionView::Template.register_template_handler :jpbuilder, JPbuilderHandler
data/lib/jpbuilder.rb ADDED
@@ -0,0 +1 @@
1
+ require "jpbuilder-handler" if defined?(ActionView::Template)
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jpbuilder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Webb
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jbuilder
16
+ requirement: &70344064915660 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70344064915660
25
+ description:
26
+ email:
27
+ - bigjasonwebb@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - ./Gemfile
33
+ - ./jpbuilder.gemspec
34
+ - ./lib/jpbuilder-handler.rb
35
+ - ./lib/jpbuilder.rb
36
+ - ./LICENSE
37
+ - ./README.md
38
+ homepage: https://github.com/bigjason/jpbuilder
39
+ licenses: []
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.10
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: A small template extension to add JSONP support to Jbuilder.
62
+ test_files: []