mht 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/mht.rb +10 -6
  3. data/mht.gemspec +2 -2
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/mht.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  # generate mhtml file
2
3
  # == uri target uri
3
4
  # return mhtml file
@@ -18,6 +19,7 @@ require 'thread'
18
19
  #mhtml = MHT::MhtmlGenerator.generate("https://rubygems.org/")
19
20
  #open("output.mht", "w+"){|f| f.write mhtml }
20
21
  class MhtmlGenerator
22
+ attr_accessor :conf
21
23
  def MhtmlGenerator.generate(uri)
22
24
  generateror = MhtmlGenerator.new
23
25
  return generateror.convert(uri)
@@ -26,8 +28,9 @@ class MhtmlGenerator
26
28
  @contents = {}
27
29
  @src = StringIO.new
28
30
  @boundary = "mimepart_#{Digest::MD5.hexdigest(Time.now.to_s)}"
29
- @threads =[]
30
- @queue = Queue.new
31
+ @threads = []
32
+ @queue = Queue.new
33
+ @conf = { :base64_except=>["html"]}
31
34
  end
32
35
  def convert(filename_or_uri)
33
36
  f = open(filename_or_uri)
@@ -71,11 +74,12 @@ class MhtmlGenerator
71
74
  @src.puts "Content-Type: #{f.meta['content-type']}"
72
75
  @src.puts "Content-Id: #{Digest::MD5.hexdigest(filename_or_uri)}"
73
76
  @src.puts "Content-Location: #{filename_or_uri}"
74
- #@src.puts "Content-Transfer-Encoding: 8bit"
75
- @src.puts "Content-Transfer-Encoding: Base64"
77
+ @src.puts "Content-Transfer-Encoding: 8bit" if @conf[:base64_except].find("html")
78
+ @src.puts "Content-Transfer-Encoding: Base64" unless @conf[:base64_except].find("html")
76
79
  @src.puts ""
77
80
  #@src.puts html
78
- @src.puts "#{Base64.encode64(html)}"
81
+ @src.puts "#{html}" if @conf[:base64_except].find("html")
82
+ #@src.puts "#{Base64.encode64(html)}" unless @conf[:base64_except].find("html")
79
83
  @src.puts ""
80
84
  self.attach_contents
81
85
  @src.puts "--#{@boundary}--"
@@ -106,7 +110,7 @@ class MhtmlGenerator
106
110
  @contents.each{|k,v| @queue.push k}
107
111
  #start download threads
108
112
  self.start_download_thread
109
- # wait
113
+ # wait until download finished.
110
114
  @threads.each{|t|t.join}
111
115
  @contents.each{|k,v|self.add_html_content(k)}
112
116
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mht}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["takuya"]
12
- s.date = %q{2011-06-10}
12
+ s.date = %q{2011-07-15}
13
13
  s.description = %q{mht is builder of mhtml file}
14
14
  s.email = %q{takuya.1st@gmail}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mht
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - takuya
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-10 00:00:00 +09:00
18
+ date: 2011-07-15 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency