gmail_attach_many 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/gmail_attach_many.gemspec +25 -0
- data/lib/gmail_attach_many.rb +66 -0
- data/lib/gmail_attach_many/version.rb +3 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cc73c48a39555839c905f4ed6f185ff55a63e4ee
|
4
|
+
data.tar.gz: 32914a0f760aa0b72d39a74d96a1ddf0b9aa02b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21913c2636a283c7e703edafe0e452944f8f54f33760ac21fd80980cadccb0686875e0d6cf455fd651fd3eed22dffee4b20c5a60c8b1080f081ad75b844db126
|
7
|
+
data.tar.gz: 1578aa766f12c0afeb55bdaca5cec400f082525257a5fdfe718703b2815822adb17524cde0e61a664186c55f29fabedcb544fdcd5e220ce032a5caa98dd252c3
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Monarch Jhaveri
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# GmailAttachMany
|
2
|
+
|
3
|
+
Easily attach many files to Gmail messages. If the files total more than 25 MB, they will be sorted alphabetically and distributed amongst multiple new messages, which you can then send.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'gmail_attach_many'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install gmail_attach_many
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
To use:
|
22
|
+
|
23
|
+
```
|
24
|
+
gmail = Gmail.connect('username', 'password')
|
25
|
+
emailArray = gmail.attach_many('./images/*.jpg')
|
26
|
+
emailArray.messages_to = 'recipient@domain.com'
|
27
|
+
emailArray.messages_subject = 'The Subject Line Goes Here'
|
28
|
+
#number the messages, i.e. "Email 1/3", "Email 2/3", "Email 3/3"
|
29
|
+
emailArray.messages_number
|
30
|
+
# OR, you can do this instead for the same effect
|
31
|
+
emailArray.messages_subject_and_number 'The Subject Line Goes Here'
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it ( https://github.com/[my-github-username]/gmail_attach_many/fork )
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gmail_attach_many/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gmail_attach_many"
|
8
|
+
spec.version = GmailAttachMany::VERSION
|
9
|
+
spec.authors = ["Monarch Jhaveri"]
|
10
|
+
spec.email = ["monarchjhaveri@gmail.com"]
|
11
|
+
spec.summary = "Attach multiple files to messages"
|
12
|
+
spec.description = "Easily attach many files to Gmail messages. If the files total more than 25 MB, they will be sorted alphabetically and distributed amongst multiple new messages, which you can then send."
|
13
|
+
spec.homepage = "https://github.com/monarchjhaveri/gmail_attach_many"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "gmail", ">= 0.4.0"
|
25
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "gmail"
|
2
|
+
require "gmail_attach_many/version"
|
3
|
+
|
4
|
+
module GmailAttachMany
|
5
|
+
class MessageArray < Array
|
6
|
+
def messages_to (recipientString)
|
7
|
+
self.each do |m|
|
8
|
+
m.to recipientString
|
9
|
+
end
|
10
|
+
end
|
11
|
+
def messages_subject= (subjectString)
|
12
|
+
self.each do |m|
|
13
|
+
m.subject = subjectString
|
14
|
+
end
|
15
|
+
end
|
16
|
+
def messages_number
|
17
|
+
self.each_index do |m|
|
18
|
+
m.subject = m.subject + "#{m+1}/#{self.length+1}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
def messages_subject_and_number= (subjectString)
|
22
|
+
self.messages_subject = (subjectString)
|
23
|
+
self.messages_number
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Gmail::Client::Plain
|
29
|
+
def attach_many (pathPattern)
|
30
|
+
|
31
|
+
total_limit = 25*1024*1024
|
32
|
+
messageArray = GmailAttachMany::MessageArray.new
|
33
|
+
attachments = []
|
34
|
+
|
35
|
+
files = Dir.glob(pathPattern).find_all {|f| File.file? f}
|
36
|
+
files.sort_by!{ |m| m.downcase }
|
37
|
+
|
38
|
+
files.inject(0) do |sum, f|
|
39
|
+
if !(File.size(f) > total_limit)
|
40
|
+
total = sum + File.size(f)
|
41
|
+
if total > total_limit
|
42
|
+
message = self.compose
|
43
|
+
attachments.each do |a|
|
44
|
+
message.add_file a
|
45
|
+
end
|
46
|
+
messageArray.push message
|
47
|
+
attachments = [f]
|
48
|
+
total = File.size(f)
|
49
|
+
else
|
50
|
+
attachments.push f
|
51
|
+
if (files.find_index f) == (files.length - 1)
|
52
|
+
message = self.compose
|
53
|
+
attachments.each do |a|
|
54
|
+
message.add_file a
|
55
|
+
end
|
56
|
+
messageArray.push message
|
57
|
+
end
|
58
|
+
total
|
59
|
+
end
|
60
|
+
else
|
61
|
+
raise "One of the files selected is too big to attach to an email. File name: #{f}. File size: #{File.size(f)} Limit is #{total_limit} bytes."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
return messageArray
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gmail_attach_many
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Monarch Jhaveri
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gmail
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.4.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.4.0
|
55
|
+
description: Easily attach many files to Gmail messages. If the files total more than
|
56
|
+
25 MB, they will be sorted alphabetically and distributed amongst multiple new messages,
|
57
|
+
which you can then send.
|
58
|
+
email:
|
59
|
+
- monarchjhaveri@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- gmail_attach_many.gemspec
|
70
|
+
- lib/gmail_attach_many.rb
|
71
|
+
- lib/gmail_attach_many/version.rb
|
72
|
+
homepage: https://github.com/monarchjhaveri/gmail_attach_many
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Attach multiple files to messages
|
96
|
+
test_files: []
|