skype-search 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00c4ce0c7bb5fdcf7cbd221f4744f038760f235d
4
+ data.tar.gz: 8c285e71dd4c599bfb12f0040f6b3909834c144e
5
+ SHA512:
6
+ metadata.gz: 4e7453c2ce23679036cb443e3e0988ba9abe382e7ce905ebff75227e9bb07196c9844e90feb854029b1254ff101d93eeacddca983132119db4106130f3fe8af6
7
+ data.tar.gz: 8dc5dc8c3fcbc0e22cafb66072f8114da04b3224e00b35da9b811d67f56219bdbcb572fcaa83efc184bcb8653356b840a1ecb74a6fe48911015100b9f3b7a0dc
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - rbx-19mode
7
+
8
+ notifications:
9
+ email:
10
+ - despo@extractmethod.com
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord'
4
+ gem 'sqlite3'
5
+ gem 'highline'
6
+ gem 'rake'
7
+
8
+ group :test do
9
+ gem 'rspec'
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activemodel (3.2.13)
5
+ activesupport (= 3.2.13)
6
+ builder (~> 3.0.0)
7
+ activerecord (3.2.13)
8
+ activemodel (= 3.2.13)
9
+ activesupport (= 3.2.13)
10
+ arel (~> 3.0.2)
11
+ tzinfo (~> 0.3.29)
12
+ activesupport (3.2.13)
13
+ i18n (= 0.6.1)
14
+ multi_json (~> 1.0)
15
+ arel (3.0.2)
16
+ builder (3.0.4)
17
+ diff-lcs (1.2.4)
18
+ highline (1.6.13)
19
+ i18n (0.6.1)
20
+ multi_json (1.7.3)
21
+ rake (10.0.4)
22
+ rspec (2.13.0)
23
+ rspec-core (~> 2.13.0)
24
+ rspec-expectations (~> 2.13.0)
25
+ rspec-mocks (~> 2.13.0)
26
+ rspec-core (2.13.1)
27
+ rspec-expectations (2.13.0)
28
+ diff-lcs (>= 1.1.3, < 2.0)
29
+ rspec-mocks (2.13.1)
30
+ sqlite3 (1.3.7)
31
+ tzinfo (0.3.37)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ activerecord
38
+ highline
39
+ rake
40
+ rspec
41
+ sqlite3
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # skype-search
2
+
3
+ [![Build Status](https://travis-ci.org/despo/skype-search.png?branch=master)](https://travis-ci.org/despo/skype-search) [![Code Climate](https://codeclimate.com/github/despo/skype-search.png)](https://codeclimate.com/github/despo/skype-search)
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.rspec_path = 'rspec'
6
+ t.rspec_opts = ["-cfd"]
7
+ end
8
+
9
+ task :default => :spec
10
+
11
+ Bundler::GemHelper.install_tasks
data/bin/skype-search ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+
5
+ require 'skype_search/cli'
6
+
7
+ cli = SkypeSearch::Cli.new
8
+
9
+ loop do
10
+ option = cli.prompt
11
+ cli.process option
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'skype_search/settings'
2
+ require 'skype_search/db'
3
+ require 'skype_search/db/base'
4
+ require 'skype_search/db/messages'
5
+ require 'skype_search/db/conversations'
6
+
7
+ module SkypeSearch
8
+
9
+ def self.configure
10
+ SkypeSearch::DB.new(Settings.new.user_db)
11
+ end
12
+ end
@@ -0,0 +1,70 @@
1
+ require 'skype_search'
2
+ require 'highline/import'
3
+ module SkypeSearch
4
+ class Cli
5
+ def initialize
6
+ @skype_search = SkypeSearch.configure
7
+ end
8
+
9
+ def options
10
+ [ "Select conversation",
11
+ "Select group conversation",
12
+ "Search for text",
13
+ "Exit" ]
14
+ end
15
+
16
+ def prompt
17
+ choose do |menu|
18
+ menu.header = "What do you want to do"
19
+
20
+ menu.choices *options
21
+ end
22
+ end
23
+
24
+ def process selection
25
+ send selection.downcase.split(" ").join("_")
26
+ end
27
+
28
+ private
29
+
30
+ def select_conversation
31
+ puts @skype_search.find_messages_between(select_contact).map(&:to_s)
32
+ end
33
+
34
+ def select_group_conversation
35
+ puts @skype_search.find_conversation_by_id(select_group).map(&:to_s)
36
+ end
37
+
38
+ def search_for_text
39
+ search_string = ask("What are you looking for?") do |question|
40
+ question.case = :up
41
+ question.validate = -> (q) { q.length >= 3 }
42
+ question.responses[:not_valid] = "You search needs to be at least 3 characters long"
43
+ end
44
+ puts @skype_search.search_for search_string
45
+ end
46
+
47
+ def exit
48
+ abort "Game over!"
49
+ end
50
+
51
+ def select_contact
52
+ choose do |menu|
53
+ menu.prompt = "Select a contact"
54
+
55
+ menu.choices *@skype_search.find_contacts.map(&:dialog_partner)
56
+ end
57
+ end
58
+
59
+ def select_group
60
+ group_conversations = @skype_search.find_conversations
61
+ selection = choose do |menu|
62
+ menu.prompt = "Select a contact"
63
+
64
+ menu.choices *group_conversations.map(&:to_s)
65
+ end
66
+ group_conversations.select { |con| con.to_s == selection }.first.id
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,33 @@
1
+ require 'active_record'
2
+
3
+ module SkypeSearch
4
+ class DB
5
+ def initialize database
6
+ ActiveRecord::Base.establish_connection({
7
+ adapter: 'sqlite3',
8
+ database: database
9
+ })
10
+ end
11
+
12
+ def find_contacts
13
+ Messages.select("distinct(dialog_partner)")
14
+ end
15
+
16
+ def find_messages_between user
17
+ Messages.where(:dialog_partner => user).order(:timestamp)
18
+ end
19
+
20
+ def find_conversations
21
+ Conversations.all
22
+ end
23
+
24
+ def find_conversation_by_id conversation_id
25
+ Messages.where(:convo_id => conversation_id).order(:timestamp)
26
+ end
27
+
28
+ def search_for string
29
+ Messages.where('body_xml like ?', string).order(:timestamp)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,12 @@
1
+ module SkypeSearch
2
+ module Base
3
+
4
+ def self.included base
5
+ base.class_eval do
6
+ self.inheritance_column = 'class_type'
7
+ end
8
+ end
9
+
10
+ TIME_FORMATTER = "%d/%m/%Y %I:%M:%S %p"
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module SkypeSearch
2
+ class Conversations < ActiveRecord::Base
3
+ include Base
4
+
5
+ def to_s
6
+ "#{self.displayname} - created: #{self.created_at}"
7
+ end
8
+
9
+ def created_at
10
+ Time.at(self.creation_timestamp).to_datetime.strftime(TIME_FORMATTER)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module SkypeSearch
2
+ class Messages < ActiveRecord::Base
3
+ include Base
4
+
5
+ def to_s
6
+ "[#{self.created_at}] #{self.from_dispname} > #{self.body_xml}"
7
+ end
8
+
9
+ def created_at
10
+ Time.at(self.timestamp).to_datetime.strftime(TIME_FORMATTER)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ require 'rexml/document'
2
+ require 'pathname'
3
+
4
+ module SkypeSearch
5
+ class Settings
6
+
7
+ include REXML
8
+
9
+ def user_db
10
+ "#{skype_path}/#{user}/main.db"
11
+ end
12
+
13
+ def skype_settings
14
+ @skype_settings ||= REXML::Document.new(File.open("#{skype_path}/shared.xml", "r"))
15
+ end
16
+
17
+ private
18
+ def user
19
+ @user ||= XPath.first(skype_settings, '//Account//Default').text
20
+ end
21
+
22
+ def skype_path
23
+ @skype_path ||= Pathname.new("#{ENV['HOME']}/Library/Application\ Support/Skype").to_s
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ module SkypeSearch
2
+ VERSION = '1.0.0'
3
+ end
4
+
@@ -0,0 +1,28 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "skype_search/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "skype-search"
6
+ s.version = SkypeSearch::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.author = "Despo Pentara"
9
+ s.email = "despo@extractmethod.com"
10
+ s.homepage = "https://github.com/despo/skype-search"
11
+ s.summary = "Search and retrieve Skype conversations from the cli"
12
+ s.description = "Search and retrieve Skype conversations from the cli"
13
+ s.required_ruby_version = '>= 1.9.2'
14
+
15
+ s.licenses = ["MIT"]
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency "activerecord"
23
+ s.add_dependency "sqlite3"
24
+ s.add_dependency "highline"
25
+
26
+ s.add_development_dependency "rake"
27
+ s.add_development_dependency "rspec"
28
+ end
data/spec/data/test.db ADDED
Binary file
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe SkypeSearch do
4
+
5
+ subject(:db) { SkypeSearch::DB.new("#{Dir.pwd}/spec/data/test.db") }
6
+
7
+ it "retrieve all users that I exchanged messages with" do
8
+ db.find_contacts.should have(1).items
9
+ end
10
+
11
+ it 'retrieves all messages of a discussion' do
12
+ db.find_messages_between("find_in_skype").last.body_xml.should include "hey ho"
13
+ end
14
+
15
+ it 'retrieves all conversation details' do
16
+ conversations = db.find_conversations
17
+ conversations.should have(1).items
18
+ end
19
+
20
+ it 'retrieves a conversation' do
21
+ conversation_details = db.find_conversations.last
22
+
23
+ conversation = db.find_conversation_by_id conversation_details
24
+ conversation.first.convo_id.should eq conversation_details.id
25
+ end
26
+
27
+ it 'searches all conversations for a given text' do
28
+ conversations = db.search_for "Resistance is futile"
29
+
30
+ conversations.length.should == 2
31
+ end
32
+ end
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "skype_search")
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skype-search
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Despo Pentara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Search and retrieve Skype conversations from the cli
84
+ email: despo@extractmethod.com
85
+ executables:
86
+ - skype-search
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .travis.yml
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - README.md
94
+ - Rakefile
95
+ - bin/skype-search
96
+ - lib/skype_search.rb
97
+ - lib/skype_search/cli.rb
98
+ - lib/skype_search/db.rb
99
+ - lib/skype_search/db/base.rb
100
+ - lib/skype_search/db/conversations.rb
101
+ - lib/skype_search/db/messages.rb
102
+ - lib/skype_search/settings.rb
103
+ - lib/skype_search/version.rb
104
+ - skype-search.gemspec
105
+ - spec/data/test.db
106
+ - spec/skype_search_spec.rb
107
+ - spec/spec_helper.rb
108
+ homepage: https://github.com/despo/skype-search
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: 1.9.2
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.0.3
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Search and retrieve Skype conversations from the cli
132
+ test_files: []