guard-combustion 0.1.0 → 0.1.1
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 +45 -0
- data/lib/guard/combustion/combustion_helper.rb +13 -28
- data/lib/guard/combustion/version.rb +1 -1
- metadata +4 -4
- data/Readme.md +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29e25af5ba5e505b6ec2402a10fa2ecbda39a49c
|
4
|
+
data.tar.gz: 9789486bf45c5e349ee3a64ea24e85c4afec018e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 574efb532093a8f57edc146487168971089498965b9cddab9afef21cbdb52267864702bd660a996b6c87748df0f1ff0b62b0fac4b78220c4cbae849cc84833de
|
7
|
+
data.tar.gz: e1948770da602a40fff110178ab95b5f1642a2bf4db3146d7e25a56196f9d54ea71f6e5b68bd1c8788293078715f06fdae564646a944e40cd1e1f22f9e560b78
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Guard::Combustion
|
2
|
+
|
3
|
+
This guard allows you to easily develop Rails engines with [Combustion](https://github.com/pat/combustion) with no need to manually restart the dummy application after every change.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
Make sure you have [guard](http://github.com/guard/guard) installed and Combustion fully configured on your Rails engine.
|
8
|
+
|
9
|
+
Install the gem with:
|
10
|
+
|
11
|
+
gem install guard-combustion
|
12
|
+
|
13
|
+
Or add it to your Gemfile:
|
14
|
+
|
15
|
+
gem "guard-combustion", "~> 0.1.1"
|
16
|
+
|
17
|
+
And then add a basic setup to your Guardfile:
|
18
|
+
|
19
|
+
guard init combustion
|
20
|
+
|
21
|
+
## Configuration
|
22
|
+
|
23
|
+
### Combustion port
|
24
|
+
|
25
|
+
Combustion listens on the port 9292 by default.
|
26
|
+
You can choose another port (e.g. 3000) modifying (or creating) the file `/path/to/your/engine/.guard_combustion_port`
|
27
|
+
|
28
|
+
3001
|
29
|
+
|
30
|
+
If ".guard_combustion_port" doesn't exists, it will be generated and configured with the default port at the first use of guard-combustion.
|
31
|
+
|
32
|
+
### Integration with guard-rspec (or any other guard)
|
33
|
+
|
34
|
+
If you are using guard-rspec, or any other guard that uses Combustion,
|
35
|
+
you may want to stop the server while running the tests
|
36
|
+
to avoid conflicts with the instance of Combustion created by Rspec.
|
37
|
+
|
38
|
+
For doing that, you have to add theese lines into the `guard :rspec` block
|
39
|
+
|
40
|
+
callback(:run_all_begin) { CombustionHelper.stop_combustion }
|
41
|
+
callback(:run_on_modifications_begin) { CombustionHelper.stop_combustion }
|
42
|
+
callback(:run_all_end) { CombustionHelper.start_combustion }
|
43
|
+
callback(:run_on_modifications_end) { CombustionHelper.start_combustion }
|
44
|
+
|
45
|
+
For more informations about callbacks, see https://github.com/guard/guard/wiki/Hooks-and-callbacks
|
@@ -1,31 +1,16 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# Per configurare la porta utilizzata da combustion, inserire in un file ".guard_combustion_port" la porta desiderata (solo il numero).
|
5
|
-
# Se questo file non esiste, viene creato automaticamente al primo utilizzo di guard, utilizzando la porta di default.
|
6
|
-
#
|
7
|
-
# NB: .guard_combustion_port è gitignored.
|
2
|
+
# This class contains some useful functions to automatically manage the interaction between combustion and guard.
|
8
3
|
#
|
9
4
|
class CombustionHelper
|
10
5
|
|
11
|
-
#
|
12
|
-
# La porta di default utilizzata da combustion.
|
13
|
-
# Questa porta viene utilizzata solo se non è già stata configurata in .guard_combustion_port
|
14
|
-
#
|
15
|
-
# NB: per modificare la porta che si vuole far utilizzare a combustion non modificare direttamente questa variabile.
|
16
|
-
# Leggere invece le istruzioni in cima alla classe
|
17
|
-
#
|
18
6
|
@@default_port = 9292
|
19
7
|
@@last_start = Time.now - 5
|
20
8
|
@@combustion_pid_file = "./tmp/.combustion_pid"
|
21
9
|
@@guard_combustion_port = ".guard_combustion_port"
|
22
10
|
|
23
|
-
#
|
24
|
-
# Definisce tutti i metodi come statici
|
25
|
-
#
|
26
11
|
class << self
|
27
12
|
#
|
28
|
-
#
|
13
|
+
# Start combustion
|
29
14
|
#
|
30
15
|
def start_combustion
|
31
16
|
if get_combustion_pid.nil?
|
@@ -36,9 +21,9 @@ class CombustionHelper
|
|
36
21
|
@@last_start = Time.now
|
37
22
|
pid = get_combustion_pid
|
38
23
|
if pid.nil?
|
39
|
-
puts "
|
24
|
+
puts "\033[22;31msomething went wrong, likely combustion was not started\x1b[0m"
|
40
25
|
else
|
41
|
-
puts "\033[22;32mcombustion started and listening
|
26
|
+
puts "\033[22;32mcombustion started with pid #{pid} and listening on port #{combustion_port}\x1b[0m"
|
42
27
|
end
|
43
28
|
else
|
44
29
|
puts "another instance of combustion is already running with pid #{pid}"
|
@@ -47,7 +32,7 @@ class CombustionHelper
|
|
47
32
|
end
|
48
33
|
|
49
34
|
#
|
50
|
-
#
|
35
|
+
# Stop combustion
|
51
36
|
#
|
52
37
|
def stop_combustion
|
53
38
|
puts "stopping combustion..."
|
@@ -62,10 +47,10 @@ class CombustionHelper
|
|
62
47
|
end
|
63
48
|
|
64
49
|
#
|
65
|
-
#
|
50
|
+
# Restart combustion
|
66
51
|
#
|
67
52
|
def restart_combustion
|
68
|
-
if Time.now > @@last_start + 1 #
|
53
|
+
if Time.now > @@last_start + 1 # Check if the server started less than a second ago
|
69
54
|
puts "\033[01;33mrestarting combustion...\x1b[0m"
|
70
55
|
stop_combustion
|
71
56
|
start_combustion
|
@@ -75,7 +60,7 @@ class CombustionHelper
|
|
75
60
|
private
|
76
61
|
|
77
62
|
#
|
78
|
-
#
|
63
|
+
# Write the port that will be used by combustion into .guard_combustion_port
|
79
64
|
#
|
80
65
|
def set_guard_combustion_port
|
81
66
|
file = File.open(@@guard_combustion_port, "w")
|
@@ -85,8 +70,8 @@ class CombustionHelper
|
|
85
70
|
end
|
86
71
|
|
87
72
|
#
|
88
|
-
#
|
89
|
-
#
|
73
|
+
# Read the port from .guard_combustion_port
|
74
|
+
# If .guard_combustion_port doesn't exists, create it and fill it with the default port.
|
90
75
|
#
|
91
76
|
def get_guard_combustion_port
|
92
77
|
begin
|
@@ -106,7 +91,7 @@ class CombustionHelper
|
|
106
91
|
end
|
107
92
|
|
108
93
|
#
|
109
|
-
#
|
94
|
+
# Read combustion's pid from .combustion_pid
|
110
95
|
#
|
111
96
|
def get_combustion_pid
|
112
97
|
begin
|
@@ -126,7 +111,7 @@ class CombustionHelper
|
|
126
111
|
end
|
127
112
|
|
128
113
|
#
|
129
|
-
#
|
114
|
+
# Delete .combustion_pid
|
130
115
|
#
|
131
116
|
def delete_combustion_pid
|
132
117
|
if File.exists? @@combustion_pid_file
|
@@ -135,7 +120,7 @@ class CombustionHelper
|
|
135
120
|
end
|
136
121
|
|
137
122
|
#
|
138
|
-
#
|
123
|
+
# Return a string with the shell command used for starting combustion
|
139
124
|
#
|
140
125
|
def combustion_cmd combustion_port
|
141
126
|
"rackup -p #{combustion_port} -D -P #{@@combustion_pid_file}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-combustion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruben Caliandro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -33,7 +33,7 @@ extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- LICENSE
|
36
|
-
-
|
36
|
+
- README.md
|
37
37
|
- lib/guard/combustion.rb
|
38
38
|
- lib/guard/combustion/combustion_helper.rb
|
39
39
|
- lib/guard/combustion/templates/Guardfile
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.2.
|
61
|
+
rubygems_version: 2.2.1
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Guard gem for running Combustion
|
data/Readme.md
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Guard::Combustion
|
2
|
-
|
3
|
-
This guard allows you to easily develop Rails engines with [Combustion](https://github.com/pat/combustion) with no need to restart the dummy application after every change.
|
4
|
-
|
5
|
-
|
6
|
-
## Install
|
7
|
-
|
8
|
-
Make sure you have [guard](http://github.com/guard/guard) installed and Combustion fully configured on your Rails engine.
|
9
|
-
|
10
|
-
Install the gem with:
|
11
|
-
|
12
|
-
gem install guard-combustion
|
13
|
-
|
14
|
-
Or add it to your Gemfile:
|
15
|
-
|
16
|
-
gem 'guard-combustion'
|
17
|
-
|
18
|
-
And then add a basic setup to your Guardfile:
|
19
|
-
|
20
|
-
guard init combustion
|
21
|
-
|
22
|
-
|
23
|
-
## Integration with guard-rspec
|
24
|
-
|
25
|
-
If you are using guard-rspec, maybe you want to stop Combustion while running tests,
|
26
|
-
just to avoid conflicts with the instance of Combustion created by Rspec.
|
27
|
-
|
28
|
-
For doing that, you have to add theese lines into the `guard :rspec` block
|
29
|
-
|
30
|
-
callback(:run_all_begin) { CombustionHelper.stop_combustion }
|
31
|
-
callback(:run_on_modifications_begin) { CombustionHelper.stop_combustion }
|
32
|
-
callback(:run_all_end) { CombustionHelper.start_combustion }
|
33
|
-
callback(:run_on_modifications_end) { CombustionHelper.start_combustion }
|