ip21 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +1 -0
- data/LICENSE +7 -0
- data/README.md +49 -0
- data/ip21.gemspec +19 -0
- data/lib/ip21.rb +92 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5f2ff27e5846b94cea2044e6dae841e67fdbcc8f71b60b98b3a83414bd36a5a7
|
4
|
+
data.tar.gz: 5ccba3e19ebe69ef3a1e8a336f1ea24105ac943c7a3bb20c05a9ea3d0cb63de8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1ddc0aa93c48e956364ad5bd1af42b9c341f42e0f8dcd1dc6acb9aea68d22969f48c4e8f3fb2c12a0ab51f3504124cd960018498588a479b471b9196356840aa
|
7
|
+
data.tar.gz: a95c8b4c947ed19786cd5a3897e7f9eaddc08229239ab3a66741a43cf553ec32204fb6eeae1c5dbe73993d774f7bd9365a87c698ec90bf840a94f83971a82008
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private --protected - README.md LICENSE
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2019 Rhuan Barreto
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Aspentech IP21 Ruby Gem
|
2
|
+
|
3
|
+
With this gem you will be able to connect to IP21 and execute queries against the database using SQL statements.
|
4
|
+
|
5
|
+
## Installing
|
6
|
+
|
7
|
+
To install this gem, use the following command:
|
8
|
+
|
9
|
+
```sh
|
10
|
+
$ gem install ip21
|
11
|
+
```
|
12
|
+
|
13
|
+
Or add to your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
# Gemfile
|
17
|
+
gem 'ip21'
|
18
|
+
```
|
19
|
+
|
20
|
+
And use the class in your code to execute queries:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
IP21.new(
|
24
|
+
auth: {
|
25
|
+
account: 'john.doe',
|
26
|
+
domain: 'contoso.com',
|
27
|
+
password: 'set_your_own_password'
|
28
|
+
},
|
29
|
+
sqlplus_address: '127.0.0.1',
|
30
|
+
ip21_address: '127.0.0.1',
|
31
|
+
).query('SELECT IP_PLANT_AREA, Name, IP_DESCRIPTION FROM IP_AnalogDef')
|
32
|
+
```
|
33
|
+
|
34
|
+
## Prerequisites
|
35
|
+
|
36
|
+
- IP21 Database
|
37
|
+
- SQLPlus with REST or SOAP Web Service installed
|
38
|
+
|
39
|
+
## Authentication
|
40
|
+
|
41
|
+
This gem uses Windows authentication to connect to SQLPlus, so don't forget to set your credentials correctly.
|
42
|
+
|
43
|
+
On domain you can use the Netbios name (CONTOSO) or the normal domain name (contoso.com)
|
44
|
+
|
45
|
+
# Changelog
|
46
|
+
See the [commit page](https://github.com/rhuanbarreto/ip21-ruby/commits) for a list of changes.
|
47
|
+
|
48
|
+
# License
|
49
|
+
IP21 Gem by Rhuan Barreto. IP21 Gem is licensed under the MIT license. Please see the LICENSE file for more information.
|
data/ip21.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'ip21'
|
3
|
+
s.summary = 'Aspentech IP21 Adapter for Ruby'
|
4
|
+
s.description = 'Aspentech IP21 Adapter for executing queries using SQLPlus' \
|
5
|
+
'WebService or REST API'
|
6
|
+
s.version = '0.0.1'
|
7
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
8
|
+
s.author = 'Rhuan Barreto'
|
9
|
+
s.email = 'rhuan@rhuan.com.br'
|
10
|
+
s.homepage = 'http://rubygems.org/gems/ip21'
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.add_dependency 'ruby-ntlm'
|
14
|
+
s.add_dependency 'rubyntlm'
|
15
|
+
s.add_dependency 'savon'
|
16
|
+
s.files = Dir.glob('{docs,bin,lib,spec,templates,benchmarks}/**/*') +
|
17
|
+
['LICENSE', 'README.md', '.yardopts', __FILE__]
|
18
|
+
s.require_path = 'lib'
|
19
|
+
end
|
data/lib/ip21.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Aspentech IP21 Adapter for executing queries using SQLPlus
|
2
|
+
#
|
3
|
+
# This library uses Windows Authentication for connecting to SQLPlus
|
4
|
+
#
|
5
|
+
# @author Rhuan Barreto
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# IP21.new(
|
9
|
+
# auth: {
|
10
|
+
# account: 'john.doe',
|
11
|
+
# domain: 'contoso.com',
|
12
|
+
# password: 'set_your_own_password'
|
13
|
+
# },
|
14
|
+
# sqlplus_address: '127.0.0.1',
|
15
|
+
# ip21_address: '127.0.0.1',
|
16
|
+
# ).query('SELECT IP_PLANT_AREA, Name, IP_DESCRIPTION FROM IP_AnalogDef')
|
17
|
+
class IP21
|
18
|
+
# Initializes the connection
|
19
|
+
#
|
20
|
+
# @param [Hash] auth The Windows account, domain and password for connecting
|
21
|
+
# to SQLPLus
|
22
|
+
# @param [String] sqlplus_address The hostname or IP address for connecting
|
23
|
+
# to SQLPlus
|
24
|
+
# @param [String] ip21_address The hostname or IP address for connecting to
|
25
|
+
# the IP21 Database
|
26
|
+
# @param [Boolean] soap Set this parameter to true for connecting to SQLPlus
|
27
|
+
# using the SOAP Web Service
|
28
|
+
def initialize(
|
29
|
+
auth: {
|
30
|
+
account: 'john.doe',
|
31
|
+
domain: 'contoso.com',
|
32
|
+
password: 'set_your_own_password'
|
33
|
+
},
|
34
|
+
sqlplus_address: '127.0.0.1',
|
35
|
+
ip21_address: '127.0.0.1',
|
36
|
+
soap: false
|
37
|
+
)
|
38
|
+
@account = auth[:account]
|
39
|
+
@domain = auth[:domain]
|
40
|
+
@password = auth[:password]
|
41
|
+
@sqlplus_address = sqlplus_address
|
42
|
+
@ip21_address = ip21_address
|
43
|
+
@soap = soap
|
44
|
+
end
|
45
|
+
|
46
|
+
# Executes a direct query againt the database
|
47
|
+
#
|
48
|
+
# @param [String] sql The query to be executed
|
49
|
+
# @param [Integer] limit The maximum number of rows that the query will output
|
50
|
+
#
|
51
|
+
# @return [Hash] Response from the query
|
52
|
+
def query(sql, limit = 100)
|
53
|
+
@soap ? soap(sql) : rest(sql, limit)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def soap(sql)
|
59
|
+
require 'savon'
|
60
|
+
client = Savon.client(
|
61
|
+
wsdl: soap_address,
|
62
|
+
ntlm: [@account, @password, @domain],
|
63
|
+
env_namespace: :soap,
|
64
|
+
namespace_identifier: nil
|
65
|
+
)
|
66
|
+
client.call(:execute_sql, message: { command: sql }).body
|
67
|
+
end
|
68
|
+
|
69
|
+
def rest(sql, limit)
|
70
|
+
require 'net/http'
|
71
|
+
require 'ntlm/http'
|
72
|
+
uri = URI(rest_address(sql, limit))
|
73
|
+
http = Net::HTTP.new(uri.host)
|
74
|
+
request = Net::HTTP::Get.new(uri)
|
75
|
+
request.ntlm_auth(@account, @domain, @password)
|
76
|
+
response = http.request(request)
|
77
|
+
response.body
|
78
|
+
end
|
79
|
+
|
80
|
+
def soap_address
|
81
|
+
"http://#{@sqlplus_address}/SQLplusWebService/SQLplusWebService.asmx?WSDL"
|
82
|
+
end
|
83
|
+
|
84
|
+
def rest_address(sql, limit)
|
85
|
+
query = '/ProcessData/AtProcessDataREST.dll/SQL?<SQL c="' \
|
86
|
+
"DRIVER={AspenTech SQLplus};HOST=#{@ip21_address};" \
|
87
|
+
'PORT=10014;CHARISNULL=Y;CHARINT=N;CHARFLOAT=N;CHARTIME=N;' \
|
88
|
+
'CONVERTERRORS=N;ROWID=Y;TIMEOUT=10"' \
|
89
|
+
" m=\"#{limit}\"><![CDATA[#{sql}]]></SQL>"
|
90
|
+
"http://#{@sqlplus_address}#{query}"
|
91
|
+
end
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ip21
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rhuan Barreto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby-ntlm
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubyntlm
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: savon
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Aspentech IP21 Adapter for executing queries using SQLPlusWebService
|
56
|
+
or REST API
|
57
|
+
email: rhuan@rhuan.com.br
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".yardopts"
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- ip21.gemspec
|
66
|
+
- lib/ip21.rb
|
67
|
+
homepage: http://rubygems.org/gems/ip21
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.0.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Aspentech IP21 Adapter for Ruby
|
90
|
+
test_files: []
|