sms-logparser 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d75a8ac15fa11b1e6efc7aad0a57614bb01f948
4
- data.tar.gz: 5b0efac19f07e16f6ac36c0a8bd2425189e6412f
3
+ metadata.gz: 038037b20ed15c61e41f16b8dbdaf98ccce4df63
4
+ data.tar.gz: d2717600032260e584b99d6467176ba2a4301d55
5
5
  SHA512:
6
- metadata.gz: 2a3acae57b6f2f06a407e2329044e2007948e7ab93371e66aa5274515044ee6bbc18d5bff0867ab11a2f8c6e50b5eb242c7df4e59a1339c00c8038ffba5999d4
7
- data.tar.gz: dcd28686f0d12f173ea318d0c8361190afe878b5b32aa0ca1247a8f537b1a6f08b615a6d8809f8da83823c3849ccbe9492c97cdc72973a4cbb0de3011455f1f2
6
+ metadata.gz: 77f4e55d44aa15408cd9b89ea105128dc184ebfda13cbb041c52d4d2980251de3699414280879636851ef6237918ec200217cca5bee6c83abfb7572fd52c16bf
7
+ data.tar.gz: e7869987d1c8fb3baffef551c2e7a0b14ac86fe391434cd3db89bed7134e4f232cab038091c0fb5a623abdb37aa260640890640a503426a227cbaa519c07c6bb
data/README.md CHANGED
@@ -18,10 +18,22 @@ Or install it yourself as:
18
18
 
19
19
  ## Setup
20
20
 
21
+ Create the database table to track which logs have been parsed:
22
+
21
23
  $ sms-logparser create_parser_table
22
24
 
25
+ Make a testrun:
26
+
27
+ $ sms-logparser parse --simulate
28
+
23
29
  ## Usage
24
30
 
31
+ See available commamds:
32
+
33
+ $ sms-logparser help
34
+
35
+ Parse logs from database and send them to the API
36
+
25
37
  $ sms-logparser parse
26
38
 
27
39
  ## Contributing
@@ -13,9 +13,9 @@ module SmsLogparser
13
13
  class_option :mysql_user, :default => 'root'
14
14
  class_option :mysql_db, :default => 'Syslog'
15
15
 
16
- desc "parse_db", "Check the database for pcache logs and send them to SMS"
16
+ desc "parse", "Check the database for pcache logs and send them to SMS"
17
17
  option :api_base_path, :default => 'http://dev.simplex.tv/creator/rest'
18
- option :debug, :type => :boolean, :default => false
18
+ option :simulate, :type => :boolean, :default => false
19
19
  def parse
20
20
  count = 0
21
21
  last_id = get_last_parse_id
@@ -38,19 +38,25 @@ module SmsLogparser
38
38
  url += "#{data[:project_id]}/"
39
39
  url += "#{data[:traffic_type]}/"
40
40
  url += "#{data[:bytes]}"
41
- if options[:debug]
42
- puts result['ID']
41
+ if options[:simulate]
42
+ puts "Message ID: #{result['ID']}"
43
43
  puts "URL: #{url}"
44
44
  puts "Data: #{data}"
45
45
  puts "-----------------------"
46
46
  else
47
- RestClient.get(url)
47
+ begin
48
+ RestClient.get(url)
49
+ rescue
50
+ say "Error: Can't send log to #{url}", :red
51
+ say "Aborting.", :red
52
+ exit 1
53
+ end
48
54
  end
49
55
  count += 1
50
56
  end
51
57
  last_id = result['ID']
52
58
  end
53
- write_parse_result(last_id, count) unless options[:debug]
59
+ write_parse_result(last_id, count) unless options[:simulate]
54
60
  puts "Number of valid messages found: #{count}"
55
61
  end
56
62
 
@@ -1,3 +1,3 @@
1
1
  module SmsLogparser
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
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.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - niwo