filegen 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -1
- data/README.md +1 -0
- data/lib/filegen/data_source_builder.rb +2 -1
- data/lib/filegen/erb_generator.rb +5 -1
- data/lib/filegen/exceptions.rb +3 -0
- data/lib/filegen/runner.rb +4 -1
- data/lib/filegen/version.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
0.
|
1
|
+
0.3.1: 2014-01-14
|
2
|
+
* Add handling of erb syntax errors
|
3
|
+
* Improved documentation: gem badge
|
4
|
+
* Fix rubocop offence
|
5
|
+
|
6
|
+
0.3.0: 2014-01-14
|
2
7
|
* Activate erb trim mode (see http://ruby-doc.org/stdlib-2.0.0/libdoc/erb/rdoc/ERB.html : new)
|
3
8
|
|
4
9
|
0.2.3: 2014-01-14
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/dg-vrnetze/filegen.png?branch=master)](https://travis-ci.org/dg-vrnetze/filegen)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/dg-vrnetze/filegen.png)](https://codeclimate.com/github/dg-vrnetze/filegen)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/dg-vrnetze/filegen/badge.png?branch=master)](https://coveralls.io/r/dg-vrnetze/filegen?branch=master)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/filegen.png)](http://badge.fury.io/rb/filegen)
|
6
7
|
|
7
8
|
Have you ever felt the need to generate files based on environment variables or
|
8
9
|
yaml files? If your answer is yes, then `filegen` can be quite helpful for
|
@@ -43,7 +43,8 @@ module Filegen
|
|
43
43
|
|
44
44
|
def validate_data_sources
|
45
45
|
invalid_data_sources = chosen_data_sources - allowed_data_sources
|
46
|
-
|
46
|
+
message = "Unknown data source#{invalid_data_sources.size > 1 ? 's' : ''} \"#{invalid_data_sources.join(', ')}\" found."
|
47
|
+
fail Exceptions::DataSourcesAreInvalid, message unless invalid_data_sources.empty?
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
@@ -24,7 +24,11 @@ module Filegen
|
|
24
24
|
# The output io handle
|
25
25
|
def compile(source, destination)
|
26
26
|
erb = ERB.new(source.read, nil, '-')
|
27
|
-
|
27
|
+
begin
|
28
|
+
destination.puts erb.result(data.instance_binding)
|
29
|
+
rescue SyntaxError => e
|
30
|
+
raise Exceptions::ErbTemplateHasSyntaxErrors, e.message
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
data/lib/filegen/exceptions.rb
CHANGED
@@ -13,5 +13,8 @@ module Filegen
|
|
13
13
|
|
14
14
|
# raised if one uses an invalid template name (missing erb)
|
15
15
|
class TemplateNameIsInvalid < RuntimeError; end
|
16
|
+
|
17
|
+
# raised if a given erb template has syntax errors in it
|
18
|
+
class ErbTemplateHasSyntaxErrors < Exception; end
|
16
19
|
end
|
17
20
|
end
|
data/lib/filegen/runner.rb
CHANGED
@@ -35,9 +35,12 @@ module Filegen
|
|
35
35
|
rescue RuntimeError => e
|
36
36
|
Filegen::Ui.error e.message
|
37
37
|
exitstatus = 1
|
38
|
-
rescue Interrupt
|
38
|
+
rescue Interrupt
|
39
39
|
Filegen::Ui.warning 'You told me to stop command execution.'
|
40
40
|
exitstatus = 2
|
41
|
+
rescue Exceptions::ErbTemplateHasSyntaxErrors => e
|
42
|
+
Filegen::Ui.error "Syntax error in ERB-Template: \n" + e.message
|
43
|
+
exitstatus = 3
|
41
44
|
end
|
42
45
|
|
43
46
|
@kernel.exit(exitstatus)
|
data/lib/filegen/version.rb
CHANGED