Class: Ajimi::Client

Inherits:
Thor
  • Object
show all
Defined in:
lib/ajimi/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
# File 'lib/ajimi/client.rb', line 11

def initialize(*args)
  super
  @config = Ajimi::Config.load(options[:ajimifile])
  @config[:verbose] = options[:verbose] unless options[:verbose].nil?
end

Instance Attribute Details

#checkerObject

Returns the value of attribute checker.



5
6
7
# File 'lib/ajimi/client.rb', line 5

def checker
  @checker
end

#reporterObject

Returns the value of attribute reporter.



5
6
7
# File 'lib/ajimi/client.rb', line 5

def reporter
  @reporter
end

Instance Method Details

#checkObject



22
23
24
25
26
27
28
29
30
# File 'lib/ajimi/client.rb', line 22

def check
  @config.merge!( {
    find_max_depth: options[:find_max_depth],
    enable_check_contents: options[:enable_check_contents],
    limit_check_contents: options[:limit_check_contents]
  } )
  @config[:check_root_path] = options[:check_root_path] if options[:check_root_path]
  _check
end

#dir(path) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/ajimi/client.rb', line 35

def dir(path)
  @config.merge!( {
    check_root_path: path,
    find_max_depth: options[:find_max_depth],
    enable_check_contents: false
  } )
  @config[:ignored_paths] << Regexp.new(options[:ignored_pattern]) if options[:ignored_pattern]

  _check
end

#exec(server, command) ⇒ Object

Raises:

  • (ArgumentError)


59
60
61
62
63
64
65
66
67
# File 'lib/ajimi/client.rb', line 59

def exec(server, command)
  raise ArgumentError, "server option must be source or target" unless %w(source target).include? server

  @server = @config[server.to_sym]
  puts "Execute command at #{server}_host: #{@server.host}\n"
  stdout = @server.command_exec(command)
  puts "#{stdout}"
  puts "\n"
end

#file(path) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/ajimi/client.rb', line 48

def file(path)
  @config.merge!( {
    check_root_path: path,
    enable_check_contents: true
  } )
  @config[:ignored_contents].merge!( { path => Regexp.new(options[:ignored_pattern]) } ) if options[:ignored_pattern]

  _check
end