Class: PropertyGenerator::Generator
- Inherits:
-
Object
- Object
- PropertyGenerator::Generator
- Includes:
- PropertyGenerator
- Defined in:
- lib/generator/generator.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(options) ⇒ Generator
constructor
purpose: initialize globals and configs serve as a broker between tasks.
- #upload(out, config) ⇒ Object
Methods included from PropertyGenerator
get_list_of_files, invalid_paths, read_services, sync, test_runner, valid_paths, writer
Constructor Details
#initialize(options) ⇒ Generator
purpose: initialize globals and configs serve as a broker between tasks
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/generator/generator.rb', line 13 def initialize() project_path = File.(['project_path']) @configs = PropertyGenerator::Config.new(project_path) @globals = PropertyGenerator::Globals.new(project_path, @configs) @globals = @globals.globals @output_path = "#{File.expand_path(options['output'])}/properties/#{SecureRandom.hex}" puts "Properties will be output here #{@output_path}" @service_list = PropertyGenerator.read_services(project_path) end |
Instance Method Details
#generate ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/generator/generator.rb', line 24 def generate output = [] @service_list.each do | service, path| service_instance = PropertyGenerator::Service.new(YAML.load_file(path), @configs, @globals) service_instance.service service_instance.interpolate out = PropertyGenerator.writer(service, service_instance.service, @configs, @output_path) (output << out).flatten! end output end |
#upload(out, config) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generator/generator.rb', line 37 def upload(out, config) upload_account = config['upload_account'] upload_region = config['upload_region'] upload_bucket = config['upload_bucket'] out.each do |file| next unless file.include?("#{upload_account}") && file.include?("#{upload_region}") file_region = file.split("/")[-2] PropertyGenerator.sync(upload_region, upload_account, upload_bucket, file, file_region) end end |