tropo_tail 0.2.0 → 0.2.1

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: f36511604b5a8c4eb3449439af6d070af506387c
4
- data.tar.gz: 6af4871d3633ba0895d3aa13c16bc10c1d8fa395
3
+ metadata.gz: b475ed627615e59655fcf14f7d8bb096184c17b8
4
+ data.tar.gz: a823d2efd54b8ad9f93ccebc0075b0d3b1aa6e3f
5
5
  SHA512:
6
- metadata.gz: cb142802098ca0c0b21f92dee64c252ea3ba47068e454206348446b3e55681c077ec3386b706f9a832fa395561deec48be2b64e13fe96dad7af793fe08ae1429
7
- data.tar.gz: 28f5799273257d4558e1543831719ca47b2966fc04207735923dd9601fb8e370ab60b87f5a24ab858faaecdb84eb0609896442f8bb0d68641b4f7529095e58bd
6
+ metadata.gz: b1ee43da1e3050c68187c5e1ff185641455f7677a984eb184dea2964eb9475364d66caf999a8a638999276abf95d52c918c62d3555e44217b5c7ca1c58627f4a
7
+ data.tar.gz: 8d8dc833232cb3726835f42655592f6b6b8075b6cae6ad8205773df12eec39239870fad97a96cb6c10644b539e31fa90bd37da744899c849bc9e9e5f41ed07f7
data/exe/tropo_tail ADDED
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'tropo_tail.rb'
6
+ require 'net/ftp'
7
+ require 'colorize'
8
+
9
+ class App
10
+ include Methadone::Main
11
+ include Methadone::CLILogging
12
+
13
+ main do # Add args you want: |like,so|
14
+ @ftp = Net::FTP.new('ftp.tropo.com')
15
+ run
16
+ @ftp.login(@username, @password)
17
+ @ftp.chdir('logs')
18
+ get_latest
19
+ if @filename.nil?
20
+ puts "No new logs"
21
+ else
22
+ tail
23
+ end
24
+ end
25
+
26
+ # supplemental methods here
27
+ def self.run
28
+ puts "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
29
+ puts "Please type your Tropo Username..."
30
+ @username = gets.chomp
31
+ begin
32
+ puts "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
33
+ puts "Please enter your Tropo Password"
34
+ system 'stty -echo'
35
+ @password = gets.chomp
36
+ system 'stty echo'
37
+ rescue
38
+ system 'stty echo'
39
+ exit
40
+ end
41
+ end
42
+
43
+ def self.get_latest
44
+ @ftp.list.each do |file|
45
+ if file[-4..-1] == ".txt"
46
+ @filename = file[-19..-1]
47
+ end
48
+ end
49
+ end
50
+
51
+ def self.tail
52
+ maxline = 0
53
+ orig_log = @filename
54
+ while 0 < 1
55
+ get_latest
56
+ if orig_log != @filename
57
+ maxline = 0
58
+ orig_log = @filename
59
+ end
60
+ linecount = 0
61
+ @ftp.gettextfile(@filename, nil) do |line|
62
+ info = /(?<=PRISM )(?<=PRISM )(\d{7}\/\d{7}\/)(\w{32}\/|0\/)(\w{32}\/)(1\/)(\S{1,50}\/)(\[\S{1,50}\])/.match(line).to_s.yellow
63
+ linecount += 1
64
+ if linecount > maxline
65
+ maxline = linecount
66
+ if options['truncate']
67
+ puts "#{line[0..19].blue} #{line[(info.length + 38)..-1]}"
68
+ else
69
+ puts "#{line[0..19].blue}#{line[21..50].yellow} #{info}#{line[(info.length + 38)..-1]}"
70
+ end
71
+ end
72
+ end
73
+ sleep 3
74
+ end
75
+ end
76
+
77
+ def self.log_line_break
78
+ Thread.new do
79
+ while 0 < 1
80
+ char = STDIN.getc
81
+ if char == "\r"
82
+ puts ""
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+
89
+ # Declare command-line interface here
90
+
91
+ # description "one line description of your app"
92
+ #
93
+ # Accept flags via:
94
+ # on("--flag VAL","Some flag")
95
+ # options[flag] will contain VAL
96
+ #
97
+ # Specify switches via:
98
+ on("--truncate","Some switch")
99
+ #
100
+ # Or, just call OptionParser methods on opts
101
+ #
102
+ # Require an argument
103
+ # arg :some_arg
104
+ #
105
+ # # Make an argument optional
106
+ # arg :optional_arg, :optional
107
+
108
+ version TropoTail::VERSION
109
+
110
+ use_log_level_option :toggle_debug_on_signal => 'USR1'
111
+
112
+ go!
113
+ end
@@ -1,3 +1,3 @@
1
1
  module TropoTail
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/tropo_tail.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
26
  spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.executables = "tropo_tail"
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.11"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tropo_tail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Gisin
@@ -114,7 +114,8 @@ description: Currently the only way to access Tropo logs is to download a text f
114
114
  when Tropo creates a new log file, for a better development experience.
115
115
  email:
116
116
  - jgisin@gmail.com
117
- executables: []
117
+ executables:
118
+ - tropo_tail
118
119
  extensions: []
119
120
  extra_rdoc_files: []
120
121
  files:
@@ -126,6 +127,7 @@ files:
126
127
  - bin/console
127
128
  - bin/setup
128
129
  - bin/tropo_tail
130
+ - exe/tropo_tail
129
131
  - lib/tropo_tail.rb
130
132
  - lib/tropo_tail/version.rb
131
133
  - tropo_tail.gemspec