rphp 0.0.2 → 0.0.2.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/lib/rphp/server.rb +12 -9
- data/lib/rphp/version.rb +1 -1
- data/lib/rphp.rb +0 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f57e6e5ffd398dad5c902686f95ea802c415fcf68ef708d0d3382b5f94f738c
|
4
|
+
data.tar.gz: 2d81c65779da9731918f0da186209f67114582609d14a2fa29dfef0740dcfe5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0442603e676fc004beded88d2c968fdc544df833ba574554e9139c83782710254e2fdc7a89d84d46f222e29abb3fdbab752b422185eefd8fc66c7ffa214b495b
|
7
|
+
data.tar.gz: f051cbd31f4fb3e381112af4e301ade3e55ef08dfef6aa4683630c7ac5b5d6dec983c3e9ca9759da826106d8e6ea754062454ddb411eae48ec6998164caf4e3a
|
data/lib/rphp/server.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
# this file is about the PHP server class
|
2
2
|
|
3
|
-
class Server
|
3
|
+
class Rphp::Server
|
4
4
|
require 'fileutils'
|
5
5
|
require 'listen'
|
6
6
|
require 'tilt'
|
7
7
|
|
8
|
-
|
8
|
+
attr_accessor :port, :input, :output
|
9
|
+
|
10
|
+
def initialize(port = 4321)
|
9
11
|
@port = port
|
10
|
-
|
12
|
+
@input = 'ruby'
|
13
|
+
@output = 'public_html'
|
11
14
|
end
|
12
15
|
|
13
16
|
def generate_initial_files
|
14
|
-
Dir.mkdir
|
17
|
+
Dir.mkdir @input unless Dir.exist?(@input)
|
15
18
|
File.write(
|
16
|
-
"
|
19
|
+
"#{@input}/index.php.erb",
|
17
20
|
"<h1>Generated by RPHP</h1>"
|
18
|
-
) unless File.exist?("
|
21
|
+
) unless File.exist?("#{@input}/index.php.erb")
|
19
22
|
end
|
20
23
|
|
21
24
|
def parse_file filename
|
@@ -30,15 +33,15 @@ class Server
|
|
30
33
|
File.write("#{output}.#{extension}",file)
|
31
34
|
end
|
32
35
|
|
33
|
-
def
|
36
|
+
def start
|
34
37
|
puts "PHP development server started at port #{@port}"
|
35
|
-
`nohup php -S localhost:#{@port} >/dev/null 2>&1 &`
|
38
|
+
`nohup php -S localhost:#{@port} -t #{@output} >/dev/null 2>&1 &`
|
36
39
|
listen
|
37
40
|
end
|
38
41
|
|
39
42
|
def listen
|
40
43
|
parse_file 'index.php.erb'
|
41
|
-
listener = Listen.to(
|
44
|
+
listener = Listen.to(@input) do |modified, added, removed|
|
42
45
|
parse_file 'index.php.erb'
|
43
46
|
end
|
44
47
|
listener.start # not blocking
|
data/lib/rphp/version.rb
CHANGED
data/lib/rphp.rb
CHANGED