Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for Rails 3.2.5 #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,82 +1,82 @@
PATH
remote: .
specs:
prototype-rails (3.2.1)
rails (~> 3.2)
prototype-rails (3.2.5)
rails (>= 3.2.5)

GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.0)
actionpack (= 3.2.0)
mail (~> 2.4.0)
actionpack (3.2.0)
activemodel (= 3.2.0)
activesupport (= 3.2.0)
actionmailer (3.2.6)
actionpack (= 3.2.6)
mail (~> 2.4.4)
actionpack (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.0)
activesupport (= 3.2.0)
sprockets (~> 2.1.3)
activemodel (3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
activerecord (3.2.0)
activemodel (= 3.2.0)
activesupport (= 3.2.0)
arel (~> 3.0.0)
activerecord (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.0)
activemodel (= 3.2.0)
activesupport (= 3.2.0)
activesupport (3.2.0)
activeresource (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.0)
arel (3.0.2)
builder (3.0.0)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.0)
json (1.6.5)
mail (2.4.1)
journey (1.0.4)
json (1.7.3)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.17.2)
mime-types (1.19)
mocha (0.10.3)
metaclass (~> 0.0.1)
multi_json (1.0.4)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.0)
actionmailer (= 3.2.0)
actionpack (= 3.2.0)
activerecord (= 3.2.0)
activeresource (= 3.2.0)
activesupport (= 3.2.0)
rails (3.2.6)
actionmailer (= 3.2.6)
actionpack (= 3.2.6)
activerecord (= 3.2.6)
activeresource (= 3.2.6)
activesupport (= 3.2.6)
bundler (~> 1.0)
railties (= 3.2.0)
railties (3.2.0)
actionpack (= 3.2.0)
activesupport (= 3.2.0)
railties (= 3.2.6)
railties (3.2.6)
actionpack (= 3.2.6)
activesupport (= 3.2.6)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sprockets (2.1.2)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
Expand All @@ -85,7 +85,7 @@ GEM
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
tzinfo (0.3.33)

PLATFORMS
ruby
Expand Down
8 changes: 4 additions & 4 deletions lib/action_view/helpers/prototype_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def [](id)
# Returns an object whose <tt>to_json</tt> evaluates to +code+. Use this to pass a literal JavaScript
# expression as an argument to another JavaScriptGenerator method.
def literal(code)
::ActiveSupport::JSON::Variable.new(code.to_s)
::PrototypeRails::JSON::Literal.new(code)
end

# Returns a collection reference by finding it through a CSS +pattern+ in the DOM. This collection can then be
Expand Down Expand Up @@ -730,7 +730,7 @@ def reload(options_for_replace = {})

class JavaScriptVariableProxy < JavaScriptProxy #:nodoc:
def initialize(generator, variable)
@variable = ::ActiveSupport::JSON::Variable.new(variable)
@variable = ::PrototypeRails::JSON::Literal.new(variable)
@empty = true # only record lines if we have to. gets rid of unnecessary linebreaks
super(generator)
end
Expand Down Expand Up @@ -773,7 +773,7 @@ def each_slice(variable, number, &block)
end

def grep(variable, pattern, &block)
enumerate :grep, :variable => variable, :return => true, :method_args => [::ActiveSupport::JSON::Variable.new(pattern.inspect)], :yield_args => %w(value index), &block
enumerate :grep, :variable => variable, :return => true, :method_args => [::PrototypeRails::JSON::Literal.new(pattern.inspect)], :yield_args => %w(value index), &block
end

def in_groups_of(variable, number, fill_with = nil)
Expand All @@ -797,7 +797,7 @@ def zip(variable, *arguments, &block)
append_enumerable_function!("zip(#{arguments_for_call arguments}")
if block
function_chain[-1] += ", function(array) {"
yield ::ActiveSupport::JSON::Variable.new('array')
yield ::PrototypeRails::JSON::Literal.new('array')
add_return_statement!
@generator << '});'
else
Expand Down
8 changes: 8 additions & 0 deletions lib/prototype-rails/json/literal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module PrototypeRails
module JSON
class Literal < String
def as_json(options = nil) self end
def encode_json(encoder) self end
end
end
end
1 change: 1 addition & 0 deletions lib/prototype-rails/on_load_action_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'action_view/template/handlers/rjs'
require 'prototype-rails/javascript_helper'
require 'prototype-rails/rendering'
require 'prototype-rails/json/literal'

ActionView::Base.class_eval do
cattr_accessor :debug_rjs
Expand Down
4 changes: 2 additions & 2 deletions prototype-rails.gemspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Gem::Specification.new do |spec|
spec.name = 'prototype-rails'
spec.version = '3.2.1'
spec.version = '3.2.5'
spec.summary = 'Prototype, Scriptaculous, and RJS for Ruby on Rails'
spec.homepage = 'http://github.com/rails/prototype-rails'
spec.author = 'Xavier Noria'
spec.email = '[email protected]'

spec.files = %w(README Rakefile Gemfile) + Dir['lib/**/*', 'vendor/**/*', 'test/**/*']

spec.add_dependency('rails', '~> 3.2')
spec.add_dependency('rails', '>= 3.2.5')
spec.add_development_dependency('mocha')
end
8 changes: 8 additions & 0 deletions test/json_literal_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'abstract_unit'

class JsonLiteralTest < ActiveSupport::TestCase
def test_as_json
assert_equal PrototypeRails::JSON::Literal.new("foo").as_json, "foo"
assert_equal PrototypeRails::JSON::Literal.new('alert("foo")').as_json, 'alert("foo")'
end
end