rda 0.0.4 → 0.0.6
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 +1 -0
- data/.rspec +1 -1
- data/CHANGELOG.md +24 -0
- data/Gemfile +16 -2
- data/Gemfile.lock +79 -67
- data/{README.textile → README.md} +63 -42
- data/lib/rda.rb +9 -9
- data/lib/rda/nginx.rb +34 -7
- data/lib/rda/rails.rb +1 -1
- data/lib/rda/templates/setup_load_paths.rb +4 -19
- data/lib/rda/version.rb +1 -1
- data/rda.gemspec +12 -23
- data/spec/lib/rda/nginx_spec.rb +1 -55
- metadata +17 -68
- data/CHANGELOG +0 -6
data/.gitignore
CHANGED
data/.rspec
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
--color
|
|
2
|
-
--format
|
|
2
|
+
--format Fivemat
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
TODO
|
|
2
|
+
|
|
3
|
+
* Check the permission when setup nginx
|
|
4
|
+
* Specify passenger_default_user and passenger_default_group manually
|
|
5
|
+
* Specify the hostname of the application
|
|
6
|
+
|
|
7
|
+
**0.0.6 (Mon, Jul 2, 2012)**
|
|
8
|
+
|
|
9
|
+
* Fixed gemspec error
|
|
10
|
+
|
|
11
|
+
**0.0.5 (Mon, Jul 2, 2012)**
|
|
12
|
+
|
|
13
|
+
* Updated the dependencies
|
|
14
|
+
* Check whether passenger_default_user is set
|
|
15
|
+
* Check whether passenger_default_group is set
|
|
16
|
+
* Check whether sites-enabled is included
|
|
17
|
+
* Check whether the hostname is set
|
|
18
|
+
|
|
19
|
+
**0.0.2 (Wed, Jan 25, 2012)**
|
|
20
|
+
|
|
21
|
+
* Fixed rvmrc template errors
|
|
22
|
+
* Idented sites-enabled inclusion
|
|
23
|
+
* Set default passenger user and group
|
|
24
|
+
* Added setup_load_paths.rb
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'http://ruby.taobao.org'
|
|
2
2
|
|
|
3
3
|
# Declare your gem's dependencies in rda.gemspec.
|
|
4
4
|
# Bundler will treat runtime dependencies like base dependencies, and
|
|
@@ -6,7 +6,7 @@ source "http://rubygems.org"
|
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
8
|
# jquery-rails is used by the dummy application
|
|
9
|
-
gem
|
|
9
|
+
gem 'jquery-rails'
|
|
10
10
|
|
|
11
11
|
# Declare any dependencies that are still in development here instead of in
|
|
12
12
|
# your gemspec. These might include edge Rails or gems from your path or
|
|
@@ -15,3 +15,17 @@ gem "jquery-rails"
|
|
|
15
15
|
|
|
16
16
|
# To use debugger
|
|
17
17
|
# gem 'ruby-debug19', :require => 'ruby-debug'
|
|
18
|
+
|
|
19
|
+
group :test do
|
|
20
|
+
gem 'pry'
|
|
21
|
+
gem 'rspec'
|
|
22
|
+
gem 'guard'
|
|
23
|
+
gem 'guard-bundler'
|
|
24
|
+
gem 'guard-rspec'
|
|
25
|
+
gem 'fivemat'
|
|
26
|
+
if RUBY_PLATFORM =~ /darwin/
|
|
27
|
+
gem 'ruby_gntp'
|
|
28
|
+
elsif RUBY_PLATFORM =~ /linux/
|
|
29
|
+
gem 'libnotify'
|
|
30
|
+
end
|
|
31
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,125 +1,137 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rda (0.0.
|
|
4
|
+
rda (0.0.6)
|
|
5
5
|
confstruct
|
|
6
6
|
rails (>= 3.1)
|
|
7
7
|
thor
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
|
-
remote: http://
|
|
10
|
+
remote: http://ruby.taobao.org/
|
|
11
11
|
specs:
|
|
12
|
-
actionmailer (3.2.
|
|
13
|
-
actionpack (= 3.2.
|
|
14
|
-
mail (~> 2.4.
|
|
15
|
-
actionpack (3.2.
|
|
16
|
-
activemodel (= 3.2.
|
|
17
|
-
activesupport (= 3.2.
|
|
12
|
+
actionmailer (3.2.6)
|
|
13
|
+
actionpack (= 3.2.6)
|
|
14
|
+
mail (~> 2.4.4)
|
|
15
|
+
actionpack (3.2.6)
|
|
16
|
+
activemodel (= 3.2.6)
|
|
17
|
+
activesupport (= 3.2.6)
|
|
18
18
|
builder (~> 3.0.0)
|
|
19
19
|
erubis (~> 2.7.0)
|
|
20
20
|
journey (~> 1.0.1)
|
|
21
21
|
rack (~> 1.4.0)
|
|
22
|
-
rack-cache (~> 1.
|
|
22
|
+
rack-cache (~> 1.2)
|
|
23
23
|
rack-test (~> 0.6.1)
|
|
24
|
-
sprockets (~> 2.1.
|
|
25
|
-
activemodel (3.2.
|
|
26
|
-
activesupport (= 3.2.
|
|
24
|
+
sprockets (~> 2.1.3)
|
|
25
|
+
activemodel (3.2.6)
|
|
26
|
+
activesupport (= 3.2.6)
|
|
27
27
|
builder (~> 3.0.0)
|
|
28
|
-
activerecord (3.2.
|
|
29
|
-
activemodel (= 3.2.
|
|
30
|
-
activesupport (= 3.2.
|
|
31
|
-
arel (~> 3.0.
|
|
28
|
+
activerecord (3.2.6)
|
|
29
|
+
activemodel (= 3.2.6)
|
|
30
|
+
activesupport (= 3.2.6)
|
|
31
|
+
arel (~> 3.0.2)
|
|
32
32
|
tzinfo (~> 0.3.29)
|
|
33
|
-
activeresource (3.2.
|
|
34
|
-
activemodel (= 3.2.
|
|
35
|
-
activesupport (= 3.2.
|
|
36
|
-
activesupport (3.2.
|
|
33
|
+
activeresource (3.2.6)
|
|
34
|
+
activemodel (= 3.2.6)
|
|
35
|
+
activesupport (= 3.2.6)
|
|
36
|
+
activesupport (3.2.6)
|
|
37
37
|
i18n (~> 0.6)
|
|
38
38
|
multi_json (~> 1.0)
|
|
39
|
-
arel (3.0.
|
|
39
|
+
arel (3.0.2)
|
|
40
40
|
builder (3.0.0)
|
|
41
|
-
coderay (1.0.
|
|
42
|
-
confstruct (0.2.
|
|
41
|
+
coderay (1.0.7)
|
|
42
|
+
confstruct (0.2.3)
|
|
43
43
|
diff-lcs (1.1.3)
|
|
44
44
|
erubis (2.7.0)
|
|
45
45
|
ffi (1.0.11)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
fivemat (1.0.0)
|
|
47
|
+
guard (1.2.1)
|
|
48
|
+
listen (>= 0.4.2)
|
|
49
|
+
thor (>= 0.14.6)
|
|
50
|
+
guard-bundler (1.0.0)
|
|
51
|
+
bundler (~> 1.0)
|
|
52
|
+
guard (~> 1.1)
|
|
53
|
+
guard-rspec (1.1.0)
|
|
54
|
+
guard (>= 1.1)
|
|
54
55
|
hike (1.2.1)
|
|
55
56
|
i18n (0.6.0)
|
|
56
|
-
journey (1.0.
|
|
57
|
-
jquery-rails (2.0.
|
|
58
|
-
railties (>= 3.2.0
|
|
57
|
+
journey (1.0.4)
|
|
58
|
+
jquery-rails (2.0.2)
|
|
59
|
+
railties (>= 3.2.0, < 5.0)
|
|
59
60
|
thor (~> 0.14)
|
|
60
|
-
json (1.
|
|
61
|
-
libnotify (0.7.
|
|
62
|
-
|
|
61
|
+
json (1.7.3)
|
|
62
|
+
libnotify (0.7.4)
|
|
63
|
+
ffi (~> 1.0.11)
|
|
64
|
+
listen (0.4.7)
|
|
65
|
+
rb-fchange (~> 0.0.5)
|
|
66
|
+
rb-fsevent (~> 0.9.1)
|
|
67
|
+
rb-inotify (~> 0.8.8)
|
|
68
|
+
mail (2.4.4)
|
|
63
69
|
i18n (>= 0.4.0)
|
|
64
70
|
mime-types (~> 1.16)
|
|
65
71
|
treetop (~> 1.4.8)
|
|
66
|
-
method_source (0.7.
|
|
67
|
-
mime-types (1.
|
|
68
|
-
multi_json (1.
|
|
72
|
+
method_source (0.7.1)
|
|
73
|
+
mime-types (1.19)
|
|
74
|
+
multi_json (1.3.6)
|
|
69
75
|
polyglot (0.3.3)
|
|
70
|
-
pry (0.9.
|
|
76
|
+
pry (0.9.9.6)
|
|
71
77
|
coderay (~> 1.0.5)
|
|
72
|
-
method_source (~> 0.7)
|
|
73
|
-
slop (>= 2.4.
|
|
78
|
+
method_source (~> 0.7.1)
|
|
79
|
+
slop (>= 2.4.4, < 3)
|
|
74
80
|
rack (1.4.1)
|
|
75
|
-
rack-cache (1.
|
|
81
|
+
rack-cache (1.2)
|
|
76
82
|
rack (>= 0.4)
|
|
77
83
|
rack-ssl (1.3.2)
|
|
78
84
|
rack
|
|
79
85
|
rack-test (0.6.1)
|
|
80
86
|
rack (>= 1.0)
|
|
81
|
-
rails (3.2.
|
|
82
|
-
actionmailer (= 3.2.
|
|
83
|
-
actionpack (= 3.2.
|
|
84
|
-
activerecord (= 3.2.
|
|
85
|
-
activeresource (= 3.2.
|
|
86
|
-
activesupport (= 3.2.
|
|
87
|
+
rails (3.2.6)
|
|
88
|
+
actionmailer (= 3.2.6)
|
|
89
|
+
actionpack (= 3.2.6)
|
|
90
|
+
activerecord (= 3.2.6)
|
|
91
|
+
activeresource (= 3.2.6)
|
|
92
|
+
activesupport (= 3.2.6)
|
|
87
93
|
bundler (~> 1.0)
|
|
88
|
-
railties (= 3.2.
|
|
89
|
-
railties (3.2.
|
|
90
|
-
actionpack (= 3.2.
|
|
91
|
-
activesupport (= 3.2.
|
|
94
|
+
railties (= 3.2.6)
|
|
95
|
+
railties (3.2.6)
|
|
96
|
+
actionpack (= 3.2.6)
|
|
97
|
+
activesupport (= 3.2.6)
|
|
92
98
|
rack-ssl (~> 1.3.2)
|
|
93
99
|
rake (>= 0.8.7)
|
|
94
100
|
rdoc (~> 3.4)
|
|
95
|
-
thor (
|
|
101
|
+
thor (>= 0.14.6, < 2.0)
|
|
96
102
|
rake (0.9.2.2)
|
|
103
|
+
rb-fchange (0.0.5)
|
|
104
|
+
ffi
|
|
105
|
+
rb-fsevent (0.9.1)
|
|
106
|
+
rb-inotify (0.8.8)
|
|
107
|
+
ffi (>= 0.5.0)
|
|
97
108
|
rdoc (3.12)
|
|
98
109
|
json (~> 1.4)
|
|
99
|
-
rspec (2.
|
|
100
|
-
rspec-core (~> 2.
|
|
101
|
-
rspec-expectations (~> 2.
|
|
102
|
-
rspec-mocks (~> 2.
|
|
103
|
-
rspec-core (2.
|
|
104
|
-
rspec-expectations (2.
|
|
105
|
-
diff-lcs (~> 1.1.
|
|
106
|
-
rspec-mocks (2.
|
|
107
|
-
slop (2.4.
|
|
108
|
-
sprockets (2.1.
|
|
110
|
+
rspec (2.10.0)
|
|
111
|
+
rspec-core (~> 2.10.0)
|
|
112
|
+
rspec-expectations (~> 2.10.0)
|
|
113
|
+
rspec-mocks (~> 2.10.0)
|
|
114
|
+
rspec-core (2.10.1)
|
|
115
|
+
rspec-expectations (2.10.0)
|
|
116
|
+
diff-lcs (~> 1.1.3)
|
|
117
|
+
rspec-mocks (2.10.1)
|
|
118
|
+
slop (2.4.4)
|
|
119
|
+
sprockets (2.1.3)
|
|
109
120
|
hike (~> 1.2)
|
|
110
121
|
rack (~> 1.0)
|
|
111
122
|
tilt (~> 1.1, != 1.3.0)
|
|
112
|
-
thor (0.
|
|
123
|
+
thor (0.15.4)
|
|
113
124
|
tilt (1.3.3)
|
|
114
125
|
treetop (1.4.10)
|
|
115
126
|
polyglot
|
|
116
127
|
polyglot (>= 0.3.1)
|
|
117
|
-
tzinfo (0.3.
|
|
128
|
+
tzinfo (0.3.33)
|
|
118
129
|
|
|
119
130
|
PLATFORMS
|
|
120
131
|
ruby
|
|
121
132
|
|
|
122
133
|
DEPENDENCIES
|
|
134
|
+
fivemat
|
|
123
135
|
guard
|
|
124
136
|
guard-bundler
|
|
125
137
|
guard-rspec
|
|
@@ -1,65 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
## Rda
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### Description
|
|
4
4
|
|
|
5
5
|
Rda(Rails Development Assist) is combined with lots of useful rake tasks which can help you to setup your development enviroments and tools more quickly.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### Features
|
|
8
8
|
|
|
9
9
|
* Setup RVM for your rails application
|
|
10
10
|
* Deploy your rails application to Nginx (rails_env is set to development by default)
|
|
11
11
|
* Release your rails application
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Usage
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
#### Installation
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
```bash
|
|
18
|
+
gem install rda
|
|
19
|
+
```
|
|
18
20
|
|
|
19
21
|
Or simply add rda to the Gemfile
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
```ruby
|
|
24
|
+
gem 'rda'
|
|
25
|
+
```
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
#### Configuration
|
|
24
28
|
|
|
25
29
|
For configuring rda, you need to create an initializer for rda:
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
<code>
|
|
31
|
+
```ruby
|
|
29
32
|
# config/initializers/rda.rb
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
if Rails.env == 'development'
|
|
34
|
+
Rda.configure do
|
|
35
|
+
nginx_conf_paths ['/etc/nginx', '/opt/nginx/conf', '/usr/local/nginx/conf']
|
|
36
|
+
end
|
|
32
37
|
end
|
|
33
|
-
|
|
34
|
-
</pre>
|
|
38
|
+
```
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
#### Setup RVM
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
```bash
|
|
43
|
+
rake rda:rvm:setup
|
|
44
|
+
```
|
|
39
45
|
|
|
40
46
|
First of all, this task will check whether the RVM is installed. If RVM is installed, it will create a .rvmrc for the application with the content which looks like:
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
. "/path/to/rvm/environments/ruby-1.9.3-p0@app_name"
|
|
48
|
+
```bash
|
|
49
|
+
if [[ -s '/path/to/rvm/environments/ruby-1.9.3-p194@app_name' ]]; then
|
|
50
|
+
. '/path/to/rvm/environments/ruby-1.9.3-p194@app_name'
|
|
46
51
|
else
|
|
47
|
-
rvm use ruby-1.9.3-
|
|
52
|
+
rvm use ruby-1.9.3-p194@app_name --create
|
|
48
53
|
fi
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
After RVM setup, you need to trust the rvmrc by:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
rvm rvmrc trust
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Or you can set `rvm_trust_rvmrcs_flag=1` in ~/.rvmrc or /etc/rvmrc.
|
|
51
63
|
|
|
52
64
|
If RVM is not installed this task will do nothing but exit.
|
|
53
65
|
|
|
54
|
-
|
|
66
|
+
#### Discard RVM settings
|
|
55
67
|
|
|
56
|
-
|
|
68
|
+
```bash
|
|
69
|
+
rake rda:rvm:discard
|
|
70
|
+
```
|
|
57
71
|
|
|
58
72
|
This task removes the .rvmrc from your rails application.
|
|
59
73
|
|
|
60
|
-
|
|
74
|
+
#### Setup Nginx
|
|
61
75
|
|
|
62
|
-
|
|
76
|
+
```bash
|
|
77
|
+
rake rda:nginx:setup
|
|
78
|
+
```
|
|
63
79
|
|
|
64
80
|
First this task will try to find the config files of Nginx which you have installed from the following paths:
|
|
65
81
|
|
|
@@ -69,15 +85,15 @@ First this task will try to find the config files of Nginx which you have instal
|
|
|
69
85
|
|
|
70
86
|
You can change the default searching paths by:
|
|
71
87
|
|
|
72
|
-
|
|
73
|
-
<code>
|
|
88
|
+
```ruby
|
|
74
89
|
Rda.configure { nginx_conf_paths ['/path/to/nginx/conf'] }
|
|
75
|
-
|
|
76
|
-
</pre>
|
|
90
|
+
```
|
|
77
91
|
|
|
78
92
|
Please make sure that you have the write permission of the directory you choosed, or you can run:
|
|
79
93
|
|
|
80
|
-
|
|
94
|
+
```bash
|
|
95
|
+
rvmsudo rake rda:nginx:setup
|
|
96
|
+
```
|
|
81
97
|
|
|
82
98
|
If there are more than one paths found, it will give you a choice to decide which one will be used. After choosing a proper path, it will try to create two directories sites-available and sites-enabled to save the configs of rails applications.
|
|
83
99
|
|
|
@@ -86,30 +102,35 @@ If there are more than one paths found, it will give you a choice to decide whic
|
|
|
86
102
|
|
|
87
103
|
Next it will set Nginx to include the configs under sites-enabled. It means that only the applications under sites-enabled will be loaded. And than it will create a config file for your application under sites-available and create a link to the config file under sites-enabled. After all, it will create a local hostname for your application in /etc/hosts.
|
|
88
104
|
|
|
89
|
-
h3. Discard Nginx settings
|
|
90
105
|
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
Finally, You need to start Nginx `/path/to/nginx/sbin/nginx` and then visit http://your_app_name.local.
|
|
107
|
+
|
|
108
|
+
#### Discard Nginx settings
|
|
109
|
+
|
|
110
|
+
```bash
|
|
93
111
|
rake rda:nginx:discard # Or
|
|
94
112
|
|
|
95
113
|
sudo rake rda:nginx:discard # Or
|
|
96
114
|
|
|
97
115
|
rvmsudo rake rda:nginx:discard # Using RVM
|
|
98
|
-
|
|
99
|
-
</pre>
|
|
116
|
+
```
|
|
100
117
|
|
|
101
118
|
This task will clean up all the things created or configured by rda:nginx:setup.
|
|
102
119
|
|
|
103
|
-
|
|
120
|
+
#### Restart application
|
|
104
121
|
|
|
105
|
-
|
|
122
|
+
```bash
|
|
123
|
+
rake rda:app:restart
|
|
124
|
+
```
|
|
106
125
|
|
|
107
126
|
This task touches tmp/restart.txt to restart your rails application, For detail, please visit "http://bit.ly/ztKA07":http://bit.ly/ztKA07
|
|
108
127
|
|
|
109
|
-
|
|
128
|
+
#### Release your rails application(not yet)
|
|
110
129
|
|
|
111
|
-
|
|
130
|
+
```bash
|
|
131
|
+
rake rda:app:release
|
|
132
|
+
```
|
|
112
133
|
|
|
113
|
-
|
|
134
|
+
### License
|
|
114
135
|
|
|
115
136
|
This project rocks and uses MIT-LICENSE.
|
data/lib/rda.rb
CHANGED
|
@@ -9,15 +9,15 @@ require 'rda/nginx'
|
|
|
9
9
|
require 'rda/app'
|
|
10
10
|
|
|
11
11
|
module Rda
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
12
|
+
class << self
|
|
13
|
+
def config
|
|
14
|
+
@config ||= Confstruct::Configuration.new do
|
|
15
|
+
nginx_conf_paths ['/etc/nginx', '/usr/local/nginx/conf', '/opt/nginx/conf']
|
|
16
|
+
end
|
|
17
|
+
end
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
def configure(&block)
|
|
20
|
+
config.configure(&block)
|
|
21
|
+
end
|
|
22
22
|
end
|
|
23
23
|
end
|
data/lib/rda/nginx.rb
CHANGED
|
@@ -19,8 +19,10 @@ module Rda
|
|
|
19
19
|
|
|
20
20
|
template("templates/nginx", "#{conf_path}/sites-available/#{hostname}")
|
|
21
21
|
link_file("#{conf_path}/sites-available/#{hostname}", "#{conf_path}/sites-enabled/#{hostname}")
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
|
|
23
|
+
unless configured?('/etc/hosts', "127.0.0.1 #{hostname}")
|
|
24
|
+
append_file "/etc/hosts", "127.0.0.1 #{hostname}"
|
|
25
|
+
end
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
desc "Discard", "Remove the Nginx setting of rails application"
|
|
@@ -71,7 +73,7 @@ module Rda
|
|
|
71
73
|
end
|
|
72
74
|
|
|
73
75
|
def prompt_not_found
|
|
74
|
-
$stderr.puts "Config directory of Nginx is not found in the following paths:\n\n"
|
|
76
|
+
$stderr.puts "ERROR: Config directory of Nginx is not found in the following paths:\n\n"
|
|
75
77
|
Rda.config.nginx_conf_paths.each { |p| $stderr.puts "* #{p}" }
|
|
76
78
|
$stderr.puts "\n"
|
|
77
79
|
end
|
|
@@ -99,19 +101,44 @@ module Rda
|
|
|
99
101
|
|
|
100
102
|
def set_passenger_user_and_group
|
|
101
103
|
conf = conf_path + '/nginx.conf'
|
|
102
|
-
|
|
104
|
+
|
|
105
|
+
unless configured?(conf, 'passenger_default_user')
|
|
106
|
+
gsub_file conf, /http {/, <<-PASSENGER
|
|
103
107
|
http {
|
|
104
108
|
passenger_default_user root;
|
|
109
|
+
PASSENGER
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
unless configured?(conf, 'passenger_default_group')
|
|
113
|
+
gsub_file conf, /http {/, <<-PASSENGER
|
|
114
|
+
http {
|
|
105
115
|
passenger_default_group root;
|
|
106
|
-
|
|
116
|
+
PASSENGER
|
|
117
|
+
end
|
|
107
118
|
end
|
|
108
119
|
|
|
109
120
|
def include_sites_enabled
|
|
110
121
|
conf = conf_path + '/nginx.conf'
|
|
111
|
-
|
|
122
|
+
unless configured?(conf, "include #{conf_path}/sites-enabled/*;")
|
|
123
|
+
gsub_file conf, /http {/, <<-INCLUDE_SITES_ENABLED
|
|
112
124
|
http {
|
|
113
125
|
include #{conf_path}/sites-enabled/*;
|
|
114
|
-
|
|
126
|
+
INCLUDE_SITES_ENABLED
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def configured?(fname, conf)
|
|
131
|
+
File.open(fname) do |f|
|
|
132
|
+
f.readlines.each do |l|
|
|
133
|
+
if l.strip.start_with?(conf)
|
|
134
|
+
$stderr.puts "INFO: #{conf} has already been set!"
|
|
135
|
+
|
|
136
|
+
return true
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
false
|
|
115
142
|
end
|
|
116
143
|
end
|
|
117
144
|
end
|
data/lib/rda/rails.rb
CHANGED
|
@@ -1,28 +1,13 @@
|
|
|
1
1
|
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
|
|
2
2
|
begin
|
|
3
|
-
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
|
|
4
|
-
rvm_lib_path = File.join(rvm_path, 'lib')
|
|
5
|
-
$LOAD_PATH.unshift rvm_lib_path
|
|
6
3
|
require 'rvm'
|
|
7
4
|
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
|
|
8
5
|
rescue LoadError
|
|
9
|
-
|
|
10
|
-
raise "RVM ruby lib is currently unavailable."
|
|
6
|
+
raise "RVM gem is currently unavailable."
|
|
11
7
|
end
|
|
12
8
|
end
|
|
13
9
|
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# Require Bundler 1.0
|
|
18
|
-
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
|
|
10
|
+
# If you're not using Bundler at all, remove lines bellow
|
|
11
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile',
|
|
12
|
+
File.dirname(__FILE__))
|
|
19
13
|
require 'bundler/setup'
|
|
20
|
-
|
|
21
|
-
# Require Bundler 0/9
|
|
22
|
-
# if File.exist?(".bundle/environment.rb")
|
|
23
|
-
# require '.bundle/environment'
|
|
24
|
-
# else
|
|
25
|
-
# require 'rubygems'
|
|
26
|
-
# require 'bundler'
|
|
27
|
-
# Bundler.setup
|
|
28
|
-
# end
|
data/lib/rda/version.rb
CHANGED
data/rda.gemspec
CHANGED
|
@@ -1,34 +1,23 @@
|
|
|
1
|
-
$:.push File.expand_path(
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
|
3
3
|
# Maintain your gem's version:
|
|
4
|
-
require
|
|
4
|
+
require 'rda/version'
|
|
5
5
|
|
|
6
6
|
# Describe your gem and declare its dependencies:
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
|
-
s.name =
|
|
8
|
+
s.name = 'rda'
|
|
9
9
|
s.version = Rda::VERSION
|
|
10
|
-
s.authors = [
|
|
11
|
-
s.email = [
|
|
12
|
-
s.homepage =
|
|
13
|
-
s.summary =
|
|
14
|
-
s.description =
|
|
10
|
+
s.authors = ['Tower He']
|
|
11
|
+
s.email = ['towerhe@gmail.com']
|
|
12
|
+
s.homepage = 'https://github.com/towerhe/rda'
|
|
13
|
+
s.summary = 'Rails Development Assist'
|
|
14
|
+
s.description = 'Rda(Rails Development Assist) is combined with lots of useful rake tasks which can help you to setup your development enviroments and tools more quickly.'
|
|
15
15
|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
|
17
17
|
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
|
18
|
-
s.require_paths = [
|
|
18
|
+
s.require_paths = ['lib']
|
|
19
19
|
|
|
20
|
-
s.add_dependency
|
|
21
|
-
s.add_dependency
|
|
22
|
-
s.add_dependency
|
|
23
|
-
|
|
24
|
-
s.add_development_dependency "pry"
|
|
25
|
-
s.add_development_dependency "rspec"
|
|
26
|
-
s.add_development_dependency "guard"
|
|
27
|
-
s.add_development_dependency "guard-bundler"
|
|
28
|
-
s.add_development_dependency "guard-rspec"
|
|
29
|
-
if RUBY_PLATFORM =~ /darwin/
|
|
30
|
-
s.add_development_dependency "ruby_gntp"
|
|
31
|
-
elsif RUBY_PLATFORM =~ /linux/
|
|
32
|
-
s.add_development_dependency "libnotify"
|
|
33
|
-
end
|
|
20
|
+
s.add_dependency 'rails', '>= 3.1'
|
|
21
|
+
s.add_dependency 'thor'
|
|
22
|
+
s.add_dependency 'confstruct'
|
|
34
23
|
end
|
data/spec/lib/rda/nginx_spec.rb
CHANGED
|
@@ -19,7 +19,7 @@ describe Rda::Nginx do
|
|
|
19
19
|
capture(:stderr) do
|
|
20
20
|
subject.setup
|
|
21
21
|
end.should == <<-PROMPT
|
|
22
|
-
Config directory of Nginx is not found in the following paths:
|
|
22
|
+
ERROR: Config directory of Nginx is not found in the following paths:
|
|
23
23
|
|
|
24
24
|
* /etc/nginx
|
|
25
25
|
* /usr/local/nginx/conf
|
|
@@ -51,60 +51,6 @@ Found more than one config directory of Nginx, please choose one to setup:
|
|
|
51
51
|
end.strip.should == choice.strip
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
-
|
|
55
|
-
context 'when only one config directory of nginx found' do
|
|
56
|
-
let(:dummy_path) { File.dirname(__FILE__) + "/../../tmp/nginx" }
|
|
57
|
-
|
|
58
|
-
before do
|
|
59
|
-
FileUtils.mkdir_p dummy_path unless Dir.exists?(dummy_path)
|
|
60
|
-
FileUtils.copy_file(File.dirname(__FILE__) + "/../../fixtures/nginx.conf", dummy_path + '/nginx.conf')
|
|
61
|
-
Rda.configure { nginx_conf_paths [File.dirname(__FILE__) + "/../../tmp/nginx"] }
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
after do
|
|
65
|
-
FileUtils.rm_r dummy_path if Dir.exists?(dummy_path)
|
|
66
|
-
Rda.configure { nginx_conf_paths Rda::Nginx::DEFAULT_CONF_PATHS }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'sets Nginx properly' do
|
|
70
|
-
# loads RVM
|
|
71
|
-
subject.should_receive(:copy_file).with("templates/setup_load_paths.rb", "#{::Rails.root}/config/setup_load_paths.rb")
|
|
72
|
-
|
|
73
|
-
# creates sites-available and sites-enabled
|
|
74
|
-
%W(available enabled).each do |n|
|
|
75
|
-
path = "#{dummy_path}/sites-#{n}"
|
|
76
|
-
subject.should_receive(:empty_directory).with(path)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# sets default passenger user and group
|
|
80
|
-
subject.should_receive(:gsub_file).with("#{dummy_path}/nginx.conf", /http {/, <<-PASSENGER
|
|
81
|
-
http {
|
|
82
|
-
passenger_default_user root;
|
|
83
|
-
passenger_default_group root;
|
|
84
|
-
PASSENGER
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
# sets Nginx to include sites-enabled
|
|
88
|
-
subject.should_receive(:gsub_file).with("#{dummy_path}/nginx.conf", /http {/, <<-INCLUSION
|
|
89
|
-
http {
|
|
90
|
-
include #{dummy_path}/sites-enabled/*;
|
|
91
|
-
INCLUSION
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
# creates a nginx config file for the rails application under
|
|
95
|
-
# sites-available
|
|
96
|
-
subject.should_receive(:template).with('templates/nginx', "#{dummy_path}/sites-available/dummy.local")
|
|
97
|
-
|
|
98
|
-
# creates a symbol link to the nginx config file of the rails
|
|
99
|
-
# application
|
|
100
|
-
subject.should_receive(:link_file).with("#{dummy_path}/sites-available/dummy.local", "#{dummy_path}/sites-enabled/dummy.local")
|
|
101
|
-
|
|
102
|
-
# creates a local hostname for the rails application
|
|
103
|
-
subject.should_receive(:append_file).with("/etc/hosts", "127.0.0.1 dummy.local")
|
|
104
|
-
|
|
105
|
-
subject.setup
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
54
|
end
|
|
109
55
|
|
|
110
56
|
describe '#discard' do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rda
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|
|
16
|
-
requirement:
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,21 +21,15 @@ dependencies:
|
|
|
21
21
|
version: '3.1'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements:
|
|
25
|
-
- !ruby/object:Gem::Dependency
|
|
26
|
-
name: thor
|
|
27
|
-
requirement: &13471060 !ruby/object:Gem::Requirement
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
28
25
|
none: false
|
|
29
26
|
requirements:
|
|
30
27
|
- - ! '>='
|
|
31
28
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
33
|
-
type: :runtime
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: *13471060
|
|
29
|
+
version: '3.1'
|
|
36
30
|
- !ruby/object:Gem::Dependency
|
|
37
|
-
name:
|
|
38
|
-
requirement:
|
|
31
|
+
name: thor
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
39
33
|
none: false
|
|
40
34
|
requirements:
|
|
41
35
|
- - ! '>='
|
|
@@ -43,73 +37,28 @@ dependencies:
|
|
|
43
37
|
version: '0'
|
|
44
38
|
type: :runtime
|
|
45
39
|
prerelease: false
|
|
46
|
-
version_requirements:
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: pry
|
|
49
|
-
requirement: &13468820 !ruby/object:Gem::Requirement
|
|
50
|
-
none: false
|
|
51
|
-
requirements:
|
|
52
|
-
- - ! '>='
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
|
-
type: :development
|
|
56
|
-
prerelease: false
|
|
57
|
-
version_requirements: *13468820
|
|
58
|
-
- !ruby/object:Gem::Dependency
|
|
59
|
-
name: rspec
|
|
60
|
-
requirement: &13467400 !ruby/object:Gem::Requirement
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
61
41
|
none: false
|
|
62
42
|
requirements:
|
|
63
43
|
- - ! '>='
|
|
64
44
|
- !ruby/object:Gem::Version
|
|
65
45
|
version: '0'
|
|
66
|
-
type: :development
|
|
67
|
-
prerelease: false
|
|
68
|
-
version_requirements: *13467400
|
|
69
46
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
71
|
-
requirement:
|
|
72
|
-
none: false
|
|
73
|
-
requirements:
|
|
74
|
-
- - ! '>='
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: '0'
|
|
77
|
-
type: :development
|
|
78
|
-
prerelease: false
|
|
79
|
-
version_requirements: *13644220
|
|
80
|
-
- !ruby/object:Gem::Dependency
|
|
81
|
-
name: guard-bundler
|
|
82
|
-
requirement: &13643540 !ruby/object:Gem::Requirement
|
|
83
|
-
none: false
|
|
84
|
-
requirements:
|
|
85
|
-
- - ! '>='
|
|
86
|
-
- !ruby/object:Gem::Version
|
|
87
|
-
version: '0'
|
|
88
|
-
type: :development
|
|
89
|
-
prerelease: false
|
|
90
|
-
version_requirements: *13643540
|
|
91
|
-
- !ruby/object:Gem::Dependency
|
|
92
|
-
name: guard-rspec
|
|
93
|
-
requirement: &13642840 !ruby/object:Gem::Requirement
|
|
47
|
+
name: confstruct
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
94
49
|
none: false
|
|
95
50
|
requirements:
|
|
96
51
|
- - ! '>='
|
|
97
52
|
- !ruby/object:Gem::Version
|
|
98
53
|
version: '0'
|
|
99
|
-
type: :
|
|
54
|
+
type: :runtime
|
|
100
55
|
prerelease: false
|
|
101
|
-
version_requirements:
|
|
102
|
-
- !ruby/object:Gem::Dependency
|
|
103
|
-
name: libnotify
|
|
104
|
-
requirement: &13641900 !ruby/object:Gem::Requirement
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
57
|
none: false
|
|
106
58
|
requirements:
|
|
107
59
|
- - ! '>='
|
|
108
60
|
- !ruby/object:Gem::Version
|
|
109
61
|
version: '0'
|
|
110
|
-
type: :development
|
|
111
|
-
prerelease: false
|
|
112
|
-
version_requirements: *13641900
|
|
113
62
|
description: Rda(Rails Development Assist) is combined with lots of useful rake tasks
|
|
114
63
|
which can help you to setup your development enviroments and tools more quickly.
|
|
115
64
|
email:
|
|
@@ -120,12 +69,12 @@ extra_rdoc_files: []
|
|
|
120
69
|
files:
|
|
121
70
|
- .gitignore
|
|
122
71
|
- .rspec
|
|
123
|
-
- CHANGELOG
|
|
72
|
+
- CHANGELOG.md
|
|
124
73
|
- Gemfile
|
|
125
74
|
- Gemfile.lock
|
|
126
75
|
- Guardfile
|
|
127
76
|
- MIT-LICENSE
|
|
128
|
-
- README.
|
|
77
|
+
- README.md
|
|
129
78
|
- Rakefile
|
|
130
79
|
- lib/rda.rb
|
|
131
80
|
- lib/rda/app.rb
|
|
@@ -192,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
192
141
|
version: '0'
|
|
193
142
|
segments:
|
|
194
143
|
- 0
|
|
195
|
-
hash:
|
|
144
|
+
hash: 93405623145392106
|
|
196
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
146
|
none: false
|
|
198
147
|
requirements:
|
|
@@ -201,10 +150,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
201
150
|
version: '0'
|
|
202
151
|
segments:
|
|
203
152
|
- 0
|
|
204
|
-
hash:
|
|
153
|
+
hash: 93405623145392106
|
|
205
154
|
requirements: []
|
|
206
155
|
rubyforge_project:
|
|
207
|
-
rubygems_version: 1.8.
|
|
156
|
+
rubygems_version: 1.8.24
|
|
208
157
|
signing_key:
|
|
209
158
|
specification_version: 3
|
|
210
159
|
summary: Rails Development Assist
|