nexoform 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nexoform +43 -33
  3. data/lib/nexoform/version.rb +2 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8210b96451615b27d39e2bbafd827b34bbfe262872ada1622df46ca9b70ed143
4
- data.tar.gz: '08d53cde72e871f596c3ecff3da95fdfc8ae8e24ab6ec1a26e3c862a5d08f0bd'
3
+ metadata.gz: 49c30beaa3d694a24e90963ca1385052390875dc38dd480013c77b9129479239
4
+ data.tar.gz: 289f9685367b3971520c57842e97d80ef107ac0c1e6fd5dbfa1b531ed847d0f1
5
5
  SHA512:
6
- metadata.gz: b116bdcf03e8520c33b245ababa552a6fe97dd68d12d1513f76870f953ea46f76e6fb47397bb464a313d19c105a86bf12d6b2b7190c11605fb05418a4376271a
7
- data.tar.gz: 3d382aad3235762e85fba2ba7a10cab028735ddad098d8fa8856cbc08c6b38bf1facc130991e9c236330d70e5a5d8de7a3e3d77d11909d56283e7be4f8208db8
6
+ metadata.gz: fc2054ef934dcf381e62ec76ea181b222ff3489aa17feeee7deb37821b955dbfcf5231292532f6f29bb7f7a14f33d5669fa831ffc92f99ced58dddd445a7deac
7
+ data.tar.gz: 582e5beae666034fb39ec5577fac917cb380330e97b08d2f0adaa8bd50c3a0251d05ceac9266ecf327569cec18349519cd7ceeb1e333773762e24f115dc98f13
data/bin/nexoform CHANGED
@@ -514,37 +514,38 @@ class NexoformBin < Thor
514
514
  generate_files(options, chdir: false)
515
515
  end
516
516
 
517
+ def process_dir(options, directory)
518
+ Dir.chdir(directory) do
519
+ # Go through and process ERB into output then delete the ERB file
520
+ Dir.glob('*.erb').each do |f|
521
+ header = "# This file was generated by nexoform. Changes will be lost\n"
522
+ content = ERB.new(File.read(f), 0, "%<>").result(binding)
523
+ File.write(f.gsub(/\.erb$/i, ''), "#{header}#{content}")
524
+ FileUtils.rm([f])
525
+ end
526
+
527
+ Dir.glob('*')
528
+ .select{ |f| File.directory?(f) }
529
+ .each{ |f| process_dir(options, f) } # recursive
530
+ end
531
+ end
532
+
517
533
  def generate_files(options, chdir:)
518
- print_next_color 'Generating terraform files ' \
519
- 'for environment: '
534
+ print_next_color 'Generating terraform files for environment: '
520
535
  puts_next_color env(options)
521
-
522
- clean_output_dir(options)
523
- # find all .*.erb files, run them through erb and output the result
524
- process_copy_erb_files(options)
525
- # find all .* files (that don't end in erb) and copy them straight through
526
- copy_other_files(options)
527
536
 
528
- set_working_dir(options) if chdir
529
- end
537
+ clean_output_dir(options)
530
538
 
531
- def copy_other_files(options)
532
- Dir.glob('*')
533
- .select { |f| !File.directory?(f) }
534
- .select { |f| !(f =~ /\.erb$/i) }
535
- .each { |f| FileUtils.cp(File.basename(f), output_dir(options)) }
536
- end
539
+ # Copy everything to new directory
540
+ FileUtils.cp_r(
541
+ Dir.glob('*').reject{ |f| Nexoform::Config.envs.include?(f) },
542
+ output_dir(options)
543
+ )
537
544
 
538
- def erb_file_to_out_file(f, options)
539
- "#{output_dir(options)}/#{f.gsub(/\.erb$/i, '')}"
540
- end
545
+ # Go through and process ERB into output then delete the ERB file
546
+ process_dir(options, output_dir(options))
541
547
 
542
- def process_copy_erb_files(options)
543
- Dir.glob('*.erb').each do |f|
544
- header = "# This file was generated by nexoform. Changes will be lost\n"
545
- content = ERB.new(File.read(f), 0, "%<>").result(binding)
546
- File.write(erb_file_to_out_file(f, options), "#{header}#{content}")
547
- end
548
+ set_working_dir(options) if chdir
548
549
  end
549
550
 
550
551
  def clean_output_dir(options)
@@ -559,11 +560,20 @@ class NexoformBin < Thor
559
560
  "#{Dir.pwd}/#{env(options)}"
560
561
  end
561
562
 
562
- def has_erb_files?
563
- Dir.glob('*.erb').count > 0
563
+ def has_erb_files?(directory = Dir.pwd)
564
+ #return true if Dir.glob('*.erb').count > 0
565
+ Dir.chdir(directory) do
566
+ if Dir.glob('*.erb').count > 0
567
+ true
568
+ else
569
+ Dir.glob('*')
570
+ .select { |f| File.directory?(f) }
571
+ .any? { |f| has_erb_files?(f) } # recursive
572
+ end
573
+ end
564
574
  end
565
575
 
566
- def set_working_dir(optioons)
576
+ def set_working_dir(options)
567
577
  Dir.chdir(output_dir(options)) if has_erb_files?
568
578
  end
569
579
  end
@@ -571,10 +581,10 @@ end
571
581
  if !ARGV.empty? && %w[-v --version].include?(ARGV.first)
572
582
  puts "Nexoform - Version: #{Nexoform.version}"
573
583
  else
574
- #begin
584
+ begin
575
585
  NexoformBin.start(ARGV)
576
- #rescue StandardError => e
577
- # puts "* Encountered an error. Make sure your config-file isn't messed up".red
578
- # puts "\n* Exception message: #{e.message}".yellow
579
- #end
586
+ rescue StandardError => e
587
+ puts "* Encountered an error. Make sure your config-file isn't messed up".red
588
+ puts "\n* Exception message: #{e.message}".yellow
589
+ end
580
590
  end
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Nexoform
4
4
  def self.version
5
- '0.1.0'
5
+ '0.1.1'
6
6
  end
7
7
 
8
8
  def self.date
9
- '2019-07-18'
9
+ '2019-07-22'
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexoform
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
  - Ben Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-18 00:00:00.000000000 Z
11
+ date: 2019-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport