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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f57e6e5ffd398dad5c902686f95ea802c415fcf68ef708d0d3382b5f94f738c
4
- data.tar.gz: 2d81c65779da9731918f0da186209f67114582609d14a2fa29dfef0740dcfe5b
3
+ metadata.gz: 967e41a59c5dc6bda57e6b2a7818821610ede79cb257ff969487e7d57751f296
4
+ data.tar.gz: ae17f4513ac40aa25b06606e26c149c98469929091451cc39612bc048112986f
5
5
  SHA512:
6
- metadata.gz: 0442603e676fc004beded88d2c968fdc544df833ba574554e9139c83782710254e2fdc7a89d84d46f222e29abb3fdbab752b422185eefd8fc66c7ffa214b495b
7
- data.tar.gz: f051cbd31f4fb3e381112af4e301ade3e55ef08dfef6aa4683630c7ac5b5d6dec983c3e9ca9759da826106d8e6ea754062454ddb411eae48ec6998164caf4e3a
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 filename
25
- generate_initial_files
26
- output = filename.split('.')[0]
27
- extension = filename.split('.')[1]
28
- engine = filename.split('.')[2]
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
- parse_file 'index.php.erb'
62
+ parse_folder "./#{@input}/*"
44
63
  listener = Listen.to(@input) do |modified, added, removed|
45
- parse_file 'index.php.erb'
64
+ parse_folder "./#{@input}/*"
46
65
  end
47
66
  listener.start # not blocking
48
67
  sleep
data/lib/rphp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rphp
2
- VERSION = "0.0.2.1"
2
+ VERSION = "0.0.2.2"
3
3
  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.1
4
+ version: 0.0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walter Melo