web_methods 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Mark Ryall
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,15 @@
1
+ This is a simple gem for interacting with an instance of webMethods Integration Server
2
+
3
+ It does HTTP GET requests passing query string parameters and parses the default IS HTML output into a ruby hash.
4
+
5
+ It authenticates using basic http authentication (if necessary).
6
+
7
+ For example:
8
+
9
+ require 'web_method'
10
+
11
+ wm = WebMethods::Server.new('localhost', 5555, 'Administrator', 'manage')
12
+
13
+ results = wm.invoke('net.customware.wmunit', 'testSuite', 'packageName' => 'WmUnit')
14
+
15
+ puts "Succesfully ran #{result['numberOfSuccessfulTests']} of #{result['numberOfTests']} tests in #{result['testRunExecutionTime']}ms"
@@ -0,0 +1,51 @@
1
+ require 'nokogiri'
2
+
3
+ module WebMethods
4
+ class HtmlParser
5
+ def initialize body
6
+ @doc = Nokogiri::HTML(body)
7
+ end
8
+
9
+ def parse
10
+ table_to_hash @doc.css('body > table')
11
+ end
12
+ private
13
+ def array? table
14
+ table.xpath('tr').first.xpath('td').length == 1
15
+ end
16
+
17
+ def table_to_array table
18
+ out = []
19
+ table.xpath('tr').each do |tr|
20
+ tds = tr.xpath('td')
21
+ if tds.length == 1
22
+ if tds[0].at('table')
23
+ child_table = tds[0].at('table')
24
+ out << table_to_hash(child_table)
25
+ else
26
+ out << tds[0].inner_text
27
+ end
28
+ end
29
+ end
30
+ out
31
+ end
32
+
33
+ def table_to_hash table
34
+ out = {}
35
+ table.xpath('tr').each do |tr|
36
+ tds = tr.xpath('td')
37
+ if tds.length == 2
38
+ if tds[1].at('table')
39
+ 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)
41
+ else
42
+ out[tds[0].inner_text] = tds[1].inner_text
43
+ end
44
+ end
45
+ end
46
+ out
47
+ end
48
+
49
+
50
+ end
51
+ end
@@ -0,0 +1,18 @@
1
+ require 'net/http'
2
+ require 'web_methods/html_parser'
3
+
4
+ module WebMethods
5
+ class Server
6
+ def initialize host, port, username, password
7
+ @host, @port, @username, @password = host, port, username, password
8
+ end
9
+
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
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ require 'web_methods\server'
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: web_methods
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mark Ryall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-09 00:00:00 +11:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: nokogiri
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.4.0
24
+ version:
25
+ description: |
26
+ Some classes for encapsulating interaction with an instance of webMethods Integration Server
27
+
28
+ email: mark@ryall.name
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - lib/web_methods/html_parser.rb
37
+ - lib/web_methods/server.rb
38
+ - lib/web_methods.rb
39
+ - README
40
+ - MIT-LICENSE
41
+ has_rdoc: true
42
+ homepage: http://bitbucket.org/markryall/web_methods/
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.3.5
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: simple webMethods ruby binding
69
+ test_files: []
70
+