web_methods 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,9 +9,14 @@ module WebMethods
9
9
  def parse
10
10
  table_to_hash @doc.css('body > table')
11
11
  end
12
- private
12
+ private
13
+ def convert_table table
14
+ return nil if table.children.length == 0
15
+ array?(table) ? table_to_array(table) : table_to_hash(table)
16
+ end
17
+
13
18
  def array? table
14
- table.xpath('tr').first.xpath('td').length == 1
19
+ table.at('tr').xpath('td').length == 1
15
20
  end
16
21
 
17
22
  def table_to_array table
@@ -37,7 +42,7 @@ private
37
42
  if tds.length == 2
38
43
  if tds[1].at('table')
39
44
  child_table = tds[1].at('table')
40
- out[tds[0].inner_text] = array?(child_table) ? table_to_array(child_table) : table_to_hash(child_table)
45
+ out[tds[0].inner_text] = convert_table(child_table)
41
46
  else
42
47
  out[tds[0].inner_text] = tds[1].inner_text
43
48
  end
@@ -45,7 +50,5 @@ private
45
50
  end
46
51
  out
47
52
  end
48
-
49
-
50
53
  end
51
54
  end
@@ -1,18 +1,31 @@
1
1
  require 'net/http'
2
2
  require 'web_methods/html_parser'
3
+ require 'log4r'
3
4
 
4
5
  module WebMethods
5
- class Server
6
- def initialize host, port, username, password
7
- @host, @port, @username, @password = host, port, username, password
8
- end
6
+ class Server
7
+ attr_reader :logger
8
+
9
+ def initialize host, port, username, password
10
+ @host, @port, @username, @password = host, port, username, password
11
+ @logger = Log4r::Logger.new("WebMethods::Server")
12
+ end
9
13
 
10
- def invoke package, service, params
11
- res = Net::HTTP.start(@host, @port) do |http|
12
- req = Net::HTTP::Get.new("/invoke/#{package}/#{service}?#{params.map{|k,v|"#{k}=#{v}"}.join('&')}")
13
- req.basic_auth @username, @password
14
- HtmlParser.new(http.request(req).body).parse
14
+ def invoke package, service, params
15
+ @logger.debug "Connecting to #{@host}:#{@port}"
16
+ res = Net::HTTP.start(@host, @port) do |http|
17
+ url = "/invoke/#{package}/#{service}?#{params.map{|k,v|"#{k}=#{v}"}.join('&')}"
18
+ @logger.debug "Sending request to #{url}"
19
+ req = Net::HTTP::Get.new(url)
20
+ req.basic_auth @username, @password
21
+ response = http.request(req)
22
+ @logger.debug "Received response: #{response}"
23
+ body = response.body
24
+ @logger.debug "Body was:\n#{body}"
25
+ hash = HtmlParser.new(body).parse
26
+ @logger.debug "Parsed to #{hash.inspect}"
27
+ hash
28
+ end
15
29
  end
16
30
  end
17
31
  end
18
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_methods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Ryall
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-09 00:00:00 +11:00
12
+ date: 2010-01-25 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.4.0
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: log4r
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.2
34
+ version:
25
35
  description: |
26
36
  Some classes for encapsulating interaction with an instance of webMethods Integration Server
27
37