mailcvt 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ class BigMailGenerator
5
+ def initialize(input, output, number)
6
+ @input = input
7
+ @output = output
8
+ @number = number
9
+ end
10
+
11
+ def generate
12
+ start = Time.now
13
+ cpall
14
+ diff = Time.now - start
15
+ if diff / 60 < 1
16
+ puts "Elapsed time: #{diff.round(3)} seconds."
17
+ else
18
+ puts "Elapsed time: #{(diff / 60).round(1)} minutes."
19
+ end
20
+ system("du -h #{@output}")
21
+ end
22
+
23
+ def cpall
24
+ inputfiles = Dir.glob(File.join(@input, '*'))
25
+
26
+ count = 0
27
+ copycounts = @number / inputfiles.length
28
+ inputfiles.each do |ifile|
29
+ size = File.size(ifile)
30
+ puts "copy #{ifile}(#{size / 1024}KB) #{copycounts} times"
31
+ copycounts.times do |i|
32
+ cpfile ifile, i
33
+ count += 1
34
+ puts "#{count} files copied." if (count % 3000 == 0)
35
+ end
36
+ end
37
+
38
+ remains = @number % inputfiles.length
39
+ remains.times do |i|
40
+ cpfile inputfiles[i], copycounts + i
41
+ count += 1
42
+ puts "#{count} files copied." if (count % 3000 == 0)
43
+ end
44
+
45
+ puts "Done. #{count} files copied."
46
+ end
47
+
48
+ def cpfile(ifile, i)
49
+ fn = File.basename(ifile)
50
+ ofile = File.join(@output, "#{fn}_#{i + 1}")
51
+ FileUtils.cp(ifile, ofile)
52
+ end
53
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ class MailParser
5
+ def initialize(input, output)
6
+ @input = input
7
+ @output = output
8
+ end
9
+
10
+ def parse
11
+ start = Time.now
12
+ parseall
13
+ diff = Time.now - start
14
+ if diff / 60 < 1
15
+ puts "Elapsed time: #{diff.round(3)} seconds."
16
+ else
17
+ puts "Elapsed time: #{(diff / 60).round(1)} minutes."
18
+ end
19
+ system("du -h #{@output}")
20
+ end
21
+
22
+ def parseall
23
+ File.open(File.join(@output, "test_log.log"), 'w') do |out|
24
+ Dir.glob(File.join(@input, '*')) do |file|
25
+ parsefile file, out
26
+ File.delete file
27
+ end
28
+ end
29
+ end
30
+
31
+ def parsefile(file, out)
32
+ out.puts(file)
33
+ out.flush
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Mailcvt
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailcvt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -87,6 +87,8 @@ files:
87
87
  - bin/mailcvt
88
88
  - lib/mailcvt/version.rb
89
89
  - lib/mailcvt.rb
90
+ - lib/big_mail_generator.rb
91
+ - lib/mail_parser.rb
90
92
  - README.rdoc
91
93
  - mailcvt.rdoc
92
94
  homepage: http://github.com/ryu-kahou/mailcvt
@@ -109,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
111
  version: '0'
110
112
  segments:
111
113
  - 0
112
- hash: -432718095918672412
114
+ hash: 4318318595746491093
113
115
  required_rubygems_version: !ruby/object:Gem::Requirement
114
116
  none: false
115
117
  requirements:
@@ -118,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  version: '0'
119
121
  segments:
120
122
  - 0
121
- hash: -432718095918672412
123
+ hash: 4318318595746491093
122
124
  requirements: []
123
125
  rubyforge_project:
124
126
  rubygems_version: 1.8.25