gena 0.0.6 → 0.0.7

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: b0aae731249981adfb88a04ec9198cb040af78cd
4
- data.tar.gz: a3df22d7230b6f7aca67da17b1dad4ff14896fb1
3
+ metadata.gz: 9394c4d63919ceaf86b70b90e8338ab8927b7b41
4
+ data.tar.gz: 7028e23fd9c244d528e07ff1a5bbf7c51b36a8b5
5
5
  SHA512:
6
- metadata.gz: aed64a6d719183eacf9ab288bc0e1307bab3b77a0efa8856efa2ddae3cfe8106658f040511f2708d6d1fb5dd0d4ece0ec43ac17b95def6e56381d78d37050009
7
- data.tar.gz: a8a9add9f040ea237db43e93574ec47f376284ca7df547762d350ebc1e93dd64a011eca9cde756b535482765fa4ba29fde040af52e18ef1cab666cde45c83a72
6
+ metadata.gz: 9d3135276f6d6b0fdb7dc0e322d60d5beca16fe3e94875352f98d285985957f0b299ebb736456050e4c6770328cfc92c9b2c7bf5c81ccbf051284320a4adf01a
7
+ data.tar.gz: e48bde3e2dfe2b332c53e42951e7a7bd83e3c519c19733e66b25a739547cfdd7d81ae8a92453ad9faf755cb10052711522b4cb47cd7ab9793ca0ba03e4af2d46
data/bin/gena CHANGED
@@ -6,12 +6,18 @@ unless system "which xc-resave >> /dev/null"
6
6
  raise "\nPlease install xc-resave utility first. Run: \n\nbrew install alexgarbarev/core/xc-resave\n\n"
7
7
  end
8
8
 
9
- TEMPLATES_FOLDER = "Templates"
10
-
9
+ TEMPLATES_PROJECT_FOLDER = File.expand_path('Templates')
10
+ TEMPLATES_SYSTEM_FOLDER = File.expand_path('~/.gena/templates')
11
11
 
12
12
  # Include all template code files
13
- Dir["#{TEMPLATES_FOLDER}/**/*.rb"].each do |file|
14
- require "./#{file}"
13
+
14
+ registered = []
15
+ Dir["#{TEMPLATES_PROJECT_FOLDER}/**/*.rb", "#{TEMPLATES_SYSTEM_FOLDER}/**/*.rb"].each do |file|
16
+ template_name = file.split(File::SEPARATOR)[-2]
17
+ unless registered.include? template_name
18
+ registered << template_name
19
+ require file
20
+ end
15
21
  end
16
22
 
17
23
  cli = GenerateCli.new
@@ -36,6 +42,13 @@ end
36
42
  config = Generate::Config.new
37
43
  config.load_plist_config
38
44
 
45
+ if options[:fetch]
46
+ FileUtils.rm_rf File.expand_path(TEMPLATES_SYSTEM_FOLDER)
47
+ FileUtils.mkdir_p File.expand_path(TEMPLATES_SYSTEM_FOLDER)
48
+ command = "git clone --depth 1 #{config.config['templates_url']} #{TEMPLATES_SYSTEM_FOLDER}"
49
+ exec command
50
+ end
51
+
39
52
  template = Generate::BaseTemplate.new_from_options(options, config)
40
53
 
41
54
  unless template.class.generamba?
@@ -55,5 +68,4 @@ if options[:verbose]
55
68
  puts "#{cli_command}"
56
69
  end
57
70
 
58
- exec "#{cli_command}"
59
-
71
+ exec "#{cli_command}"
@@ -25,6 +25,7 @@ class GenerateCli
25
25
  opts.on('-v', '--verbose') { options[:verbose] = true }
26
26
  opts.on('--tests', 'Generate tests if possible') { options[:generate_tests] = true }
27
27
  opts.on('--cleanup', 'Removes temporary data instead of generation') { options[:cleanup] = true; return options; }
28
+ opts.on('--fetch', 'Fetches templates from remote repository') { options[:fetch] = true; return options; }
28
29
  end
29
30
 
30
31
  parser.parse!
@@ -19,7 +19,7 @@ class RambaAdapter
19
19
  end
20
20
 
21
21
  def delete_rambafile
22
- FileUtils.rm("./#{RAMBAFILE_NAME}")
22
+ FileUtils.rm_f("./#{RAMBAFILE_NAME}")
23
23
  end
24
24
 
25
25
  def regenerate_default_template
@@ -62,7 +62,14 @@ class RambaAdapter
62
62
  end
63
63
 
64
64
  def template_directory(template)
65
- "#{TEMPLATES_FOLDER}/#{template.class.template_name}"
65
+ project_path = "#{TEMPLATES_PROJECT_FOLDER}/#{template.class.template_name}"
66
+ if File.exists?(project_path)
67
+ puts 'Using project template'
68
+ project_path
69
+ else
70
+ puts 'Using system template'
71
+ "#{TEMPLATES_SYSTEM_FOLDER}/#{template.class.template_name}"
72
+ end
66
73
  end
67
74
 
68
75
  def copy_if_needed(src, dst)
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.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey Garbarev