sanji 1.0.0.pre.4 → 1.0.0.pre.5
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 +4 -4
- data/README.md +8 -8
- data/lib/sanji/recipe.rb +2 -2
- data/lib/sanji/recipes/admin_namespace.rb +54 -0
- data/lib/sanji/recipes/draper.rb +1 -1
- data/lib/sanji/recipes/paloma.rb +2 -0
- data/lib/sanji/recipes/postgresql.rb +7 -0
- data/lib/sanji/recipes/public_module.rb +67 -0
- data/lib/sanji/recipes/readme.rb +8 -0
- data/lib/sanji.yml +3 -0
- data/templates/README.md.erb +33 -0
- metadata +6 -3
- data/lib/sanji/recipes/controllers.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14ba224e7a05f550d0248df7e734d610d5d548a9
|
4
|
+
data.tar.gz: 742c4417b7e9c7a66802cf4e535790610b96f0d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd1c2ff58dd300468c0efc2bca26c3d925d9300c7697a03723c9f80a8f5b2755c5ae4d33c85c5f0e388edb311aa972bfbabdb3fbda0444f1fd9c52689dec4c14
|
7
|
+
data.tar.gz: 6337c58ae4fc096b5d7092a10dcffd084bb012f5b6abd55c09ae7bb41bfae5febaf0ba3481751726c1ae0bd8ae91e24470c68fdbcaeac63aec96ff7f92cb9a28
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# sanji
|
2
2
|
|
3
|
+

|
4
|
+
|
3
5
|
Customized Rails application generator.
|
4
6
|
Inspired by [suspenders](https://github.com/thoughtbot/suspenders) and [rails_apps_composer](https://github.com/RailsApps/rails_apps_composer) gems.
|
5
7
|
|
6
|
-

|
7
|
-
|
8
8
|
## Installation
|
9
9
|
|
10
10
|
```
|
@@ -22,18 +22,18 @@ sanji app_name
|
|
22
22
|
```ruby
|
23
23
|
class Sanji::Locals::MyRecipe < Sanji::Recipe
|
24
24
|
|
25
|
-
def
|
25
|
+
def confirm
|
26
26
|
# return a string (boolean question) to make this recipe optional
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def after_create
|
30
30
|
# execute after app is created
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def after_bundle
|
34
34
|
# execute after bundle
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def after_everything
|
38
38
|
# execute after "after_bundle"
|
39
39
|
end
|
@@ -52,13 +52,13 @@ end
|
|
52
52
|
```ruby
|
53
53
|
cookbook: cookbook_name
|
54
54
|
recipes: /path/to/recipes
|
55
|
-
|
55
|
+
|
56
56
|
cookbooks:
|
57
57
|
cookbook_name:
|
58
58
|
- recipe_name
|
59
59
|
- other_recipe_name
|
60
60
|
- another_recipe
|
61
|
-
|
61
|
+
|
62
62
|
my_cookbook:
|
63
63
|
- my_recipe
|
64
64
|
```
|
data/lib/sanji/recipe.rb
CHANGED
@@ -8,7 +8,7 @@ class Sanji::Recipe
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run_after_create
|
11
|
-
@disabled = a.no?(self.
|
11
|
+
@disabled = a.no?(self.confirm) if self.confirm.present?
|
12
12
|
return if @disabled
|
13
13
|
|
14
14
|
a.log_start :after_create
|
@@ -41,7 +41,7 @@ class Sanji::Recipe
|
|
41
41
|
def after_everything
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def confirm
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Sanji::Recipes::AdminNamespace < Sanji::Recipe
|
2
|
+
|
3
|
+
def confirm
|
4
|
+
'Create admin namespace for controllers?'
|
5
|
+
end
|
6
|
+
|
7
|
+
def after_bundle
|
8
|
+
a.generate 'controller', 'admin/base'
|
9
|
+
|
10
|
+
# Delete base folder created by generate
|
11
|
+
a.inside 'app/views/admin' do
|
12
|
+
a.run 'rm -R base'
|
13
|
+
end
|
14
|
+
|
15
|
+
self.add_route
|
16
|
+
end
|
17
|
+
|
18
|
+
def after_everything
|
19
|
+
if a.yes? 'Create admin layout?'
|
20
|
+
self.create_layout
|
21
|
+
|
22
|
+
a.insert_into_file 'app/controllers/admin/base_controller.rb',
|
23
|
+
:after => /ApplicationController\n/ do
|
24
|
+
a.text { |t| t.indent.puts "layout 'admin'" }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
def add_route
|
33
|
+
route =
|
34
|
+
a.text do |t|
|
35
|
+
t.puts 'namespace :admin do'
|
36
|
+
t.indent.puts 'end'
|
37
|
+
end
|
38
|
+
|
39
|
+
a.route route
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_layout
|
43
|
+
a.inside 'app/views/layouts' do
|
44
|
+
a.run 'cp application.html.haml admin.html.haml'
|
45
|
+
end
|
46
|
+
|
47
|
+
a.insert_into_file(
|
48
|
+
'app/views/layouts/admin.html.haml',
|
49
|
+
'.admin',
|
50
|
+
:after => '%body'
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/lib/sanji/recipes/draper.rb
CHANGED
data/lib/sanji/recipes/paloma.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
class Sanji::Recipes::PublicModule < Sanji::Recipe
|
2
|
+
|
3
|
+
def after_bundle
|
4
|
+
self.create_public_module if self.create_public_module?
|
5
|
+
self.create_home if self.create_home?
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def create_public_module?
|
12
|
+
if @create_public_module.nil?
|
13
|
+
@create_public_module = a.yes? 'Create public module for controllers?'
|
14
|
+
end
|
15
|
+
|
16
|
+
@create_public_module
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_public_module
|
20
|
+
a.generate 'controller', 'public/base'
|
21
|
+
|
22
|
+
# Remove base folder create by generate.
|
23
|
+
a.inside 'app/views/public' do
|
24
|
+
a.run 'rm -R base'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_home?
|
29
|
+
a.yes? 'Create public home controller?'
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_home
|
33
|
+
if self.create_public_module?
|
34
|
+
self.create_home_inside_module
|
35
|
+
else
|
36
|
+
self.create_home_outside_module
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_home_inside_module
|
41
|
+
a.generate 'controller', 'public/home', 'index'
|
42
|
+
|
43
|
+
a.gsub_file 'app/controllers/public/home_controller.rb',
|
44
|
+
/ApplicationController/,
|
45
|
+
'Public::BaseController'
|
46
|
+
|
47
|
+
a.route "root :to => 'public/home#index'"
|
48
|
+
|
49
|
+
# Change public namespace created by generate to module.
|
50
|
+
a.gsub_file 'config/routes.rb',
|
51
|
+
/namespace :public/,
|
52
|
+
'scope :module => :public'
|
53
|
+
|
54
|
+
# Remove route created by 'public/home index'
|
55
|
+
a.gsub_file 'config/routes.rb', /get 'home\/index'/, ''
|
56
|
+
end
|
57
|
+
|
58
|
+
def create_home_outside_module
|
59
|
+
a.generate 'controller', 'home', 'index'
|
60
|
+
|
61
|
+
# Remove route created by 'home index'
|
62
|
+
a.gsub_file 'config/routes.rb', /get 'home\/index'/, ''
|
63
|
+
|
64
|
+
a.route "root :to => 'home#index'"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/lib/sanji.yml
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# <%= app_name.titleize %>
|
2
|
+
|
3
|
+
## Servers
|
4
|
+
|
5
|
+
*none*
|
6
|
+
|
7
|
+
## Environment
|
8
|
+
|
9
|
+
- Ruby <%= RUBY_VERSION %>
|
10
|
+
- Rails <%= Rails.version %>
|
11
|
+
- PostgreSQL
|
12
|
+
|
13
|
+
## Development Setup
|
14
|
+
|
15
|
+
1. `bundle install`.
|
16
|
+
2. `rake db:create; rake db:migrate; rake db:seed`.
|
17
|
+
|
18
|
+
## Run
|
19
|
+
|
20
|
+
1. `bundle exec rails s`
|
21
|
+
|
22
|
+
## Tests
|
23
|
+
|
24
|
+
*none*
|
25
|
+
|
26
|
+
## Depolyment
|
27
|
+
|
28
|
+
*none*
|
29
|
+
|
30
|
+
## Developer Notes
|
31
|
+
|
32
|
+
*none*
|
33
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Paragua
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: rails application generator
|
14
14
|
email: kb.paragua@gmail.com
|
@@ -27,9 +27,9 @@ files:
|
|
27
27
|
- lib/sanji/config.rb
|
28
28
|
- lib/sanji/options.rb
|
29
29
|
- lib/sanji/recipe.rb
|
30
|
+
- lib/sanji/recipes/admin_namespace.rb
|
30
31
|
- lib/sanji/recipes/annotate.rb
|
31
32
|
- lib/sanji/recipes/cleanup.rb
|
32
|
-
- lib/sanji/recipes/controllers.rb
|
33
33
|
- lib/sanji/recipes/devise.rb
|
34
34
|
- lib/sanji/recipes/draper.rb
|
35
35
|
- lib/sanji/recipes/figaro.rb
|
@@ -37,11 +37,14 @@ files:
|
|
37
37
|
- lib/sanji/recipes/haml.rb
|
38
38
|
- lib/sanji/recipes/paloma.rb
|
39
39
|
- lib/sanji/recipes/postgresql.rb
|
40
|
+
- lib/sanji/recipes/public_module.rb
|
41
|
+
- lib/sanji/recipes/readme.rb
|
40
42
|
- lib/sanji/recipes/reform.rb
|
41
43
|
- lib/sanji/recipes/seedbank.rb
|
42
44
|
- lib/sanji/recipes/setup.rb
|
43
45
|
- lib/sanji/recipes/simple_gems.rb
|
44
46
|
- lib/sanji/utilities/text.rb
|
47
|
+
- templates/README.md.erb
|
45
48
|
- templates/base_form.rb
|
46
49
|
- templates/database.yml.erb
|
47
50
|
- templates/public_home_controller.rb
|
@@ -1,80 +0,0 @@
|
|
1
|
-
class Sanji::Recipes::Controllers < Sanji::Recipe
|
2
|
-
|
3
|
-
def after_bundle
|
4
|
-
self.setup_public
|
5
|
-
|
6
|
-
self.setup_admin if self.has_admin?
|
7
|
-
self.setup_private if self.has_private?
|
8
|
-
end
|
9
|
-
|
10
|
-
protected
|
11
|
-
|
12
|
-
def has_admin?
|
13
|
-
a.yes? 'Create admin namespace?'
|
14
|
-
end
|
15
|
-
|
16
|
-
def has_private?
|
17
|
-
a.yes? 'Create private module for logged-in non-admin users?'
|
18
|
-
end
|
19
|
-
|
20
|
-
def has_homepage?
|
21
|
-
a.yes? 'Create controller for public home page?'
|
22
|
-
end
|
23
|
-
|
24
|
-
def setup_admin
|
25
|
-
a.generate 'controller', 'admin/base'
|
26
|
-
|
27
|
-
a.inside 'app/views/admin' do
|
28
|
-
a.run 'rm -R base'
|
29
|
-
end
|
30
|
-
|
31
|
-
route =
|
32
|
-
a.text do |t|
|
33
|
-
t.indent.puts 'namespace :admin do'
|
34
|
-
t.indent.puts 'end'
|
35
|
-
end
|
36
|
-
|
37
|
-
a.route route
|
38
|
-
end
|
39
|
-
|
40
|
-
def setup_private
|
41
|
-
a.generate 'controller', 'private/base'
|
42
|
-
|
43
|
-
a.inside 'app/views/private' do
|
44
|
-
a.run 'rm -R base'
|
45
|
-
end
|
46
|
-
|
47
|
-
route =
|
48
|
-
a.text do |t|
|
49
|
-
t.indent.puts 'scope :module => :private do'
|
50
|
-
t.indent.puts 'end'
|
51
|
-
end
|
52
|
-
|
53
|
-
a.route route
|
54
|
-
end
|
55
|
-
|
56
|
-
def setup_public
|
57
|
-
a.generate 'controller', 'public/base'
|
58
|
-
|
59
|
-
a.inside 'app/views/public' do
|
60
|
-
a.run 'rm -R base'
|
61
|
-
end
|
62
|
-
|
63
|
-
if self.has_homepage?
|
64
|
-
a.copy_file 'public_home_controller.rb',
|
65
|
-
'app/controller/public/home_controller.rb'
|
66
|
-
|
67
|
-
a.template 'public_home_index.haml.erb', 'app/views/public/home/index.haml'
|
68
|
-
|
69
|
-
a.route "root :to => 'public/home#index'"
|
70
|
-
|
71
|
-
# Change public namespace to module only.
|
72
|
-
a.gsub_file 'config/routes.rb',
|
73
|
-
/namespace :public/,
|
74
|
-
'scope :module => :public'
|
75
|
-
else
|
76
|
-
a.route "scope :module => :public do\n end"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|