jquery-rails_vho 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ tmp
3
+ spec/support/*/Gemfile.lock
4
+ spec/support/*/public/javascripts
data/CHANGELOG.md ADDED
@@ -0,0 +1,119 @@
1
+ ## 1.0.9 (25 May 2011)
2
+
3
+ - Merged with new rails repo (3.1 fix)
4
+
5
+ ## 1.0.8 (25 May 2011)
6
+
7
+ - Updated to latest jquery-ujs with `[disabled][required]` fix
8
+
9
+ ## 1.0.7 (21 May 2011)
10
+
11
+ - Fix assert_select_jquery's bad call to unescape_rjs
12
+
13
+ ## 1.0.6 (21 May 2011)
14
+
15
+ - Updated to latest jquery-ujs with `data-params` support
16
+
17
+ ## 1.0.5 (17 May 2011)
18
+
19
+ - Updated to latest jquery-ujs
20
+ - Remove old rails.js in Rails 3.0 generator
21
+
22
+ ## 1.0.4 (17 May 2011)
23
+
24
+ - Fix exception in Rails 3.0 generator
25
+
26
+ ## 1.0.3 (17 May 2011)
27
+
28
+ - Update to jQuery 1.6.1
29
+ - Remove useless --version generator option
30
+
31
+ ## 1.0.2 (12 May 2011)
32
+
33
+ - Fix Rails 3.0 now that rails.js is named jquery_ujs.js
34
+
35
+ ## 1.0.1 (10 May 2011)
36
+
37
+ - Stop downloading rails.js from GitHub
38
+ - Vendor jQuery UI for those who want it
39
+ - Fix assert_select_jquery now that Rails 3.1 has no RJS at all
40
+ - Fix rails dependency to just be railties
41
+
42
+ ## 1.0.rc (3 May 2011)
43
+
44
+ - Rails 3.1 asset pipeline edition
45
+ - Removes generators and railties
46
+ - Just provides jquery.js and jquery_ujs.js
47
+ - Still compatible with Rails 3.0 via the old generator code
48
+
49
+ ## 0.2.7 (5 February 2011)
50
+
51
+ - Updated to use jQuery 1.5 by default
52
+
53
+ ## 0.2.6 (1 December 2010)
54
+
55
+ Feature:
56
+
57
+ - Updated to use jQuery 1.4.4 by default
58
+
59
+ ## 0.2.5 (4 November 2010)
60
+
61
+ Bugfix:
62
+
63
+ - Download JQuery Rails UJS via HTTPS since Github is now HTTPS only
64
+
65
+ ## 0.2.4 (16 October 2010)
66
+
67
+ Features:
68
+
69
+ - Updated to use the new jQuery 1.4.3 by default, with the IE .live() bug fixed
70
+ - Always download the newest 1.x release of jQuery UI
71
+ - Try to install unknown versions of jQuery, with fallback to the default
72
+ - Print informative messages in the correct Generator style
73
+
74
+ ## 0.2.3 (13 October 2010)
75
+
76
+ Features:
77
+
78
+ - Support Edge Rails 3.1 by depending on Rails ~>3.0
79
+ - Add Sam Ruby's assert_select_jquery test helper method
80
+ - Use jquery.min only in production (and not in the test env)
81
+
82
+ ## 0.2.2 (8 October 2010)
83
+
84
+ Feature:
85
+
86
+ - Depend on Rails >=3.0 && <4.0 for edge Rails compatibility
87
+
88
+ ## 0.2.1 (2 October 2010)
89
+
90
+ Bugfix:
91
+
92
+ - Default to jQuery 1.4.1 as recommended by jQuery-ujs
93
+ due to a bug in 1.4.2 (http://jsbin.com/uboxu3/7/)
94
+
95
+ ## 0.2 (2 October 2010)
96
+
97
+ Features:
98
+
99
+ - Allow specifying which version of jQuery to install
100
+ - Add generator tests (thanks, Louis T.)
101
+ - Automatically use non-minified JS in development mode
102
+
103
+ ## 0.1.3 (16 September 2010)
104
+
105
+ Bugfix:
106
+
107
+ - allow javascript :defaults tag to be overridden
108
+
109
+ ## 0.1.2 (18 August 2010)
110
+
111
+ Bugfix:
112
+
113
+ - check for jQueryUI in the right place
114
+
115
+ ## 0.1.1 (16 August 2010)
116
+
117
+ Bugfix:
118
+
119
+ - fix generator by resolving namespace conflict between Jquery::Rails and ::Rails
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in jquery-rails.gemspec
4
+ gemspec
5
+ # Rails is already being pulled in through gemspec
6
+ # gem "rails", :git => "git://github.com/rails/rails.git"
7
+ gem "rack", :git => "git://github.com/rack/rack.git"
8
+ gem "sprockets", :git => "git://github.com/sstephenson/sprockets.git"
9
+ gem "i18n", "0.6.0beta1"
data/Gemfile.lock ADDED
@@ -0,0 +1,120 @@
1
+ GIT
2
+ remote: git://github.com/rack/rack.git
3
+ revision: a9beb476b27914794743d0677b327d5bafb5e8a3
4
+ specs:
5
+ rack (1.2.1)
6
+
7
+ GIT
8
+ remote: git://github.com/rails/rails.git
9
+ revision: 2fbbd08616c25dc2931eca914349dd2161766f69
10
+ specs:
11
+ actionmailer (3.1.0.beta)
12
+ actionpack (= 3.1.0.beta)
13
+ mail (~> 2.3.0)
14
+ actionpack (3.1.0.beta)
15
+ activemodel (= 3.1.0.beta)
16
+ activesupport (= 3.1.0.beta)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ i18n (~> 0.6.0beta1)
20
+ rack (~> 1.2.1)
21
+ rack-cache (~> 1.0.0)
22
+ rack-mount (~> 0.7.2)
23
+ rack-test (~> 0.5.7)
24
+ sprockets (~> 2.0.0.beta.2)
25
+ tzinfo (~> 0.3.23)
26
+ activemodel (3.1.0.beta)
27
+ activesupport (= 3.1.0.beta)
28
+ bcrypt-ruby (~> 2.1.4)
29
+ builder (~> 3.0.0)
30
+ i18n (~> 0.6.0beta1)
31
+ activerecord (3.1.0.beta)
32
+ activemodel (= 3.1.0.beta)
33
+ activesupport (= 3.1.0.beta)
34
+ arel (~> 2.1.0)
35
+ tzinfo (~> 0.3.23)
36
+ activeresource (3.1.0.beta)
37
+ activemodel (= 3.1.0.beta)
38
+ activesupport (= 3.1.0.beta)
39
+ activesupport (3.1.0.beta)
40
+ multi_json (~> 1.0.0)
41
+ rails (3.1.0.beta)
42
+ actionmailer (= 3.1.0.beta)
43
+ actionpack (= 3.1.0.beta)
44
+ activerecord (= 3.1.0.beta)
45
+ activeresource (= 3.1.0.beta)
46
+ activesupport (= 3.1.0.beta)
47
+ bundler (~> 1.0)
48
+ railties (= 3.1.0.beta)
49
+ railties (3.1.0.beta)
50
+ actionpack (= 3.1.0.beta)
51
+ activesupport (= 3.1.0.beta)
52
+ rack-ssl (~> 1.3.2)
53
+ rake (>= 0.8.7)
54
+ thor (~> 0.14.4)
55
+
56
+ GIT
57
+ remote: git://github.com/sstephenson/sprockets.git
58
+ revision: c4800417792744c11eb1fb888bbe9a3a82859952
59
+ specs:
60
+ sprockets (2.0.0.beta.2)
61
+ hike (~> 1.0)
62
+ rack (~> 1.0)
63
+ tilt (~> 1.0)
64
+
65
+ PATH
66
+ remote: .
67
+ specs:
68
+ jquery-rails (0.3)
69
+ rails (~> 3.1)
70
+ thor (~> 0.14.4)
71
+
72
+ GEM
73
+ remote: http://rubygems.org/
74
+ specs:
75
+ addressable (2.2.4)
76
+ arel (2.1.0)
77
+ bcrypt-ruby (2.1.4)
78
+ builder (3.0.0)
79
+ crack (0.1.8)
80
+ erubis (2.7.0)
81
+ hike (1.0.0)
82
+ i18n (0.6.0beta1)
83
+ mail (2.3.0)
84
+ i18n (>= 0.4.0)
85
+ mime-types (~> 1.16)
86
+ treetop (~> 1.4.8)
87
+ mime-types (1.16)
88
+ multi_json (1.0.0)
89
+ polyglot (0.3.1)
90
+ rack-cache (1.0.1)
91
+ rack (>= 0.4)
92
+ rack-mount (0.7.2)
93
+ rack (>= 1.0.0)
94
+ rack-ssl (1.3.2)
95
+ rack
96
+ rack-test (0.5.7)
97
+ rack (>= 1.0)
98
+ rake (0.8.7)
99
+ rspec (1.3.1)
100
+ thor (0.14.6)
101
+ tilt (1.3)
102
+ treetop (1.4.9)
103
+ polyglot (>= 0.3.1)
104
+ tzinfo (0.3.27)
105
+ webmock (1.6.2)
106
+ addressable (>= 2.2.2)
107
+ crack (>= 0.1.7)
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ bundler (~> 1.0.0)
114
+ i18n (= 0.6.0beta1)
115
+ jquery-rails!
116
+ rack!
117
+ rails!
118
+ rspec (~> 1.3)
119
+ sprockets!
120
+ webmock (~> 1.6.2)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Andre Arko
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Jquery-rails
2
+
3
+ jQuery! For Rails! So great.
4
+
5
+ Also provided is Sam Ruby's assert_select_jquery function, which is automatically included for use in tests.
6
+
7
+ ## Rails 3.1
8
+
9
+ This gem vendors jQuery 1.6 and the latest jQuery UJS adapter for Rails 3.1 and greater. The files will be added to the asset pipeline and available for you to use. These two lines will be added to the file `app/assets/javascripts/application.js` by default:
10
+
11
+ //= require jquery
12
+ //= require jquery_ujs
13
+
14
+ If you wish to use jQuery UI as well, you can add this line to `application.js`:
15
+
16
+ //= require jquery-ui
17
+
18
+ In order to use the themed parts of jQuery UI, you will also need to supply your own theme CSS. See [jqueryui.com](http://jqueryui.com) for more information.
19
+
20
+ ### Installation
21
+
22
+ New Rails 3.1 apps include jquery-rails in the Gemfile by default. So just make a new app:
23
+
24
+ rails new myapp
25
+
26
+ You're done!
27
+
28
+ ## Rails 3.0
29
+
30
+ This gem adds a single generator to Rails 3, jquery:install. Running the generator will remove any Prototype JS files you may happen to have, fetch jQuery and the jQuery-ujs driver for Rails, and (optionally) fetch jQuery UI.
31
+
32
+ The gem will also hook into the Rails configuration process, removing Prototype and adding jQuery to the javascript files included by the `javascript_include_tag(:defaults)` call. While the plugin downloads minified and un-minified versions of jQuery and jQuery UI, only the minified versions are included in :default.
33
+
34
+ ### Installation
35
+
36
+ In your Gemfile, add this line:
37
+
38
+ gem "jquery-rails"
39
+
40
+ Then, run `bundle install`. To invoke the generator, run:
41
+
42
+ rails generate jquery:install #--ui to enable jQuery UI
43
+
44
+ You're done!
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ # require "spec/rake/spectask"
5
+ # desc "Run all examples"
6
+ # Spec::Rake::SpecTask.new(:spec) do |t|
7
+ # t.ruby_opts = ['-r test/unit']
8
+ # t.spec_opts = %w[--color]
9
+ # end
10
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/jquery/rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "jquery-rails_vho"
6
+ s.version = Jquery::Rails::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["André Arko", "Volker Hochstein"]
9
+ s.email = ["andre@arko.net", "vhochstein@googlemail.com"]
10
+ s.homepage = "https://github.com/vhochstein/jquery-rails"
11
+ s.summary = "Use jQuery with Rails 3.1 and ActiveScaffold"
12
+ s.description = "This gem provides jQuery and the jQuery-ujs drivers for your Rails 3.1 activescaffold application."
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "jquery-rails"
16
+
17
+ s.add_dependency "railties", "~> 3.0"
18
+ s.add_dependency "thor", "~> 0.14"
19
+ s.add_development_dependency "bundler", "~> 1.0.0"
20
+ s.add_development_dependency "rails", "~> 3.1"
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
24
+ s.require_path = 'lib'
25
+ end
@@ -0,0 +1,42 @@
1
+ require 'rails'
2
+
3
+ module Jquery
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ @@jquery_version = "1.6.1"
7
+ @@jquery_ui_version = "1.8.12"
8
+ @@jquery_ujs_version = "dad6982dc592686677e6845e681233c40d2ead27"
9
+
10
+ desc "This generator installs jQuery #{@@jquery_version}, jQuery-ujs, and (optionally) jQuery UI #{@@jquery_ui_version}"
11
+ class_option :ui, :type => :boolean, :default => false, :desc => "Include jQueryUI"
12
+ source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__)
13
+
14
+ def remove_prototype
15
+ Rails::PROTOTYPE_JS.each do |name|
16
+ remove_file "public/javascripts/#{name}.js"
17
+ end
18
+ end
19
+
20
+ def copy_jquery
21
+ say_status("copying", "jQuery (#{@@jquery_version})", :green)
22
+ copy_file "jquery.js", "public/javascripts/jquery.js"
23
+ copy_file "jquery.min.js", "public/javascripts/jquery.min.js"
24
+ end
25
+
26
+ def copy_jquery_ui
27
+ if options.ui?
28
+ say_status("copying", "jQuery UI (#{@@jquery_ui_version})", :green)
29
+ copy_file "jquery-ui.js", "public/javascripts/jquery-ui.js"
30
+ copy_file "jquery-ui.min.js", "public/javascripts/jquery-ui.min.js"
31
+ end
32
+ end
33
+
34
+ def copy_ujs_driver
35
+ say_status("copying", "jQuery UJS adapter (#{@@jquery_ujs_version[0..5]})", :green)
36
+ remove_file "public/javascripts/rails.js"
37
+ copy_file "jquery_ujs.js", "public/javascripts/jquery_ujs.js"
38
+ end
39
+
40
+ end
41
+ end
42
+ end if ::Rails.version < "3.1"
@@ -0,0 +1,98 @@
1
+ module ActionDispatch
2
+ module Assertions
3
+ module SelectorAssertions
4
+ # Selects content from a JQuery response. Patterned loosely on
5
+ # assert_select_rjs.
6
+ #
7
+ # === Narrowing down
8
+ #
9
+ # With no arguments, asserts that one or more method calls are made.
10
+ #
11
+ # Use the +method+ argument to narrow down the assertion to only
12
+ # statements that call that specific method.
13
+ #
14
+ # Use the +opt+ argument to narrow down the assertion to only statements
15
+ # that pass +opt+ as the first argument.
16
+ #
17
+ # Use the +id+ argument to narrow down the assertion to only statements
18
+ # that invoke methods on the result of using that identifier as a
19
+ # selector.
20
+ #
21
+ # === Using blocks
22
+ #
23
+ # Without a block, +assert_select_jquery_ merely asserts that the
24
+ # response contains one or more statements that match the conditions
25
+ # specified above
26
+ #
27
+ # With a block +assert_select_jquery_ also asserts that the method call
28
+ # passes a javascript escaped string containing HTML. All such HTML
29
+ # fragments are selected and passed to the block. Nested assertions are
30
+ # supported.
31
+ #
32
+ # === Examples
33
+ #
34
+ # # asserts that the #notice element is hidden
35
+ # assert_select :hide, '#notice'
36
+ #
37
+ # # asserts that the #cart element is shown with a blind parameter
38
+ # assert_select :show, :blind, '#cart'
39
+ #
40
+ # # asserts that #cart content contains a #current_item
41
+ # assert_select :html, '#cart' do
42
+ # assert_select '#current_item'
43
+ # end
44
+
45
+ PATTERN_HTML = "\"((\\\\\"|[^\"])*)\""
46
+ PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
47
+
48
+ def assert_select_jquery(*args, &block)
49
+ jquery_method = args.first.is_a?(Symbol) ? args.shift : nil
50
+ jquery_opt = args.first.is_a?(Symbol) ? args.shift : nil
51
+ id = args.first.is_a?(String) ? args.shift : nil
52
+
53
+ pattern = "\\.#{jquery_method || '\\w+'}\\("
54
+ pattern = "#{pattern}['\"]#{jquery_opt}['\"],?\\s*" if jquery_opt
55
+ pattern = "#{pattern}#{PATTERN_HTML}" if block
56
+ pattern = "(?:jQuery|\\$)\\(['\"]#{id}['\"]\\)#{pattern}" if id
57
+
58
+ fragments = []
59
+ response.body.scan(Regexp.new(pattern)).each do |match|
60
+ doc = HTML::Document.new(unescape_js(match.first))
61
+ doc.root.children.each do |child|
62
+ fragments.push child if child.tag?
63
+ end
64
+ end
65
+
66
+ if fragments.empty?
67
+ opts = [jquery_method, jquery_opt, id].compact
68
+ flunk "No JQuery call matches #{opts.inspect}"
69
+ end
70
+
71
+ if block
72
+ begin
73
+ in_scope, @selected = @selected, fragments
74
+ yield
75
+ ensure
76
+ @selected = in_scope
77
+ end
78
+ end
79
+ end
80
+
81
+ private
82
+
83
+ # Unescapes a JS string.
84
+ def unescape_js(js_string)
85
+ # js encodes double quotes and line breaks.
86
+ unescaped= js_string.gsub('\"', '"')
87
+ unescaped.gsub!(/\\\//, '/')
88
+ unescaped.gsub!('\n', "\n")
89
+ unescaped.gsub!('\076', '>')
90
+ unescaped.gsub!('\074', '<')
91
+ # js encodes non-ascii characters.
92
+ unescaped.gsub!(PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
93
+ unescaped
94
+ end
95
+
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,12 @@
1
+ # Configure Rails 3.1 to have assert_select_jquery() in tests
2
+ module Jquery
3
+ module Rails
4
+
5
+ class Engine < ::Rails::Engine
6
+ config.before_configuration do
7
+ require "jquery/assert_select" if ::Rails.env.test?
8
+ end
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ # Configure Rails 3.0 to use public/javascripts/jquery et al
2
+ module Jquery
3
+ module Rails
4
+
5
+ class Railtie < ::Rails::Railtie
6
+ config.before_configuration do
7
+ require "jquery/assert_select" if ::Rails.env.test?
8
+
9
+ if ::Rails.root.join("public/javascripts/jquery-ui.min.js").exist?
10
+ jq_defaults = %w(jquery jquery-ui)
11
+ jq_defaults.map!{|a| a + ".min" } if ::Rails.env.production?
12
+ else
13
+ jq_defaults = ::Rails.env.production? ? %w(jquery.min) : %w(jquery)
14
+ end
15
+
16
+ # Merge the jQuery scripts, remove the Prototype defaults and finally add 'rails'
17
+ # at the end, because load order is important
18
+ config.action_view.javascript_expansions[:defaults] -= PROTOTYPE_JS + ['rails']
19
+ config.action_view.javascript_expansions[:defaults] |= jq_defaults
20
+ config.action_view.javascript_expansions[:defaults] << 'jquery_ujs'
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ module Jquery
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module Jquery
2
+ module Rails
3
+ PROTOTYPE_JS = %w{prototype effects dragdrop controls}
4
+
5
+ if ::Rails.version < "3.1"
6
+ require 'jquery/rails/railtie'
7
+ else
8
+ require 'jquery/rails/engine'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ require 'jquery/rails'
@@ -0,0 +1,3 @@
1
+ require 'spec_helper'
2
+
3
+ it "should probably test something, but I'm damned if I know what"
@@ -0,0 +1,29 @@
1
+ # Set up RSpec
2
+ require 'webmock/rspec'
3
+
4
+ Spec::Runner.configure do |config|
5
+ config.include WebMock::API
6
+ end
7
+
8
+ # Set up generator tests
9
+ require 'rails/all'
10
+ require 'rails/generators'
11
+ require 'rails/generators/test_case'
12
+
13
+ class TestApp < Rails::Application
14
+ config.root = File.dirname(__FILE__)
15
+ end
16
+ Rails.application = TestApp
17
+
18
+ module Rails
19
+ def self.root
20
+ @root ||= File.expand_path("../../tmp/rails", __FILE__)
21
+ end
22
+ end
23
+ Rails.application.config.root = Rails.root
24
+
25
+ # Call configure to load the settings from
26
+ # Rails.application.config.generators to Rails::Generators
27
+ Rails::Generators.configure!
28
+
29
+