rails_pages 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +17 -49
- data/lib/generators/rails_pages/controller/controller_generator.rb +1 -3
- data/lib/generators/rails_pages/helper/USAGE +4 -0
- data/lib/generators/rails_pages/helper/helper_generator.rb +11 -0
- data/lib/generators/rails_pages/helper/templates/helper.rb +2 -0
- data/lib/generators/rails_pages/resource_route/resource_route_generator.rb +2 -2
- data/lib/generators/rails_pages/scaffold/scaffold_generator.rb +3 -7
- data/lib/rails_pages/version.rb +1 -1
- data/spec/integration/helper_generator_spec.rb +30 -0
- data/spec/integration/scaffold_generator_spec.rb +12 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c868c2add079ac10f1a6fa9d245f81e0bc93c12c
|
4
|
+
data.tar.gz: 3ad0ed3082e87e83d189fbcda2e6b681128e5f09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb32c9da657d0f486456e04af0f36898fa9d3032a25aa4596d9f02d8aaa3a57cb6ce62610bb5547577b8338168d01e3254b06ec5b1b670dc0b64ce15d5e12cc
|
7
|
+
data.tar.gz: 775a55ac815fad89fed233cf15b9f43e00beb11a7f604916d4731857395c7132134fe4049ab7956f7c808314d66885ccf85a9517ccff4461e8455b2292f31b60
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# rails_pages
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/niclasgelin/rails_pages.png?branch=master)](https://travis-ci.org/niclasgelin/rails_pages)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/niclasgelin/rails_pages.png)](https://codeclimate.com/github/niclasgelin/rails_pages)
|
5
|
+
[![Dependency Status](https://gemnasium.com/niclasgelin/rails_pages.png)](https://gemnasium.com/niclasgelin/rails_pages)
|
6
|
+
|
3
7
|
Static pages on Rails.
|
4
8
|
|
5
9
|
## Installation
|
@@ -15,8 +19,6 @@ gem 'rails_pages'
|
|
15
19
|
|
16
20
|
## Usage
|
17
21
|
|
18
|
-
Note that nested page directory structures are accepted by default.
|
19
|
-
|
20
22
|
Create static pages:
|
21
23
|
|
22
24
|
```
|
@@ -24,7 +26,9 @@ $ mkdir app/views/rails_pages
|
|
24
26
|
$ touch app/views/rails_pages/page.html.erb
|
25
27
|
```
|
26
28
|
|
27
|
-
Visit pages `http://
|
29
|
+
Visit pages `http://localhost:3000/pages/page`.
|
30
|
+
|
31
|
+
Default behavior accepts nested page directory structures using `:constraints`.
|
28
32
|
|
29
33
|
### Generating resources
|
30
34
|
|
@@ -41,10 +45,8 @@ end
|
|
41
45
|
```
|
42
46
|
|
43
47
|
```ruby
|
44
|
-
#
|
45
|
-
|
46
|
-
|
47
|
-
describe ProductsController do
|
48
|
+
# app/helpers/products_helper.rb
|
49
|
+
module ProductsHelper
|
48
50
|
end
|
49
51
|
```
|
50
52
|
|
@@ -63,36 +65,32 @@ $ mkdir app/views/products
|
|
63
65
|
$ touch app/views/products/product.html.erb
|
64
66
|
```
|
65
67
|
|
66
|
-
Visit pages `http://
|
68
|
+
Visit pages `http://localhost:3000/products/product`.
|
67
69
|
|
68
70
|
## Routing
|
69
71
|
|
70
|
-
|
72
|
+
Add root page:
|
71
73
|
|
72
|
-
[named-helpers]: http://guides.rubyonrails.org/routing.html#overriding-the-named-helpers
|
73
|
-
|
74
|
-
```erb
|
75
|
-
<%= link_to 'Page', page_path('page') %>
|
76
74
|
```
|
77
|
-
|
78
|
-
|
75
|
+
$ touch app/views/rails_pages/home.html.erb
|
76
|
+
```
|
79
77
|
|
80
78
|
```ruby
|
81
79
|
# config/routes.rb
|
82
|
-
root '
|
80
|
+
root 'rails_pages#show', :id => 'home'
|
83
81
|
```
|
84
82
|
|
85
|
-
|
83
|
+
Use top-level routes:
|
86
84
|
|
87
85
|
```ruby
|
88
86
|
# config/routes.rb
|
89
|
-
get '/:id' => '
|
87
|
+
get '/:id' => 'rails_pages#show',
|
90
88
|
:as => :page,
|
91
89
|
:format => false,
|
92
90
|
:constraints => { :id => /.+?/ }
|
93
91
|
```
|
94
92
|
|
95
|
-
Exclude specific pages from
|
93
|
+
Exclude specific pages from routes:
|
96
94
|
|
97
95
|
```ruby
|
98
96
|
:constraints => { :id => /.+?(?<!home|new|edit)/ }
|
@@ -107,36 +105,6 @@ RailsPages.configure do |config|
|
|
107
105
|
end
|
108
106
|
```
|
109
107
|
|
110
|
-
## Testing
|
111
|
-
|
112
|
-
[Rspec controller][rspec-controller] example:
|
113
|
-
|
114
|
-
[rspec-controller]: https://github.com/rspec/rspec-rails#controller-specs
|
115
|
-
|
116
|
-
```ruby
|
117
|
-
# spec/controllers/products_controller_spec.rb
|
118
|
-
require 'spec_helper'
|
119
|
-
|
120
|
-
describe ProductsController do
|
121
|
-
describe 'GET /products/product' do
|
122
|
-
before { get :show, :id => 'product' }
|
123
|
-
|
124
|
-
it 'responds successfully with an HTTP 200 status code' do
|
125
|
-
expect(response).to be_success
|
126
|
-
expect(response.status).to eq(200)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'renders requested template' do
|
130
|
-
expect(response).to render_template('product')
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'inherits layout from ApplicationController' do
|
134
|
-
expect(response).to render_template('layouts/application')
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
```
|
139
|
-
|
140
108
|
## License
|
141
109
|
|
142
110
|
This is free and unencumbered software released into the public domain.
|
@@ -4,10 +4,8 @@ module RailsPages
|
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
|
6
6
|
def create_controller
|
7
|
-
template 'controller.rb', File.join('app/controllers', "#{
|
7
|
+
template 'controller.rb', File.join('app/controllers', "#{plural_name}_controller.rb")
|
8
8
|
end
|
9
|
-
|
10
|
-
hook_for :test_framework, :as => :controller
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module RailsPages
|
2
|
+
module Generators
|
3
|
+
class HelperGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
def create_controller
|
7
|
+
template 'helper.rb', File.join('app/helpers', "#{plural_name}_helper.rb")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module RailsPages
|
2
2
|
module Generators
|
3
3
|
class ResourceRouteGenerator < Rails::Generators::NamedBase
|
4
|
-
source_root File.expand_path(__FILE__)
|
4
|
+
source_root File.expand_path('../', __FILE__)
|
5
5
|
|
6
6
|
def insert_resource_route
|
7
|
-
route "resources :#{
|
7
|
+
route "resources :#{plural_name}, :only => :show, :format => false, :constraints => { :id => /.+?/ }"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,13 +1,9 @@
|
|
1
1
|
module RailsPages
|
2
2
|
module Generators
|
3
3
|
class ScaffoldGenerator < Rails::Generators::Base
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
class_option :resource_route, :type => :boolean, :default => true
|
8
|
-
|
9
|
-
hook_for :controller
|
10
|
-
hook_for :resource_route
|
4
|
+
hook_for :controller, :type => :boolean, :default => true
|
5
|
+
hook_for :helper, :type => :boolean, :default => true
|
6
|
+
hook_for :resource_route, :type => :boolean, :default => true
|
11
7
|
end
|
12
8
|
end
|
13
9
|
end
|
data/lib/rails_pages/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'generators/rails_pages/helper/helper_generator'
|
3
|
+
|
4
|
+
describe RailsPages::Generators::ControllerGenerator do
|
5
|
+
destination = File.expand_path('../../dummy', __FILE__)
|
6
|
+
|
7
|
+
context 'generate' do
|
8
|
+
before(:all) do
|
9
|
+
Dir.chdir(destination) { %x(rails generate rails_pages:helper test) }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'tests_helper.rb' do
|
13
|
+
it 'should exist' do
|
14
|
+
expect(File.exist? "#{destination}/app/helpers/tests_helper.rb").to be_true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'destroy' do
|
20
|
+
before(:all) do
|
21
|
+
Dir.chdir(destination) { %x(rails destroy rails_pages:helper test) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'tests_helper.rb' do
|
25
|
+
it 'should not exist' do
|
26
|
+
expect(File.exist? "#{destination}/app/helpers/tests_helper.rb").to be_false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -15,6 +15,12 @@ describe RailsPages::Generators::ScaffoldGenerator do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
describe 'tests_helper.rb' do
|
19
|
+
it 'should exist' do
|
20
|
+
expect(File.exist? "#{destination}/app/helpers/tests_helper.rb").to be_true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
18
24
|
describe 'resources :tests' do
|
19
25
|
it 'should be defined' do
|
20
26
|
expect(File.read "#{destination}/config/routes.rb").to include('resources :tests')
|
@@ -33,6 +39,12 @@ describe RailsPages::Generators::ScaffoldGenerator do
|
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
42
|
+
describe 'tests_helper.rb' do
|
43
|
+
it 'should not exist' do
|
44
|
+
expect(File.exist? "#{destination}/app/helpers/tests_helper.rb").to be_false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
36
48
|
describe 'resources :tests' do
|
37
49
|
it 'should not be defined' do
|
38
50
|
expect(File.read "#{destination}/config/routes.rb").to_not include('resources :tests')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niclas Gelin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
|
+
- .travis.yml
|
77
78
|
- Gemfile
|
78
79
|
- Gemfile.lock
|
79
80
|
- README.md
|
@@ -83,6 +84,9 @@ files:
|
|
83
84
|
- lib/generators/rails_pages/controller/USAGE
|
84
85
|
- lib/generators/rails_pages/controller/controller_generator.rb
|
85
86
|
- lib/generators/rails_pages/controller/templates/controller.rb
|
87
|
+
- lib/generators/rails_pages/helper/USAGE
|
88
|
+
- lib/generators/rails_pages/helper/helper_generator.rb
|
89
|
+
- lib/generators/rails_pages/helper/templates/helper.rb
|
86
90
|
- lib/generators/rails_pages/resource_route/USAGE
|
87
91
|
- lib/generators/rails_pages/resource_route/resource_route_generator.rb
|
88
92
|
- lib/generators/rails_pages/scaffold/USAGE
|
@@ -114,6 +118,7 @@ files:
|
|
114
118
|
- spec/dummy/public/favicon.ico
|
115
119
|
- spec/dummy/public/index.html
|
116
120
|
- spec/integration/controller_generator_spec.rb
|
121
|
+
- spec/integration/helper_generator_spec.rb
|
117
122
|
- spec/integration/resource_route_generator_spec.rb
|
118
123
|
- spec/integration/scaffold_generator_spec.rb
|
119
124
|
- spec/rails_pages/configuration_spec.rb
|
@@ -166,6 +171,7 @@ test_files:
|
|
166
171
|
- spec/dummy/public/favicon.ico
|
167
172
|
- spec/dummy/public/index.html
|
168
173
|
- spec/integration/controller_generator_spec.rb
|
174
|
+
- spec/integration/helper_generator_spec.rb
|
169
175
|
- spec/integration/resource_route_generator_spec.rb
|
170
176
|
- spec/integration/scaffold_generator_spec.rb
|
171
177
|
- spec/rails_pages/configuration_spec.rb
|