bigsister 0.2.2 → 0.2.3
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.
- checksums.yaml +4 -4
- data/GHANGELOG.md +6 -1
- data/bigsister.gemspec +0 -1
- data/lib/bigsister/application.rb +0 -1
- data/lib/bigsister/configuration.rb +4 -1
- data/lib/bigsister/reporter.rb +8 -0
- data/lib/bigsister/reporters/zoho_analytics_reporter.rb +81 -0
- data/lib/bigsister/version.rb +1 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aad2c542438b280a4bf0152242b450d198b8d1f4978d73bb3e3e3628f51a7a9
|
4
|
+
data.tar.gz: d7f0e75f9b58242da0b06958784bf04185ad13a77a76168625c2db49fe673d3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3812e625be0f6802129385ff1f61ce975f40277e45bb950dd5a001bc76d9d7b133a33a1369561cf2b1447d0c6bd28a4062a703febe99fe3ed2bacc271a595cd6
|
7
|
+
data.tar.gz: b0276e7858ee71da575c7208379667dd40759aa679140475c6d3c8f69eae5e468f9b1e3ccb87770c24f977ea9661a2ef4b9ce0056fe993f1691435c22ae44ce3
|
data/GHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to BigSister will be documented in this file.
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [0.2.3] - Nov 13, 2019
|
8
|
+
### Added
|
9
|
+
* Zoho Analytics reporter
|
10
|
+
|
7
11
|
## [0.2.2] - Nov 12, 2019
|
8
12
|
### Changed
|
9
13
|
* Adjust timestamp format
|
@@ -29,9 +33,10 @@ All notable changes to BigSister will be documented in this file.
|
|
29
33
|
* Basic Application object
|
30
34
|
* CLI tool
|
31
35
|
|
32
|
-
[Unreleased]: https://github.com/paulholden2/bigsister/compare/0.2.
|
36
|
+
[Unreleased]: https://github.com/paulholden2/bigsister/compare/0.2.3...HEAD
|
33
37
|
[0.1.1]: https://github.com/paulholden2/bigsister/releases/tag/0.1.1
|
34
38
|
[0.1.2]: https://github.com/paulholden2/bigsister/releases/tag/0.1.2
|
35
39
|
[0.2.0]: https://github.com/paulholden2/bigsister/releases/tag/0.2.0
|
36
40
|
[0.2.1]: https://github.com/paulholden2/bigsister/releases/tag/0.2.1
|
37
41
|
[0.2.2]: https://github.com/paulholden2/bigsister/releases/tag/0.2.2
|
42
|
+
[0.2.3]: https://github.com/paulholden2/bigsister/releases/tag/0.2.3
|
data/bigsister.gemspec
CHANGED
@@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
30
|
spec.add_dependency "springcm-sdk", "~> 0.3.2"
|
31
|
-
spec.add_dependency "os", "~> 1.0"
|
32
31
|
|
33
32
|
spec.add_development_dependency "bundler", "~> 2.0"
|
34
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require "bigsister/monitors/local"
|
2
2
|
require "bigsister/monitors/springcm"
|
3
3
|
require "bigsister/reporters/csv_reporter"
|
4
|
+
require "bigsister/reporters/zoho_analytics_reporter"
|
4
5
|
|
5
6
|
module BigSister
|
6
7
|
class Configuration
|
7
8
|
MONITOR_TYPES = %w(local springcm).freeze
|
8
|
-
REPORTER_TYPES = %w(csv).freeze
|
9
|
+
REPORTER_TYPES = %w(csv zoho-analytics).freeze
|
9
10
|
|
10
11
|
attr_reader :monitors, :reporters
|
11
12
|
|
@@ -65,6 +66,8 @@ module BigSister
|
|
65
66
|
def load_reporter(type, reporter, i)
|
66
67
|
if type == "csv"
|
67
68
|
BigSister::CsvReporter.new(reporter, i)
|
69
|
+
elsif type == "zoho-analytics"
|
70
|
+
BigSister::ZohoAnalyticsReporter.new(reporter, i)
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
data/lib/bigsister/reporter.rb
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "net/http"
|
3
|
+
require "net/http/post/multipart"
|
4
|
+
|
5
|
+
module BigSister
|
6
|
+
class ZohoAnalyticsReporter < BigSister::Reporter
|
7
|
+
# TODO: UPDATE action
|
8
|
+
IMPORT_ACTIONS = %w(TRUNCATEADD APPEND).freeze
|
9
|
+
|
10
|
+
def initialize(schema, i)
|
11
|
+
super(schema, i)
|
12
|
+
@email = schema.fetch("email", nil)
|
13
|
+
@workspace = schema.fetch("workspace", nil)
|
14
|
+
@table = schema.fetch("table", nil)
|
15
|
+
@auth_token = schema.fetch("auth_token", nil)
|
16
|
+
@import_type = schema.fetch("import_type", nil)
|
17
|
+
if @email.nil?
|
18
|
+
raise BigSister::InvalidConfiguration.new("Zoho Analytics email is required.")
|
19
|
+
elsif @workspace.nil?
|
20
|
+
raise BigSister::InvalidConfiguration.new("Zoho Analytics workspace is required.")
|
21
|
+
elsif @table.nil?
|
22
|
+
raise BigSister::InvalidConfiguration.new("Zoho Analytics table is required.")
|
23
|
+
elsif @auth_token.nil?
|
24
|
+
raise BigSister::InvalidConfiguration.new("Zoho Analytics auth token is required.")
|
25
|
+
elsif @import_type.nil?
|
26
|
+
raise BigSister::InvalidConfiguration.new("Zoho Analytics import_type is required.")
|
27
|
+
elsif !IMPORT_ACTIONS.include?(@import_type)
|
28
|
+
raise BigSister::InvalidConfiguration.new("Zoho Analytics import_type must be one of: #{IMPORT_ACTIONS.join(', ')}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def render
|
33
|
+
uri = URI.parse(URI.encode(zoho_uri))
|
34
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
35
|
+
http.use_ssl = true
|
36
|
+
# Body of request
|
37
|
+
data = []
|
38
|
+
zoho_rows.each { |row|
|
39
|
+
h = {}
|
40
|
+
@columns.each_with_index { |col, i|
|
41
|
+
h[col["title"]] = row[i]
|
42
|
+
}
|
43
|
+
data.push(h)
|
44
|
+
}
|
45
|
+
io = UploadIO.new(StringIO.new(data.to_json), "application/json", "import.json")
|
46
|
+
path = uri.path + "?#{URI.encode_www_form(zoho_params)}"
|
47
|
+
req = Net::HTTP::Post::Multipart.new(path, "ZOHO_FILE" => io)
|
48
|
+
res = http.request(req)
|
49
|
+
res.kind_of?(Net::HTTPSuccess)
|
50
|
+
end
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
def zoho_params
|
55
|
+
{
|
56
|
+
"authtoken" => @auth_token,
|
57
|
+
"ZOHO_API_VERSION" => "1.0",
|
58
|
+
"ZOHO_ACTION" => "IMPORT",
|
59
|
+
"ZOHO_IMPORT_FILETYPE" => "JSON",
|
60
|
+
"ZOHO_IMPORT_TYPE" => @import_type,
|
61
|
+
"ZOHO_OUTPUT_FORMAT" => "JSON",
|
62
|
+
"ZOHO_ERROR_FORMAT" => "JSON",
|
63
|
+
"ZOHO_AUTO_IDENTIFY" => "true",
|
64
|
+
"ZOHO_CREATE_TABLE" => "true",
|
65
|
+
"ZOHO_ON_IMPORT_ERROR" => "ABORT"
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def zoho_uri
|
70
|
+
"https://analyticsapi.zoho.com/api/#{@email}/#{@workspace}/#{@table}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def zoho_rows
|
74
|
+
if summary?
|
75
|
+
[rows]
|
76
|
+
else
|
77
|
+
rows
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/bigsister/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigsister
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Holden
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: springcm-sdk
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.3.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: os
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +110,7 @@ files:
|
|
124
110
|
- lib/bigsister/monitors/springcm.rb
|
125
111
|
- lib/bigsister/reporter.rb
|
126
112
|
- lib/bigsister/reporters/csv_reporter.rb
|
113
|
+
- lib/bigsister/reporters/zoho_analytics_reporter.rb
|
127
114
|
- lib/bigsister/version.rb
|
128
115
|
homepage: https://github.com/paulholden2/bigsister
|
129
116
|
licenses:
|