sms-logparser 0.4.3 → 0.5.0

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: 68b3faab7670b5bc5754b7418ad0c3906dd9caf8
4
- data.tar.gz: 062592b33ab6e405d9bac193c33234b207c547c8
3
+ metadata.gz: 9947d072a5d20d349783fd951fdd84a0e7ae399d
4
+ data.tar.gz: df012488b0a89171d4266a01c05a98e20f7e6e35
5
5
  SHA512:
6
- metadata.gz: 289c94bd76b9988527c2b417c62d09dd2a417ddefe8276094625ebbb44a6293c0a7eb3040a7d0517fc9af49d16cf2e133cd1ff3c09514920043f7661f3b805ac
7
- data.tar.gz: ed1e0cfe7f29147f7f0a3caf2e96c65723b9ca3e45447acd5f04c9642f5329026afb0b2520f1f47dd3ce8c02756184af60e460249a7adbb8625184adb0941c6b
6
+ metadata.gz: fa94858261fc273a87d3ebba39120795631c477979d0fef1b770d1092b17c50c95387a662b8b7743c841f34a06e687bf3e0ce0181c630e07a05549145ebd5685
7
+ data.tar.gz: f97dd70501d1b23919b52e79159b179eb1d91da5bcc192738ee0d0419a581543307c599b627bcdfc6f48f4464e2079add11e7492be4d3e5a77f954388d739822
@@ -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
- base_url = @options[:api_base_path] || 'http://localhost:8080'
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
- base_uri = ["/#{data[:customer_id]}", data[:author_id], data[:project_id]].join('/')
29
+ base_path = [@base_url.path, data[:customer_id], data[:author_id], data[:project_id]].join('/')
29
30
  unless data[:file] =~ /.*\.m3u8$/
30
- uris << [base_uri, data[:traffic_type], data[:bytes]].join('/')
31
+ uris << [base_path, data[:traffic_type], data[:bytes]].join('/')
31
32
  end
32
33
  if data[:visitor_type]
33
- uris << [base_uri, data[:visitor_type], 1].join('/')
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 response code (#{response.status}) from API.", caller
44
+ raise RuntimeError, "Received HTTP status #{response.status} from API.", caller
44
45
  end
45
46
  end
46
47
  end
@@ -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 :api_base_path,
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,
@@ -1,3 +1,3 @@
1
1
  module SmsLogparser
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms-logparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - niwo