Class: EnvSync::Syncer
- Inherits:
-
Object
- Object
- EnvSync::Syncer
- Defined in:
- lib/env_sync.rb
Defined Under Namespace
Classes: EnvSetting, InvalidFormat
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Syncer
constructor
A new instance of Syncer.
- #sync! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Syncer
Returns a new instance of Syncer.
38 39 40 41 |
# File 'lib/env_sync.rb', line 38 def initialize(={}) @basic_envfile = ( || {}).fetch(:basic_envfile) { 'env.yaml' } @envs = parse_env_file!(File.read(@basic_envfile)) end |
Instance Method Details
#sync! ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/env_sync.rb', line 43 def sync! @envs.each do |env| fullpath = env.target_env_path if File.exist?(fullpath) puts "** Overwrite #{fullpath}" puts "Before" puts File.read(fullpath) puts "---" else puts "** Write #{fullpath}" end env.write! puts File.read(fullpath) puts "Done." end end |