skype-search 1.0.0 → 1.0.1
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/README.md +2 -0
- data/lib/skype_search.rb +1 -0
- data/lib/skype_search/cli.rb +33 -3
- data/lib/skype_search/output_processor.rb +42 -0
- data/lib/skype_search/version.rb +1 -1
- data/spec/skype_search/output_processor_spec.rb +18 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd61ce7e6aafb466d561db5bc345f916811bec0e
|
4
|
+
data.tar.gz: ca7bdff5f40dc8a014bea1e52f4a9037e782374d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94d7b6c941d66426556d2e4903a94f341f55ea11a57aae333e9d41a0c6265bd87e245610540dfc2c9d86bc72eacbef5b0c91dc262277396964ba75cb68a6e74f
|
7
|
+
data.tar.gz: 1ce1206acb496b8b657494035e2f6bb1411a6623161f8a881d797e33bbce51e0c31854e05f86a17ba410758d0657b37a4ab049b34881ec9bc817fb7944f45f4d
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
1
|
# skype-search
|
2
2
|
|
3
3
|
[](https://travis-ci.org/despo/skype-search) [](https://codeclimate.com/github/despo/skype-search)
|
4
|
+
|
5
|
+
Only OS X is currently supported
|
data/lib/skype_search.rb
CHANGED
data/lib/skype_search/cli.rb
CHANGED
@@ -2,8 +2,10 @@ require 'skype_search'
|
|
2
2
|
require 'highline/import'
|
3
3
|
module SkypeSearch
|
4
4
|
class Cli
|
5
|
+
|
5
6
|
def initialize
|
6
7
|
@skype_search = SkypeSearch.configure
|
8
|
+
set_color_scheme
|
7
9
|
end
|
8
10
|
|
9
11
|
def options
|
@@ -28,11 +30,11 @@ module SkypeSearch
|
|
28
30
|
private
|
29
31
|
|
30
32
|
def select_conversation
|
31
|
-
|
33
|
+
print "Conversation", @skype_search.find_messages_between(select_contact).map(&:to_s)
|
32
34
|
end
|
33
35
|
|
34
36
|
def select_group_conversation
|
35
|
-
|
37
|
+
print "Group conversation", @skype_search.find_conversation_by_id(select_group).map(&:to_s)
|
36
38
|
end
|
37
39
|
|
38
40
|
def search_for_text
|
@@ -41,7 +43,7 @@ module SkypeSearch
|
|
41
43
|
question.validate = -> (q) { q.length >= 3 }
|
42
44
|
question.responses[:not_valid] = "You search needs to be at least 3 characters long"
|
43
45
|
end
|
44
|
-
|
46
|
+
print "Search results", @skype_search.search_for(search_string)
|
45
47
|
end
|
46
48
|
|
47
49
|
def exit
|
@@ -66,5 +68,33 @@ module SkypeSearch
|
|
66
68
|
group_conversations.select { |con| con.to_s == selection }.first.id
|
67
69
|
end
|
68
70
|
|
71
|
+
def set_color_scheme
|
72
|
+
colors = HighLine::ColorScheme.new do |cs|
|
73
|
+
cs[:headline] = [ :bold, :yellow, :on_black ]
|
74
|
+
cs[:horizontal_line] = [ :bold, :white, :on_blue]
|
75
|
+
cs[:even_row] = [ :yellow ]
|
76
|
+
cs[:odd_row] = [ :gray ]
|
77
|
+
end
|
78
|
+
HighLine.color_scheme = colors
|
79
|
+
end
|
80
|
+
|
81
|
+
def print title=nil, messages
|
82
|
+
print_title title if title
|
83
|
+
messages.each_with_index do |message, index|
|
84
|
+
OutputProcessor.new(message).parse
|
85
|
+
|
86
|
+
say(%{<%= color('#{message}', '#{get_row_color(index)}') %>})
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def print_title title
|
91
|
+
say("<%= color('#{title}', :headline) %>")
|
92
|
+
say("<%= color('*'*30, :horizontal_line) %>")
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_row_color index
|
96
|
+
index.odd? ? :odd_row : :even_row
|
97
|
+
end
|
98
|
+
|
69
99
|
end
|
70
100
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module SkypeSearch
|
2
|
+
class OutputProcessor
|
3
|
+
|
4
|
+
EMOTICON_MATCHER = /<ss type=\"(?<type>.{,6})\">(?<symbol>.{,6})<\/ss>/
|
5
|
+
EMOTICON_REPLACE = /<ss type=\".{,6}\">.{,6}<\/ss>/
|
6
|
+
|
7
|
+
attr_accessor :output
|
8
|
+
|
9
|
+
def initialize output
|
10
|
+
@output = output
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse
|
14
|
+
replace_all matches unless matches.nil?
|
15
|
+
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def matches
|
22
|
+
scan_for_emoticons.map { |emoticon| EMOTICON_MATCHER.match(emoticon) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def scan_for_emoticons
|
26
|
+
@output.scan(EMOTICON_REPLACE)
|
27
|
+
end
|
28
|
+
|
29
|
+
def replace_all matches
|
30
|
+
matches.each { |match| replace(match, match[:symbol]) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def replace match, symbol
|
34
|
+
@output.gsub!(match.to_s, colorize(symbol))
|
35
|
+
end
|
36
|
+
|
37
|
+
def colorize text, color_code=31
|
38
|
+
"\e[#{color_code}m#{text}\e[0m"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/lib/skype_search/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe SkypeSearch::OutputProcessor do
|
3
|
+
|
4
|
+
it 'can parse emoticons' do
|
5
|
+
message = %{[05/04/2013 09:20:33 PM] John Doe > <ss type="hi">(wave)</ss>}
|
6
|
+
processor = SkypeSearch::OutputProcessor.new(message).parse
|
7
|
+
|
8
|
+
processor.output.should eq %{[05/04/2013 09:20:33 PM] John Doe > \e[31m(wave)\e[0m}
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'can parse multiple emoticons' do
|
12
|
+
message = %{[05/04/2013 09:20:33 PM] John Doe > <ss type="hi">(wave)</ss> <ss type="smile">:)</ss>}
|
13
|
+
processor = SkypeSearch::OutputProcessor.new(message).parse
|
14
|
+
|
15
|
+
processor.output.should eq %{[05/04/2013 09:20:33 PM] John Doe > \e[31m(wave)\e[0m \e[31m:)\e[0m}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skype-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Despo Pentara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -99,10 +99,12 @@ files:
|
|
99
99
|
- lib/skype_search/db/base.rb
|
100
100
|
- lib/skype_search/db/conversations.rb
|
101
101
|
- lib/skype_search/db/messages.rb
|
102
|
+
- lib/skype_search/output_processor.rb
|
102
103
|
- lib/skype_search/settings.rb
|
103
104
|
- lib/skype_search/version.rb
|
104
105
|
- skype-search.gemspec
|
105
106
|
- spec/data/test.db
|
107
|
+
- spec/skype_search/output_processor_spec.rb
|
106
108
|
- spec/skype_search_spec.rb
|
107
109
|
- spec/spec_helper.rb
|
108
110
|
homepage: https://github.com/despo/skype-search
|