dynamic_router 0.0.1

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 (46) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +55 -0
  4. data/.travis.yml +10 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +22 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +31 -0
  9. data/Rakefile +10 -0
  10. data/dynamic_router.gemspec +30 -0
  11. data/lib/dynamic_router.rb +8 -0
  12. data/lib/dynamic_router/class_methods.rb +59 -0
  13. data/lib/dynamic_router/version.rb +3 -0
  14. data/spec/db/create_database.rb +13 -0
  15. data/spec/dummy/Rakefile +7 -0
  16. data/spec/dummy/app/controllers/application_controller.rb +6 -0
  17. data/spec/dummy/app/controllers/dummy_controller.rb +5 -0
  18. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  19. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  20. data/spec/dummy/config.ru +4 -0
  21. data/spec/dummy/config/application.rb +47 -0
  22. data/spec/dummy/config/boot.rb +10 -0
  23. data/spec/dummy/config/database.yml +22 -0
  24. data/spec/dummy/config/environment.rb +5 -0
  25. data/spec/dummy/config/environments/development.rb +26 -0
  26. data/spec/dummy/config/environments/production.rb +50 -0
  27. data/spec/dummy/config/environments/test.rb +35 -0
  28. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  29. data/spec/dummy/config/initializers/inflections.rb +10 -0
  30. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  31. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  32. data/spec/dummy/config/initializers/session_store.rb +8 -0
  33. data/spec/dummy/config/locales/en.yml +5 -0
  34. data/spec/dummy/config/locales/pt_BR.yml +2 -0
  35. data/spec/dummy/config/routes.rb +2 -0
  36. data/spec/dummy/db/test.sqlite3 +0 -0
  37. data/spec/dummy/log/test.log +1463 -0
  38. data/spec/dummy/public/404.html +26 -0
  39. data/spec/dummy/public/422.html +26 -0
  40. data/spec/dummy/public/500.html +26 -0
  41. data/spec/dummy/public/favicon.ico +0 -0
  42. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  43. data/spec/dummy/script/rails +6 -0
  44. data/spec/dynamic_router_spec.rb +46 -0
  45. data/spec/spec_helper.rb +31 -0
  46. metadata +219 -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,26 @@
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
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
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,46 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe DynamicRouter do
4
+ before(:each) do
5
+ class Example < ActiveRecord::Base
6
+ extend DynamicRouter
7
+ end
8
+
9
+ Example.create!(:first_path => "path_a", :second_path => "path_a_a", :default_field => "default_value")
10
+ end
11
+
12
+ it "should check the the existence of the table" do
13
+ connection = ActiveRecord::Base.connection
14
+
15
+ allow(ActiveRecord::Base).to receive(:connection).and_return(connection)
16
+ expect(connection).to receive(:table_exists?).with(Example.table_name)
17
+
18
+ Example.send(:has_dynamic_route, Proc.new {|example| "/#{example.first_path}/#{example.second_path}"}, "dummy#dummy_method")
19
+ end
20
+
21
+ it "should create a get route with the supplied url" do
22
+ Example.send(:has_dynamic_route, Proc.new {|example| "/#{example.first_path}/#{example.second_path}"}, "dummy#dummy_method")
23
+
24
+ expect(Rails.application.routes.recognize_path('/path_a/path_a_a', :method => :get))
25
+ end
26
+
27
+ it "should accept the method option" do
28
+ Example.send(:has_dynamic_route, Proc.new {|example| "/#{example.first_path}/#{example.second_path}"}, "dummy#dummy_method", :method => :post)
29
+
30
+ expect(Rails.application.routes.recognize_path('/path_a/path_a_a', :method => :post))
31
+ end
32
+
33
+ it "should accept the defaults option" do
34
+ Example.send(:has_dynamic_route, Proc.new {|example| "/#{example.first_path}/#{example.second_path}"}, "dummy#dummy_method", :defaults => {:default_value => Proc.new {|example| example.default_field}})
35
+
36
+ expect(Rails.application.routes.routes.named_routes["path_a_path_a_a"].defaults).to match a_hash_including(:default_value => "default_value")
37
+ end
38
+
39
+ it "should create the route after save the model" do
40
+ Example.send(:has_dynamic_route, Proc.new {|example| "/#{example.first_path}/#{example.second_path}"}, "dummy#dummy_method", :defaults => {:default_value => Proc.new {|example| example.default_field}})
41
+
42
+ Example.create!(:first_path => "path_a", :second_path => "path_a_b")
43
+
44
+ expect(Rails.application.routes.recognize_path('/path_a/path_a_b', :method => :get))
45
+ end
46
+ end
@@ -0,0 +1,31 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ # Configure Rails Envinronment
5
+ ENV["RAILS_ENV"] = "test"
6
+
7
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
8
+ require 'pry'
9
+ require 'dynamic_router'
10
+
11
+ ActionMailer::Base.delivery_method = :test
12
+ ActionMailer::Base.perform_deliveries = true
13
+ ActionMailer::Base.default_url_options[:host] = "test.com"
14
+
15
+ Rails.backtrace_cleaner.remove_silencers!
16
+
17
+ ActiveRecord::Base.establish_connection :adapter=>"sqlite3", :database => ":memory:"
18
+ require File.dirname(__FILE__) + "/db/create_database"
19
+
20
+ CreateDatabase.migrate(:up)
21
+
22
+ # Run any available migration
23
+ ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
24
+
25
+ # Load support files
26
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
27
+
28
+ RSpec.configure do |config|
29
+ config.mock_with :rspec
30
+ config.include ActionView::Helpers
31
+ end
metadata ADDED
@@ -0,0 +1,219 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dynamic_router
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gustavo Berdugo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.3'
111
+ description: Use this gem to add dynamic routes to your project.
112
+ email:
113
+ - gberdugo@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - LICENSE
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - dynamic_router.gemspec
127
+ - lib/dynamic_router.rb
128
+ - lib/dynamic_router/class_methods.rb
129
+ - lib/dynamic_router/version.rb
130
+ - spec/db/create_database.rb
131
+ - spec/dummy/Rakefile
132
+ - spec/dummy/app/controllers/application_controller.rb
133
+ - spec/dummy/app/controllers/dummy_controller.rb
134
+ - spec/dummy/app/helpers/application_helper.rb
135
+ - spec/dummy/app/views/layouts/application.html.erb
136
+ - spec/dummy/config.ru
137
+ - spec/dummy/config/application.rb
138
+ - spec/dummy/config/boot.rb
139
+ - spec/dummy/config/database.yml
140
+ - spec/dummy/config/environment.rb
141
+ - spec/dummy/config/environments/development.rb
142
+ - spec/dummy/config/environments/production.rb
143
+ - spec/dummy/config/environments/test.rb
144
+ - spec/dummy/config/initializers/backtrace_silencers.rb
145
+ - spec/dummy/config/initializers/inflections.rb
146
+ - spec/dummy/config/initializers/mime_types.rb
147
+ - spec/dummy/config/initializers/secret_token.rb
148
+ - spec/dummy/config/initializers/session_store.rb
149
+ - spec/dummy/config/locales/en.yml
150
+ - spec/dummy/config/locales/pt_BR.yml
151
+ - spec/dummy/config/routes.rb
152
+ - spec/dummy/db/test.sqlite3
153
+ - spec/dummy/log/test.log
154
+ - spec/dummy/public/404.html
155
+ - spec/dummy/public/422.html
156
+ - spec/dummy/public/500.html
157
+ - spec/dummy/public/favicon.ico
158
+ - spec/dummy/public/stylesheets/.gitkeep
159
+ - spec/dummy/script/rails
160
+ - spec/dynamic_router_spec.rb
161
+ - spec/spec_helper.rb
162
+ homepage: http://rubygems.org/gems/dynamic_router
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.4.2
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Add dynamic routes to your project
186
+ test_files:
187
+ - spec/db/create_database.rb
188
+ - spec/dummy/Rakefile
189
+ - spec/dummy/app/controllers/application_controller.rb
190
+ - spec/dummy/app/controllers/dummy_controller.rb
191
+ - spec/dummy/app/helpers/application_helper.rb
192
+ - spec/dummy/app/views/layouts/application.html.erb
193
+ - spec/dummy/config.ru
194
+ - spec/dummy/config/application.rb
195
+ - spec/dummy/config/boot.rb
196
+ - spec/dummy/config/database.yml
197
+ - spec/dummy/config/environment.rb
198
+ - spec/dummy/config/environments/development.rb
199
+ - spec/dummy/config/environments/production.rb
200
+ - spec/dummy/config/environments/test.rb
201
+ - spec/dummy/config/initializers/backtrace_silencers.rb
202
+ - spec/dummy/config/initializers/inflections.rb
203
+ - spec/dummy/config/initializers/mime_types.rb
204
+ - spec/dummy/config/initializers/secret_token.rb
205
+ - spec/dummy/config/initializers/session_store.rb
206
+ - spec/dummy/config/locales/en.yml
207
+ - spec/dummy/config/locales/pt_BR.yml
208
+ - spec/dummy/config/routes.rb
209
+ - spec/dummy/db/test.sqlite3
210
+ - spec/dummy/log/test.log
211
+ - spec/dummy/public/404.html
212
+ - spec/dummy/public/422.html
213
+ - spec/dummy/public/500.html
214
+ - spec/dummy/public/favicon.ico
215
+ - spec/dummy/public/stylesheets/.gitkeep
216
+ - spec/dummy/script/rails
217
+ - spec/dynamic_router_spec.rb
218
+ - spec/spec_helper.rb
219
+ has_rdoc: