gena 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: d011b05b5a46e8082c31e35c5937526e60813077
4
- data.tar.gz: 8faa576c158597b3a126c55c380aaf9e44e0b266
3
+ metadata.gz: 51d813b88b44bbcb481e7e910f4bd317eb07cf76
4
+ data.tar.gz: ee01de046fb62ec208e9e58f5246247f9a4aab70
5
5
  SHA512:
6
- metadata.gz: 2329244fb94233fc4a8c538401a1047470d080c86b2dda958c3f79860f79c5832026d0eb66dfa6900becb34b6bdd17cdec7f50b4dd6213607d7f7321f90ac69a
7
- data.tar.gz: 240c13add3eb328b128c9cb5c5a2f4831379e656f3cbcc70f718e9943664c07e76944321d0dbe2018350a2ba9fcaa988c93abae8b927231bd8c0cc8d13dd1cdc
6
+ metadata.gz: b4b5cf34acc5337c977c6d8fb25c21bd8c41211c713d54978f4083c958a5888120abf715b89035da207813427e51ce8c18737f025c3840c727e70d7811d33371
7
+ data.tar.gz: 724e32b7928e804d123839aaffb34078ef572eadeeb02fc422dc28532872819d4c488135316f9615c1ccf18cc022711a883a6fafd8c07af3c7474cca81aa225c
@@ -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
- if $config.header_dir.empty?
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
@@ -42,7 +42,7 @@ module Gena
42
42
 
43
43
  def header_dir
44
44
  if @data['header'] && !@data['header'].empty?
45
- expand_to_project(File.dirname(@data['header']))
45
+ expand_to_project(@data['header'])
46
46
  else
47
47
  ''
48
48
  end
data/lib/constants.rb CHANGED
@@ -2,6 +2,6 @@ module Gena
2
2
  GENA_HOME = '~/.gena'
3
3
  GENA_UPDATE_CHECK_INTERVAL = 10800
4
4
  GENA_PLUGINS_CONFIG_KEY = 'configs'
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  RELEASE_DATE = '2017-10-04'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gena
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey Garbarev