chili 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.
- data/README.md +6 -7
- data/bin/chili +2 -1
- data/lib/chili.rb +1 -0
- data/lib/chili/extensions/rails/engine.rb +9 -0
- data/lib/chili/template.rb +1 -8
- data/lib/chili/version.rb +1 -1
- metadata +2 -1
data/README.md
CHANGED
@@ -19,7 +19,6 @@ Unobtrusively(!)...
|
|
19
19
|
|
20
20
|
### Obstacles
|
21
21
|
|
22
|
-
- Resource route generator adds routes both to engine and main routes file
|
23
22
|
- Deface caches overrides in production. Monkey patch?
|
24
23
|
|
25
24
|
### Minor niggles
|
@@ -38,10 +37,10 @@ Assuming you want to add a new extension that adds "like" capabilities to a subs
|
|
38
37
|
|
39
38
|
chili likes
|
40
39
|
|
41
|
-
This is basically a shortcut for running the rails engine generator with
|
42
|
-
a custom template:
|
40
|
+
This is basically a shortcut for running the `rails plugin new` engine generator with a custom template.
|
43
41
|
|
44
|
-
|
42
|
+
The script will prompt you for the location of your main app repository to which you are adding the chili extension.
|
43
|
+
The repo will be added as a submodule in the main_app directory.
|
45
44
|
|
46
45
|
### Prepare main app
|
47
46
|
|
@@ -78,16 +77,16 @@ As an example, assuming the main app has a partial at `app/views/posts/_post.htm
|
|
78
77
|
### Adding new resources
|
79
78
|
|
80
79
|
Use `rails g scaffold Like` as usual when using engines. The new resource will be namespaced to ChiliLikes::Like
|
81
|
-
and automounted in the main app at `/
|
82
|
-
[engine-based models](http://railscasts.com/episodes/277-mountable-engines?view=asciicast) apply.
|
80
|
+
and automounted in the main app at `/chili_likes/likes`, but only accessible when active_if is true.
|
81
|
+
All the rules for using [engine-based models](http://railscasts.com/episodes/277-mountable-engines?view=asciicast) apply.
|
83
82
|
|
84
83
|
### Modifying existing models
|
85
84
|
|
86
85
|
Create a model with the same name as the one you want to modify: `rails g model User --migration=false`
|
87
86
|
and inherit from the original:
|
88
87
|
|
89
|
-
```ruby
|
90
88
|
# app/model/chili_likes/user.rb
|
89
|
+
```ruby
|
91
90
|
module ChiliLikes
|
92
91
|
class User < ::User
|
93
92
|
has_many :likes
|
data/bin/chili
CHANGED
@@ -1,3 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
template_file = File.join(File.dirname(__FILE__), '..', 'lib', 'chili', 'template.rb')
|
4
|
+
system "rails plugin new chili_#{ARGV.first} --mountable -m #{template_file}"
|
data/lib/chili.rb
CHANGED
data/lib/chili/template.rb
CHANGED
@@ -60,14 +60,7 @@ RUBY
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# Automount engine
|
63
|
-
|
64
|
-
|
65
|
-
# Automount engine
|
66
|
-
Rails.application.routes.draw do
|
67
|
-
mount #{app_path.camelcase}::Engine => "/#{app_path}"
|
68
|
-
end
|
69
|
-
RUBY
|
70
|
-
end
|
63
|
+
prepend_to_file 'config/routes.rb', "#{app_path.camelcase}::Engine.automount!\n"
|
71
64
|
|
72
65
|
# Include chili libs
|
73
66
|
prepend_to_file "lib/#{app_path}.rb" do <<-RUBY
|
data/lib/chili/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chili
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- lib/chili.rb
|
31
31
|
- lib/chili/activatable.rb
|
32
32
|
- lib/chili/engine.rb
|
33
|
+
- lib/chili/extensions/rails/engine.rb
|
33
34
|
- lib/chili/overrides.rb
|
34
35
|
- lib/chili/tasks.rb
|
35
36
|
- lib/chili/template.rb
|