skype-history-import 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,6 +3,9 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
+ # russian translate, email from skype nice name
7
+ gem 'stringex', '~> 1.2'
8
+
6
9
  # Add dependencies to develop your gem here.
7
10
  # Include everything needed to run rake, tests, features, etc.
8
11
  group :development do
data/Gemfile.lock CHANGED
@@ -9,6 +9,7 @@ GEM
9
9
  rake (0.9.2)
10
10
  rcov (0.9.9)
11
11
  shoulda (2.11.3)
12
+ stringex (1.2.2)
12
13
 
13
14
  PLATFORMS
14
15
  ruby
@@ -18,3 +19,4 @@ DEPENDENCIES
18
19
  jeweler (~> 1.6.2)
19
20
  rcov
20
21
  shoulda
22
+ stringex (~> 1.2)
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # skype-history-import
2
+
3
+ Open Skype -> Throught context menu Select all message -> Put them in file or string -> run function 'import'
4
+
5
+ How to use, example
6
+
7
+ ``` ruby
8
+ require 'rubygems'
9
+ require 'skype-history-import'
10
+
11
+ file = File.open("/home/msa/real_skype_chat.txt", "rb")
12
+ messages = file.read
13
+
14
+ result = import(messages)
15
+
16
+ p "so real messages count is #{result.size}"
17
+ p "first message #{result[0].inspect}"
18
+ ```
19
+
20
+ ## Contributing to skype-history-import
21
+
22
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
23
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
24
+ * Fork the project
25
+ * Start a feature/bugfix branch
26
+ * Commit and push until you are happy with your contribution
27
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
28
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
29
+
30
+ ## Copyright
31
+
32
+ Copyright (c) 2011 SergXIIIth. See LICENSE.txt for
33
+ further details.
34
+
data/README.rdoc CHANGED
@@ -4,6 +4,7 @@ Open Skype -> Throught context menu Select all message -> Put them in file or st
4
4
 
5
5
  How to use, example
6
6
 
7
+ ``` ruby
7
8
  require 'rubygems'
8
9
  require 'skype-history-import'
9
10
 
@@ -14,7 +15,7 @@ How to use, example
14
15
 
15
16
  p "so real messages count is #{result.size}"
16
17
  p "first message #{result[0].inspect}"
17
-
18
+ ```
18
19
 
19
20
  == Contributing to skype-history-import
20
21
 
data/Rakefile CHANGED
@@ -57,3 +57,8 @@ task :done do
57
57
  sh "git commit -a -m \"#{ENV['m']}\""
58
58
  sh 'git push'
59
59
  end
60
+
61
+ task :up do
62
+ sh 'git pull origin master'
63
+ end
64
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.4
1
+ 1.0.5
@@ -1,46 +1,84 @@
1
1
  require 'date'
2
+ require 'stringex'
2
3
 
3
- def import(text)
4
- result = []
5
-
6
- message = Message.new
7
-
8
- while text.strip.size > 0
9
- if text =~ /^\[(.+)\] (.+?): (.*)/
4
+ module SkypeHistoryImport
5
+ class Importer
6
+ attr_accessor :nike_to_email_mapping
7
+
8
+ def nike_to_email_map(nick, email)
9
+ @nike_to_email_map = Hash.new if @nike_to_email_map.nil?
10
+ @nike_to_email_map[nick] = email
11
+ end
12
+
13
+ def run(text)
14
+ result = []
10
15
 
11
- # handle tail of prev multi line message
12
- unless $` == nil or message.text == nil or $`.strip == ""
13
- message.text += $`
14
- end
16
+ message = Message.new
15
17
 
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
18
+ while text.strip.size > 0
19
+ if text =~ /^\[(.+)\] (.+?): (.*)/
20
+
21
+ # handle tail of prev multi line message
22
+ unless $` == nil or message.text == nil or $`.strip == ""
23
+ message.text += $`
24
+ end
25
+
26
+ # if date is only time, then found string is boby of prev message
27
+ time = DateTime.strptime($1, "%H:%M:%S") rescue nil
28
+ if time
29
+ message.text += $&
30
+ else
31
+ # message start
32
+ message = Message.new
33
+
34
+ begin
35
+ message.date = DateTime.strptime($1, "%d/%m/%Y %H:%M:%S")
36
+ message.nick = $2
37
+ message.text = $3
38
+
39
+ if @nike_to_email_map.nil? == false && @nike_to_email_map.has_key?(message.nick)
40
+ message.email = @nike_to_email_map[message.nick]
41
+ end
42
+
43
+ rescue
44
+ puts "Exception '#{$!}' on match *** #{$~} ***"
45
+ raise
46
+ end
47
+
48
+ result.push(message)
49
+ end
50
+
31
51
  end
32
52
 
33
- result.push(message)
53
+ text = $'
34
54
  end
35
-
55
+
56
+ result
57
+ end
58
+ end
59
+
60
+ class Message
61
+ attr_accessor :date, :nick, :text
62
+
63
+ # make email from nick, like nick@skype.com
64
+ def email
65
+ if @email.nil?
66
+ @email = nick.to_url.gsub(/\W/,'')
67
+ @email = "#{@email}@skype.com"
68
+ end
69
+ @email
36
70
  end
37
71
 
38
- text = $'
72
+ def email=(value)
73
+ @email = value
74
+ end
39
75
  end
76
+ end
40
77
 
41
- result
78
+ def import(text)
79
+ importer = SkypeHistoryImport::Importer.new
80
+ importer.run(text)
42
81
  end
43
82
 
44
- class Message
45
- attr_accessor :date, :nick, :text
83
+ class Message < SkypeHistoryImport::Message
46
84
  end
@@ -5,15 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{skype-history-import}
8
- s.version = "1.0.4"
8
+ s.version = "1.0.5"
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-25}
12
+ s.date = %q{2011-07-25}
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 = [
16
16
  "LICENSE.txt",
17
+ "README.md",
17
18
  "README.rdoc"
18
19
  ]
19
20
  s.files = [
@@ -21,6 +22,7 @@ Gem::Specification.new do |s|
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
25
+ "README.md",
24
26
  "README.rdoc",
25
27
  "Rakefile",
26
28
  "VERSION",
@@ -39,17 +41,20 @@ Gem::Specification.new do |s|
39
41
  s.specification_version = 3
40
42
 
41
43
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<stringex>, ["~> 1.2"])
42
45
  s.add_development_dependency(%q<shoulda>, [">= 0"])
43
46
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
44
47
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
45
48
  s.add_development_dependency(%q<rcov>, [">= 0"])
46
49
  else
50
+ s.add_dependency(%q<stringex>, ["~> 1.2"])
47
51
  s.add_dependency(%q<shoulda>, [">= 0"])
48
52
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
49
53
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
50
54
  s.add_dependency(%q<rcov>, [">= 0"])
51
55
  end
52
56
  else
57
+ s.add_dependency(%q<stringex>, ["~> 1.2"])
53
58
  s.add_dependency(%q<shoulda>, [">= 0"])
54
59
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
55
60
  s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
@@ -17,6 +17,7 @@ class TestSkypeHistoryImport < Test::Unit::TestCase
17
17
  di = result[0]
18
18
 
19
19
  assert_equal("Di", di.nick)
20
+ assert_equal("di@skype.com", di.email)
20
21
  assert_equal(DateTime.new(2011,06,14, 9,25,15), di.date)
21
22
  assert_equal("a deal? are you trading something?", di.text)
22
23
  end
@@ -102,6 +103,19 @@ Exception#to_s was found to be problematic around it. The method can trick safe
102
103
  result = import(messages)[0]
103
104
  assert_equal("Di", result.nick)
104
105
  end
106
+
107
+ should "email maping" do
108
+ messages = <<-message
109
+ [14/06/2011 09:25:15] Di: a deal? are you: trading something?
110
+ message
111
+
112
+ importer = SkypeHistoryImport::Importer.new
113
+
114
+ importer.nike_to_email_map "Di", "Di@mail.com"
115
+
116
+ result = importer.run(messages)[0]
117
+ assert_equal("Di@mail.com", result.email)
118
+ end
105
119
  =begin
106
120
  file send
107
121
  [08/12/2010 17:01:46] *** sam sent ps.js ***
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
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,23 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-25 00:00:00.000000000 -07:00
12
+ date: 2011-07-25 00:00:00.000000000 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: stringex
17
+ requirement: &21245640 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.2'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *21245640
15
26
  - !ruby/object:Gem::Dependency
16
27
  name: shoulda
17
- requirement: &5653440 !ruby/object:Gem::Requirement
28
+ requirement: &21245160 !ruby/object:Gem::Requirement
18
29
  none: false
19
30
  requirements:
20
31
  - - ! '>='
@@ -22,10 +33,10 @@ dependencies:
22
33
  version: '0'
23
34
  type: :development
24
35
  prerelease: false
25
- version_requirements: *5653440
36
+ version_requirements: *21245160
26
37
  - !ruby/object:Gem::Dependency
27
38
  name: bundler
28
- requirement: &5652400 !ruby/object:Gem::Requirement
39
+ requirement: &21244680 !ruby/object:Gem::Requirement
29
40
  none: false
30
41
  requirements:
31
42
  - - ~>
@@ -33,10 +44,10 @@ dependencies:
33
44
  version: 1.0.0
34
45
  type: :development
35
46
  prerelease: false
36
- version_requirements: *5652400
47
+ version_requirements: *21244680
37
48
  - !ruby/object:Gem::Dependency
38
49
  name: jeweler
39
- requirement: &5650920 !ruby/object:Gem::Requirement
50
+ requirement: &21244200 !ruby/object:Gem::Requirement
40
51
  none: false
41
52
  requirements:
42
53
  - - ~>
@@ -44,10 +55,10 @@ dependencies:
44
55
  version: 1.6.2
45
56
  type: :development
46
57
  prerelease: false
47
- version_requirements: *5650920
58
+ version_requirements: *21244200
48
59
  - !ruby/object:Gem::Dependency
49
60
  name: rcov
50
- requirement: &5649420 !ruby/object:Gem::Requirement
61
+ requirement: &21243720 !ruby/object:Gem::Requirement
51
62
  none: false
52
63
  requirements:
53
64
  - - ! '>='
@@ -55,7 +66,7 @@ dependencies:
55
66
  version: '0'
56
67
  type: :development
57
68
  prerelease: false
58
- version_requirements: *5649420
69
+ version_requirements: *21243720
59
70
  description: Manualy user copy chat history to file or string and after gem import(parse)
60
71
  it to class Message
61
72
  email: smkrbr@gmail.com
@@ -63,12 +74,14 @@ executables: []
63
74
  extensions: []
64
75
  extra_rdoc_files:
65
76
  - LICENSE.txt
77
+ - README.md
66
78
  - README.rdoc
67
79
  files:
68
80
  - .document
69
81
  - Gemfile
70
82
  - Gemfile.lock
71
83
  - LICENSE.txt
84
+ - README.md
72
85
  - README.rdoc
73
86
  - Rakefile
74
87
  - VERSION
@@ -92,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
105
  version: '0'
93
106
  segments:
94
107
  - 0
95
- hash: -1625539411613459907
108
+ hash: -1247341894705888594
96
109
  required_rubygems_version: !ruby/object:Gem::Requirement
97
110
  none: false
98
111
  requirements: