ajax 0.1.2

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.
Files changed (44) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +291 -0
  3. data/Rakefile +49 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/ajax_controller.rb +3 -0
  6. data/app/views/ajax/framework.html.erb +7 -0
  7. data/config/initializers/ajax.rb +14 -0
  8. data/lib/ajax.rb +79 -0
  9. data/lib/ajax/action_controller.rb +154 -0
  10. data/lib/ajax/action_view.rb +56 -0
  11. data/lib/ajax/helpers.rb +15 -0
  12. data/lib/ajax/helpers/request_helper.rb +76 -0
  13. data/lib/ajax/helpers/robot_helper.rb +31 -0
  14. data/lib/ajax/helpers/url_helper.rb +47 -0
  15. data/lib/ajax/railtie.rb +7 -0
  16. data/lib/ajax/routes.rb +12 -0
  17. data/lib/ajax/spec/extension.rb +34 -0
  18. data/lib/ajax/spec/helpers.rb +95 -0
  19. data/lib/ajax/tasks.rb +1 -0
  20. data/lib/rack-ajax.rb +60 -0
  21. data/lib/rack-ajax/decision_tree.rb +60 -0
  22. data/lib/rack-ajax/parser.rb +115 -0
  23. data/public/images/loading-icon-large.gif +0 -0
  24. data/public/images/loading-icon-small.gif +0 -0
  25. data/public/javascripts/ajax.js +529 -0
  26. data/public/javascripts/jquery.address-1.1.js +450 -0
  27. data/public/javascripts/jquery.address-1.1.min.js +11 -0
  28. data/public/javascripts/jquery.address-1.2.js +528 -0
  29. data/public/javascripts/jquery.address-1.2.min.js +25 -0
  30. data/public/javascripts/jquery.address-1.2rc.js +599 -0
  31. data/public/javascripts/jquery.address-1.2rc.min.js +27 -0
  32. data/public/javascripts/jquery.json-2.2.js +178 -0
  33. data/public/javascripts/jquery.json-2.2.min.js +31 -0
  34. data/rails/init.rb +4 -0
  35. data/rails/install.rb +23 -0
  36. data/rails/uninstall.rb +1 -0
  37. data/spec/ajax/helpers_spec.rb +102 -0
  38. data/spec/ajax/request_helper_spec.rb +33 -0
  39. data/spec/integration/ajax_spec.rb +146 -0
  40. data/spec/rack-ajax/parser_spec.rb +62 -0
  41. data/spec/spec.opts +1 -0
  42. data/spec/spec_helper.rb +18 -0
  43. data/tasks/ajax_tasks.rake +15 -0
  44. metadata +106 -0
@@ -0,0 +1,62 @@
1
+ # Test Rack middleware using integration tests because the Spec controller tests
2
+ # do not invoke Rack.
3
+ require 'spec_helper'
4
+ require 'ajax/spec/helpers'
5
+ require 'uri'
6
+
7
+ include Ajax::Spec::Helpers
8
+
9
+ # Test the Rack::Ajax::Parser. See <tt>lib/rack-ajax-parser.rb</tt>
10
+ #
11
+ # Test Rack middleware using integration tests because the Spec controller tests
12
+ # do not invoke Rack.
13
+ describe Rack::Ajax::Parser, :type => :integration do
14
+ before :all do
15
+ mock_ajax
16
+ create_app
17
+ end
18
+
19
+ it "should recognize robots" do
20
+ call_rack('/', 'GET', { 'HTTP_USER_AGENT' => 'Googlebot' }) do
21
+ rack_response(user_is_robot?)
22
+ end
23
+ should_set_ajax_request_header('robot', true)
24
+ end
25
+
26
+ it "should recognize regular users" do
27
+ call_rack('/', { 'HTTP_USER_AGENT' => 'Safari' }) do
28
+ rack_response(user_is_robot?)
29
+ end
30
+ should_set_ajax_request_header('robot', false)
31
+ end
32
+
33
+ it "should be able to tell if a url is root" do
34
+ call_rack('/') { rack_response(url_is_root?) }
35
+ should_respond_with('true')
36
+
37
+ call_rack('/Beyonce') { rack_response(url_is_root?) }
38
+ should_respond_with('false')
39
+
40
+ call_rack('/#/Beyonce?query2') { rack_response(url_is_root?) }
41
+ should_respond_with('true')
42
+ end
43
+
44
+ it "should redirect to hashed url from fragment" do
45
+ call_rack('/Beyonce?page=1#/Akon') do
46
+ redirect_to_hashed_url_from_fragment
47
+ end
48
+ should_redirect_to('/#/Akon', 302)
49
+ end
50
+
51
+ it "should rewrite to traditional url from fragment" do
52
+ call_rack('/Beyonce?page=1#/Akon?query2') do
53
+ rewrite_to_traditional_url_from_fragment
54
+ end
55
+ should_rewrite_to('/Akon?query2')
56
+ end
57
+
58
+ it "should return a valid rack response" do
59
+ call_rack('/') { rack_response('test') }
60
+ should_respond_with('test')
61
+ end
62
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,18 @@
1
+ require 'spec'
2
+ require 'spec/autorun'
3
+ require 'rubygems'
4
+ require 'ajax/spec/extension'
5
+
6
+ # Just drop in 'debugger' to debug test code
7
+ require 'ruby-debug'
8
+
9
+ # Rails dependencies
10
+ require 'action_controller'
11
+ require 'active_support/core_ext'
12
+
13
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
14
+ require File.join(File.dirname(__FILE__), '..', 'rails', 'init')
15
+
16
+ Spec::Runner.configure do |config|
17
+ include Ajax::Spec::Extension
18
+ end
@@ -0,0 +1,15 @@
1
+ require 'ajax'
2
+
3
+ namespace :ajax do
4
+ desc "Install required Ajax files."
5
+ task :install do
6
+ load(File.join(File.dirname(__FILE__), '..', 'rails', 'install.rb'))
7
+ end
8
+
9
+ namespace :install do
10
+ desc "Install Ajax integration spec tests into spec/integration."
11
+ task :specs do
12
+ puts "Coming soon..."
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ajax
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Karl Varga
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-04-20 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Augment a traditional Rails application with a completely AJAX frontend, while transparently handling issues important to both the enterprise and end users, such as testing, SEO and browser history.
26
+ email: kjvarga@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - VERSION
38
+ - app/controllers/ajax_controller.rb
39
+ - app/views/ajax/framework.html.erb
40
+ - config/initializers/ajax.rb
41
+ - lib/ajax.rb
42
+ - lib/ajax/action_controller.rb
43
+ - lib/ajax/action_view.rb
44
+ - lib/ajax/helpers.rb
45
+ - lib/ajax/helpers/request_helper.rb
46
+ - lib/ajax/helpers/robot_helper.rb
47
+ - lib/ajax/helpers/url_helper.rb
48
+ - lib/ajax/railtie.rb
49
+ - lib/ajax/routes.rb
50
+ - lib/ajax/spec/extension.rb
51
+ - lib/ajax/spec/helpers.rb
52
+ - lib/ajax/tasks.rb
53
+ - lib/rack-ajax.rb
54
+ - lib/rack-ajax/decision_tree.rb
55
+ - lib/rack-ajax/parser.rb
56
+ - public/images/loading-icon-large.gif
57
+ - public/images/loading-icon-small.gif
58
+ - public/javascripts/ajax.js
59
+ - public/javascripts/jquery.address-1.1.js
60
+ - public/javascripts/jquery.address-1.1.min.js
61
+ - public/javascripts/jquery.address-1.2.js
62
+ - public/javascripts/jquery.address-1.2.min.js
63
+ - public/javascripts/jquery.address-1.2rc.js
64
+ - public/javascripts/jquery.address-1.2rc.min.js
65
+ - public/javascripts/jquery.json-2.2.js
66
+ - public/javascripts/jquery.json-2.2.min.js
67
+ - rails/init.rb
68
+ - rails/install.rb
69
+ - rails/uninstall.rb
70
+ - spec/ajax/helpers_spec.rb
71
+ - spec/ajax/request_helper_spec.rb
72
+ - spec/integration/ajax_spec.rb
73
+ - spec/rack-ajax/parser_spec.rb
74
+ - spec/spec.opts
75
+ - spec/spec_helper.rb
76
+ - tasks/ajax_tasks.rake
77
+ has_rdoc: true
78
+ homepage: http://github.com/kjvarga/ajax
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --charset=UTF-8
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ version:
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ version:
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.5
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: A framework to augment a traditional Rails application with a completely AJAX frontend.
105
+ test_files: []
106
+