imperituroard 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea2e261cb7b266d484bee777701f4ba81f6e89f2
4
- data.tar.gz: 878e56910db4b711f8fc924e152d18dbc43bfc02
3
+ metadata.gz: 6fb131c986ddab24b594df2acd6575d10fafd515
4
+ data.tar.gz: dabb303f1d40dbc7741fa6d1e68337165d3fd551
5
5
  SHA512:
6
- metadata.gz: a5fc1bd349752041cccf2f85531acb66871452692c4f1889db34d11d8b23168653e56fa0de80eb23cdfba9d87010931e28bea8ae8927fe51835f6e9a64f17168
7
- data.tar.gz: 7f2aa2e84ae69c5ed224350dda3a1523d7fa88fc2099184d67ad20a17b1db8a8b2f2e9e6bc22e394d5f764e0a6a6bf624c82f542d197137742f9003dbdce4197
6
+ metadata.gz: 6b9879f24087c8662cb1e6e81cde96b5945c4faeb9709da1da88206ec04269b010574dbe67da9755c7e52932cc91c1879ab3c1abe928cd8a65d6e43ff8a18f81
7
+ data.tar.gz: 3ce55acd489a807ee9e1ff987d33ed0e4a03c8146bf6b01360f320d81a076cd15277f22a1c6e83ba139e6ede8cd0663372197381bd118502130bb5fc162b8b7e
data/.gitignore ADDED
@@ -0,0 +1,71 @@
1
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
2
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3
+
4
+ # User-specific stuff
5
+ .idea/**/workspace.xml
6
+ .idea/**/tasks.xml
7
+ .idea/**/usage.statistics.xml
8
+ .idea/**/dictionaries
9
+ .idea/**/shelf
10
+
11
+ # Generated files
12
+ .idea/**/contentModel.xml
13
+
14
+ # Sensitive or high-churn files
15
+ .idea/**/dataSources/
16
+ .idea/**/dataSources.ids
17
+ .idea/**/dataSources.local.xml
18
+ .idea/**/sqlDataSources.xml
19
+ .idea/**/dynamic.xml
20
+ .idea/**/uiDesigner.xml
21
+ .idea/**/dbnavigator.xml
22
+
23
+ # Gradle
24
+ .idea/**/gradle.xml
25
+ .idea/**/libraries
26
+
27
+ # Gradle and Maven with auto-import
28
+ # When using Gradle or Maven with auto-import, you should exclude module files,
29
+ # since they will be recreated, and may cause churn. Uncomment if using
30
+ # auto-import.
31
+ # .idea/artifacts
32
+ # .idea/compiler.xml
33
+ # .idea/jarRepositories.xml
34
+ # .idea/modules.xml
35
+ # .idea/*.iml
36
+ # .idea/modules
37
+ # *.iml
38
+ # *.ipr
39
+
40
+ # CMake
41
+ cmake-build-*/
42
+
43
+ # Mongo Explorer plugin
44
+ .idea/**/mongoSettings.xml
45
+
46
+ # File-based project format
47
+ *.iws
48
+
49
+ # IntelliJ
50
+ out/
51
+
52
+ # mpeltonen/sbt-idea plugin
53
+ .idea_modules/
54
+
55
+ # JIRA plugin
56
+ atlassian-ide-plugin.xml
57
+
58
+ # Cursive Clojure plugin
59
+ .idea/replstate.xml
60
+
61
+ # Crashlytics plugin (for Android Studio and IntelliJ)
62
+ com_crashlytics_export_strings.xml
63
+ crashlytics.properties
64
+ crashlytics-build.properties
65
+ fabric.properties
66
+
67
+ # Editor-based Rest Client
68
+ .idea/httpRequests
69
+
70
+ # Android studio 3.1+ serialized cache file
71
+ .idea/caches/build_file_checksums.ser
data/Gemfile CHANGED
@@ -8,4 +8,5 @@ gem "minitest", "~> 5.0"
8
8
  gem 'mysql2', '>= 0.3.13', '< 0.5'
9
9
  gem 'savon'
10
10
  gem 'json'
11
- gem 'uri'
11
+ #gem 'uri'
12
+ gem 'mongo'
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://rubygems.org/"
18
+ spec.metadata["source_code_uri"] = "https://github.com/imperituroard/imperituroard"
19
19
  spec.metadata["changelog_uri"] = "https://rubygems.org/"
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
@@ -27,12 +27,12 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.16"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "net-ssh", '~> 4.0.0'
33
- spec.add_development_dependency "mysql2"
34
- spec.add_development_dependency "savon"
35
- spec.add_development_dependency "json"
36
- spec.add_development_dependency "uri"
37
-
30
+ spec.add_development_dependency "bundler", "2.1.4"
31
+ spec.add_development_dependency "rake", "12.3.3"
32
+ spec.add_development_dependency "net-ssh", '4.0.1'
33
+ spec.add_development_dependency "mysql2", "0.4.10"
34
+ spec.add_development_dependency "savon", "2.12.0"
35
+ spec.add_development_dependency "json", "2.3.0"
36
+ #spec.add_development_dependency "uri"
37
+ spec.add_development_dependency "mongo", "2.11.4"
38
38
  end
data/lib/imperituroard.rb CHANGED
@@ -1,6 +1,11 @@
1
+ $LOAD_PATH.unshift File.expand_path("../projects/iot", __dir__)
2
+ $LOAD_PATH.unshift File.expand_path("../projects/wttx", __dir__)
3
+
1
4
  require "imperituroard/version"
2
5
  require "imperituroard/phpipamdb"
3
6
  require "imperituroard/phpipamcps"
7
+ require "imperituroard/projects/iot/mongoconnector"
8
+ require "imperituroard/projects/iot/hua_oceanconnect_adapter"
4
9
 
5
10
  module Imperituroard
6
11
  class Error < StandardError; end
@@ -63,4 +68,29 @@ class Pipam
63
68
  include Phpipam
64
69
  end
65
70
 
71
+ class Iot
72
+ attr_accessor :mongoip, :mongoport, :iotip, :iottoken, :database, :iotplatform_ip, :iotplatform_port
73
+
74
+ def initialize(mongoip, mongoport, iotip, database, iotplatform_ip, iotplatform_port)
75
+ @mongoip = mongoip
76
+ @mongoport = mongoport
77
+ @iotip = iotip
78
+ @database = database
79
+ @iotplatform_ip = iotplatform_ip
80
+ @iotplatform_port = iotplatform_port
81
+ end
82
+
83
+ def test()
84
+ ddd = MongoIot.new(mongoip, mongoport, iotip, database)
85
+ ddd.ttt
86
+ end
87
+
88
+ def testhua()
89
+ ddd1 = HuaIot.new(iotplatform_ip, iotplatform_port, "", "")
90
+ ddd1.test
66
91
 
92
+ end
93
+
94
+
95
+
96
+ end
@@ -143,7 +143,8 @@ class Pcps
143
143
  else
144
144
  "error"
145
145
  end
146
-
147
146
  end
148
147
 
148
+
149
+
149
150
  end
@@ -0,0 +1,56 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require 'json'
5
+
6
+
7
+ class HuaIot
8
+
9
+ attr_accessor :platformip, :platformport, :client, :database
10
+
11
+ def initialize(platformip, platformport, iotip, database)
12
+ @database = database
13
+ @platformip = platformip
14
+ @platformport = platformport
15
+ @iotip = iotip
16
+ #client_host = [mongoip + ":" + mongoport]
17
+ #@client = Mongo::Client.new(client_host, :database => database)
18
+ end
19
+
20
+ def test()
21
+
22
+ url_string = "https://134.17.93.4:8743/iocm/app/authorize/v1.3.0/app"
23
+ headers = {
24
+ 'Authorization'=>'Bearer O2k2aMStOweZOeSoVDYjI3c6uaMa',
25
+ 'Content-Type' =>'application/json',
26
+ 'Accept'=>'application/json'
27
+ }
28
+
29
+ req = {"dstAppId": "Cd1v0k2gTBCbpQlMVlW1FVqOSqga" }
30
+
31
+ uri = URI.parse url_string
32
+
33
+ p uri.host
34
+ p uri.port
35
+ p uri.path
36
+
37
+ p https = Net::HTTP.new(uri.host, uri.port)
38
+ https.use_ssl = true
39
+
40
+ request = Net::HTTP::Post.new( uri.path, headers)
41
+
42
+ p request.body = req
43
+ request['app_key'] = ''
44
+ request['Authorization'] = 'Bearer O2k2aMStOweZOeSoVDYjI3c6uaMa'
45
+ request.content_type = 'application/json'
46
+ res = https.request(request)
47
+ p res.message
48
+
49
+ end
50
+
51
+ # App ID
52
+ # password O2k2aMStOweZOeSoVDYjI3c6uaMa
53
+
54
+
55
+
56
+ end
@@ -0,0 +1,46 @@
1
+ require 'mongo'
2
+
3
+ #class for communication with mongo database for iot API
4
+ class MongoIot
5
+
6
+ attr_accessor :mongoip, :mongoport, :client, :database
7
+
8
+ def initialize(mongoip, mongoport, iotip, database)
9
+ @database = database
10
+ @mongoip = mongoip
11
+ @mongoport = mongoport
12
+ @iotip = iotip
13
+ client_host = [mongoip + ":" + mongoport]
14
+ @client = Mongo::Client.new(client_host, :database => database)
15
+
16
+ end
17
+
18
+ def ttt
19
+ p "111111"
20
+ begin
21
+ puts(client.cluster.inspect)
22
+ puts
23
+ puts('Collection Names: ')
24
+ puts(client.database.collection_names)
25
+ puts('Connected!')
26
+ collection = client[:audit]
27
+ doc = {
28
+ name: 'Steve',
29
+ hobbies: [ 'hiking', 'tennis', 'fly fishing' ],
30
+ siblings: {
31
+ brothers: 0,
32
+ sisters: 1
33
+ }
34
+ }
35
+ result = collection.insert_one(doc)
36
+ p result
37
+ client.close
38
+ rescue StandardError => err
39
+ puts('Error: ')
40
+ puts(err)
41
+ end
42
+
43
+
44
+
45
+ end
46
+ end
@@ -0,0 +1,73 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'rexml/document'
4
+
5
+
6
+ class StateWTTX
7
+
8
+ def update_statuswttx(imsi, imei)
9
+
10
+ doc = REXML::Document.new
11
+ #doc.context[:attribute_quote] = :quote # <-- Set double-quote as the attribute value delimiter
12
+ root = doc.add_element('row')
13
+
14
+ attr1 = root.add_element('key')
15
+ attr1.add_attribute('code', 'imsi')
16
+ attr1.add_attribute('value', imsi)
17
+
18
+ attr2 = root.add_element('field')
19
+ attr2.add_attribute('code', 'imei')
20
+ attr2.add_attribute('value', imei)
21
+
22
+ attr3 = root.add_element('field')
23
+ attr3.add_attribute('code', 'status')
24
+ attr3.add_attribute('value', 'TRUE')
25
+
26
+ xmlout = ""
27
+ doc.write xmlout
28
+ p xmlout
29
+
30
+ url_string = "http://172.24.220.77:8080/custrefdata/wttx/_update"
31
+ xml_string = xmlout
32
+ uri = URI.parse url_string
33
+ request = Net::HTTP::Post.new uri.path
34
+ p request.body = xml_string
35
+ request.content_type = 'application/xml'
36
+ p response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
37
+ p response.body
38
+ end
39
+
40
+
41
+ def getrest_cps(imsi)
42
+
43
+ url = "http://172.24.220.77:8080/custrefdata/wttx/_query?imsi=#{imsi}"
44
+ uri = URI.parse(url)
45
+ http = Net::HTTP.new(uri.host, uri.port)
46
+ response = http.request(Net::HTTP::Get.new(uri.request_uri))
47
+ p content = response.body
48
+ p resultcode = response.to_s.include?("OK")
49
+ #Rails.logger = Logger.new(STDOUT)
50
+ #logger.info "WTTX service getrestCPS result code: #{response.to_s}"
51
+ #logger.info "WTTX service getrestCPS soap body: #{content.to_s}"
52
+
53
+
54
+
55
+ if resultcode = false
56
+ "false"
57
+ else
58
+ regimsi = /<field code=\"imsi\" value=\"([0-9]{10,15})\"/
59
+ regimei = /<field code=\"imei\" value=\"([0-9]{10,17})\"/
60
+
61
+ m1 = regimsi.match(content)
62
+ m2 = regimei.match(content)
63
+ imsi = m1[1]
64
+ imei = m2[1]
65
+
66
+ res = resultcode.to_s + " " + imsi + " " + imei
67
+ p res
68
+ return res
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,113 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-12 00:00:00.000000000 Z
11
+ date: 2020-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 2.1.4
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: 2.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: net-ssh
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 4.0.0
47
+ version: 4.0.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 4.0.0
54
+ version: 4.0.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mysql2
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.4.10
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.4.10
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: savon
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 2.12.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 2.12.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: json
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 2.3.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 2.3.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: uri
98
+ name: mongo
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 2.11.4
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 2.11.4
111
111
  description: Gem from imperituroard for different actions
112
112
  email:
113
113
  - imperituro.ard@gmail.com
@@ -115,15 +115,7 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - ".DS_Store"
119
- - ".idea/.rakeTasks"
120
- - ".idea/imperituroard.iml"
121
- - ".idea/inspectionProfiles/Project_Default.xml"
122
- - ".idea/misc.xml"
123
- - ".idea/modules.xml"
124
- - ".idea/runConfigurations/test_helper.xml"
125
- - ".idea/vcs.xml"
126
- - ".idea/workspace.xml"
118
+ - ".gitignore"
127
119
  - ".ruby-gemset"
128
120
  - ".ruby-version"
129
121
  - ".travis.yml"
@@ -139,6 +131,9 @@ files:
139
131
  - lib/imperituroard.rb
140
132
  - lib/imperituroard/phpipamcps.rb
141
133
  - lib/imperituroard/phpipamdb.rb
134
+ - lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb
135
+ - lib/imperituroard/projects/iot/mongoconnector.rb
136
+ - lib/imperituroard/projects/wttx/updatepostcps.rb
142
137
  - lib/imperituroard/version.rb
143
138
  homepage: https://rubygems.org/
144
139
  licenses:
@@ -146,7 +141,7 @@ licenses:
146
141
  metadata:
147
142
  allowed_push_host: https://rubygems.org/
148
143
  homepage_uri: https://rubygems.org/
149
- source_code_uri: https://rubygems.org/
144
+ source_code_uri: https://github.com/imperituroard/imperituroard
150
145
  changelog_uri: https://rubygems.org/
151
146
  post_install_message:
152
147
  rdoc_options: []