sql_pager 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +38 -0
  4. data/lib/generators/active_record/sql_pager_generator.rb +47 -0
  5. data/lib/generators/active_record/templates/migration.rb +15 -0
  6. data/lib/generators/sql_pager/install_generator.rb +9 -0
  7. data/lib/generators/sql_pager/sql_pager_generator.rb +24 -0
  8. data/lib/generators/sql_pager/templates/controller.rb +9 -0
  9. data/lib/generators/sql_pager/templates/sql_pager.rb +6 -0
  10. data/lib/sql_pager/controller_helper.rb +13 -0
  11. data/lib/sql_pager/railtie.rb +5 -0
  12. data/lib/sql_pager/resolver.rb +106 -0
  13. data/lib/sql_pager/version.rb +3 -0
  14. data/lib/sql_pager.rb +24 -0
  15. data/lib/tasks/sql_pager_tasks.rake +4 -0
  16. data/test/dummy/README.rdoc +261 -0
  17. data/test/dummy/Rakefile +7 -0
  18. data/test/dummy/app/assets/javascripts/application.js +15 -0
  19. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  20. data/test/dummy/app/controllers/application_controller.rb +3 -0
  21. data/test/dummy/app/controllers/email_pages_controller.rb +9 -0
  22. data/test/dummy/app/controllers/pages_controller.rb +8 -0
  23. data/test/dummy/app/helpers/application_helper.rb +2 -0
  24. data/test/dummy/app/helpers/pages_helper.rb +2 -0
  25. data/test/dummy/app/models/email_page.rb +15 -0
  26. data/test/dummy/app/models/page.rb +16 -0
  27. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  28. data/test/dummy/config/application.rb +56 -0
  29. data/test/dummy/config/boot.rb +10 -0
  30. data/test/dummy/config/database.yml +25 -0
  31. data/test/dummy/config/environment.rb +5 -0
  32. data/test/dummy/config/environments/development.rb +37 -0
  33. data/test/dummy/config/environments/production.rb +67 -0
  34. data/test/dummy/config/environments/test.rb +37 -0
  35. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/test/dummy/config/initializers/inflections.rb +15 -0
  37. data/test/dummy/config/initializers/mime_types.rb +5 -0
  38. data/test/dummy/config/initializers/secret_token.rb +7 -0
  39. data/test/dummy/config/initializers/session_store.rb +8 -0
  40. data/test/dummy/config/initializers/sql_pager.rb +6 -0
  41. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/test/dummy/config/locales/en.yml +5 -0
  43. data/test/dummy/config/routes.rb +60 -0
  44. data/test/dummy/config.ru +4 -0
  45. data/test/dummy/db/development.sqlite3 +0 -0
  46. data/test/dummy/db/migrate/20120318120137_create_pages.rb +13 -0
  47. data/test/dummy/db/migrate/20120423192012_sql_pager_create_email_pages.rb +15 -0
  48. data/test/dummy/db/schema.rb +38 -0
  49. data/test/dummy/db/test.sqlite3 +0 -0
  50. data/test/dummy/log/development.log +32 -0
  51. data/test/dummy/log/test.log +2136 -0
  52. data/test/dummy/public/404.html +26 -0
  53. data/test/dummy/public/422.html +26 -0
  54. data/test/dummy/public/500.html +25 -0
  55. data/test/dummy/public/favicon.ico +0 -0
  56. data/test/dummy/script/rails +6 -0
  57. data/test/dummy/test/fixtures/email_pages.yml +11 -0
  58. data/test/dummy/test/fixtures/pages.yml +11 -0
  59. data/test/dummy/test/functional/pages_controller_test.rb +38 -0
  60. data/test/dummy/test/unit/email_page_test.rb +7 -0
  61. data/test/dummy/test/unit/helpers/pages_helper_test.rb +4 -0
  62. data/test/dummy/test/unit/page_test.rb +26 -0
  63. data/test/resolver_test.rb +30 -0
  64. data/test/sql_pager_test.rb +31 -0
  65. data/test/test_helper.rb +11 -0
  66. metadata +230 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ class PagesControllerTest < ActionController::TestCase
4
+ include Capybara::DSL
5
+
6
+ tests PagesController
7
+
8
+ setup do
9
+ page1 = Page.create!({
10
+ body: '<h1><%= "Hello world from ruby !" %></h1>',
11
+ path: 'posts/index',
12
+ handler: 'erb',
13
+ format: 'html',
14
+ locale: 'en'
15
+ })
16
+ page2 = Page.create!({
17
+ body: '<h1><%= "Hello world from ruby !" %></h1>',
18
+ path: 'posts',
19
+ handler: 'erb',
20
+ format: 'html',
21
+ locale: 'en'
22
+ })
23
+ end
24
+
25
+ test "PagesController responds to with_sql_resolver" do
26
+ assert PagesController.respond_to? :with_sql_resolver
27
+ end
28
+
29
+ test "PagesController displays the correct page retrieved from the database" do
30
+ visit '/posts/index'
31
+ assert_match "<h1>Hello world from ruby !</h1>", page.body
32
+ end
33
+
34
+ test "/posts should display a page" do
35
+ visit '/posts'
36
+ assert_match "<h1>Hello world from ruby !</h1>", page.body
37
+ end
38
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class EmailPageTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class PagesHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ class PageTest < ActiveSupport::TestCase
4
+
5
+ test "Page is a valid record" do
6
+ assert !Page.new.valid?, "Empty page should not be valid."
7
+
8
+ page = Page.new body: '<h1>Hello Wolrd <%= "from ruby" ?></h1>'
9
+ assert !page.valid?
10
+ page.assign_attributes handler: 'erb'
11
+ assert !page.valid?
12
+ page.assign_attributes format: 'html'
13
+ assert !page.valid?
14
+ page.assign_attributes locale: 'en'
15
+ assert !page.valid?
16
+ page.assign_attributes path: 'posts/index'
17
+ assert page.valid?
18
+ assert !page.partial
19
+
20
+ assert_equal 'html', page.format
21
+ assert_equal 'en', page.locale
22
+ assert_equal 'posts/index', page.path
23
+ assert_equal '<h1>Hello Wolrd <%= "from ruby" ?></h1>', page.body
24
+ end
25
+
26
+ end
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ class ResolverTest < ActiveSupport::TestCase
4
+
5
+ test "resolver returns a template with the saved body" do
6
+ resolver = SqlPager::Resolver.instance :page
7
+ details_1 = { formats: [:html], locale: [:fr], handlers: [:erb] }
8
+ details_2 = { formats: [:html], locale: [:en], handlers: [:erb] }
9
+
10
+ assert resolver.find_all('index', 'posts', false, details_1).empty?
11
+
12
+ Page.create!(
13
+ body: "<h1>You are at <%= 'posts/index' %></h1>",
14
+ path: 'posts/index',
15
+ format: 'html',
16
+ locale: 'en',
17
+ handler: 'erb',
18
+ partial: false
19
+ )
20
+
21
+ assert resolver.find_all('index', 'posts', false, details_1).empty?
22
+ template = resolver.find_all('index', 'posts', false, details_2).first
23
+ assert_kind_of ActionView::Template, template
24
+
25
+ assert_equal "<h1>You are at <%= 'posts/index' %></h1>", template.source
26
+ assert_equal [:html], template.formats
27
+ assert_equal 'posts/index', template.virtual_path
28
+ end
29
+
30
+ end
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ class SqlPagerTest < ActiveSupport::TestCase
4
+
5
+ test "SqlPager is a module" do
6
+ assert_kind_of Module, SqlPager
7
+ end
8
+
9
+ test "SqlPager exposes a config API" do
10
+ variables = ['model_name']
11
+
12
+ variables.each do |v|
13
+ # default values
14
+ assert_not_nil SqlPager.send(v), "#{v} should not be null by default"
15
+ # direct API
16
+ SqlPager.send("#{v}=","test_class")
17
+ assert_equal "test_class", SqlPager.send(v), "#{v} should now be equal to test_class"
18
+ # config API
19
+ SqlPager.setup do |config|
20
+ config.send("#{v}=","test_class2")
21
+ end
22
+ assert_equal "test_class2", SqlPager.send(v), "#{v} should now be equal to test_class2"
23
+ end
24
+
25
+ end
26
+
27
+ test "SqlPager adds a config namespace to rails" do
28
+ assert_equal Rails.application.config.sql_pager, SqlPager
29
+ end
30
+
31
+ end
@@ -0,0 +1,11 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+ require 'capybara/rails'
7
+
8
+ Rails.backtrace_cleaner.remove_silencers!
9
+
10
+ # Load support files
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
metadata ADDED
@@ -0,0 +1,230 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sql_pager
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Cyril Picard
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: sqlite3
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: capybara
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: turn
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Description of SqlPager.
79
+ email:
80
+ - cyril@picard.ch
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - lib/generators/active_record/sql_pager_generator.rb
86
+ - lib/generators/active_record/templates/migration.rb
87
+ - lib/generators/sql_pager/install_generator.rb
88
+ - lib/generators/sql_pager/sql_pager_generator.rb
89
+ - lib/generators/sql_pager/templates/controller.rb
90
+ - lib/generators/sql_pager/templates/sql_pager.rb
91
+ - lib/sql_pager/controller_helper.rb
92
+ - lib/sql_pager/railtie.rb
93
+ - lib/sql_pager/resolver.rb
94
+ - lib/sql_pager/version.rb
95
+ - lib/sql_pager.rb
96
+ - lib/tasks/sql_pager_tasks.rake
97
+ - MIT-LICENSE
98
+ - Rakefile
99
+ - README.rdoc
100
+ - test/dummy/app/assets/javascripts/application.js
101
+ - test/dummy/app/assets/stylesheets/application.css
102
+ - test/dummy/app/controllers/application_controller.rb
103
+ - test/dummy/app/controllers/email_pages_controller.rb
104
+ - test/dummy/app/controllers/pages_controller.rb
105
+ - test/dummy/app/helpers/application_helper.rb
106
+ - test/dummy/app/helpers/pages_helper.rb
107
+ - test/dummy/app/models/email_page.rb
108
+ - test/dummy/app/models/page.rb
109
+ - test/dummy/app/views/layouts/application.html.erb
110
+ - test/dummy/config/application.rb
111
+ - test/dummy/config/boot.rb
112
+ - test/dummy/config/database.yml
113
+ - test/dummy/config/environment.rb
114
+ - test/dummy/config/environments/development.rb
115
+ - test/dummy/config/environments/production.rb
116
+ - test/dummy/config/environments/test.rb
117
+ - test/dummy/config/initializers/backtrace_silencers.rb
118
+ - test/dummy/config/initializers/inflections.rb
119
+ - test/dummy/config/initializers/mime_types.rb
120
+ - test/dummy/config/initializers/secret_token.rb
121
+ - test/dummy/config/initializers/session_store.rb
122
+ - test/dummy/config/initializers/sql_pager.rb
123
+ - test/dummy/config/initializers/wrap_parameters.rb
124
+ - test/dummy/config/locales/en.yml
125
+ - test/dummy/config/routes.rb
126
+ - test/dummy/config.ru
127
+ - test/dummy/db/development.sqlite3
128
+ - test/dummy/db/migrate/20120318120137_create_pages.rb
129
+ - test/dummy/db/migrate/20120423192012_sql_pager_create_email_pages.rb
130
+ - test/dummy/db/schema.rb
131
+ - test/dummy/db/test.sqlite3
132
+ - test/dummy/log/development.log
133
+ - test/dummy/log/test.log
134
+ - test/dummy/public/404.html
135
+ - test/dummy/public/422.html
136
+ - test/dummy/public/500.html
137
+ - test/dummy/public/favicon.ico
138
+ - test/dummy/Rakefile
139
+ - test/dummy/README.rdoc
140
+ - test/dummy/script/rails
141
+ - test/dummy/test/fixtures/email_pages.yml
142
+ - test/dummy/test/fixtures/pages.yml
143
+ - test/dummy/test/functional/pages_controller_test.rb
144
+ - test/dummy/test/unit/email_page_test.rb
145
+ - test/dummy/test/unit/helpers/pages_helper_test.rb
146
+ - test/dummy/test/unit/page_test.rb
147
+ - test/resolver_test.rb
148
+ - test/sql_pager_test.rb
149
+ - test/test_helper.rb
150
+ homepage: https://github.com/cyrilpic/sql_pager
151
+ licenses: []
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ segments:
163
+ - 0
164
+ hash: 533125148854135074
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ! '>='
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ segments:
172
+ - 0
173
+ hash: 533125148854135074
174
+ requirements: []
175
+ rubyforge_project:
176
+ rubygems_version: 1.8.19
177
+ signing_key:
178
+ specification_version: 3
179
+ summary: SqlPager adds an sql ActionView Resolver
180
+ test_files:
181
+ - test/dummy/app/assets/javascripts/application.js
182
+ - test/dummy/app/assets/stylesheets/application.css
183
+ - test/dummy/app/controllers/application_controller.rb
184
+ - test/dummy/app/controllers/email_pages_controller.rb
185
+ - test/dummy/app/controllers/pages_controller.rb
186
+ - test/dummy/app/helpers/application_helper.rb
187
+ - test/dummy/app/helpers/pages_helper.rb
188
+ - test/dummy/app/models/email_page.rb
189
+ - test/dummy/app/models/page.rb
190
+ - test/dummy/app/views/layouts/application.html.erb
191
+ - test/dummy/config/application.rb
192
+ - test/dummy/config/boot.rb
193
+ - test/dummy/config/database.yml
194
+ - test/dummy/config/environment.rb
195
+ - test/dummy/config/environments/development.rb
196
+ - test/dummy/config/environments/production.rb
197
+ - test/dummy/config/environments/test.rb
198
+ - test/dummy/config/initializers/backtrace_silencers.rb
199
+ - test/dummy/config/initializers/inflections.rb
200
+ - test/dummy/config/initializers/mime_types.rb
201
+ - test/dummy/config/initializers/secret_token.rb
202
+ - test/dummy/config/initializers/session_store.rb
203
+ - test/dummy/config/initializers/sql_pager.rb
204
+ - test/dummy/config/initializers/wrap_parameters.rb
205
+ - test/dummy/config/locales/en.yml
206
+ - test/dummy/config/routes.rb
207
+ - test/dummy/config.ru
208
+ - test/dummy/db/development.sqlite3
209
+ - test/dummy/db/migrate/20120318120137_create_pages.rb
210
+ - test/dummy/db/migrate/20120423192012_sql_pager_create_email_pages.rb
211
+ - test/dummy/db/schema.rb
212
+ - test/dummy/db/test.sqlite3
213
+ - test/dummy/log/development.log
214
+ - test/dummy/log/test.log
215
+ - test/dummy/public/404.html
216
+ - test/dummy/public/422.html
217
+ - test/dummy/public/500.html
218
+ - test/dummy/public/favicon.ico
219
+ - test/dummy/Rakefile
220
+ - test/dummy/README.rdoc
221
+ - test/dummy/script/rails
222
+ - test/dummy/test/fixtures/email_pages.yml
223
+ - test/dummy/test/fixtures/pages.yml
224
+ - test/dummy/test/functional/pages_controller_test.rb
225
+ - test/dummy/test/unit/email_page_test.rb
226
+ - test/dummy/test/unit/helpers/pages_helper_test.rb
227
+ - test/dummy/test/unit/page_test.rb
228
+ - test/resolver_test.rb
229
+ - test/sql_pager_test.rb
230
+ - test/test_helper.rb