sinatraband 0.1.5 → 0.1.6
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.
- data/bin/helper.rb +20 -14
- metadata +2 -2
data/bin/helper.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
def generate_file_from_template input={:directory => './'+@name, :template => '', :final_file => '', :extension => ''}
|
2
|
-
|
3
|
-
File.open("./#{@name}#{input[:directory]}/#{input[:final_file]}.#{input[:extension]}", "w") do |f|
|
4
|
-
begin
|
5
|
-
file_template = ERB.new(File.open("#{@root}#{input[:directory]}/#{input[:template]}.erb").read)
|
6
|
-
rescue (Errno::ENOENT)
|
7
|
-
put_error_and_quit "Error: Missing template for file #{@root}#{input[:directory]}/#{input[:template]}.#{input[:extension]}."
|
8
|
-
end
|
9
|
-
|
10
|
-
begin
|
11
|
-
f.write(file_template.result(binding))
|
12
|
-
puts ".#{input[:directory]}/#{input[:final_file]}.#{input[:extension]} file created."
|
13
|
-
rescue (Errno::ENOENT)
|
14
|
-
put_error_and_quit "Error creating #{input[:final_file]}.#{input[:extension]}."
|
15
|
-
end
|
16
2
|
|
3
|
+
file_name = "./#{@name}#{input[:directory]}/#{input[:final_file]}.#{input[:extension]}"
|
4
|
+
|
5
|
+
if File.exists?(file_name) && File.file?(file_name)
|
6
|
+
File.delete(file_name)
|
7
|
+
puts "Notice: You already have a file #{file_name}. Older version deleted."
|
8
|
+
end
|
9
|
+
|
10
|
+
File.open(file_name, 'w') do |f|
|
11
|
+
begin
|
12
|
+
file_template = ERB.new(File.open("#{@root}#{input[:directory]}/#{input[:template]}.erb").read)
|
13
|
+
rescue (Errno::ENOENT)
|
14
|
+
put_error_and_quit "Error: Missing template for file #{@root}#{input[:directory]}/#{input[:template]}.#{input[:extension]}."
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
f.write(file_template.result(binding))
|
19
|
+
puts ".#{input[:directory]}/#{input[:final_file]}.#{input[:extension]} file created."
|
20
|
+
rescue (Errno::ENOENT)
|
21
|
+
put_error_and_quit "Error creating #{input[:final_file]}.#{input[:extension]}."
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sinatraband
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Julio Bueno
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-20 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Ruby gem to create a basic scaffold sinatra app.
|