skyp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e87862967262dec55271c2ac5cbd569ec760e082
4
+ data.tar.gz: d996bfe7e318799852ee519ab710a8493e244b04
5
+ SHA512:
6
+ metadata.gz: 5e5652b5f7d73bd797d64f3a6214b36dd36ea9db2296e29d1ca588542f320b649fb7aecf4b6478f555b89632d7300d30c8dc4672a2a70c0b39f0dea45813872a
7
+ data.tar.gz: 702585ef998ffdd5774a45f390dcc790bd590f64ef2765b16217bed3ca1e93c1ae1497ec354d6a7a0b27f9040c562da51c5a0c9c7060aae589d31db0254554ef
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in skyp.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Chun-wei Kuo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # Skyp
2
+
3
+ A command-line tool to search Skype history.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's `Gemfile`:
9
+
10
+ gem 'skyp'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install skyp
19
+
20
+
21
+ ## Usage
22
+
23
+ List recent chats:
24
+
25
+ skyp chats
26
+
27
+ Search `TERM` in the chatroom `CHAT`:
28
+
29
+ skyp search TERM -c CHAT
30
+
31
+
32
+ ## Config
33
+
34
+ Please set your account (Skype Name) in `~./skyp`.
35
+
36
+
37
+ ## Platforms
38
+
39
+ Currently Skyp only works on Mac.
40
+
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
49
+
50
+ ## Copyright
51
+
52
+ Copyright (c) 2013 Chun-wei Kuo. See [LICENSE][] for details.
53
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sqlite3'
4
+ require 'active_record'
5
+ require 'thor'
6
+
7
+ module Skyp
8
+ class Chat < ActiveRecord::Base
9
+ self.table_name = 'Chats'
10
+
11
+ has_many :messages, :primary_key => :name, :foreign_key => :chatname
12
+
13
+ scope :latest, -> { order(:activity_timestamp => :desc) }
14
+ end
15
+
16
+ class Message < ActiveRecord::Base
17
+ self.table_name = 'Messages'
18
+
19
+ belongs_to :chat, :primary_key => :name, :foreign_key => :chatname
20
+
21
+ scope :search, ->(term) { where('body_xml like ?', "%#{ term }%").order(:timestamp) }
22
+ end
23
+
24
+ class CLI < Thor
25
+ class_option :account, :type => :string, :desc => 'Set account (Skype Name)'
26
+
27
+ desc 'chats', 'List chat names'
28
+ option :all, :type => :boolean, :aliases => '-a', :desc => 'List all chats'
29
+ option :limit, :type => :numeric, :aliases => '-l', :desc => 'Only list the latest N chats', :default => 10
30
+ def chats
31
+ setup_database(options[:account])
32
+
33
+ chats = Chat.latest
34
+ chats = chats.limit(options[:limit]) unless options[:all]
35
+ chats.each do |chat|
36
+ puts chat.friendlyname
37
+ end
38
+ end
39
+
40
+ desc 'search TERM', 'Search the term TERM'
41
+ option :chat, :type => :string, :aliases => '-c', :desc => 'Search in the chatroom CHAT'
42
+ def search(term)
43
+ setup_database(options[:account])
44
+
45
+ chat = Chat.find_by_friendlyname(options[:chat])
46
+
47
+ message_scope = chat.try(:messages) || Message
48
+
49
+ messages = message_scope.search(term)
50
+ messages.each do |message|
51
+ time = Time.at(message.timestamp)
52
+ puts "[#{ time }] #{ message.from_dispname }: #{ message.body_xml }"
53
+ end
54
+ end
55
+
56
+ private
57
+
58
+ def setup_database(account)
59
+ account ||= default_account
60
+
61
+ # Disable STI
62
+ ActiveRecord::Base.inheritance_column = nil
63
+
64
+ database_path = "#{ Dir.home }/Library/Application Support/Skype/#{ account }/main.db"
65
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', encoding: 'utf8', database: database_path)
66
+ end
67
+
68
+ def default_account
69
+ path = "#{ Dir.home }/.skyp"
70
+
71
+ unless File.exists?(path)
72
+ account = ask('Please enter your account (Skype Name):')
73
+ IO.write(path, account)
74
+ end
75
+
76
+ IO.read(path).chomp
77
+ end
78
+ end
79
+ end
80
+
81
+ Skyp::CLI.start(ARGV)
82
+
@@ -0,0 +1,4 @@
1
+ require 'skyp/version'
2
+
3
+ module Skyp
4
+ end
@@ -0,0 +1,3 @@
1
+ module Skyp
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'skyp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'skyp'
8
+ spec.version = Skyp::VERSION
9
+ spec.authors = ['Chun-wei Kuo']
10
+ spec.email = ['Dendoh@gmail.com']
11
+ spec.description = %q{A command-line tool to search Skype history.}
12
+ spec.summary = %q{A command-line tool to search Skype history.}
13
+ spec.homepage = 'https://github.com/Domon/skyp'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'sqlite3', '~> 1.3.7'
22
+ spec.add_dependency 'activerecord', '~> 4.0.0'
23
+ spec.add_dependency 'thor', '~> 0.18.1'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rake', '~> 10.1.0'
27
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skyp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chun-wei Kuo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sqlite3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.18.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.18.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 10.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 10.1.0
83
+ description: A command-line tool to search Skype history.
84
+ email:
85
+ - Dendoh@gmail.com
86
+ executables:
87
+ - skyp
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/skyp
98
+ - lib/skyp.rb
99
+ - lib/skyp/version.rb
100
+ - skyp.gemspec
101
+ homepage: https://github.com/Domon/skyp
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.0.3
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: A command-line tool to search Skype history.
125
+ test_files: []