Sha256: 425776b3d4423065ed183dcb0d8060ea464ad225700971fcddbea9e220eb6886
Contents?: true
Size: 1.42 KB
Versions: 29
Compression:
Stored size: 1.42 KB
Contents
module Localeapp module CLI class Push < Command include ::Localeapp::ApiCall def execute(path = nil) @output.puts "Localeapp Push" if path_is_directory?(path) yaml_files_in_directory(path).each do |path| push_file(path) end else push_file(path) end end def push_file(file_path) @output.puts "" @file_path = file_path # for callbacks file = sanitize_file(file_path) if file @output.puts "Pushing file #{File.basename(file_path)}:" api_call :import, :payload => { :file => file }, :success => :report_success, :failure => :report_failure, :max_connection_attempts => 3 else @output.puts "Could not load file" end end def report_success(response) @output.puts "Success!" @output.puts "" @output.puts "#{@file_path} queued for processing." end def report_failure(response) @output.puts "Failed!" end private def sanitize_file(file_path) if File.exist?(file_path) File.new(file_path) else nil end end def path_is_directory?(path) File.directory?(path) end def yaml_files_in_directory(path) Dir.glob(File.join(path, '*.yml')).sort end end end end
Version data entries
29 entries across 29 versions & 1 rubygems