skype-history-import 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -51,3 +51,9 @@ Rake::RDocTask.new do |rdoc|
51
51
  rdoc.rdoc_files.include('README*')
52
52
  rdoc.rdoc_files.include('lib/**/*.rb')
53
53
  end
54
+
55
+ task :done do
56
+ sh 'git add .'
57
+ sh "git commit -a -m \"#{ENV['m']}\""
58
+ sh 'git push'
59
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 1.0.0
@@ -0,0 +1,38 @@
1
+ def import(text)
2
+ result = []
3
+
4
+ message = Message.new
5
+
6
+ while text.strip.size > 0
7
+ if text =~ /^\[(.*)\] (.*): (.*)/
8
+
9
+ # handle tail of prev multi line message
10
+ unless $` == nil or message.text == nil or $`.strip == ""
11
+ message.text += $`
12
+ end
13
+
14
+ # message start
15
+ message = Message.new
16
+
17
+ begin
18
+ message.date = DateTime.strptime($1, "%d/%m/%Y %H:%M:%S")
19
+ message.nick = $2
20
+ message.text = $3
21
+ rescue
22
+ puts "Exception '#{$!}' on match *** #{$~} ***"
23
+ raise
24
+ end
25
+
26
+ result.push(message)
27
+ end
28
+
29
+
30
+ text = $'
31
+ end
32
+
33
+ result
34
+ end
35
+
36
+ class Message
37
+ attr_accessor :date, :nick, :text
38
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{skype-history-import}
8
- s.version = "0.1.0"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["SergXIIIth"]
12
- s.date = %q{2011-06-17}
12
+ s.date = %q{2011-06-23}
13
13
  s.description = %q{Skype history import to JSON}
14
14
  s.email = %q{smkrbr@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -1,7 +1,81 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'helper'
3
+ require 'date'
2
4
 
3
5
  class TestSkypeHistoryImport < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
6
+ context "a importer" do
7
+ should "import two message" do
8
+ messages = <<-message
9
+ [14/06/2011 09:25:15] Di: a deal? are you trading something?
10
+ [14/06/2011 09:28:45] sam: not yet, just personal staff
11
+ message
12
+
13
+ result = import(messages)
14
+
15
+ assert_equal(2, result.count, "Two message should be")
16
+
17
+ di = result[0]
18
+
19
+ assert_equal("Di", di.nick)
20
+ assert_equal(DateTime.new(2011,06,14, 9,25,15), di.date)
21
+ assert_equal("a deal? are you trading something?", di.text)
22
+ end
23
+
24
+
25
+ should "import milti lines message" do
26
+ messages = <<-message
27
+ [14/06/2011 09:28:45] sam: In Ruby's $SAFE semantics, safe level of 4 is used to run a untrusted code (such as plugin). So in upper safe levels, some sort of operations are prohibited to prevent untrusted codes from attacking outer (trusted) data.
28
+
29
+ Exception#to_s was found to be problematic around it. The method can trick safe level mechanism and destructively modifies an untaitned string to be tainted. With this an attacker can modify arbitrary untainted strings like this:
30
+ [14/06/2011 09:28:50] sam: wedwed
31
+ message
32
+
33
+ result = import(messages)
34
+
35
+ assert_equal(2, result.count, "Two message should be")
36
+ message = result[0]
37
+ assert_equal(452, message.text.size, "message too short")
38
+ end
39
+
40
+ should "edited message" do
41
+ messages = <<-message
42
+ [14/06/2011 09:28:45 | Edited 09:29:02] sam: not yet, just personal staff
43
+ message
44
+
45
+ result = import(messages)[0]
46
+
47
+ assert_equal("sam", result.nick)
48
+ assert_equal(DateTime.new(2011,06,14, 9,28,45), result.date)
49
+ end
50
+
51
+ should "deleted message" do
52
+ messages = <<-message
53
+ [22/06/2011 16:26:57 | Removed 11:49:30] sam: This message has been removed.
54
+ message
55
+
56
+ result = import(messages)[0]
57
+
58
+ assert_equal("sam", result.nick)
59
+ assert_equal(DateTime.new(2011,06,22, 16,26,57), result.date)
60
+ end
61
+
62
+ should "import real chat" do
63
+ file = File.open("/home/msa/real_skypy_chat.txt", "rb")
64
+ messages = file.read
65
+ result = import(messages)
66
+ p "so real messages count is #{result.size}"
67
+ end
68
+
69
+ =begin
70
+ file send
71
+ [08/12/2010 17:01:46] *** sam sent ps.js ***
72
+
73
+ call
74
+ [20/06/2011 18:37:28] *** Call to Echo / Sound Test Service, duration 00:44. ***
75
+
76
+ today
77
+ [16:57:04] sam: ок, я Юре в понедельник тогда подвезу ноут или в воскресенье, если он работает
78
+
79
+ =end
80
+ end
7
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skype-history-import
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-17 00:00:00.000000000 -07:00
12
+ date: 2011-06-23 00:00:00.000000000 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: shoulda
17
- requirement: &17515080 !ruby/object:Gem::Requirement
17
+ requirement: &21344620 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *17515080
25
+ version_requirements: *21344620
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
- requirement: &17514540 !ruby/object:Gem::Requirement
28
+ requirement: &21343820 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *17514540
36
+ version_requirements: *21343820
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: jeweler
39
- requirement: &17513680 !ruby/object:Gem::Requirement
39
+ requirement: &21342660 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.6.2
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *17513680
47
+ version_requirements: *21342660
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rcov
50
- requirement: &17512920 !ruby/object:Gem::Requirement
50
+ requirement: &21341900 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *17512920
58
+ version_requirements: *21341900
59
59
  description: Skype history import to JSON
60
60
  email: smkrbr@gmail.com
61
61
  executables: []
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  segments:
93
93
  - 0
94
- hash: -1858194079791668911
94
+ hash: 4171949496189517685
95
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements: