health_tools 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 62189d573e2246476974aa86087c31e719dc4f78f0b2eb871233189c3b08cfdf
4
+ data.tar.gz: 32d9380bd461c37119af9f53eab8bb74364a77657ee109dbf4f095e098039e8b
5
+ SHA512:
6
+ metadata.gz: e7a34d45d91adf99c161531aef34d6442ec61480679b779a54e8550441dfb15fdd97b95c7094dea943e62db0870467b02c167b57d7ab9867b411958d40fa1fd1
7
+ data.tar.gz: '0964cb2d94c70fb746c66c97b1540d213957e7ed84ea170d3e3e92a2b74bf7272fc658219ed2b741a901618de46f6506a9f074744fb6edb015bd7c9b416f91e4'
Binary file
@@ -0,0 +1 @@
1
+ .idea
@@ -0,0 +1,3 @@
1
+ 1. 新增`app_environment_variables.rb`,將`app_environment_variables_example.rb`內容複製到`app_environment_variables.rb`
2
+ 2. 更改`app_environment_variables.rb`變數
3
+ 3. `gem install httparty`
@@ -0,0 +1 @@
1
+ ENV['api_url'] = "http://localhost:3000/api/reply"
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require '../lib/health_tools'
4
+ data = {
5
+ "service_code" => ENV['service_code'],
6
+ "action_name" => "check",
7
+ "start_time" => DateTime.now.strftime("%d/%m/%Y %H:%M"),
8
+ "status_code" => "400",
9
+ "value" => "1",
10
+ "note" => "cool",
11
+ }
12
+ puts HealthTools.check(data)
13
+
@@ -0,0 +1,13 @@
1
+ require 'rake'
2
+ Gem::Specification.new do |s|
3
+ s.name = 'health_tools'
4
+ s.version = '0.0.1'
5
+ s.date = '2021-01-08'
6
+ s.summary = "Check up"
7
+ s.description = "health_tools tools"
8
+ s.authors = ["bao"]
9
+ s.email = 'bao@eunomics.net'
10
+ s.files = `git ls-files`.split("\n")
11
+ s.license = 'MIT'
12
+ s.add_dependency 'httparty'
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'httparty'
2
+ require File.expand_path('../../app_environment_variables', __FILE__)
3
+ class HealthTools
4
+ def self.check(data_content)
5
+ self.reply_health(data_content)
6
+ end
7
+
8
+ def self.reply_health(data)
9
+ data.store("checksum", get_checksum(data))
10
+ HTTParty.post(ENV['api_url'], body: data)
11
+ end
12
+
13
+ def self.get_checksum(data)
14
+ Digest::SHA2.hexdigest(data.to_s)
15
+ end
16
+
17
+ end
@@ -0,0 +1,26 @@
1
+ class HealthTools::Service
2
+ require 'httparty'
3
+
4
+ def reply_health
5
+ data = set_content
6
+ data.store("checksum", get_checksum)
7
+ HTTParty.post(ENV['api_url'], body: data)
8
+ end
9
+
10
+ def set_content
11
+ {
12
+ "service_code" => ENV['service_code'],
13
+ "action_name" => "check",
14
+ "start_time" => DateTime.now.strftime("%d/%m/%Y %H:%M"),
15
+ "status_code" => "200",
16
+ "value" => "1",
17
+ "note" => "cool",
18
+ }
19
+ end
20
+
21
+ def get_checksum
22
+ Digest::SHA2.hexdigest(set_content.to_s)
23
+ end
24
+
25
+ end
26
+
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: health_tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - bao
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
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
+ description: health_tools tools
28
+ email: bao@eunomics.net
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".DS_Store"
34
+ - ".gitignore"
35
+ - README.md
36
+ - app_environment_variables.rb
37
+ - bin/health_tools
38
+ - health_tools.gemspec
39
+ - lib/health_tools.rb
40
+ - lib/health_tools/service.rb
41
+ homepage:
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.0.8
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Check up
64
+ test_files: []