skype-history-import 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/skype-history-import.rb +19 -13
- data/skype-history-import.gemspec +2 -2
- data/test/test_skype-history-import.rb +32 -4
- metadata +11 -11
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/lib/skype-history-import.rb
CHANGED
@@ -7,28 +7,34 @@ def import(text)
|
|
7
7
|
|
8
8
|
while text.strip.size > 0
|
9
9
|
if text =~ /^\[(.*)\] (.*): (.*)/
|
10
|
-
|
10
|
+
|
11
11
|
# handle tail of prev multi line message
|
12
12
|
unless $` == nil or message.text == nil or $`.strip == ""
|
13
13
|
message.text += $`
|
14
14
|
end
|
15
15
|
|
16
|
-
# message
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
message
|
22
|
-
message
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
# if date is only time, then found string is boby of prev message
|
17
|
+
time = DateTime.strptime($1, "%H:%M:%S") rescue nil
|
18
|
+
if time
|
19
|
+
message.text += $&
|
20
|
+
else
|
21
|
+
# message start
|
22
|
+
message = Message.new
|
23
|
+
|
24
|
+
begin
|
25
|
+
message.date = DateTime.strptime($1, "%d/%m/%Y %H:%M:%S")
|
26
|
+
message.nick = $2
|
27
|
+
message.text = $3
|
28
|
+
rescue
|
29
|
+
puts "Exception '#{$!}' on match *** #{$~} ***"
|
30
|
+
raise
|
31
|
+
end
|
32
|
+
|
33
|
+
result.push(message)
|
26
34
|
end
|
27
35
|
|
28
|
-
result.push(message)
|
29
36
|
end
|
30
37
|
|
31
|
-
|
32
38
|
text = $'
|
33
39
|
end
|
34
40
|
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{skype-history-import}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.3"
|
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-
|
12
|
+
s.date = %q{2011-06-24}
|
13
13
|
s.description = %q{Manualy user copy chat history to file or string and after gem import(parse) it to class Message}
|
14
14
|
s.email = %q{smkrbr@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -59,11 +59,39 @@ Exception#to_s was found to be problematic around it. The method can trick safe
|
|
59
59
|
assert_equal(DateTime.new(2011,06,22, 16,26,57), result.date)
|
60
60
|
end
|
61
61
|
|
62
|
-
should "
|
63
|
-
|
64
|
-
|
62
|
+
should "message with only time go to prev message" do
|
63
|
+
messages = <<-message
|
64
|
+
[22/06/2011 16:26:57] sam: This message has been removed.
|
65
|
+
[16:26:57] mtv: Boby of prev message.
|
66
|
+
message
|
67
|
+
|
65
68
|
result = import(messages)
|
66
|
-
|
69
|
+
|
70
|
+
assert_equal(1, result.size, "should be one message")
|
71
|
+
|
72
|
+
result = result[0]
|
73
|
+
|
74
|
+
assert_equal("sam", result.nick)
|
75
|
+
assert_equal(DateTime.new(2011,06,22, 16,26,57), result.date)
|
76
|
+
assert(result.text =~ /\[16:26:57\] mtv/, "message text have second line")
|
77
|
+
end
|
78
|
+
|
79
|
+
should "import real chat" do
|
80
|
+
#return
|
81
|
+
pattern = "#{Dir.home}/skype_history/*.txt"
|
82
|
+
|
83
|
+
Dir[pattern].each do |file_path|
|
84
|
+
p ""
|
85
|
+
p "Importing #{file_path} ... "
|
86
|
+
|
87
|
+
file = File.open(file_path, "rb")
|
88
|
+
messages = file.read
|
89
|
+
file.close
|
90
|
+
|
91
|
+
result = import(messages)
|
92
|
+
|
93
|
+
p "ok. Messages count is #{result.size}"
|
94
|
+
end
|
67
95
|
end
|
68
96
|
|
69
97
|
=begin
|
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: 1.0.
|
4
|
+
version: 1.0.3
|
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-
|
12
|
+
date: 2011-06-24 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: &
|
17
|
+
requirement: &13539880 !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: *
|
25
|
+
version_requirements: *13539880
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bundler
|
28
|
-
requirement: &
|
28
|
+
requirement: &13539240 !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: *
|
36
|
+
version_requirements: *13539240
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: jeweler
|
39
|
-
requirement: &
|
39
|
+
requirement: &13538420 !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: *
|
47
|
+
version_requirements: *13538420
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rcov
|
50
|
-
requirement: &
|
50
|
+
requirement: &13537100 !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: *
|
58
|
+
version_requirements: *13537100
|
59
59
|
description: Manualy user copy chat history to file or string and after gem import(parse)
|
60
60
|
it to class Message
|
61
61
|
email: smkrbr@gmail.com
|
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
segments:
|
94
94
|
- 0
|
95
|
-
hash:
|
95
|
+
hash: 1262013932544102761
|
96
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|