ip21 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/ip21.gemspec +2 -2
  3. data/lib/ip21.rb +47 -23
  4. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dd35382e2131fbd28394514ad75654306db5c1b82ab25020582e66cc68c70aa
4
- data.tar.gz: 50a792351ef0bd99c769cd4375234a0ca308d2c3c0f137faeca3ee1ddc090471
3
+ metadata.gz: f638df374799c3d306c2dc305384e7c796b64a31c75e5a9e8320e73eb27db0d7
4
+ data.tar.gz: 2c73764f135c65782921cee24dcf03cd5a778431b0c8313e7bcfa264376006eb
5
5
  SHA512:
6
- metadata.gz: 4c551cb26ae0f39eea73adda7585a4f886c6db379e815e8de8565e50450f76c2c84b59310c9101ad1505baf3d7d45faef584be583c0a0aba82b9187806964614
7
- data.tar.gz: cdc1dc78116e7ce6b5f4ac2915ae64c9be5e3bbdc7130065ccdff4623d253c5be9462e7683c28f9b28dfb348f43d8b35fa3251048d0555d8822ecb8759c73eb1
6
+ metadata.gz: 6c845f6d07f705b6dfa5e6dad7ab86cfcb6aedfe903af71a7e07b55b05c81b7b5bd7adf14b42827b26dd967267b53f9d1b6a3501390842d6e33f82a0e486df69
7
+ data.tar.gz: 83ea282fef5124401e7b2ab4eccfd8d052de345e559ff2b5012e9fd06e5638a673c8d928b2d4b16fac8bd23f5b771de4924fe55ed570a6a8b1bba2202871ac3c
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.name = 'ip21'
5
5
  s.summary = 'Aspentech IP21 Adapter for Ruby'
6
6
  s.description = 'Aspentech IP21 Adapter for executing queries using SQLPlus' \
7
- 'WebService or REST API'
8
- s.version = '1.0.0'
7
+ ' REST API'
8
+ s.version = '1.0.1'
9
9
  s.date = Time.now.strftime('%Y-%m-%d')
10
10
  s.author = 'Rhuan Barreto'
11
11
  s.email = 'rhuan@rhuan.com.br'
@@ -45,7 +45,7 @@ class IP21
45
45
  @debug = debug
46
46
  end
47
47
 
48
- # Executes a direct query againt the database
48
+ # Executes a direct query against the database
49
49
  #
50
50
  # @param [String] sql The query to be executed
51
51
  # @param [Integer] limit The maximum number of rows that the query will output
@@ -73,30 +73,31 @@ class IP21
73
73
  # - 1: Record as String
74
74
  # @option opts [Integer] retrieval_type The retrieval type of the query.
75
75
  # Possible values are:
76
- # 0 - Actual
77
- # 1 - Interpolated
78
- # 2 - Best Fit
79
- # 3 - Manual
80
- # 10 - Not Good
81
- # 11 - Good
82
- # 12 - Average
83
- # 13 - Maximum
84
- # 14 - Minimum
85
- # 15 - Range
86
- # 16 - Sum
87
- # 17 - Standard Deviation
88
- # 18 - Variance
89
- # 19 - Good Only
90
- # 20 - Suspect Only
91
- # 21 - First
92
- # 22 - Last
93
- # @option opts [Integer] outsiders Whether or not to include outsiders
94
- # 0 - False
95
- # 1 - True
76
+ # - 0 - Actual
77
+ # - 1 - Interpolated
78
+ # - 2 - Best Fit
79
+ # - 3 - Manual
80
+ # - 10 - Not Good
81
+ # - 11 - Good
82
+ # - 12 - Average
83
+ # - 13 - Maximum
84
+ # - 14 - Minimum
85
+ # - 15 - Range
86
+ # - 16 - Sum
87
+ # - 17 - Standard Deviation
88
+ # - 18 - Variance
89
+ # - 19 - Good Only
90
+ # - 20 - Suspect Only
91
+ # - 21 - First
92
+ # - 22 - Last
93
+ # @option opts [Integer] outsiders Whether or not to include the closest
94
+ # values outside the date/time range
95
+ # - 0 - False
96
+ # - 1 - True
96
97
  #
97
98
  # @return [Hash] Response from IP21
98
99
  def history(tag, start_time, end_time, opts = {
99
- limit: 1000, outsiders: 1, history_format: 0, retrieval_type: 0
100
+ limit: 1000, outsiders: 0, history_format: 0, retrieval_type: 0
100
101
  })
101
102
  parse_rest(
102
103
  rest_request(
@@ -112,6 +113,10 @@ class IP21
112
113
 
113
114
  private
114
115
 
116
+ # Execute the request
117
+ #
118
+ # @param [String] type The request type to be passed to rest_address function
119
+ # @param [String] body The request body
115
120
  def rest_request(type, body)
116
121
  require 'net/http'
117
122
  require 'ntlm/http'
@@ -125,12 +130,22 @@ class IP21
125
130
  response
126
131
  end
127
132
 
133
+ # Generates request debug info
134
+ #
135
+ # @param [String] address The request address
136
+ # @param [String] body The request body
137
+ # @param [String] response The request response
128
138
  def debug_info(address, body, response)
129
139
  puts "Request: #{address}"
130
140
  puts "Body: #{body}"
131
141
  puts "Response: #{response.body}"
132
142
  end
133
143
 
144
+ # Parse the API response displaying errors if needed
145
+ #
146
+ # @param [Object] response The request response
147
+ #
148
+ # @return [Hash] Response or error from the API
134
149
  def parse_rest(response)
135
150
  if response.code == '200'
136
151
  require 'json'
@@ -143,6 +158,11 @@ class IP21
143
158
  end
144
159
  end
145
160
 
161
+ # Generate the URL for accessing IP21 based on type
162
+ #
163
+ # @param [String] type The type of the request.
164
+ #
165
+ # @return [String] Address to access request
146
166
  def rest_address(type)
147
167
  "http://#{@sqlplus_address}/ProcessData/AtProcessDataREST.dll/#{type}"
148
168
  end
@@ -164,7 +184,11 @@ class IP21
164
184
  end
165
185
 
166
186
  def history_query_body(tag, start_time, end_time, opts)
167
- '<Q f="D" allQuotes="1"><Tag>' + "<N><![CDATA[#{tag}]]></N>" \
187
+ opts[:limit] ||= 1000
188
+ opts[:outsiders] ||= 0
189
+ opts[:history_format] ||= 0
190
+ opts[:retrieval_type] ||= 0
191
+ '<Q appId="20" f="D" allQuotes="1"><Tag>' + "<N><![CDATA[#{tag}]]></N>" \
168
192
  "<D><![CDATA[#{@ip21_address}]]></D>" + "<HF>#{opts[:history_format]}</HF>" \
169
193
  "<St>#{start_time}</St>" + "<Et>#{end_time}</Et>" \
170
194
  "<RT>#{opts[:retrieval_type]}</RT>" + "<X>#{opts[:limit]}</X>" \
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip21
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhuan Barreto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,8 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.6'
41
- description: Aspentech IP21 Adapter for executing queries using SQLPlusWebService
42
- or REST API
41
+ description: Aspentech IP21 Adapter for executing queries using SQLPlus REST API
43
42
  email: rhuan@rhuan.com.br
44
43
  executables: []
45
44
  extensions: []