app2engine 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +31 -20
- data/lib/app2engine/rake/convert_tasks.rb +1 -1
- metadata +4 -4
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -2,12 +2,18 @@
|
|
2
2
|
|
3
3
|
Convert a Rails 3 app to an Engine.
|
4
4
|
|
5
|
-
The structure of a standard Rails application is very similar to what you need for an Engine.
|
6
|
-
|
7
|
-
But a few details need to be changed.
|
5
|
+
The structure of a standard Rails application is very similar to what you need for an Engine, but a few details need to be changed.
|
8
6
|
|
9
7
|
This tool intend to do most of them for you.
|
10
8
|
|
9
|
+
## enginex
|
10
|
+
|
11
|
+
[`enginex`](http://github.com/josevalim/enginex) from José Valim is a similar tool, except it generates the structure of an Engine instead of converting.
|
12
|
+
|
13
|
+
If app2engine does not work as expected, I recommend to use enginex, since it is likely more up-to-date and made by a member of the Rails core team.
|
14
|
+
|
15
|
+
app2engine however keep all its interest as a light solution for converting applications.
|
16
|
+
|
11
17
|
## Install
|
12
18
|
|
13
19
|
gem install app2engine
|
@@ -26,7 +32,9 @@ Then convert it with Rake:
|
|
26
32
|
|
27
33
|
rake engine:convert # or simply rake engine
|
28
34
|
|
29
|
-
Follow the instructions:
|
35
|
+
Follow the instructions:
|
36
|
+
|
37
|
+
To the main app's Gemfile, add
|
30
38
|
|
31
39
|
gem 'myengine', :path => 'path/to/myengine'
|
32
40
|
|
@@ -34,6 +42,22 @@ Use extras if you want:
|
|
34
42
|
|
35
43
|
rake engine:extra
|
36
44
|
|
45
|
+
### Static assets (public/ folder) in production
|
46
|
+
|
47
|
+
In Production environment, you must comment (or set to `true`) the line in mainapp/config/environments/production.rb
|
48
|
+
|
49
|
+
Change
|
50
|
+
|
51
|
+
config.serve_static_assets = false
|
52
|
+
|
53
|
+
to
|
54
|
+
|
55
|
+
config.serve_static_assets = true # This is needed to serve static assets from engines
|
56
|
+
|
57
|
+
Because the engine modify the static assets by appending its own public folder.
|
58
|
+
|
59
|
+
(A workaround may be to config your server to serve both the engine and the mainapp public files)
|
60
|
+
|
37
61
|
## You are done setting up your engine
|
38
62
|
|
39
63
|
If you want a little test:
|
@@ -56,16 +80,6 @@ In your main app's dir:
|
|
56
80
|
|
57
81
|
The folders `{controllers,models,views}/myengine` are created because you should namespace your engine.
|
58
82
|
|
59
|
-
### Production
|
60
|
-
|
61
|
-
In Production environment, you must comment (or set to `true`) the line in mainapp/config/environments/production.rb
|
62
|
-
|
63
|
-
# Disable Rails's static asset server
|
64
|
-
# In production, Apache or nginx will already do this
|
65
|
-
config.serve_static_assets = false
|
66
|
-
|
67
|
-
Because the engine modify the static assets by appending its own public folder. (A workaround may be to config you server)
|
68
|
-
|
69
83
|
### Code reloading / overwriting / load order
|
70
84
|
|
71
85
|
This is a discussion about what happen if you want to modify behavior in the mainapp.
|
@@ -90,7 +104,8 @@ In production, however, not using this trick works, but letting it will not hurt
|
|
90
104
|
Controllers of the mainapp overwrite the one of the engine, completely.
|
91
105
|
(The one of the engine will not be loaded if there is the same in the mainapp)
|
92
106
|
|
93
|
-
You then have to load the engine controller yourself,
|
107
|
+
You then have to load the engine controller yourself, if you want also the old controller,
|
108
|
+
by adding this at the top of the mainapp controller:
|
94
109
|
|
95
110
|
load "myengine/app/controllers/test_controller.rb"
|
96
111
|
|
@@ -99,7 +114,7 @@ There is the problem we do not know how to access that file,
|
|
99
114
|
|
100
115
|
So again a workaround, I created a symlink in the mainapp root (called myengine) to the engine root.
|
101
116
|
|
102
|
-
In production, you also need to load the file itself (but you could do a simple `require` as it
|
117
|
+
In production, you also need to load the file itself (but you could do a simple `require` as it would be loaded once, so no need to change anything).
|
103
118
|
|
104
119
|
#### Views
|
105
120
|
|
@@ -114,10 +129,6 @@ In development, public assets are served as expected, with the mainapp overwriti
|
|
114
129
|
In production, however, the engine files do not seem to be served at all.
|
115
130
|
(and if you do not do the trick said upper with serve\_static\_assets, even the mainapp files will not load)
|
116
131
|
|
117
|
-
Update:
|
118
|
-
It seems it works with changing syntax in the "static assets" initializer of the engine. The gem is then updated.
|
119
|
-
(delete your lib/myengine/engine.rb, and call again `rake engine` and `rake engine:extra` if you want)
|
120
|
-
|
121
132
|
## Author
|
122
133
|
|
123
134
|
Benoit Daloze
|
@@ -41,7 +41,7 @@ module App2Engine
|
|
41
41
|
|
42
42
|
def initializers
|
43
43
|
define_task(:initializers, "remove initializers as they would conflict and create NameError") do
|
44
|
-
Dir['config/initializers
|
44
|
+
Dir['config/initializers/{secret_token,session_store}.rb'].each { |file| comment_whole_file(file) }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app2engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- eregon
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-03 00:00:00 +02:00
|
19
19
|
default_executable: app2engine
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|