gena 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gena +18 -6
- data/lib/generate_cli.rb +1 -0
- data/lib/ramba_adapter.rb +9 -2
- 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: 9394c4d63919ceaf86b70b90e8338ab8927b7b41
|
4
|
+
data.tar.gz: 7028e23fd9c244d528e07ff1a5bbf7c51b36a8b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
14
|
-
|
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}"
|
data/lib/generate_cli.rb
CHANGED
@@ -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!
|
data/lib/ramba_adapter.rb
CHANGED
@@ -19,7 +19,7 @@ class RambaAdapter
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def delete_rambafile
|
22
|
-
FileUtils.
|
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
|
-
"#{
|
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)
|