pjstadig-easy_imap 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -2,3 +2,9 @@
2
2
 
3
3
  * 1 major enhancement:
4
4
  * Initial release
5
+
6
+ == 0.0.2 2008-12-17
7
+
8
+ * 1 minor enhancement:
9
+ * Added support for simple LOGIN authentication. (intabulas)
10
+
data/Manifest.txt CHANGED
@@ -11,6 +11,7 @@ lib/easy_imap/server.rb
11
11
  script/console
12
12
  script/destroy
13
13
  script/generate
14
+ script/txt2html
14
15
  spec/easy_imap_spec.rb
15
16
  spec/spec.opts
16
17
  spec/spec_helper.rb
data/README.rdoc CHANGED
@@ -8,20 +8,20 @@ A simple interface to proccessing e-mail messages using IMAP, including handling
8
8
 
9
9
  == SYNOPSIS:
10
10
 
11
- Create a connection using +EasyIMAP.connect+, and with the connection you can access Folders and Messages. To
12
- get a list of all Folders use +Server.folders+, to access the messages in a folder use +Folder.messages+, and to
13
- access the Attachments on a Message use +Message.attachments+.
14
-
15
- EasyIMAP::Server.connect('mail.example.com', :username => 'username, :password => 'password) do |conn|
16
- inbox = conn.folders.first
17
- inbox.messages.each do |m|
18
- if m.attachments.any? && m.attachments.first.content_type == "application/vnd.ms-excel"
19
- File.open("/tmp/first_attachment.xls", "w") do |f|
20
- f.write(m.attachments.first.body)
11
+ Create a connection using EasyIMAP::Server.connect, and with the connection you can access Folders and Messages. To
12
+ get a list of all Folders use EasyIMAP::Server#folders, to access the messages in a folder use EasyIMAP::Folder#messages, and to
13
+ access the Attachments on a Message use EasyIMAP::Message#attachments.
14
+
15
+ EasyIMAP::Server.connect('mail.example.com', :username => 'username, :password => 'password) do |conn|
16
+ inbox = conn.folders.first
17
+ inbox.messages.each do |m|
18
+ if m.attachments.any? && m.attachments.first.content_type == "application/vnd.ms-excel"
19
+ File.open("/tmp/first_attachment.xls", "w") do |f|
20
+ f.write(m.attachments.first.body)
21
+ end
21
22
  end
22
23
  end
23
24
  end
24
- end
25
25
 
26
26
  == REQUIREMENTS:
27
27
 
@@ -29,7 +29,12 @@ end
29
29
 
30
30
  == INSTALL:
31
31
 
32
- * sudo gem install tmail easy_imap
32
+ * sudo gem install easy_imap
33
+
34
+ == CONTRIBUTORS:
35
+
36
+ * Paul Stadig (pjstadig)
37
+ * Mark Lussier (intabulas)
33
38
 
34
39
  == LICENSE:
35
40
 
@@ -54,4 +59,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
54
59
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
55
60
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
56
61
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
57
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -8,9 +8,9 @@ $hoe = Hoe.new('easy_imap', EasyIMAP::VERSION) do |p|
8
8
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
9
  p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
10
  p.rubyforge_name = p.name # TODO this is default value
11
- # p.extra_deps = [
12
- # ['activesupport','>= 2.0.2'],
13
- # ]
11
+ p.extra_deps = [
12
+ ['tmail','>= 1.2.3.1'],
13
+ ]
14
14
  p.extra_dev_deps = [
15
15
  ['newgem', ">= #{::Newgem::VERSION}"]
16
16
  ]
@@ -9,6 +9,10 @@ module EasyIMAP
9
9
  @body.content_type
10
10
  end
11
11
 
12
+ def filename
13
+ @body.disposition_param("filename")
14
+ end
15
+
12
16
  # The body of this attachment.
13
17
  def body
14
18
  @body.body
@@ -5,10 +5,22 @@ module EasyIMAP
5
5
  class Server
6
6
  # Makes a connection to +host+ and returns an instance of Server.
7
7
  #
8
+ # It is recommended that you use this method to connect instead
9
+ # of Server#new, because at some time in the future there may be
10
+ # multiple server classes to smooth over "quirks" in IMAP
11
+ # implementations. This method should automatically select the
12
+ # right server class for you.
13
+ #
8
14
  # If given a block it will yield the Server instance to the
9
15
  # block, and then close the connection to the IMAP server
10
16
  # after the block has finished. Otherwise you must close the connection
11
17
  # yourself.
18
+ #
19
+ # Valid options are:
20
+ # port:: the server port on which to connect (defaults to 143)
21
+ # username:: the username with which to connect
22
+ # password:: the password with which to connect
23
+ # auth_type:: the authentication type with which to connect (defaults to LOGIN)
12
24
  def self.connect(host, options = nil)
13
25
  conn = Server.new(host, options)
14
26
  if block_given?
@@ -23,8 +35,12 @@ module EasyIMAP
23
35
  def initialize(host, options = nil)
24
36
  options ||= {}
25
37
  @host = host
26
- @conn = Net::IMAP.new(host)#, options[:port])
27
- @conn.authenticate(options[:auth_type] || "LOGIN", options[:username], options[:password])
38
+ @conn = Net::IMAP.new(host, options[:port] || 143)
39
+ if options[:auth_type].to_s.downcase == "plain"
40
+ @conn.login(options[:username], options[:password])
41
+ else
42
+ @conn.authenticate(options[:auth_type] || "LOGIN", options[:username], options[:password])
43
+ end
28
44
  end
29
45
 
30
46
  # Returns an array of Folder instances, one for each
data/lib/easy_imap.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module EasyIMAP
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  end
7
7
 
8
8
  require 'easy_imap/server'
data/script/txt2html ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.dirname(__FILE__) + "/../Rakefile"
4
+ require 'rubyforge'
5
+ require 'redcloth'
6
+ require 'syntax/convertors/html'
7
+ require 'erb'
8
+
9
+ download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
10
+ version = $hoe.version
11
+
12
+ def rubyforge_project_id
13
+ RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
14
+ end
15
+
16
+ class Fixnum
17
+ def ordinal
18
+ # teens
19
+ return 'th' if (10..19).include?(self % 100)
20
+ # others
21
+ case self % 10
22
+ when 1: return 'st'
23
+ when 2: return 'nd'
24
+ when 3: return 'rd'
25
+ else return 'th'
26
+ end
27
+ end
28
+ end
29
+
30
+ class Time
31
+ def pretty
32
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
33
+ end
34
+ end
35
+
36
+ def convert_syntax(syntax, source)
37
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
38
+ end
39
+
40
+ if ARGV.length >= 1
41
+ src, template = ARGV
42
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
43
+ else
44
+ puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
45
+ exit!
46
+ end
47
+
48
+ template = ERB.new(File.open(template).read)
49
+
50
+ title = nil
51
+ body = nil
52
+ File.open(src) do |fsrc|
53
+ title_text = fsrc.readline
54
+ body_text_template = fsrc.read
55
+ body_text = ERB.new(body_text_template).result(binding)
56
+ syntax_items = []
57
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
58
+ ident = syntax_items.length
59
+ element, syntax, source = $1, $2, $3
60
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
61
+ "syntax-temp-#{ident}"
62
+ }
63
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
64
+ body = RedCloth.new(body_text).to_html
65
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
66
+ end
67
+ stat = File.stat(src)
68
+ created = stat.ctime
69
+ modified = stat.mtime
70
+
71
+ $stdout << template.result(binding)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pjstadig-easy_imap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Stadig
@@ -9,9 +9,18 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-10 00:00:00 -08:00
12
+ date: 2008-12-17 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: tmail
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.2.3.1
23
+ version:
15
24
  - !ruby/object:Gem::Dependency
16
25
  name: newgem
17
26
  version_requirement:
@@ -56,6 +65,7 @@ files:
56
65
  - script/console
57
66
  - script/destroy
58
67
  - script/generate
68
+ - script/txt2html
59
69
  - spec/easy_imap_spec.rb
60
70
  - spec/spec.opts
61
71
  - spec/spec_helper.rb