jmcarbo-imapstore 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -6,6 +6,24 @@
6
6
 
7
7
  ruby gem to use an imap server as a file storage device
8
8
 
9
+ == USAGE
10
+
11
+ * recursive storign files
12
+
13
+ imapstore -c put -r -d <folder> -f <files>
14
+
15
+ * snipplets
16
+
17
+ imapstore -c snipplet -s <subject> -d <folder> -t <text>
18
+
19
+ * verbose output
20
+
21
+ -x
22
+
23
+ * select imap account
24
+
25
+ -i <account in config.yml>
26
+
9
27
  == FEATURES/PROBLEMS:
10
28
 
11
29
  * many
data/bin/imapstore CHANGED
@@ -7,8 +7,8 @@ require 'getoptions'
7
7
  #old versions of ruby require this
8
8
  require 'rdoc/ri/ri_paths'
9
9
 
10
- COMMAND_LIST = ['ls', 'rm', 'put', 'get', 'rmdir', 'mkdir', 'quota', 'setup' ]
11
- opt = GetOptions.new(%w( help subject=s command=s dir=s files=@s recursive! versioned! all! imapstore:s x! ))
10
+ COMMAND_LIST = ['ls', 'rm', 'put', 'get', 'rmdir', 'mkdir', 'quota', 'setup', 'snipplet' ]
11
+ opt = GetOptions.new(%w( help subject=s command=s dir=s files=@s recursive! versioned! all! imapstore:s x! text=s))
12
12
 
13
13
  if opt['help']
14
14
  puts "Usage: imapstore -c <#{COMMAND_LIST.join(', ')}> -s <subject> -d <folder> -f <file list or glob> "
@@ -26,7 +26,7 @@ recursive = opt['recursive'] || false
26
26
  all = opt['all'] || false
27
27
  versioned = opt['versioned']
28
28
  verbose = opt['x'] || false
29
-
29
+ text = opt['text'] || "no text"
30
30
 
31
31
  begin
32
32
  if COMMAND_LIST.include? command
@@ -88,6 +88,9 @@ if COMMAND_LIST.include? command
88
88
  when 'quota':
89
89
  q = i.quota("INBOX")
90
90
  puts "Used #{q[1]['usage'].to_s} of #{q[1]['quota'].to_s}"
91
+ when 'snipplet':
92
+
93
+ i.snipplet(subject,text,dir, nil)
91
94
  else
92
95
  puts "unimplemented command #{command}"
93
96
  end
data/lib/imapstore.rb CHANGED
@@ -4,6 +4,6 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'imapstore/imapstore.rb'
5
5
 
6
6
  module IMAPSTORE
7
- VERSION = '0.4.1'
7
+ VERSION = '0.4.2'
8
8
 
9
9
  end
@@ -111,6 +111,35 @@ END
111
111
  @imap_port = aConfig[imapstore]['imap_port']
112
112
  #END CONFIGURATION SECTION
113
113
  end
114
+
115
+ def snipplet(subject = "snipplet", body = "", folder="snipplets", file = nil)
116
+ puts "Storing snipplet" if @verbose
117
+
118
+ mail = TMail::Mail.new
119
+ mail.to = @email
120
+ mail.from = @email
121
+ mail.subject = subject
122
+
123
+ mail.date = Time.now
124
+ mail.mime_version = '1.0'
125
+
126
+ mailpart1=TMail::Mail.new
127
+ mailpart1.set_content_type 'text', 'plain'
128
+ mailpart1.body = body
129
+ mail.parts << mailpart1
130
+ mail.set_content_type 'multipart', 'mixed'
131
+
132
+ # if file && FileTest.exists?(file)
133
+ # mailpart=TMail::Mail.new
134
+ # mailpart.body = Base64.encode64(chunk.to_s)
135
+ # mailpart.transfer_encoding="Base64"
136
+ # mailpart['Content-Disposition'] = "attachment; filename=#{CGI::escape(basename)}"
137
+ # mail.parts.push(mailpart)
138
+ # end
139
+ @imap.create(folder) if !@imap.list("", folder)
140
+ @imap.append(folder, mail.to_s, [:Seen], Time.now)
141
+
142
+ end
114
143
 
115
144
  def store_file_chunk( file, folder = "INBOX", subject = "", chunk=nil, chunk_no=0, max_chunk_no=0 )
116
145
  if(max_chunk_no>0)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jmcarbo-imapstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joan Marc Carbo Arnau
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-10 00:00:00 -08:00
12
+ date: 2009-01-11 00:00:00 -08:00
13
13
  default_executable: imapstore
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency