runoff 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cbece2f0614ed17f5c62f98227f7c000e3b7985
4
- data.tar.gz: f10c4978d07c72e9e004d7bbdb9647c54f36bc32
3
+ metadata.gz: 30527da833e016b926ae2d4690df9d977dc7c0eb
4
+ data.tar.gz: 36ea0b94d751a0a127c4e4db3d8024d357f517be
5
5
  SHA512:
6
- metadata.gz: b086d0b09ba49f49d81a376d7c4c0f8c56aa2f9f6f4ecc04851046129f53567ae07a70adb05b48bc8342f5cbc921f65c88b275f893fb05d385fd02db8c0f6bb3
7
- data.tar.gz: 9b149cab21193959a02575b6ad5111a63b9b71e80e21817cc5ad7dace585db70018f12f9131511d42b15f13b8083a34239566c502ae3d155bf342ab0a42edc22
6
+ metadata.gz: 6d1de800329cb5cac9bea6503adea06c7aec4769691f8cfabdf6e60c113f8265aea4145f2c28b8c761462ea06f90971d17611473576d5045d996b80b0bb6b005
7
+ data.tar.gz: 45bd434c446a6410cf77ffc34291e31a7a0e259c99e8ec9cd1173e2ca3ca1e24678953f7f4c65b7eb7bd93909863cadd335b0871d2c2874c2a1c277e0475743c
data/README.md CHANGED
@@ -36,6 +36,5 @@ Things to do in the future versions:
36
36
 
37
37
  - Parse body_xml to filter XML tags and character entities.
38
38
  - Append only new messages to the previously genetrated files instead of appending everything or create different versions for the files when using `-a false` option.
39
- - Add some colors.
40
39
 
41
40
  If you have something to say about this gem or anything else, you can find me on Twitter as [@aigarsdz](http://twitter.com/aigarsdz "@aigarsdz").
@@ -1,4 +1,4 @@
1
- require 'zip/zip'
1
+ require 'zip'
2
2
  require 'fileutils'
3
3
 
4
4
  module Runoff
@@ -25,16 +25,14 @@ module Runoff
25
25
  #
26
26
  # Returns a String that contains the path to the Skype database file.
27
27
  def self.default_skype_data_location(skype_username)
28
- if RbConfig::CONFIG['host_os'] =~ /mingw/
29
- location = "#{ENV['APPDATA']}\\Skype\\#{skype_username}\\main.db"
30
-
31
- unless File.exist?("#{ENV['APPDATA']}\\Skype")
32
- location = self.get_default_skype_data_location_on_windows_8 skype_username
28
+ case RbConfig::CONFIG['host_os']
29
+ when /mingw/
30
+ if File.exist?("#{ENV['APPDATA']}\\Skype")
31
+ format_windows_path "#{ENV['APPDATA']}\\Skype\\#{skype_username}\\main.db"
32
+ else
33
+ format_windows_path self.get_default_skype_data_location_on_windows_8(skype_username)
33
34
  end
34
-
35
- location.gsub!(/\\/, '/')
36
- location.gsub(/^[a-zA-Z]:/, '')
37
- elsif RbConfig::CONFIG['host_os'] =~ /linux/
35
+ when /linux/
38
36
  "#{ENV['HOME']}/.Skype/#{skype_username}/main.db"
39
37
  else
40
38
  "#{ENV['HOME']}/Library/Application Support/Skype/#{skype_username}/main.db"
@@ -43,7 +41,22 @@ module Runoff
43
41
 
44
42
  private
45
43
 
46
- # Public: Composes the default Skype database location for the Windows 8 operating system.
44
+ # Internal: Replaces backslashes with forward slashes and removes drive letter.
45
+ #
46
+ # path - String containing a directory path.
47
+ #
48
+ # Examples
49
+ #
50
+ # format_windows_path 'C:\Users\username\AppData\Roaming\Skype\skype_username\main.db'
51
+ # # => /Users/username/AppData/ROaming/Skype/skype_username/main.db
52
+ #
53
+ # Returns a String with modified directory path.
54
+ def self.format_windows_path(path)
55
+ path = path.gsub(/\\/, '/')
56
+ path.gsub(/^[a-zA-Z]:/, '')
57
+ end
58
+
59
+ # Internal: Composes the default Skype database location for the Windows 8 operating system.
47
60
  #
48
61
  # skype_username - A String that contains a username of the Skype account,
49
62
  # which database we want to access.
@@ -56,14 +69,11 @@ module Runoff
56
69
  # Returns a String that contains the path to the Skype database file.
57
70
  def self.get_default_skype_data_location_on_windows_8(skype_username)
58
71
  location = "#{ENV['HOME']}/AppData/Local/Packages"
72
+ skype_folder = Dir["#{location}/Microsoft.SkypeApp*"].first
59
73
 
60
- Dir["#{location}/*"].each do |item|
61
- if item =~ /Microsoft\.SkypeApp/
62
- location = "#{item}/LocalState/#{skype_username}/main.db"
63
- end
64
- end
74
+ raise IOError.new "The default Skype directory doesn't exist." unless skype_folder
65
75
 
66
- location
76
+ "#{skype_folder}/LocalState/#{skype_username}/main.db"
67
77
  end
68
78
  end
69
- end
79
+ end
@@ -1,3 +1,3 @@
1
1
  module Runoff
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -3,21 +3,27 @@ require 'minitest/unit'
3
3
  require 'runoff'
4
4
 
5
5
  class TestLocation < MiniTest::Test
6
- def setup
7
- @path = Runoff::Location.default_skype_data_location 'aidzis_skype'
8
- end
9
-
10
6
  def test_must_return_a_default_path_depending_on_the_operating_system
7
+ path = Runoff::Location.default_skype_data_location 'aidzis_skype'
8
+
11
9
  if RbConfig::CONFIG['host_os'] =~ /mingw/
10
+ skip
12
11
  if File.exist?("#{ENV['APPDATA']}\\Skype")
13
- assert_match /\/Users\/[a-zA-Z0-9]+\/AppData\/Roaming\/Skype\/aidzis_skype\/main\.db/, @path
12
+ assert_match /\/Users\/[a-zA-Z0-9]+\/AppData\/Roaming\/Skype\/aidzis_skype\/main\.db/, path
14
13
  else
15
- assert_match /\/Users\/[a-zA-Z0-9]+\/AppData\/Local\/Packages\/[a-zA-Z0-9_\/\.]+\/aidzis_skype\/main\.db/, @path
14
+ assert_match /\/Users\/[a-zA-Z0-9]+\/AppData\/Local\/Packages\/[a-zA-Z0-9_\/\.]+\/aidzis_skype\/main\.db/, path
16
15
  end
17
16
  elsif RbConfig::CONFIG['host_os'] =~ /linux/
18
- assert_match /\/home\/[a-zA-Z0-9]+\/\.Skype\/aidzis_skype\/main\.db/, @path
17
+ assert_match /\/home\/[a-zA-Z0-9]+\/\.Skype\/aidzis_skype\/main\.db/, path
19
18
  else
20
- assert_match /~\/Library\/Application Support\/Skype\/aidzis_skype\/main\.db/, @path
19
+ assert_match /~\/Library\/Application Support\/Skype\/aidzis_skype\/main\.db/, path
21
20
  end
22
21
  end
22
+
23
+ def test_must_replace_backslashes_with_forward_slashes_and_remowe_drive_letter
24
+ windows_path = 'C:\\Users\\user\\AppData\\Roaming\\Skype'
25
+ unix_style_path = Runoff::Location.send :format_windows_path, windows_path
26
+
27
+ assert_equal '/Users/user/AppData/Roaming/Skype', unix_style_path
28
+ end
23
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aigars Dzerviniks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-30 00:00:00.000000000 Z
11
+ date: 2013-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.0.2
122
+ rubygems_version: 2.0.3
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Tool to export Skype chat history from the SQLite database to text files