rphp 0.0.2 → 0.0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a57a94180f428853f52c7aa4cc65c56e7dbdf84eb6cd19a01f180afababc1c4e
4
- data.tar.gz: 5938d33c121221f45fa2783da6651eee6914d02cb4573d4bad9a503460602b0c
3
+ metadata.gz: 8f57e6e5ffd398dad5c902686f95ea802c415fcf68ef708d0d3382b5f94f738c
4
+ data.tar.gz: 2d81c65779da9731918f0da186209f67114582609d14a2fa29dfef0740dcfe5b
5
5
  SHA512:
6
- metadata.gz: bddd63aa74d650dcd3173172edeb47665959450ded63ae11de4e5a7c56332b4f4d1b4823b740da7ef866de39f6b94d5826e997f349e3786f32c85e7366fc4643
7
- data.tar.gz: 32ae0d6a099446abddceb7f5250e98219aa638d0c324ad5e02e1c9bce6d814008832b7c62f4239134617ef7f12d1e88c9f1efaa35f24591b36b14c9477864dd1
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
- def initialize(port)
8
+ attr_accessor :port, :input, :output
9
+
10
+ def initialize(port = 4321)
9
11
  @port = port
10
- start_server
12
+ @input = 'ruby'
13
+ @output = 'public_html'
11
14
  end
12
15
 
13
16
  def generate_initial_files
14
- Dir.mkdir 'ruby' unless Dir.exist?('ruby')
17
+ Dir.mkdir @input unless Dir.exist?(@input)
15
18
  File.write(
16
- "ruby/index.php.erb",
19
+ "#{@input}/index.php.erb",
17
20
  "<h1>Generated by RPHP</h1>"
18
- ) unless File.exist?("ruby/index.php.erb")
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 start_server
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('/') do |modified, added, removed|
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
@@ -1,3 +1,3 @@
1
1
  module Rphp
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.2.1"
3
3
  end
data/lib/rphp.rb CHANGED
@@ -4,7 +4,4 @@ require "rphp/main"
4
4
 
5
5
  module RPHP
6
6
  class Error < StandardError; end
7
- def self.serve port
8
- Server.new port
9
- end
10
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rphp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walter Melo