chili 1.0.1 → 2.0.0
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.
- data/.gitignore +7 -7
- data/README.md +33 -28
- data/Rakefile +1 -1
- data/app/controllers/chili/application_controller.rb +3 -3
- data/chili.gemspec +3 -3
- data/lib/chili.rb +5 -3
- data/lib/chili/feature.rb +15 -0
- data/lib/chili/version.rb +1 -1
- data/lib/generators/chili/feature/USAGE +8 -0
- data/lib/generators/chili/{extension_generator.rb → feature/feature_generator.rb} +36 -37
- data/lib/generators/chili/generator_proxy.rb +20 -0
- data/spec/dummy/app/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/config/application.rb +14 -0
- data/spec/dummy/{example_app → app}/config/boot.rb +1 -2
- data/spec/dummy/{example_app → app}/config/database.yml +0 -0
- data/spec/dummy/{example_app → app}/config/environment.rb +0 -0
- data/spec/dummy/{example_app → app}/config/environments/development.rb +0 -0
- data/spec/dummy/{example_app → app}/config/environments/test.rb +0 -0
- data/spec/dummy/{example_app → app}/script/rails +0 -0
- data/spec/dummy/{blank_extension → blank_feature}/MIT-LICENSE +0 -0
- data/spec/dummy/blank_feature/README.rdoc +3 -0
- data/spec/dummy/{blank_extension/app/assets/images/blank_extension → blank_feature/app/assets/images/blank_feature}/.gitkeep +0 -0
- data/spec/dummy/{blank_extension/app/assets/javascripts/blank_extension → blank_feature/app/assets/javascripts/blank_feature}/application.js +0 -0
- data/spec/dummy/{blank_extension/app/assets/stylesheets/blank_extension → blank_feature/app/assets/stylesheets/blank_feature}/application.css +0 -0
- data/spec/dummy/blank_feature/app/controllers/blank_feature/application_controller.rb +4 -0
- data/spec/dummy/blank_feature/app/overrides/layouts/application/assets.html.erb.deface +3 -0
- data/spec/dummy/{blank_extension → blank_feature}/app/overrides/layouts/application/example.html.erb.deface +2 -2
- data/spec/dummy/{blank_extension/blank_extension.gemspec → blank_feature/blank_feature.gemspec} +6 -6
- data/spec/dummy/blank_feature/config/routes.rb +3 -0
- data/spec/dummy/blank_feature/lib/blank_feature.rb +7 -0
- data/spec/dummy/blank_feature/lib/blank_feature/engine.rb +5 -0
- data/spec/dummy/{blank_extension/lib/blank_extension → blank_feature/lib/blank_feature}/version.rb +1 -1
- data/spec/dummy/blank_feature/lib/generators/blank_feature_generator.rb +3 -0
- data/spec/dummy/{blank_extension/lib/tasks/blank_extension_tasks.rake → blank_feature/lib/tasks/blank_feature_tasks.rake} +1 -1
- data/spec/{dummy/example_app → example_app}/README.rdoc +0 -0
- data/spec/{dummy/example_app → example_app}/Rakefile +0 -0
- data/spec/{dummy/example_app → example_app}/app/assets/javascripts/application.js +0 -0
- data/spec/{dummy/example_app → example_app}/app/assets/stylesheets/application.css +0 -0
- data/spec/{dummy/example_app → example_app}/app/assets/stylesheets/posts.css +0 -0
- data/spec/{dummy/example_app → example_app}/app/assets/stylesheets/scaffold.css +0 -0
- data/spec/{dummy/example_app → example_app}/app/assets/stylesheets/users.css +0 -0
- data/spec/{dummy/example_app → example_app}/app/controllers/application_controller.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/controllers/posts_controller.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/controllers/sessions_controller.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/controllers/users_controller.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/helpers/application_helper.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/helpers/posts_helper.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/helpers/users_helper.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/mailers/.gitkeep +0 -0
- data/spec/{dummy/example_app → example_app}/app/models/.gitkeep +0 -0
- data/spec/{dummy/example_app → example_app}/app/models/post.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/models/user.rb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/layouts/application.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/posts/_form.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/posts/_post.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/posts/edit.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/posts/index.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/posts/new.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/posts/show.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/sessions/new.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/users/_form.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/users/edit.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/users/index.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/users/new.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/app/views/users/show.html.erb +0 -0
- data/spec/{dummy/example_app → example_app}/config.ru +0 -0
- data/spec/{dummy/example_app → example_app}/config/application.rb +2 -2
- data/spec/example_app/config/boot.rb +12 -0
- data/spec/example_app/config/database.yml +25 -0
- data/spec/example_app/config/environment.rb +5 -0
- data/spec/example_app/config/environments/development.rb +37 -0
- data/spec/{dummy/example_app → example_app}/config/environments/production.rb +0 -0
- data/spec/example_app/config/environments/test.rb +37 -0
- data/spec/{dummy/example_app → example_app}/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/{dummy/example_app → example_app}/config/initializers/inflections.rb +0 -0
- data/spec/{dummy/example_app → example_app}/config/initializers/mime_types.rb +0 -0
- data/spec/{dummy/example_app → example_app}/config/initializers/secret_token.rb +0 -0
- data/spec/{dummy/example_app → example_app}/config/initializers/session_store.rb +0 -0
- data/spec/{dummy/example_app → example_app}/config/initializers/wrap_parameters.rb +0 -0
- data/spec/{dummy/example_app → example_app}/config/locales/en.yml +0 -0
- data/spec/{dummy/example_app → example_app}/config/routes.rb +0 -0
- data/spec/{dummy/example_app → example_app}/db/migrate/20120513023816_create_posts.rb +0 -0
- data/spec/{dummy/example_app → example_app}/db/migrate/20120513023840_create_users.rb +0 -0
- data/spec/example_app/db/migrate/20120513032032_create_social_feature_likes.rb +11 -0
- data/spec/{dummy/example_app → example_app}/db/schema.rb +1 -1
- data/spec/{dummy/example_app → example_app}/lib/assets/.gitkeep +0 -0
- data/spec/{dummy/example_app/vendor/chili/invites_extension → example_app/lib/chili/invites_feature}/.gitignore +0 -0
- data/spec/{dummy/example_app/log → example_app/lib/chili/invites_feature/app/assets/images/invites_feature}/.gitkeep +0 -0
- data/spec/{dummy/example_app/vendor/chili/invites_extension/app/assets/javascripts/invites_extension → example_app/lib/chili/invites_feature/app/assets/javascripts/invites_feature}/application.js +0 -0
- data/spec/{dummy/example_app/vendor/chili/invites_extension/app/assets/stylesheets/invites_extension → example_app/lib/chili/invites_feature/app/assets/stylesheets/invites_feature}/application.css +0 -0
- data/spec/example_app/lib/chili/invites_feature/app/controllers/invites_feature/application_controller.rb +4 -0
- data/spec/{dummy/example_app/vendor/chili/invites_extension → example_app/lib/chili/invites_feature}/app/overrides/posts/index/disclaimer.html.erb.deface +0 -0
- data/spec/example_app/lib/chili/invites_feature/config/routes.rb +3 -0
- data/spec/example_app/lib/chili/invites_feature/lib/generators/invites_feature_generator.rb +3 -0
- data/spec/{dummy/example_app/vendor/chili/invites_extension/lib/invites_extension.rb → example_app/lib/chili/invites_feature/lib/invites_feature.rb} +2 -2
- data/spec/example_app/lib/chili/invites_feature/lib/invites_feature/engine.rb +5 -0
- data/spec/{dummy/example_app/vendor/chili/invites_extension/app/assets/images/invites_extension → example_app/lib/chili/social_feature/app/assets/images/social_feature}/.gitkeep +0 -0
- data/spec/{dummy/example_app/vendor/chili/social_extension/app/assets/javascripts/social_extension → example_app/lib/chili/social_feature/app/assets/javascripts/social_feature}/application.js +0 -0
- data/spec/{dummy/example_app/vendor/chili/social_extension/app/assets/stylesheets/social_extension → example_app/lib/chili/social_feature/app/assets/stylesheets/social_feature}/application.css.scss +0 -0
- data/spec/example_app/lib/chili/social_feature/app/controllers/social_feature/application_controller.rb +4 -0
- data/spec/{dummy/example_app/vendor/chili/social_extension/app/controllers/social_extension → example_app/lib/chili/social_feature/app/controllers/social_feature}/likes_controller.rb +3 -3
- data/spec/{dummy/example_app/vendor/chili/social_extension/app/models/social_extension → example_app/lib/chili/social_feature/app/models/social_feature}/like.rb +1 -1
- data/spec/{dummy/example_app/vendor/chili/social_extension/app/models/social_extension → example_app/lib/chili/social_feature/app/models/social_feature}/post.rb +1 -1
- data/spec/{dummy/example_app/vendor/chili/social_extension/app/models/social_extension → example_app/lib/chili/social_feature/app/models/social_feature}/user.rb +1 -1
- data/spec/example_app/lib/chili/social_feature/app/overrides/layouts/application/likes_link.html.erb.deface +2 -0
- data/spec/{dummy/example_app/vendor/chili/social_extension → example_app/lib/chili/social_feature}/app/overrides/posts/_post/like_actions.html.erb.deface +2 -2
- data/spec/{dummy/example_app/vendor/chili/social_extension → example_app/lib/chili/social_feature}/app/overrides/posts/index/disclaimer.html.erb.deface +0 -0
- data/spec/{dummy/example_app/vendor/chili/social_extension → example_app/lib/chili/social_feature}/app/overrides/posts/index/table_headers.html.erb.deface +0 -0
- data/spec/{dummy/example_app/vendor/chili/social_extension/app/views/social_extension → example_app/lib/chili/social_feature/app/views/social_feature}/likes/index.html.erb +0 -0
- data/spec/example_app/lib/chili/social_feature/config/routes.rb +4 -0
- data/spec/example_app/lib/chili/social_feature/db/migrate/20120513031021_create_social_feature_likes.rb +10 -0
- data/spec/example_app/lib/chili/social_feature/lib/generators/social_feature_generator.rb +3 -0
- data/spec/{dummy/example_app/vendor/chili/social_extension/lib/social_extension.rb → example_app/lib/chili/social_feature/lib/social_feature.rb} +2 -2
- data/spec/example_app/lib/chili/social_feature/lib/social_feature/engine.rb +5 -0
- data/spec/{dummy/example_app/vendor/chili/social_extension/app/assets/images/social_extension → example_app/log}/.gitkeep +0 -0
- data/spec/{dummy/example_app → example_app}/public/404.html +0 -0
- data/spec/{dummy/example_app → example_app}/public/422.html +0 -0
- data/spec/{dummy/example_app → example_app}/public/500.html +0 -0
- data/spec/{dummy/example_app → example_app}/public/favicon.ico +0 -0
- data/spec/example_app/script/rails +6 -0
- data/spec/{dummy/example_app → example_app}/spec/support/user_macros.rb +0 -0
- data/spec/generators/chili/feature_generator_spec.rb +40 -0
- data/spec/generators/chili/generator_proxy_spec.rb +28 -0
- data/spec/requests/social_extension_spec.rb +5 -5
- data/spec/spec_helper.rb +2 -1
- data/spec/support/dummy_app.rb +21 -0
- metadata +251 -256
- data/lib/generators/chili/USAGE +0 -8
- data/lib/generators/rails/chili_generator.rb +0 -11
- data/lib/generators/rails/templates/controller.rb +0 -73
- data/spec/dummy/blank_extension/README.rdoc +0 -3
- data/spec/dummy/blank_extension/app/overrides/layouts/application/assets.html.erb.deface +0 -3
- data/spec/dummy/blank_extension/config/routes.rb +0 -3
- data/spec/dummy/blank_extension/lib/blank_extension.rb +0 -7
- data/spec/dummy/blank_extension/lib/blank_extension/engine.rb +0 -10
- data/spec/dummy/blank_extension/script/rails +0 -8
- data/spec/dummy/example_app/db/migrate/20120513032032_create_social_extension_likes.rb +0 -11
- data/spec/dummy/example_app/vendor/chili/invites_extension/config/routes.rb +0 -3
- data/spec/dummy/example_app/vendor/chili/invites_extension/lib/invites_extension/engine.rb +0 -10
- data/spec/dummy/example_app/vendor/chili/social_extension/app/overrides/layouts/application/likes_link.html.erb.deface +0 -2
- data/spec/dummy/example_app/vendor/chili/social_extension/config/routes.rb +0 -4
- data/spec/dummy/example_app/vendor/chili/social_extension/db/migrate/20120513031021_create_likes_extension_likes.rb +0 -10
- data/spec/dummy/example_app/vendor/chili/social_extension/lib/social_extension/engine.rb +0 -10
- data/spec/generators/chili/chili_generator_spec.rb +0 -53
data/.gitignore
CHANGED
|
@@ -12,13 +12,13 @@ lib/bundler/man
|
|
|
12
12
|
pkg
|
|
13
13
|
rdoc
|
|
14
14
|
spec/reports
|
|
15
|
-
spec/
|
|
16
|
-
spec/
|
|
17
|
-
spec/
|
|
18
|
-
spec/
|
|
19
|
-
spec/dummy/
|
|
20
|
-
spec/dummy/
|
|
21
|
-
spec/dummy/
|
|
15
|
+
spec/example_app/db/*.sqlite3
|
|
16
|
+
spec/example_app/log/*.log
|
|
17
|
+
spec/example_app/tmp/
|
|
18
|
+
spec/example_app/.sass-cache
|
|
19
|
+
spec/dummy/app/Gemfile
|
|
20
|
+
spec/dummy/app/log/
|
|
21
|
+
spec/dummy/app/lib/
|
|
22
22
|
tmp
|
|
23
23
|
.DS_Store
|
|
24
24
|
.pt
|
data/README.md
CHANGED
|
@@ -28,32 +28,32 @@ and run `bundle`.
|
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
30
30
|
|
|
31
|
-
Chili
|
|
31
|
+
Chili features are like mini apps that are created inside your main app's lib/chili directory using using the "chili" generator.
|
|
32
32
|
|
|
33
|
-
### Creating a new chili
|
|
33
|
+
### Creating a new chili feature
|
|
34
34
|
|
|
35
|
-
As an example, assuming you want to add a
|
|
35
|
+
As an example, assuming you want to add a beta feature named "social" that shows a new like-button
|
|
36
36
|
to a subset of users, first within your main app run:
|
|
37
37
|
|
|
38
|
-
$ rails g chili:
|
|
38
|
+
$ rails g chili:feature social
|
|
39
39
|
|
|
40
40
|
This will:
|
|
41
41
|
|
|
42
|
-
1. Create the directory `
|
|
43
|
-
2. Add a reference to the
|
|
42
|
+
1. Create the directory `lib/chili/social_feature` containing the basic structure for the feature
|
|
43
|
+
2. Add a reference to the feature to the main app gemfile
|
|
44
44
|
|
|
45
|
-
Since the
|
|
45
|
+
Since the feature is mounted as a gem you'll have to restart the app.
|
|
46
46
|
|
|
47
|
-
### Define who can see the
|
|
47
|
+
### Define who can see the feature
|
|
48
48
|
|
|
49
|
-
Use the active_if block to control whether new the
|
|
49
|
+
Use the active_if block to control whether new the feature is active for each user.
|
|
50
50
|
The context of the active_if block is the application controller so you can use any methods available to that.
|
|
51
51
|
|
|
52
52
|
```ruby
|
|
53
|
-
# lib/
|
|
54
|
-
module
|
|
53
|
+
# lib/social_feature.rb
|
|
54
|
+
module SocialFeature
|
|
55
55
|
extend Chili::Activatable
|
|
56
|
-
active_if { logged_in? && current_user.admin? } #
|
|
56
|
+
active_if { logged_in? && current_user.admin? } # Feature is only visible to logged in admin users
|
|
57
57
|
end
|
|
58
58
|
```
|
|
59
59
|
|
|
@@ -66,56 +66,61 @@ For example, assuming the main app has the partial `app/views/posts/_post.html.e
|
|
|
66
66
|
```erb
|
|
67
67
|
<% # app/overrides/posts/_post/like_button.html.erb.deface (folder should mirror main app view path) %>
|
|
68
68
|
<!-- insert_bottom 'tr' -->
|
|
69
|
-
<td><%= link_to 'Like!',
|
|
69
|
+
<td><%= link_to 'Like!', social_feature.likes_path(like: {post_id: post}), method: :post %></td>
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
### Adding new resources
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
You can run the usual Rails generators for each feature by prepending
|
|
75
|
+
the generator with the name of the feature:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
$ rails g social_feature scaffold Like
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The new resource will be namespaced to `SocialFeature::Like` and automounted as an [isolated engine](http://railscasts.com/episodes/277-mountable-engines?view=asciicast) in the main app at `/chili/social_feature/likes`,
|
|
76
82
|
but will only be accessible when active_if is true.
|
|
77
83
|
|
|
78
84
|
### Migrations
|
|
79
85
|
|
|
80
86
|
Migrations are handled the same way as engines. Use the
|
|
81
|
-
following commands after you've added a new migration to
|
|
87
|
+
following commands after you've added a new migration to a feature:
|
|
82
88
|
|
|
83
|
-
$ rake
|
|
89
|
+
$ rake social_feature:migrations:install
|
|
84
90
|
$ rake db:migrate
|
|
85
91
|
|
|
86
92
|
### Modifying existing models
|
|
87
93
|
|
|
88
|
-
Create a model with the same name as the one you want to modify by running: `rails g model User --migration=false`
|
|
89
|
-
and edit it to inherit from the original:
|
|
94
|
+
Create a model with the same name as the one you want to modify by running: `rails g social_feature model User --migration=false` and edit it to inherit from the original:
|
|
90
95
|
|
|
91
96
|
```ruby
|
|
92
|
-
# app/models/
|
|
93
|
-
module
|
|
97
|
+
# app/models/social_feature/user.rb
|
|
98
|
+
module SocialFeature
|
|
94
99
|
class User < ::User
|
|
95
100
|
has_many :likes
|
|
96
101
|
end
|
|
97
102
|
end
|
|
98
103
|
```
|
|
99
104
|
|
|
100
|
-
Access in your overrides/
|
|
105
|
+
Access in your overrides/feature views through the namespaced model:
|
|
101
106
|
|
|
102
107
|
```erb
|
|
103
|
-
<%=
|
|
104
|
-
<%= current_user.becomes(
|
|
108
|
+
<%= SocialFeature::User.first.likes %>
|
|
109
|
+
<%= current_user.becomes(SocialFeature::User).likes %>
|
|
105
110
|
```
|
|
106
111
|
|
|
107
112
|
### Stylesheets/javascripts
|
|
108
113
|
|
|
109
|
-
Files added to the
|
|
114
|
+
Files added to the feature's `app/assets/social_feature/javascripts|stylesheets` directory are automatically injected into the layout using a pre-generated override:
|
|
110
115
|
|
|
111
116
|
```erb
|
|
112
117
|
<% # app/overrides/layouts/application/assets.html.erb.deface %>
|
|
113
118
|
<!-- insert_bottom 'head' -->
|
|
114
|
-
<%= stylesheet_link_tag '
|
|
115
|
-
<%= javascript_include_tag '
|
|
119
|
+
<%= stylesheet_link_tag 'social_feature/application' %>
|
|
120
|
+
<%= javascript_include_tag 'social_feature/application' %>
|
|
116
121
|
```
|
|
117
122
|
|
|
118
|
-
If you don't need any css/js in your
|
|
123
|
+
If you don't need any css/js in your feature, you can remove this file.
|
|
119
124
|
|
|
120
125
|
## Gotchas
|
|
121
126
|
|
data/Rakefile
CHANGED
|
@@ -6,7 +6,7 @@ rescue LoadError
|
|
|
6
6
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
APP_RAKEFILE = File.expand_path("../spec/
|
|
9
|
+
APP_RAKEFILE = File.expand_path("../spec/example_app/Rakefile", __FILE__)
|
|
10
10
|
load 'rails/tasks/engine.rake'
|
|
11
11
|
|
|
12
12
|
require 'rspec/core/rake_task'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module Chili
|
|
2
2
|
class ApplicationController < ::ApplicationController
|
|
3
|
-
before_filter :
|
|
3
|
+
before_filter :activate_feature
|
|
4
4
|
|
|
5
5
|
private
|
|
6
|
-
def
|
|
7
|
-
raise ActionController::RoutingError, '
|
|
6
|
+
def activate_feature
|
|
7
|
+
raise ActionController::RoutingError, 'Feature Disabled' unless self.class.parent.active?(self)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
data/chili.gemspec
CHANGED
|
@@ -4,8 +4,8 @@ require File.expand_path('../lib/chili/version', __FILE__)
|
|
|
4
4
|
Gem::Specification.new do |gem|
|
|
5
5
|
gem.authors = ["Jens Balvig"]
|
|
6
6
|
gem.email = ["jens@balvig.com"]
|
|
7
|
-
gem.description = %q{The spicy
|
|
8
|
-
gem.summary = %q{The spicy
|
|
7
|
+
gem.description = %q{The spicy feature toggle framework}
|
|
8
|
+
gem.summary = %q{The spicy feature toggle framework}
|
|
9
9
|
gem.homepage = "http://balvig.github.com/chili/"
|
|
10
10
|
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
|
@@ -22,5 +22,5 @@ Gem::Specification.new do |gem|
|
|
|
22
22
|
gem.add_development_dependency 'rspec-rails', '~> 2.9.0'
|
|
23
23
|
gem.add_development_dependency 'jquery-rails'
|
|
24
24
|
gem.add_development_dependency 'capybara'
|
|
25
|
-
gem.add_development_dependency
|
|
25
|
+
gem.add_development_dependency 'sqlite3'
|
|
26
26
|
end
|
data/lib/chili.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
require "deface"
|
|
2
|
-
require "chili/version"
|
|
3
|
-
require "chili/engine"
|
|
4
|
-
require "chili/overrides"
|
|
5
2
|
require "chili/activatable"
|
|
6
3
|
require "chili/bundler"
|
|
4
|
+
require "chili/engine"
|
|
7
5
|
require "chili/extensions/rails/engine"
|
|
6
|
+
require "chili/feature"
|
|
7
|
+
require "chili/overrides"
|
|
8
|
+
require "chili/version"
|
|
9
|
+
require "generators/chili/generator_proxy"
|
data/lib/chili/version.rb
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
module Chili
|
|
2
2
|
module Generators
|
|
3
|
-
class
|
|
4
|
-
NAME = "#{ARGV[0]}_extension"
|
|
5
|
-
PATH = "vendor/chili/#{NAME}"
|
|
3
|
+
class FeatureGenerator < Rails::Generators::NamedBase
|
|
6
4
|
|
|
7
5
|
def run_plugin_generator
|
|
8
|
-
ARGV[0] =
|
|
9
|
-
ARGV[1] =
|
|
6
|
+
ARGV[0] = feature.path
|
|
7
|
+
ARGV[1] = '--mountable'
|
|
10
8
|
ARGV[2] = '--skip-test-unit'
|
|
11
9
|
ARGV[3] = '--skip-bundle'
|
|
12
10
|
|
|
@@ -20,9 +18,9 @@ module Chili
|
|
|
20
18
|
end
|
|
21
19
|
|
|
22
20
|
def edit_gemspec
|
|
23
|
-
require File.expand_path('
|
|
24
|
-
gemspec = "#{
|
|
25
|
-
gsub_file gemspec, '# s.add_dependency "jquery-rails"', "s.add_dependency 'chili', '~> #{Chili::VERSION}'"
|
|
21
|
+
require File.expand_path('../../../../chili/version', __FILE__)
|
|
22
|
+
gemspec = "#{feature.name}.gemspec"
|
|
23
|
+
gsub_file gemspec, '# s.add_dependency "jquery-rails"', "s.add_dependency 'chili', '~> #{Chili::VERSION.sub(/\.\d+$/,'')}'"
|
|
26
24
|
gsub_file gemspec, 'TODO: Your name', `git config user.NAME`.chomp
|
|
27
25
|
gsub_file gemspec, 'TODO: Your email', `git config user.email`.chomp
|
|
28
26
|
gsub_file gemspec, /TODO(:\s)?/, ''
|
|
@@ -32,38 +30,25 @@ module Chili
|
|
|
32
30
|
gemfile = "../../../Gemfile"
|
|
33
31
|
group = "group :chili do\n"
|
|
34
32
|
append_to_file gemfile, group
|
|
35
|
-
append_to_file gemfile, " gem '#{
|
|
33
|
+
append_to_file gemfile, " gem '#{feature.name}', path: '#{feature.path}'\nend", after: group
|
|
36
34
|
gsub_file gemfile, 'end gem', ' gem' #nasty cleanup
|
|
37
35
|
end
|
|
38
36
|
|
|
39
37
|
def remove_unused_files
|
|
40
|
-
remove_dir "app/
|
|
41
|
-
remove_dir "app/helpers/#{NAME}"
|
|
38
|
+
remove_dir "app/helpers/#{feature.name}"
|
|
42
39
|
remove_dir 'app/views/layouts'
|
|
40
|
+
remove_dir 'script'
|
|
43
41
|
remove_file 'Gemfile'
|
|
44
42
|
remove_file 'Rakefile'
|
|
45
43
|
end
|
|
46
44
|
|
|
47
45
|
def remove_jquery_stuff
|
|
48
|
-
gsub_file "app/assets/javascripts/#{
|
|
49
|
-
gsub_file "app/assets/javascripts/#{
|
|
46
|
+
gsub_file "app/assets/javascripts/#{feature.name}/application.js", "//= require jquery_ujs\n", ''
|
|
47
|
+
gsub_file "app/assets/javascripts/#{feature.name}/application.js", "//= require jquery\n", ''
|
|
50
48
|
end
|
|
51
49
|
|
|
52
|
-
def
|
|
53
|
-
|
|
54
|
-
config.generators do |g|
|
|
55
|
-
g.scaffold_controller :chili
|
|
56
|
-
end
|
|
57
|
-
RUBY
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def set_up_rspec
|
|
62
|
-
inject_into_file "lib/#{NAME}/engine.rb", :after => " g.scaffold_controller :chili\n" do <<-RUBY
|
|
63
|
-
g.test_framework :rspec, view_specs: false, routing_specs: false, controller_specs: false
|
|
64
|
-
g.integration_tool :rspec
|
|
65
|
-
RUBY
|
|
66
|
-
end
|
|
50
|
+
def chilify_application_controller
|
|
51
|
+
gsub_file "app/controllers/#{feature.name}/application_controller.rb", "ActionController::Base", 'Chili::ApplicationController'
|
|
67
52
|
end
|
|
68
53
|
|
|
69
54
|
def clean_up_gitignore
|
|
@@ -71,17 +56,17 @@ module Chili
|
|
|
71
56
|
end
|
|
72
57
|
|
|
73
58
|
def automount_engine
|
|
74
|
-
prepend_to_file 'config/routes.rb', "#{
|
|
59
|
+
prepend_to_file 'config/routes.rb', "#{feature.name.camelcase}::Engine.automount!\n"
|
|
75
60
|
end
|
|
76
61
|
|
|
77
62
|
def include_chili_libs
|
|
78
|
-
prepend_to_file "lib/#{
|
|
63
|
+
prepend_to_file "lib/#{feature.name}.rb", "require \"chili\"\n"
|
|
79
64
|
end
|
|
80
65
|
|
|
81
66
|
def include_active_if
|
|
82
|
-
inject_into_file "lib/#{
|
|
67
|
+
inject_into_file "lib/#{feature.name}.rb", after: "module #{feature.name.camelcase}\n" do <<-RUBY
|
|
83
68
|
extend Chili::Activatable
|
|
84
|
-
active_if { true } # edit this to activate/deactivate
|
|
69
|
+
active_if { true } # edit this to activate/deactivate feature at runtime
|
|
85
70
|
RUBY
|
|
86
71
|
end
|
|
87
72
|
end
|
|
@@ -91,8 +76,8 @@ module Chili
|
|
|
91
76
|
create_file example_file_path do <<-RUBY
|
|
92
77
|
<!-- insert_bottom 'body' -->
|
|
93
78
|
<div style='background: #FFF;text-align: center; padding: 4px 0;position: fixed;width: 100%;z-index: 9999;top: 0;'>
|
|
94
|
-
#{
|
|
95
|
-
<strong>#{
|
|
79
|
+
#{feature.name} active - edit/remove this file:<br/>
|
|
80
|
+
<strong>#{feature.path}/#{example_file_path}</strong><br/>
|
|
96
81
|
<%= link_to 'deface docs', 'https://github.com/spree/deface', target: '_blank' %>
|
|
97
82
|
</div>
|
|
98
83
|
RUBY
|
|
@@ -102,12 +87,26 @@ module Chili
|
|
|
102
87
|
def add_assets_override
|
|
103
88
|
create_file 'app/overrides/layouts/application/assets.html.erb.deface' do <<-RUBY
|
|
104
89
|
<!-- insert_bottom 'head' -->
|
|
105
|
-
<%= stylesheet_link_tag '#{
|
|
106
|
-
<%= javascript_include_tag '#{
|
|
90
|
+
<%= stylesheet_link_tag '#{feature.name}/application' %>
|
|
91
|
+
<%= javascript_include_tag '#{feature.name}/application' %>
|
|
107
92
|
RUBY
|
|
108
93
|
end
|
|
109
94
|
end
|
|
110
|
-
end
|
|
111
95
|
|
|
96
|
+
def add_generator_proxy
|
|
97
|
+
create_file "lib/generators/#{feature.name}_generator.rb" do <<-RUBY
|
|
98
|
+
class #{feature.name.camelcase}Generator < Rails::Generators::Base
|
|
99
|
+
include Chili::GeneratorProxy
|
|
100
|
+
end
|
|
101
|
+
RUBY
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
protected
|
|
106
|
+
|
|
107
|
+
def feature
|
|
108
|
+
@feature ||= Chili::Feature.new(ARGV[0])
|
|
109
|
+
end
|
|
110
|
+
end
|
|
112
111
|
end
|
|
113
112
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Chili
|
|
2
|
+
module GeneratorProxy
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.class_eval do
|
|
5
|
+
argument :generator, type: :string
|
|
6
|
+
argument :generator_options, type: :array, default: [], banner: "GENERATOR_OPTIONS"
|
|
7
|
+
|
|
8
|
+
def self.desc
|
|
9
|
+
"Generates resources (scaffold, model, migration etc) for #{generator_name}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def delegate
|
|
13
|
+
engine = self.class.generator_name.classify.constantize
|
|
14
|
+
Rails::Generators.namespace = engine
|
|
15
|
+
Rails::Generators.invoke ARGV.shift, ARGV, destination_root: Feature.new(engine).path, behavior: behavior
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'rails/all'
|
|
4
|
+
|
|
5
|
+
Bundler.require
|
|
6
|
+
require "chili"
|
|
7
|
+
Dir.glob(File.expand_path('../../lib/chili/*', __FILE__)).each do |dir|
|
|
8
|
+
require File.basename(dir)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module Dummy
|
|
12
|
+
class Application < Rails::Application
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -8,5 +8,4 @@ if File.exist?(gemfile)
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
$:.unshift File.expand_path('../../../../../lib', __FILE__)
|
|
11
|
-
$:.unshift File.expand_path('../../
|
|
12
|
-
$:.unshift File.expand_path('../../vendor/chili/invites_extension/lib', __FILE__)
|
|
11
|
+
$:.unshift File.expand_path('../../lib/chili/blank_feature/lib', __FILE__)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|