sms-logparser 0.4.3 → 0.5.0
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/lib/sms-logparser/api.rb +7 -6
- data/lib/sms-logparser/cli.rb +1 -1
- data/lib/sms-logparser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9947d072a5d20d349783fd951fdd84a0e7ae399d
|
4
|
+
data.tar.gz: df012488b0a89171d4266a01c05a98e20f7e6e35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa94858261fc273a87d3ebba39120795631c477979d0fef1b770d1092b17c50c95387a662b8b7743c841f34a06e687bf3e0ce0181c630e07a05549145ebd5685
|
7
|
+
data.tar.gz: f97dd70501d1b23919b52e79159b179eb1d91da5bcc192738ee0d0419a581543307c599b627bcdfc6f48f4464e2079add11e7492be4d3e5a77f954388d739822
|
data/lib/sms-logparser/api.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module SmsLogparser
|
2
2
|
class Api
|
3
|
+
require 'uri'
|
3
4
|
|
4
5
|
def initialize(options)
|
5
6
|
@options = options
|
7
|
+
@base_url = URI(@options[:api_base_url] || 'http://localhost:8080/creator/rest')
|
6
8
|
end
|
7
9
|
|
8
10
|
def connection
|
@@ -10,8 +12,7 @@ module SmsLogparser
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def new_connection
|
13
|
-
|
14
|
-
conn = Faraday.new(url: base_url) do |faraday|
|
15
|
+
conn = Faraday.new(url: @base_url) do |faraday|
|
15
16
|
faraday.request :url_encoded
|
16
17
|
faraday.response :logger if @options[:debug]
|
17
18
|
faraday.adapter Faraday.default_adapter
|
@@ -25,12 +26,12 @@ module SmsLogparser
|
|
25
26
|
|
26
27
|
def send(data)
|
27
28
|
uris = []
|
28
|
-
|
29
|
+
base_path = [@base_url.path, data[:customer_id], data[:author_id], data[:project_id]].join('/')
|
29
30
|
unless data[:file] =~ /.*\.m3u8$/
|
30
|
-
uris << [
|
31
|
+
uris << [base_path, data[:traffic_type], data[:bytes]].join('/')
|
31
32
|
end
|
32
33
|
if data[:visitor_type]
|
33
|
-
uris << [
|
34
|
+
uris << [base_path, data[:visitor_type], 1].join('/')
|
34
35
|
end
|
35
36
|
unless @options[:simulate]
|
36
37
|
uris.each do |uri|
|
@@ -40,7 +41,7 @@ module SmsLogparser
|
|
40
41
|
raise RuntimeError, "Can't send request to #{uri}. #{e.message}", caller
|
41
42
|
end
|
42
43
|
unless response.status == 200
|
43
|
-
raise RuntimeError, "Received
|
44
|
+
raise RuntimeError, "Received HTTP status #{response.status} from API.", caller
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
data/lib/sms-logparser/cli.rb
CHANGED
@@ -35,7 +35,7 @@ module SmsLogparser
|
|
35
35
|
map %w(-v --version) => :version
|
36
36
|
|
37
37
|
desc "parse", "Check the database for pcache logs and send them to the SMS-API"
|
38
|
-
option :
|
38
|
+
option :api_base_url,
|
39
39
|
aliases: %w(-a),
|
40
40
|
desc: "Base path of the SMS API (default: http://localhost:8080/)"
|
41
41
|
option :api_key,
|