gena 0.0.7 → 0.1.0
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 +4 -4
- data/bin/gena +9 -65
- data/lib/cli/cli.rb +138 -0
- data/lib/cli/init.rb +273 -0
- data/lib/codegen/codegen.rb +176 -0
- data/lib/config/config.rb +90 -0
- data/lib/constants.rb +7 -0
- data/lib/gena.rb +25 -6
- data/lib/plugin/plugin.rb +58 -0
- data/lib/utils/utils.rb +77 -0
- data/lib/utils/xcode_utils.rb +122 -0
- metadata +58 -15
- data/lib/base_template.rb +0 -91
- data/lib/config.rb +0 -44
- data/lib/generate_cli.rb +0 -60
- data/lib/ramba_adapter.rb +0 -102
- data/lib/string_utils.rb +0 -18
data/lib/ramba_adapter.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative 'config'
|
3
|
-
|
4
|
-
class RambaAdapter
|
5
|
-
|
6
|
-
RAMBAFILE_NAME = 'Rambafile'
|
7
|
-
RAMBA_TEMPLATES_FOLDER = 'Templates'
|
8
|
-
|
9
|
-
@template
|
10
|
-
@config
|
11
|
-
|
12
|
-
def initialize(template, config)
|
13
|
-
@template = template
|
14
|
-
@config = config
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_rambafile
|
18
|
-
File.open("./#{RAMBAFILE_NAME}", 'w') {|f| f.write @config.to_rambafile }
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete_rambafile
|
22
|
-
FileUtils.rm_f("./#{RAMBAFILE_NAME}")
|
23
|
-
end
|
24
|
-
|
25
|
-
def regenerate_default_template
|
26
|
-
delete_default_template
|
27
|
-
create_default_template
|
28
|
-
end
|
29
|
-
|
30
|
-
def delete_default_template
|
31
|
-
FileUtils.rm_rf "#{RAMBA_TEMPLATES_FOLDER}/default"
|
32
|
-
end
|
33
|
-
|
34
|
-
def create_default_template
|
35
|
-
#Create folders
|
36
|
-
dst_dir = "#{RAMBA_TEMPLATES_FOLDER}/default"
|
37
|
-
FileUtils.mkdir_p dst_dir
|
38
|
-
type_dir = template_directory(@template)
|
39
|
-
|
40
|
-
#Copy files..
|
41
|
-
copy_if_needed "#{type_dir}/Code", "#{dst_dir}/Code"
|
42
|
-
copy_if_needed "#{type_dir}/Tests", "#{dst_dir}/Tests"
|
43
|
-
copy_if_needed "#{type_dir}/snippets", "#{dst_dir}/snippets"
|
44
|
-
|
45
|
-
#Generate rambaspec
|
46
|
-
generate_rambaspec("#{dst_dir}/default.rambaspec", @template.options)
|
47
|
-
end
|
48
|
-
|
49
|
-
def generate_rambaspec(output, options)
|
50
|
-
rambaspec = {}
|
51
|
-
|
52
|
-
rambaspec['name'] = 'default'
|
53
|
-
rambaspec['summary'] = "Template generated from #{@template} template class"
|
54
|
-
rambaspec['author'] = 'generate.rb'
|
55
|
-
rambaspec['version'] = '1.0.0'
|
56
|
-
rambaspec['license'] = 'MIT'
|
57
|
-
|
58
|
-
rambaspec['code_files'] = @template.template_source_files
|
59
|
-
rambaspec['test_files'] = @template.template_test_files if options[:generate_tests]
|
60
|
-
|
61
|
-
File.open(output, 'w') {|f| f.write rambaspec.to_yaml( :UseFold => true) }
|
62
|
-
end
|
63
|
-
|
64
|
-
def template_directory(template)
|
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
|
73
|
-
end
|
74
|
-
|
75
|
-
def copy_if_needed(src, dst)
|
76
|
-
FileUtils.cp_r src, dst if File.exists? src
|
77
|
-
puts "copied #{src} #{dst} (#{File.exists? src})"
|
78
|
-
end
|
79
|
-
|
80
|
-
def generamba_gen_command(options)
|
81
|
-
sources_path = @template.sources_absolute_path
|
82
|
-
test_path = @template.tests_absolute_path
|
83
|
-
custom_params = @template.template_parameters_string
|
84
|
-
|
85
|
-
cli_command = "generamba gen #{options[:name]} default"
|
86
|
-
|
87
|
-
if sources_path.length > 0
|
88
|
-
cli_command << " --module_path #{sources_path}"
|
89
|
-
end
|
90
|
-
|
91
|
-
if test_path.length > 0
|
92
|
-
cli_command << " --test_path #{test_path}"
|
93
|
-
end
|
94
|
-
|
95
|
-
if custom_params.length > 0
|
96
|
-
cli_command << " --custom_parameters #{custom_params}"
|
97
|
-
end
|
98
|
-
|
99
|
-
cli_command
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
data/lib/string_utils.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
def include_one_of?(*array)
|
3
|
-
array.flatten.each do |str|
|
4
|
-
return true if self.include?(str)
|
5
|
-
end
|
6
|
-
return false
|
7
|
-
end
|
8
|
-
def capitalize_first
|
9
|
-
self.slice(0,1).capitalize + self.slice(1..-1)
|
10
|
-
end
|
11
|
-
def capitalize_first!
|
12
|
-
self.replace(self.capitalize_first)
|
13
|
-
end
|
14
|
-
def lowercase_first
|
15
|
-
str = to_s
|
16
|
-
str[0,1].downcase + str[1..-1]
|
17
|
-
end
|
18
|
-
end
|