module Arisaid::Syncable
Attributes
local_file[W]
Public Class Methods
new(team = nil)
click to toggle source
# File lib/arisaid/syncable.rb, line 50 def initialize(team = nil) Arisaid.slack_team = team if team end
Public Instance Methods
apply()
click to toggle source
# File lib/arisaid/syncable.rb, line 58 def apply end
local()
click to toggle source
# File lib/arisaid/syncable.rb, line 22 def local merge_users(local_by_stdin || local_by_file) end
local_by_file()
click to toggle source
# File lib/arisaid/syncable.rb, line 36 def local_by_file unless File.exist?(local_file_path) raise Arisaid::ConfNotFound.new("Not found: #{local_file_path}") end YAML.load_file(local_file_path) end
local_by_stdin()
click to toggle source
# File lib/arisaid/syncable.rb, line 26 def local_by_stdin if File.pipe?(STDIN) || File.select([STDIN], [], [], 0) != nil buffer = '' while str = STDIN.gets buffer << str end YAML.load(buffer.chomp) end end
local_file()
click to toggle source
# File lib/arisaid/syncable.rb, line 5 def local_file name = self.class.name.split('::').last.downcase @local_file ||= "#{Arisaid.conf_prefix if Arisaid.conf_prefix}#{name}.yml" end
local_file_path()
click to toggle source
# File lib/arisaid/syncable.rb, line 11 def local_file_path File.join(Dir.pwd, local_file) end
merge_users(config)
click to toggle source
# File lib/arisaid/syncable.rb, line 43 def merge_users(config) config.map do |c| c["users"] = c["users"].flatten.uniq c end end
remote()
click to toggle source
# File lib/arisaid/syncable.rb, line 15 def remote @remote ||= remote! end
remote!()
click to toggle source
# File lib/arisaid/syncable.rb, line 19 def remote! end
same?(src, dst)
click to toggle source
# File lib/arisaid/syncable.rb, line 61 def same?(src, dst) src == dst end
save()
click to toggle source
# File lib/arisaid/syncable.rb, line 65 def save File.write local_file_path, remote.to_yaml end
show()
click to toggle source
# File lib/arisaid/syncable.rb, line 54 def show puts remote.to_yaml end