rphp 0.0.2.1 → 0.0.2.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 +4 -4
- data/lib/rphp/server.rb +31 -12
- data/lib/rphp/version.rb +1 -1
- 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: 967e41a59c5dc6bda57e6b2a7818821610ede79cb257ff969487e7d57751f296
|
4
|
+
data.tar.gz: ae17f4513ac40aa25b06606e26c149c98469929091451cc39612bc048112986f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 141c3dd3670a768f4fcdcd3983c6f637fb9d735f5211791ff1d16fa38518acd1a7e9399a1699f11b1bc4bae1950cca18c82803c1322ac5de329d42a9b66571d5
|
7
|
+
data.tar.gz: 813899cf4641ce3990b92cee4db5483192ba7fae1f398ce119e8a57aef37f5305c1a3841671def45b0198b40399503dc71c28bb45f58af922e88ba2f5d7a8262
|
data/lib/rphp/server.rb
CHANGED
@@ -15,22 +15,18 @@ class Rphp::Server
|
|
15
15
|
|
16
16
|
def generate_initial_files
|
17
17
|
Dir.mkdir @input unless Dir.exist?(@input)
|
18
|
+
Dir.mkdir @output unless Dir.exist?(@output)
|
18
19
|
File.write(
|
19
20
|
"#{@input}/index.php.erb",
|
20
21
|
"<h1>Generated by RPHP</h1>"
|
21
22
|
) unless File.exist?("#{@input}/index.php.erb")
|
22
23
|
end
|
23
24
|
|
24
|
-
def parse_file
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
input_name = "#{output}.#{engine}"
|
30
|
-
output_name = "#{output}.#{extension}"
|
31
|
-
|
32
|
-
file = Tilt.new("ruby/#{filename}").render
|
33
|
-
File.write("#{output}.#{extension}",file)
|
25
|
+
def parse_file (input,output)
|
26
|
+
output = output.split('/')[1..-1].join('/')
|
27
|
+
.split('.')[0..-2].join('.')
|
28
|
+
content = Tilt.new(input).render
|
29
|
+
File.write(output,content)
|
34
30
|
end
|
35
31
|
|
36
32
|
def start
|
@@ -39,10 +35,33 @@ class Rphp::Server
|
|
39
35
|
listen
|
40
36
|
end
|
41
37
|
|
38
|
+
def teste
|
39
|
+
FileUtils.rm_rf(@output)
|
40
|
+
generate_initial_files
|
41
|
+
parse_folder "./#{@input}/*"
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse_folder folder_name
|
45
|
+
Dir["#{folder_name}"].each do |file|
|
46
|
+
filename = file.split('/')[2..-1].join('/')
|
47
|
+
if File.directory? file
|
48
|
+
file = "./#{@input}/#{filename}"
|
49
|
+
out = "./#{@output}/#{filename}"
|
50
|
+
FileUtils.rm_rf(out)
|
51
|
+
Dir.mkdir out unless Dir.exist? out
|
52
|
+
parse_folder "#{file}/*"
|
53
|
+
else
|
54
|
+
file = "./#{@input}/#{filename}"
|
55
|
+
out = "./#{@output}/#{filename}"
|
56
|
+
parse_file(file, out)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
42
61
|
def listen
|
43
|
-
|
62
|
+
parse_folder "./#{@input}/*"
|
44
63
|
listener = Listen.to(@input) do |modified, added, removed|
|
45
|
-
|
64
|
+
parse_folder "./#{@input}/*"
|
46
65
|
end
|
47
66
|
listener.start # not blocking
|
48
67
|
sleep
|
data/lib/rphp/version.rb
CHANGED