bigsister 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: 98a857b250c43c8bbf16fa525a46075ec348a7f687a37895315bf59b4e19d950
4
- data.tar.gz: 63bc297aebdcdb2ed073b9154fb98a8896d43ffa5f821bc05c57a8493801877e
3
+ metadata.gz: 8aad2c542438b280a4bf0152242b450d198b8d1f4978d73bb3e3e3628f51a7a9
4
+ data.tar.gz: d7f0e75f9b58242da0b06958784bf04185ad13a77a76168625c2db49fe673d3e
5
5
  SHA512:
6
- metadata.gz: 01dadefe89a60aee101c23240f8090295d4c5363f8066e6402307d6f987f1fcd26ebcc46cca9d5721951edfcac1184b87b9ba30b2cd496e00523ea99abcba1cf
7
- data.tar.gz: 406e2ec6fc8c641b2869cdd03d069d57e46aa7f80b1e50eb6fb6bd773c06f25347649b1428f412e7a8547686502221466e1a3deee37ac54115a964f43d2160d6
6
+ metadata.gz: 3812e625be0f6802129385ff1f61ce975f40277e45bb950dd5a001bc76d9d7b133a33a1369561cf2b1447d0c6bd28a4062a703febe99fe3ed2bacc271a595cd6
7
+ data.tar.gz: b0276e7858ee71da575c7208379667dd40759aa679140475c6d3c8f69eae5e468f9b1e3ccb87770c24f977ea9661a2ef4b9ce0056fe993f1691435c22ae44ce3
@@ -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.0...HEAD
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
@@ -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,4 +1,3 @@
1
- require "os"
2
1
  require "yaml"
3
2
  require "bigsister/configuration"
4
3
 
@@ -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
 
@@ -111,6 +111,14 @@ module BigSister
111
111
  DateTime.now.strftime("%FT%T%z")
112
112
  end
113
113
 
114
+ def rows
115
+ if summary?
116
+ summary
117
+ else
118
+ detail
119
+ end
120
+ end
121
+
114
122
  def detail
115
123
  rows = []
116
124
  rows += file_rows if log_files?
@@ -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
@@ -1,3 +1,3 @@
1
1
  module BigSister
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
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.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-12 00:00:00.000000000 Z
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: