Class: Windmill::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/windmill.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Client

Returns a new instance of Client.



11
12
13
14
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
41
42
43
44
45
46
47
# File 'lib/windmill.rb', line 11

def initialize(url)
  @jsonrpc = JsonRPC::Client.new(url)
  # Retrieve all available API methods
  
  result = execute_command(:method => "commands.getControllerMethods")
  if result["status"]
    result["result"].each do |full_method|
      method = full_method
      if loc = method.index('.')
        method = method[(loc + 1) .. method.size]
      end
      if method =~ /command/
        self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{method}(*args)
            if args.empty?
              args = {}
            elsif args.size == 1
              args = args.first
            end
            execute_command(:method => "#{full_method}", :params => args)
          end
        RUBY
      else
        self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{method}(*args)
            if args.empty?
              args = {}
            elsif args.size == 1
              args = args.first
            end
            execute_test(:method => "#{full_method}", :params => args)
          end
        RUBY
      end
    end
  end
end

Instance Method Details

#assertsObject



65
66
67
# File 'lib/windmill.rb', line 65

def asserts
  self
end

#execute_command(action_object = {}) ⇒ Object



49
50
51
52
53
# File 'lib/windmill.rb', line 49

def execute_command(action_object = {})
  action_object[:params] ||= {}
  result = @jsonrpc.request("execute_command", :action_object => action_object)
  result["result"]
end

#execute_test(action_object = {}) ⇒ Object



55
56
57
58
59
# File 'lib/windmill.rb', line 55

def execute_test(action_object = {})
  action_object[:params] ||= {}
  result = @jsonrpc.request("execute_test", :action_object => action_object)
  result["result"]
end

#start_suite(suite_name) ⇒ Object



69
70
71
72
# File 'lib/windmill.rb', line 69

def start_suite(suite_name)
  result = @jsonrpc.request("start_suite", :suite_name => suite_name)
  result["result"]
end

#stop_suiteObject



74
75
76
77
# File 'lib/windmill.rb', line 74

def stop_suite
  result = @jsonrpc.request("stop_suite", {})
  result["result"]
end

#waitsObject



61
62
63
# File 'lib/windmill.rb', line 61

def waits
  self
end