gena 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/codegen/codegen.rb +26 -11
- data/lib/config/config.rb +1 -1
- data/lib/constants.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51d813b88b44bbcb481e7e910f4bd317eb07cf76
|
4
|
+
data.tar.gz: ee01de046fb62ec208e9e58f5246247f9a4aab70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4b5cf34acc5337c977c6d8fb25c21bd8c41211c713d54978f4083c958a5888120abf715b89035da207813427e51ce8c18737f025c3840c727e70d7811d33371
|
7
|
+
data.tar.gz: 724e32b7928e804d123839aaffb34078ef572eadeeb02fc422dc28532872819d4c488135316f9615c1ccf18cc022711a883a6fafd8c07af3c7474cca81aa225c
|
data/lib/codegen/codegen.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
module Gena
|
4
2
|
|
5
3
|
module Filetype
|
@@ -43,6 +41,8 @@ module Gena
|
|
43
41
|
# Params
|
44
42
|
template_params = @template_params.merge($config.data_without_plugins)
|
45
43
|
template_params = params.merge(template_params) if params
|
44
|
+
template_params['date'] = Time.now.strftime('%d/%m/%Y')
|
45
|
+
template_params['year'] = Time.new.year
|
46
46
|
|
47
47
|
render_template_to_file(template_path, output_path, template_params)
|
48
48
|
|
@@ -81,22 +81,33 @@ module Gena
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def remove_from_project(path)
|
84
|
-
|
85
84
|
XcodeUtils.shared.delete_path(path)
|
86
|
-
|
87
85
|
end
|
88
86
|
|
89
87
|
private
|
90
88
|
|
89
|
+
def setup_header_if_needed(params)
|
90
|
+
unless Liquid::Template.file_system.is_a? GenaStaticHeader
|
91
|
+
if $config.header_dir.empty?
|
92
|
+
say "No 'header' field inside 'gena.plist'. You can specify path to header's liquid template there. Using default header", Color::YELLOW
|
93
|
+
Liquid::Template.file_system = GenaStaticHeader.new(nil)
|
94
|
+
else
|
95
|
+
if File.exists? $config.header_dir
|
96
|
+
header_content = IO.read($config.header_dir)
|
97
|
+
header_template = Liquid::Template.parse(header_content)
|
98
|
+
Liquid::Template.file_system = GenaStaticHeader.new(header_template.render(params))
|
99
|
+
else
|
100
|
+
say "Can't load header at path: #{$config.header_dir}. Using default header", Color::RED
|
101
|
+
Liquid::Template.file_system = GenaStaticHeader.new(nil)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
91
107
|
|
92
108
|
def render_template_from_path(template_path, params)
|
93
109
|
|
94
|
-
|
95
|
-
say "No 'header' field inside 'gena.plist'. You can specify path to header's liquid template there. Using default header", Color::YELLOW if $verbose
|
96
|
-
Liquid::Template.file_system = GenaStaticHeader.new
|
97
|
-
else
|
98
|
-
Liquid::Template.file_system = Liquid::LocalFileSystem.new($config.header_dir, '%s.liquid')
|
99
|
-
end
|
110
|
+
setup_header_if_needed(params)
|
100
111
|
|
101
112
|
file_source = IO.read(template_path)
|
102
113
|
template = Liquid::Template.parse(file_source)
|
@@ -158,10 +169,14 @@ module Gena
|
|
158
169
|
|
159
170
|
class GenaStaticHeader < Liquid::BlankFileSystem
|
160
171
|
|
172
|
+
def initialize(text)
|
173
|
+
@text = text
|
174
|
+
end
|
175
|
+
|
161
176
|
def read_template_file(name)
|
162
177
|
|
163
178
|
if name == 'header'
|
164
|
-
'////////////////////////////////////////////////////////////////////////////////
|
179
|
+
@text || '////////////////////////////////////////////////////////////////////////////////
|
165
180
|
//
|
166
181
|
// Generated by Gena.
|
167
182
|
//
|
data/lib/config/config.rb
CHANGED
data/lib/constants.rb
CHANGED