jquery-rails 0.1.3 → 0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-rails might be problematic. Click here for more details.

data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  pkg/*
2
- *.gem
2
+ tmp/**/*
3
+ spec/support/*/Gemfile.lock
data/README.md CHANGED
@@ -12,6 +12,6 @@ In your Gemfile, add this line:
12
12
 
13
13
  Then, run `bundle install`. To invoke the generator, run:
14
14
 
15
- rails generate jquery:install #--ui to enable jQuery UI
15
+ rails generate jquery:install #--ui to enable jQuery UI --version to install specific version of JQuery (default is 1.4.2)
16
16
 
17
17
  You're done! Don't forget to output `csrf_meta_tag` somewhere inside your `<head>` tag in your layout!
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+ Rake::TestTask.new(:test) do |test|
6
+ test.libs << 'lib' << 'test'
7
+ test.pattern = 'test/**/*_test.rb'
8
+ test.verbose = true
9
+ end
10
+ task :default => :test
@@ -1,8 +1,11 @@
1
1
  module Jquery
2
2
  module Generators
3
3
  class InstallGenerator < ::Rails::Generators::Base
4
- desc "This generator downloads and installs jQuery 1.4.2, jQuery-ujs HEAD, and (optionally) jQuery UI 1.8.4"
5
- class_option :ui, :type => :boolean, :default => false, :desc => "Indicates when to Include JQueryUI (minified version; source: Google Libraries API)"
4
+ desc "This generator downloads and installs jQuery, jQuery-ujs HEAD, and (optionally) jQuery UI 1.8.4"
5
+ class_option :ui, :type => :boolean, :default => false, :desc => "Whether to Include JQueryUI"
6
+ class_option :version, :type => :string, :default => "1.4.2", :desc => "Which version of JQuery to fetch"
7
+ @@versions = %w( 1.4.2 1.4.1 1.4.0 1.3.2 1.3.1 1.3.0 1.2.6 )
8
+
6
9
 
7
10
  def remove_prototype
8
11
  %w(controls.js dragdrop.js effects.js prototype.js).each do |js|
@@ -12,8 +15,15 @@ module Jquery
12
15
 
13
16
  def download_jquery
14
17
  # Downloading latest jQuery
15
- get "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "public/javascripts/jquery.min.js"
16
- get "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js", "public/javascripts/jquery.js"
18
+ if @@versions.include?(options.version)
19
+ puts "Fetching JQuery version #{options.version}!"
20
+ get "http://ajax.googleapis.com/ajax/libs/jquery/#{options.version}/jquery.min.js", "public/javascripts/jquery.min.js"
21
+ get "http://ajax.googleapis.com/ajax/libs/jquery/#{options.version}/jquery.js", "public/javascripts/jquery.js"
22
+ else
23
+ puts "JQuery #{options.version} is invalid; fetching #{@@versions[0]} instead."
24
+ get "http://ajax.googleapis.com/ajax/libs/jquery/#{@@versions[0]}/jquery.min.js", "public/javascripts/jquery.min.js"
25
+ get "http://ajax.googleapis.com/ajax/libs/jquery/#{@@versions[0]}/jquery.js", "public/javascripts/jquery.js"
26
+ end
17
27
 
18
28
  # Downloading latest jQueryUI minified
19
29
  get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js", "public/javascripts/jquery-ui.min.js" if options.ui?
@@ -27,4 +37,4 @@ module Jquery
27
37
 
28
38
  end
29
39
  end
30
- end
40
+ end
@@ -3,10 +3,12 @@ module Jquery
3
3
  class Railtie < ::Rails::Railtie
4
4
  config.before_configuration do
5
5
  if ::Rails.root.join("public/javascripts/jquery-ui.min.js").exist?
6
- config.action_view.javascript_expansions[:defaults] = %w(jquery.min jquery-ui.min rails)
6
+ jq_defaults = %w(jquery jquery-ui)
7
+ jq_defaults.map!{|a| a + ".min" } unless ::Rails.env.development?
7
8
  else
8
- config.action_view.javascript_expansions[:defaults] = %w(jquery.min rails)
9
+ jq_defaults = ::Rails.env.development? ? %w(jquery) : %w(jquery.min)
9
10
  end
11
+ config.action_view.javascript_expansions[:defaults] = jq_defaults + %w(rails)
10
12
  end
11
13
  end
12
14
  end
@@ -1,5 +1,5 @@
1
1
  module Jquery
2
2
  module Rails
3
- VERSION = "0.1.3"
3
+ VERSION = "0.2"
4
4
  end
5
5
  end
@@ -1,9 +1,9 @@
1
1
  describe "jQuery-Rails" do
2
- def get_js_defaults(name)
2
+ def get_js_defaults(name, env = "production")
3
3
  dir = File.expand_path("../support/#{name}_app", __FILE__)
4
4
  Dir.chdir(dir) do
5
5
  `bundle install --local`
6
- `rails runner 'puts Rails.application.config.action_view.
6
+ `rails runner -e #{env} 'puts Rails.application.config.action_view.
7
7
  javascript_expansions[:defaults].inspect'`.chomp
8
8
  end
9
9
  end
@@ -12,6 +12,10 @@ describe "jQuery-Rails" do
12
12
  get_js_defaults("default").should == ["jquery.min", "rails"].inspect
13
13
  end
14
14
 
15
+ it "uses non-minified js in development" do
16
+ get_js_defaults("default", "development").should == %w(jquery rails).inspect
17
+ end
18
+
15
19
  it "changes allows overriding the javascript expansion" do
16
20
  get_js_defaults("custom").should == ["foo", "bar", "baz"].inspect
17
21
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/andre/sw/gems/jquery-rails
3
3
  specs:
4
- jquery-rails (0.1.2)
4
+ jquery-rails (0.1.3)
5
5
  rails (~> 3.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/andre/sw/gems/jquery-rails
3
3
  specs:
4
- jquery-rails (0.1.2)
4
+ jquery-rails (0.1.3)
5
5
  rails (~> 3.0.0)
6
6
 
7
7
  GEM
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+ require 'generators/jquery/install/install_generator'
3
+
4
+ class Jquery::Generators::InstallGeneratorTest < Rails::Generators::TestCase
5
+ destination File.join(Rails.root)
6
+ tests Jquery::Generators::InstallGenerator
7
+ arguments []
8
+
9
+ setup :prepare_destination
10
+
11
+ test 'jquery is installed' do
12
+ run_generator
13
+
14
+ %w(jquery.min.js jquery.js rails.js).each { |js| assert_file "public/javascripts/#{js}" }
15
+ %w(controls.js dragdrop.js effects.js prototype.js).each { |js| assert_no_file "public/javascripts/#{js}" }
16
+ end
17
+
18
+ test 'jquery is installed with jqueyui' do
19
+ run_generator %w(--ui)
20
+
21
+ %w(jquery.min.js jquery.js jquery-ui.min.js jquery-ui.js rails.js).each { |js| assert_file "public/javascripts/#{js}" }
22
+ %w(controls.js dragdrop.js effects.js prototype.js).each { |js| assert_no_file "public/javascripts/#{js}" }
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'rails/all'
4
+ require 'rails/generators'
5
+ require 'rails/generators/test_case'
6
+
7
+ class TestApp < Rails::Application
8
+ config.root = File.dirname(__FILE__)
9
+ end
10
+ Rails.application = TestApp
11
+
12
+ module Rails
13
+ def self.root
14
+ @root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'rails'))
15
+ end
16
+ end
17
+ Rails.application.config.root = Rails.root
18
+
19
+ # Call configure to load the settings from
20
+ # Rails.application.config.generators to Rails::Generators
21
+ Rails::Generators.configure!
22
+
23
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
8
+ - 2
9
+ version: "0.2"
11
10
  platform: ruby
12
11
  authors:
13
12
  - "Andr\xC3\xA9 Arko"
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-09-16 00:00:00 -07:00
17
+ date: 2010-10-02 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -96,6 +95,8 @@ files:
96
95
  - spec/support/default_app/config/environments/test.rb
97
96
  - spec/support/default_app/config/routes.rb
98
97
  - spec/support/default_app/script/rails
98
+ - test/lib/generators/jquery/install_generator_test.rb
99
+ - test/test_helper.rb
99
100
  has_rdoc: true
100
101
  homepage: http://rubygems.org/gems/jquery-rails
101
102
  licenses: []