jpbuilder 0.1.0 → 0.2.1

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.
@@ -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!
@@ -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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ Bundler::GemHelper.install_tasks
@@ -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.0"
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
- if callback = params[:callback]
16
+ callback = params[:callback] || JPbuilderHandler.default_callback
17
+ if callback.present?
16
18
  "\#{callback}(\#{result});"
17
19
  else
18
20
  result
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.0
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-04-06 00:00:00.000000000 Z
12
+ date: 2012-06-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jbuilder
16
- requirement: &70344064915660 !ruby/object:Gem::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: *70344064915660
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
- - ./Gemfile
33
- - ./jpbuilder.gemspec
34
- - ./lib/jpbuilder-handler.rb
35
- - ./lib/jpbuilder.rb
36
- - ./LICENSE
37
- - ./README.md
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