rphp 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3f18231e01d8a6ca11f9cc4d7e12ad9c07d46e58b3504217779f127e8871600
4
- data.tar.gz: 4df7af06005c8d48a478f6f4f64bdc747ff48e0ce403a4728c354263c7c5a502
3
+ metadata.gz: a57a94180f428853f52c7aa4cc65c56e7dbdf84eb6cd19a01f180afababc1c4e
4
+ data.tar.gz: 5938d33c121221f45fa2783da6651eee6914d02cb4573d4bad9a503460602b0c
5
5
  SHA512:
6
- metadata.gz: f88437e85a8d6d1bff2ff9001e4b53e8a6f2ed9280db6d8a7f087ebd6e559a0b47be91569390f84314c834b7902c0dc79854599752a23444ca39a161779fc9cb
7
- data.tar.gz: b9df2ab681ce788c049734c49590e41a1cebb2983cd2d6311f91e6b24738c84711d0e46ee34677b8f805543fe64f1b7b628a937eba5a16d00f4a578bd166fb4d
6
+ metadata.gz: bddd63aa74d650dcd3173172edeb47665959450ded63ae11de4e5a7c56332b4f4d1b4823b740da7ef866de39f6b94d5826e997f349e3786f32c85e7366fc4643
7
+ data.tar.gz: 32ae0d6a099446abddceb7f5250e98219aa638d0c324ad5e02e1c9bce6d814008832b7c62f4239134617ef7f12d1e88c9f1efaa35f24591b36b14c9477864dd1
data/lib/rphp/main.rb ADDED
@@ -0,0 +1,2 @@
1
+ # this file exists to require everything
2
+ require 'rphp/server'
@@ -0,0 +1,47 @@
1
+ # this file is about the PHP server class
2
+
3
+ class Server
4
+ require 'fileutils'
5
+ require 'listen'
6
+ require 'tilt'
7
+
8
+ def initialize(port)
9
+ @port = port
10
+ start_server
11
+ end
12
+
13
+ def generate_initial_files
14
+ Dir.mkdir 'ruby' unless Dir.exist?('ruby')
15
+ File.write(
16
+ "ruby/index.php.erb",
17
+ "<h1>Generated by RPHP</h1>"
18
+ ) unless File.exist?("ruby/index.php.erb")
19
+ end
20
+
21
+ def parse_file filename
22
+ generate_initial_files
23
+ output = filename.split('.')[0]
24
+ extension = filename.split('.')[1]
25
+ engine = filename.split('.')[2]
26
+ input_name = "#{output}.#{engine}"
27
+ output_name = "#{output}.#{extension}"
28
+
29
+ file = Tilt.new("ruby/#{filename}").render
30
+ File.write("#{output}.#{extension}",file)
31
+ end
32
+
33
+ def start_server
34
+ puts "PHP development server started at port #{@port}"
35
+ `nohup php -S localhost:#{@port} >/dev/null 2>&1 &`
36
+ listen
37
+ end
38
+
39
+ def listen
40
+ parse_file 'index.php.erb'
41
+ listener = Listen.to('/') do |modified, added, removed|
42
+ parse_file 'index.php.erb'
43
+ end
44
+ listener.start # not blocking
45
+ sleep
46
+ end
47
+ end
data/lib/rphp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rphp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/rphp.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  require "rphp/version"
2
- require "rphp/test"
2
+ require "rphp/main"
3
3
 
4
- module Rphp
4
+
5
+ module RPHP
5
6
  class Error < StandardError; end
6
- # Your code goes here...
7
+ def self.serve port
8
+ Server.new port
9
+ end
7
10
  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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walter Melo
@@ -46,7 +46,8 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - lib/rphp.rb
49
- - lib/rphp/test.rb
49
+ - lib/rphp/main.rb
50
+ - lib/rphp/server.rb
50
51
  - lib/rphp/version.rb
51
52
  homepage: https://www.github.com/walmello24/rphp
52
53
  licenses:
data/lib/rphp/test.rb DELETED
@@ -1,7 +0,0 @@
1
- module RPHP
2
- class Tester
3
- def self.hello
4
- puts "Rélou uordi!"
5
- end
6
- end
7
- end