Class: Flapjack::CLI::Receiver
- Inherits:
-
Object
- Object
- Flapjack::CLI::Receiver
- Defined in:
- lib/flapjack/cli/receiver.rb
Instance Method Summary collapse
-
#initialize(global_options, options) ⇒ Receiver
constructor
A new instance of Receiver.
- #json ⇒ Object
- #mirror ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(global_options, options) ⇒ Receiver
Returns a new instance of Receiver.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/flapjack/cli/receiver.rb', line 15 def initialize(, ) @global_options = @options = if @global_options[:'force-utf8'] Encoding.default_external = 'UTF-8' Encoding.default_internal = 'UTF-8' end @config = Flapjack::Configuration.new @config.load([:config]) @config_env = @config.all if @config_env.nil? || @config_env.empty? unless 'mirror'.eql?(@options[:type]) exit_now! "No config data found in '#{[:config]}'" end end unless 'mirror'.eql?(@options[:type]) Flapjack::RedisProxy.config = @config.for_redis Zermelo.redis = Flapjack.redis end @redis_options = @config.for_redis end |
Instance Method Details
#json ⇒ Object
53 54 55 |
# File 'lib/flapjack/cli/receiver.rb', line 53 def json json_feeder(:from => @options[:from]) end |
#mirror ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/flapjack/cli/receiver.rb', line 57 def mirror if (@options[:dest].nil? || @options[:dest].strip.empty?) && @redis_options.nil? exit_now! "No destination redis URL passed, and none configured" end mirror_receive(:source => @options[:source], :dest => @options[:dest] || @redis_options, :include => @options[:include], :all => @options[:all], :follow => @options[:follow], :last => @options[:last], :time => @options[:time]) end |
#start ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/flapjack/cli/receiver.rb', line 42 def start puts "#{@options[:type]}-receiver starting..." begin main(:fifo => @options[:fifo], :type => @options[:type]) rescue Exception => e p e. puts e.backtrace.join("\n") end puts " done." end |