gmailer 0.0.6 → 0.0.7
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/CHANGES +5 -0
- data/README +39 -0
- data/gmailer.rb +121 -4
- metadata +2 -2
data/CHANGES
CHANGED
data/README
CHANGED
@@ -145,6 +145,45 @@ GMailer.connect(:username=>name,:password=>pwd) do |g|
|
|
145
145
|
g.unarchive(msgid)
|
146
146
|
end
|
147
147
|
|
148
|
+
=== Mark read and unread a message
|
149
|
+
|
150
|
+
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
151
|
+
#mark a message as read
|
152
|
+
g.mark_read(msgid)
|
153
|
+
|
154
|
+
#mark a message as unread
|
155
|
+
g.mark_unread(msgid)
|
156
|
+
end
|
157
|
+
|
158
|
+
=== Report spam and reverse
|
159
|
+
|
160
|
+
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
161
|
+
#report a message as not spam
|
162
|
+
g.report_spam(msgid)
|
163
|
+
|
164
|
+
#report a message as not spam
|
165
|
+
g.not_spam(msgid)
|
166
|
+
end
|
167
|
+
|
168
|
+
=== Trash In & Out and delete a message
|
169
|
+
|
170
|
+
GMailer.connect(:username=>name,:password=>pwd) do |g|
|
171
|
+
#move a message to trash
|
172
|
+
g.trash_in(msgid)
|
173
|
+
|
174
|
+
#move a message from trash to inbox
|
175
|
+
g.trash_out(msgid)
|
176
|
+
|
177
|
+
#delete a trash message forever
|
178
|
+
g.delete_trash(msgid)
|
179
|
+
|
180
|
+
#delete a spam message forever
|
181
|
+
g.delete_spam(msgid)
|
182
|
+
|
183
|
+
#delete a message forever
|
184
|
+
g.delete_message(msgid)
|
185
|
+
end
|
186
|
+
|
148
187
|
== Class Methods
|
149
188
|
GMailer.new(charset='UTF-8')
|
150
189
|
Returns a new GMailer object and set up charset.
|
data/gmailer.rb
CHANGED
@@ -46,11 +46,11 @@ GM_ACT_UNTRASH = 17
|
|
46
46
|
GM_ACT_UNDRAFT = 18
|
47
47
|
GM_ACT_TRASHMSG = 19 # trash individual message
|
48
48
|
GM_ACT_DELSPAM = 20 # delete spam, forever
|
49
|
-
|
49
|
+
GM_ACT_DELTRASH = 21 # delete trash message, forever
|
50
50
|
|
51
51
|
class GMailer
|
52
52
|
|
53
|
-
VERSION = "0.0.
|
53
|
+
VERSION = "0.0.7"
|
54
54
|
|
55
55
|
@cookie_str
|
56
56
|
@login
|
@@ -642,6 +642,123 @@ class GMailer
|
|
642
642
|
end
|
643
643
|
end
|
644
644
|
|
645
|
+
#
|
646
|
+
# return boolean
|
647
|
+
# param string msgid
|
648
|
+
# desc report a message as spam
|
649
|
+
#
|
650
|
+
def report_spam(msgid)
|
651
|
+
if is_connected()
|
652
|
+
perform_action(GM_ACT_SPAM,msgid, '')
|
653
|
+
else
|
654
|
+
false
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
#
|
659
|
+
# return boolean
|
660
|
+
# param string msgid
|
661
|
+
# desc report a message as not spam
|
662
|
+
#
|
663
|
+
def not_spam(msgid)
|
664
|
+
if is_connected()
|
665
|
+
perform_action(GM_ACT_UNSPAM,msgid, '')
|
666
|
+
else
|
667
|
+
false
|
668
|
+
end
|
669
|
+
end
|
670
|
+
|
671
|
+
#
|
672
|
+
# return boolean
|
673
|
+
# param string msgid
|
674
|
+
# desc delete a spam message forever
|
675
|
+
#
|
676
|
+
def delete_spam(msgid)
|
677
|
+
if is_connected()
|
678
|
+
perform_action(GM_ACT_DELSPAM,msgid, '')
|
679
|
+
else
|
680
|
+
false
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
684
|
+
#
|
685
|
+
# return boolean
|
686
|
+
# param string msgid
|
687
|
+
# desc mark a message as read
|
688
|
+
#
|
689
|
+
def mark_read(msgid)
|
690
|
+
if is_connected()
|
691
|
+
perform_action(GM_ACT_READ,msgid, '')
|
692
|
+
else
|
693
|
+
false
|
694
|
+
end
|
695
|
+
end
|
696
|
+
|
697
|
+
#
|
698
|
+
# return boolean
|
699
|
+
# param string msgid
|
700
|
+
# desc mark a message as unread
|
701
|
+
#
|
702
|
+
def mark_unread(msgid)
|
703
|
+
if is_connected()
|
704
|
+
perform_action(GM_ACT_UNREAD,msgid, '')
|
705
|
+
else
|
706
|
+
false
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
710
|
+
#
|
711
|
+
# return boolean
|
712
|
+
# param string msgid
|
713
|
+
# desc move a message to trash
|
714
|
+
#
|
715
|
+
def trash_in(msgid)
|
716
|
+
if is_connected()
|
717
|
+
perform_action(GM_ACT_TRASH,msgid, '')
|
718
|
+
else
|
719
|
+
false
|
720
|
+
end
|
721
|
+
end
|
722
|
+
|
723
|
+
#
|
724
|
+
# return boolean
|
725
|
+
# param string msgid
|
726
|
+
# desc move a message from trash to inbox
|
727
|
+
#
|
728
|
+
def trash_out(msgid)
|
729
|
+
if is_connected()
|
730
|
+
perform_action(GM_ACT_UNTRASH,msgid, '')
|
731
|
+
else
|
732
|
+
false
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
#
|
737
|
+
# return boolean
|
738
|
+
# param string msgid
|
739
|
+
# desc delete a trash message forever
|
740
|
+
#
|
741
|
+
def delete_trash(msgid)
|
742
|
+
if is_connected()
|
743
|
+
perform_action(GM_ACT_DELTRASH,msgid, '')
|
744
|
+
else
|
745
|
+
false
|
746
|
+
end
|
747
|
+
end
|
748
|
+
|
749
|
+
#
|
750
|
+
# return boolean
|
751
|
+
# param string msgid
|
752
|
+
# desc delete a message forever
|
753
|
+
#
|
754
|
+
def delete_message(msgid)
|
755
|
+
if is_connected()
|
756
|
+
perform_action(GM_ACT_DELFOREVER,msgid, '')
|
757
|
+
else
|
758
|
+
false
|
759
|
+
end
|
760
|
+
end
|
761
|
+
|
645
762
|
#
|
646
763
|
# return boolean
|
647
764
|
# param string msgid
|
@@ -861,7 +978,7 @@ class GMailer
|
|
861
978
|
end
|
862
979
|
postdata += "&vp="
|
863
980
|
|
864
|
-
if [GM_ACT_UNTRASH,GM_ACT_DELFOREVER,
|
981
|
+
if [GM_ACT_UNTRASH,GM_ACT_DELFOREVER,GM_ACT_DELTRASH].include?(act)
|
865
982
|
link = GM_LNK_GMAIL+"?search=trash&view=tl&start=0"
|
866
983
|
elsif (act == GM_ACT_DELSPAM)
|
867
984
|
link = GM_LNK_GMAIL+"?search=spam&view=tl&start=0"
|
@@ -1107,7 +1224,7 @@ class GMailSnapshot
|
|
1107
1224
|
"sender"=>decode(strip_tags(t[4])),
|
1108
1225
|
"flag"=>t[5],
|
1109
1226
|
"subject"=>decode(strip_tags(t[6])),
|
1110
|
-
"snippet"=>decode(t[7]),
|
1227
|
+
"snippet"=>decode(t[7].gsub('"','"').gsub('…','...')),
|
1111
1228
|
"labels"=>t[8].empty? ? [] : t[8].map{|tt|decode(tt)},
|
1112
1229
|
"attachment"=>t[9].empty? ? []: decode(t[9]).split(","),
|
1113
1230
|
"msgid"=>t[10]
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: gmailer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2005-08-
|
6
|
+
version: 0.0.7
|
7
|
+
date: 2005-08-30
|
8
8
|
summary: "An class interface of the Google's webmail service"
|
9
9
|
require_paths:
|
10
10
|
- ''
|