rails_pages 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 136a1fe8daa9d56878c52c4f163c8c239175c653
4
- data.tar.gz: f0d9c08d08a5704974e8213784a980eef575c13d
3
+ metadata.gz: c868c2add079ac10f1a6fa9d245f81e0bc93c12c
4
+ data.tar.gz: 3ad0ed3082e87e83d189fbcda2e6b681128e5f09
5
5
  SHA512:
6
- metadata.gz: 16a7c767c5ca38bb4ca51acaad755e55329f0463a4e68767ddb43065558a393be2b60b88662ae93c5a51240e3def2e21f20ee4ced64dccfc70f52aefa8a98829
7
- data.tar.gz: 56ece8c3455c6a572f7b24becc90d3b071f89170c1fe084c1bc844b2114f9a5f6fa215b05ccf09d5cf8e81d49247c40ab1877aba1ed50cb48fa45e6e4524b965
6
+ metadata.gz: 1eb32c9da657d0f486456e04af0f36898fa9d3032a25aa4596d9f02d8aaa3a57cb6ce62610bb5547577b8338168d01e3254b06ec5b1b670dc0b64ce15d5e12cc
7
+ data.tar.gz: 775a55ac815fad89fed233cf15b9f43e00beb11a7f604916d4731857395c7132134fe4049ab7956f7c808314d66885ccf85a9517ccff4461e8455b2292f31b60
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+ rvm: 2.0.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_pages (0.0.2)
4
+ rails_pages (0.0.3)
5
5
  rails (~> 4.0.0)
6
6
 
7
7
  GEM
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://0.0.0.0:3000/pages/page`.
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
- # spec/controllers/products_controller_spec.rb
45
- require 'spec_helper'
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://0.0.0.0:3000/products/product`.
68
+ Visit pages `http://localhost:3000/products/product`.
67
69
 
68
70
  ## Routing
69
71
 
70
- Link to pages with [named helpers][named-helpers]:
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
- Define root path:
75
+ $ touch app/views/rails_pages/home.html.erb
76
+ ```
79
77
 
80
78
  ```ruby
81
79
  # config/routes.rb
82
- root 'pages#show', :id => 'home'
80
+ root 'rails_pages#show', :id => 'home'
83
81
  ```
84
82
 
85
- Define root-level resource routes:
83
+ Use top-level routes:
86
84
 
87
85
  ```ruby
88
86
  # config/routes.rb
89
- get '/:id' => 'pages#show',
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 resource routes:
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', "#{ARGV[0].pluralize}_controller.rb")
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,4 @@
1
+ Description:
2
+ Generates static pages helper.
3
+
4
+ `rails destroy rails_pages:helper NAME` removes the generated file.
@@ -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
@@ -0,0 +1,2 @@
1
+ module <%= class_name %>Helper
2
+ 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 :#{ARGV[0].pluralize}, :only => :show, :format => false, :constraints => { :id => /.+?/ }"
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
- source_root File.expand_path(__FILE__)
5
-
6
- class_option :controller, :type => :boolean, :default => true
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
@@ -1,3 +1,3 @@
1
1
  module RailsPages
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -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.2
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-07 00:00:00.000000000 Z
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