mime_builder 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +11 -1
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +1 -7
- data/README.md +90 -20
- data/lib/mime_builder/file.rb +1 -3
- data/lib/mime_builder/json.rb +50 -0
- data/lib/mime_builder/text.rb +28 -1
- data/lib/mime_builder.rb +2 -1
- data/test/test_file.rb +3 -8
- data/test/test_json.rb +34 -0
- data/test/test_text.rb +8 -8
- metadata +120 -23
- data/Gemfile.lock +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c3bc85fb2a4fb507d444459978d274acd173ec68d1b0d3414878915fc9eba0b6
|
4
|
+
data.tar.gz: bc9cca5bd9c220ff653a426b7587cbb718f435c6d4ba6ceb46017bfad96c014b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76bb1ef43d0a13ae765ba4afd3585c9d1f5535a5283731b1c5aa4cf409bdeec19e93a013053a4242def7aeb0b62e82b98a670d23db59377a955e2a232f31320
|
7
|
+
data.tar.gz: 03204521aeb3731e27c5a886fbd6c07115c4f27f957bc73446a379ea534ee264ae3d82b1d075c1c601d632ff9b238d37744fd0409843a16dc549c44d71bc147c
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,14 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
|
+
- **2016-12-14**: 0.0.4
|
4
|
+
- Add JSON support
|
5
|
+
- **2016-05-30**: 0.0.3
|
6
|
+
- Add Text support for arbitrary content types
|
7
|
+
- Add Text support for content disposition
|
8
|
+
- **2016-01-25**: 0.0.2
|
9
|
+
- Improve docs
|
10
|
+
- Add tests
|
3
11
|
- **2016-01-23**: 0.0.1
|
4
|
-
- Initial release
|
12
|
+
- Initial release
|
13
|
+
- Add MIME part builder for files given a filepath
|
14
|
+
- Add MIME part builder for text given a string
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at johncwang@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,57 +2,114 @@ MIMEBuilder Ruby
|
|
2
2
|
================
|
3
3
|
|
4
4
|
[![Gem Version][gem-version-svg]][gem-version-link]
|
5
|
-
[![Build Status][build-status-svg]][build-status-
|
5
|
+
[![Build Status][build-status-svg]][build-status-url]
|
6
6
|
[![Coverage Status][coverage-status-svg]][coverage-status-link]
|
7
|
-
[![Dependency Status][dependency-status-svg]][dependency-status-link]
|
8
7
|
[![Code Climate][codeclimate-status-svg]][codeclimate-status-link]
|
9
8
|
[![Scrutinizer Code Quality][scrutinizer-status-svg]][scrutinizer-status-link]
|
9
|
+
|
10
10
|
[![Downloads][downloads-svg]][downloads-link]
|
11
11
|
[![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
|
12
12
|
[![License][license-svg]][license-link]
|
13
13
|
|
14
14
|
## Overview
|
15
15
|
|
16
|
-
This library creates
|
16
|
+
This library creates MIME parts from limited information. The MIME parts are based on the Ruby `mime` library and are all sub-classes of `MIME::Media`.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
### Via Bundler
|
21
|
+
|
22
|
+
Add `mime_builder` to Gemfile and then run `bundle`:
|
23
|
+
|
24
|
+
```sh
|
25
|
+
$ echo "gem 'mime_builder'" >> Gemfile
|
26
|
+
$ bundle
|
27
|
+
```
|
28
|
+
|
29
|
+
### Via RubyGems
|
30
|
+
|
31
|
+
```sh
|
32
|
+
$ gem install mime_builder
|
33
|
+
```
|
17
34
|
|
18
35
|
## Usage
|
19
36
|
|
20
37
|
### From Filepath
|
21
38
|
|
39
|
+
Builds a `MIME::Application` or `MIME::Type` object depending on whether base64 encoding is selected. This reads bytes from filesystem and populates the following MIME headers:
|
40
|
+
|
41
|
+
1. `Content-Disposition`
|
42
|
+
2. `Content-Transfer-Encoding`
|
43
|
+
3. `Content-Type`
|
44
|
+
|
45
|
+
This will optionally delete the following auto-generated header:
|
46
|
+
|
47
|
+
1. `Content-Id`
|
48
|
+
|
22
49
|
```ruby
|
23
|
-
builder = MIMEBuilder::Filepath
|
50
|
+
builder = MIMEBuilder::Filepath.new '/path/to/file'
|
24
51
|
mime_part = builder.mime
|
25
52
|
```
|
26
53
|
|
27
54
|
Options:
|
28
55
|
|
29
56
|
```ruby
|
30
|
-
builder = MIMEBuilder::Filepath(
|
57
|
+
builder = MIMEBuilder::Filepath.new(
|
31
58
|
'/path/to/file',
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
:is_attachment => true # add 'attachment' disposition
|
37
|
-
}
|
59
|
+
base64_encode: true, # base64 encode part
|
60
|
+
content_id_disable: true, # remove auto-generated Content-Id header
|
61
|
+
content_type: 'text/plain', # override auto-generated Content-Type
|
62
|
+
is_attachment: true # add 'attachment' disposition
|
38
63
|
)
|
39
64
|
```
|
40
65
|
|
41
66
|
### From String
|
42
67
|
|
68
|
+
Builds a `MIME::Text` object. This accepts a string and can optionally populate the following headers:
|
69
|
+
|
70
|
+
1. `Content-Disposition`
|
71
|
+
2. `Content-Type`
|
72
|
+
|
73
|
+
This will optionally delete the following auto-generated header:
|
74
|
+
|
75
|
+
1. `Content-Id`
|
76
|
+
|
43
77
|
```ruby
|
44
|
-
builder = MIMEBuilder::
|
78
|
+
builder = MIMEBuilder::Text.new 'Hi there!'
|
45
79
|
mime_part = builder.mime
|
46
80
|
```
|
47
81
|
|
48
82
|
Options:
|
49
83
|
|
50
84
|
```ruby
|
51
|
-
builder = MIMEBuilder::
|
85
|
+
builder = MIMEBuilder::Text.new(
|
52
86
|
'Hi there!',
|
53
|
-
|
54
|
-
|
55
|
-
|
87
|
+
content_id_disable: true, # remove auto-generated Content-Id header
|
88
|
+
content_type: 'text/html' # override auto-generated Content-Type
|
89
|
+
)
|
90
|
+
```
|
91
|
+
|
92
|
+
### From JSON
|
93
|
+
|
94
|
+
Builds a `MIME::Text` object. This accepts a string, hash, or array.
|
95
|
+
|
96
|
+
This will optionally:
|
97
|
+
|
98
|
+
1. delete the following auto-generated `Content-Id`
|
99
|
+
1. base64 encode the content
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
builder = MIMEBuilder::JSON.new { foo: 'bar' }
|
103
|
+
mime_part = builder.mime
|
104
|
+
```
|
105
|
+
|
106
|
+
Options:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
builder = MIMEBuilder::JSON.new(
|
110
|
+
{ foo: 'bar' },
|
111
|
+
content_id_disable: true, # remove auto-generated Content-Id header
|
112
|
+
base64_encode: false # disable default base64 encoding
|
56
113
|
)
|
57
114
|
```
|
58
115
|
|
@@ -60,6 +117,17 @@ builder = MIMEBuilder::Filepath(
|
|
60
117
|
|
61
118
|
See [CHANGELOG.md](CHANGELOG.md)
|
62
119
|
|
120
|
+
## Links
|
121
|
+
|
122
|
+
Project Repo
|
123
|
+
|
124
|
+
* https://github.com/grokify/mime-builder-ruby
|
125
|
+
|
126
|
+
MIME Library
|
127
|
+
|
128
|
+
* https://rubygems.org/gems/mime
|
129
|
+
* https://bitbucket.org/pachl/mime/src
|
130
|
+
|
63
131
|
## Contributions
|
64
132
|
|
65
133
|
Any reports of problems, comments or suggestions are most welcome.
|
@@ -68,7 +136,7 @@ Please report these on [Github](https://github.com/grokify/mime-builder-ruby)
|
|
68
136
|
|
69
137
|
## License
|
70
138
|
|
71
|
-
MIMEBuilder is available under an MIT-style license. See [LICENSE.
|
139
|
+
MIMEBuilder is available under an MIT-style license. See [LICENSE.md](LICENSE.md) for details.
|
72
140
|
|
73
141
|
MIMEBuilder © 2016 by John Wang
|
74
142
|
|
@@ -76,8 +144,10 @@ MIMEBuilder © 2016 by John Wang
|
|
76
144
|
[gem-version-link]: http://badge.fury.io/rb/mime_builder
|
77
145
|
[downloads-svg]: http://ruby-gem-downloads-badge.herokuapp.com/mime_builder
|
78
146
|
[downloads-link]: https://rubygems.org/gems/mime_builder
|
79
|
-
[build-status-svg]: https://
|
80
|
-
[build-status-
|
147
|
+
[build-status-svg]: https://github.com/grokify/mime-builder-ruby/workflows/ruby%20build/badge.svg?branch=master
|
148
|
+
[build-status-url]: https://github.com/grokify/mime-builder-ruby/actions
|
149
|
+
[codacy-svg]: https://api.codacy.com/project/badge/Grade/fa30d602e8ec4eae806bb43430989d65
|
150
|
+
[codacy-link]: https://www.codacy.com/app/grokify/mime-builder-ruby
|
81
151
|
[coverage-status-svg]: https://coveralls.io/repos/grokify/mime-builder-ruby/badge.svg?branch=master
|
82
152
|
[coverage-status-link]: https://coveralls.io/r/grokify/mime-builder-ruby?branch=master
|
83
153
|
[dependency-status-svg]: https://gemnasium.com/grokify/mime-builder-ruby.svg
|
@@ -89,4 +159,4 @@ MIMEBuilder © 2016 by John Wang
|
|
89
159
|
[docs-rubydoc-svg]: https://img.shields.io/badge/docs-rubydoc-blue.svg
|
90
160
|
[docs-rubydoc-link]: http://www.rubydoc.info/gems/mime_builder/
|
91
161
|
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
|
92
|
-
[license-link]: https://github.com/grokify/mime-builder-ruby/blob/master/LICENSE.
|
162
|
+
[license-link]: https://github.com/grokify/mime-builder-ruby/blob/master/LICENSE.md
|
data/lib/mime_builder/file.rb
CHANGED
@@ -7,7 +7,6 @@ module MIMEBuilder
|
|
7
7
|
attr_accessor :mime
|
8
8
|
attr_accessor :filepath
|
9
9
|
|
10
|
-
# {:base64_encode bool, :content_type string, :content_id_disable bool}
|
11
10
|
def initialize(filepath, opts = {})
|
12
11
|
if opts.key?(:base64_encode) && opts[:base64_encode]
|
13
12
|
@base64_encode = true
|
@@ -46,7 +45,6 @@ module MIMEBuilder
|
|
46
45
|
fail "File \"#{filepath}\" does not exist or cannot be read"
|
47
46
|
end
|
48
47
|
|
49
|
-
#File.open(filepath, 'rb:BINARY') { |f| f.read }
|
50
48
|
File.read(filepath)
|
51
49
|
end
|
52
50
|
|
@@ -67,7 +65,7 @@ module MIMEBuilder
|
|
67
65
|
|
68
66
|
def get_attachment_content_disposition(filepath = nil)
|
69
67
|
filename = File.basename(filepath.to_s)
|
70
|
-
if filename.
|
68
|
+
if filename.to_s.length > 0
|
71
69
|
return "attachment; filename=\"#{filename}\""
|
72
70
|
end
|
73
71
|
'attachment'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'mime'
|
3
|
+
require 'multi_json'
|
4
|
+
|
5
|
+
module MIMEBuilder
|
6
|
+
class JSON
|
7
|
+
BASE64_DEFAULT = true
|
8
|
+
CONTENTID_DEFAULT = false
|
9
|
+
|
10
|
+
attr_accessor :mime
|
11
|
+
attr_accessor :json
|
12
|
+
|
13
|
+
def initialize(content, opts = {})
|
14
|
+
@opts = opts
|
15
|
+
|
16
|
+
@json = content_to_json content
|
17
|
+
|
18
|
+
@json = Base64.encode64(@json) if encode_base64?
|
19
|
+
@mime = build_json_part @json
|
20
|
+
end
|
21
|
+
|
22
|
+
def content_to_json(content)
|
23
|
+
content = MultiJson.encode(content) if content.is_a?(Array) || content.is_a?(Hash)
|
24
|
+
content = content.to_s unless content.is_a? String
|
25
|
+
content
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_json_part(json)
|
29
|
+
json_part = MIME::Text.new(json)
|
30
|
+
json_part.headers.delete('Content-Id') if disable_content_id?
|
31
|
+
json_part.headers.set('Content-Type', 'application/json')
|
32
|
+
json_part.headers.set('Content-Transfer-Encoding', 'base64') if encode_base64?
|
33
|
+
return json_part
|
34
|
+
end
|
35
|
+
|
36
|
+
def encode_base64?
|
37
|
+
if @opts.key? :encode_base64
|
38
|
+
return @opts[:encode_base64] ? true : false
|
39
|
+
end
|
40
|
+
return BASE64_DEFAULT
|
41
|
+
end
|
42
|
+
|
43
|
+
def disable_content_id?
|
44
|
+
if @opts.key? :content_id_disable
|
45
|
+
return @opts[:content_id_disable] ? true : false
|
46
|
+
end
|
47
|
+
return !CONTENTID_DEFAULT
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/mime_builder/text.rb
CHANGED
@@ -7,9 +7,36 @@ module MIMEBuilder
|
|
7
7
|
|
8
8
|
def initialize(text, opts = {})
|
9
9
|
@text = text
|
10
|
-
|
10
|
+
|
11
|
+
if opts.key?(:content_type) && opts[:content_type].to_s.length>0
|
12
|
+
content_type = opts[:content_type]
|
13
|
+
if content_type =~ /^text\/([^\/]+)$/i
|
14
|
+
@mime = MIME::Text.new(text, $1.downcase)
|
15
|
+
else
|
16
|
+
raise "Unknown Content Type: " + opts[:content_type].to_s
|
17
|
+
end
|
18
|
+
else
|
19
|
+
@mime = MIME::Text.new(text, 'plain')
|
20
|
+
end
|
21
|
+
|
11
22
|
@mime.headers.delete('Content-Id') \
|
12
23
|
if opts.key?(:content_id_disable) && opts[:content_id_disable]
|
24
|
+
|
25
|
+
set_attachment_content_disposition(opts[:filename], opts[:is_attachment])
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_attachment_content_disposition(filename, is_attachment)
|
29
|
+
@mime.headers.set(
|
30
|
+
'Content-Disposition',
|
31
|
+
get_attachment_content_disposition(filename)
|
32
|
+
) if is_attachment
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_attachment_content_disposition(filename = nil)
|
36
|
+
if filename.to_s.length > 0
|
37
|
+
return "attachment; filename=\"#{filename}\""
|
38
|
+
end
|
39
|
+
'attachment'
|
13
40
|
end
|
14
41
|
end
|
15
42
|
end
|
data/lib/mime_builder.rb
CHANGED
data/test/test_file.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require './test/test_base.rb'
|
2
2
|
|
3
3
|
class MIMEBuilderFileTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_file_one
|
6
|
-
#assert_equal "bXlfYXBwX2tleTpteV9hcHBfc2VjcmV0", @rcsdk.send(:get_api_key)
|
7
|
-
end
|
8
|
-
|
9
4
|
def test_basic
|
10
5
|
filepath = './test/test_file.pdf'
|
11
6
|
filename = 'test_file.pdf'
|
@@ -21,8 +16,8 @@ class MIMEBuilderFileTest < Test::Unit::TestCase
|
|
21
16
|
end
|
22
17
|
|
23
18
|
def test_base64
|
24
|
-
filepath = './test/test_file.pdf'
|
25
19
|
filename = 'test_file.pdf'
|
20
|
+
filepath = File.join './test', filename
|
26
21
|
|
27
22
|
filepart = MIMEBuilder::Filepath.new(filepath, {:base64_encode => true})
|
28
23
|
|
@@ -47,8 +42,8 @@ class MIMEBuilderFileTest < Test::Unit::TestCase
|
|
47
42
|
end
|
48
43
|
|
49
44
|
def test_attachment
|
50
|
-
filepath = './test/test_file.pdf'
|
51
45
|
filename = 'test_file.pdf'
|
46
|
+
filepath = File.join './test', filename
|
52
47
|
|
53
48
|
filepart = MIMEBuilder::Filepath.new(filepath, {:is_attachment => true})
|
54
49
|
|
@@ -59,7 +54,7 @@ class MIMEBuilderFileTest < Test::Unit::TestCase
|
|
59
54
|
filepath = './test/test_file_nonexistent.pdf'
|
60
55
|
|
61
56
|
assert_raise do
|
62
|
-
|
57
|
+
MIMEBuilder::Filepath.new(filepath)
|
63
58
|
end
|
64
59
|
end
|
65
60
|
end
|
data/test/test_json.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require './test/test_base.rb'
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'multi_json'
|
5
|
+
|
6
|
+
class MIMEBuilderJsonTest < Test::Unit::TestCase
|
7
|
+
def test_base
|
8
|
+
test_json = { hello: 'world' }
|
9
|
+
|
10
|
+
json_part = MIMEBuilder::JSON.new test_json
|
11
|
+
|
12
|
+
assert_equal 'application/json', json_part.mime.headers.get('Content-Type')
|
13
|
+
assert_equal Base64.encode64(MultiJson.encode(test_json)), json_part.mime.body.to_s
|
14
|
+
assert_equal nil, json_part.mime.headers.get('Content-Id')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_no_base64
|
18
|
+
test_json = { hello: 'world' }
|
19
|
+
test_json = MultiJson.encode test_json
|
20
|
+
|
21
|
+
json_part = MIMEBuilder::JSON.new test_json, encode_base64: false
|
22
|
+
|
23
|
+
assert_equal test_json, json_part.mime.body.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_base64_raw
|
27
|
+
info = { hello: 'world' }
|
28
|
+
|
29
|
+
builder = MIMEBuilder::JSON.new info, encode_base64: true
|
30
|
+
|
31
|
+
assert_equal 'eyJoZWxsbyI6IndvcmxkIn0='.encode('iso-8859-1'), builder.mime.body.to_s.strip
|
32
|
+
assert_equal true, builder.encode_base64?
|
33
|
+
end
|
34
|
+
end
|
data/test/test_text.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
require './test/test_base.rb'
|
2
2
|
|
3
3
|
class MIMEBuilderTextTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_file_one
|
6
|
-
#assert_equal "bXlfYXBwX2tleTpteV9hcHBfc2VjcmV0", @rcsdk.send(:get_api_key)
|
7
|
-
end
|
8
|
-
|
9
4
|
def test_contenttype
|
10
|
-
|
5
|
+
test_text = 'Hello world!'
|
11
6
|
|
12
|
-
filepart = MIMEBuilder::Text.new
|
7
|
+
filepart = MIMEBuilder::Text.new test_text
|
13
8
|
|
14
9
|
assert_equal 'text/plain', filepart.mime.headers.get('Content-Type')
|
15
10
|
|
16
11
|
assert_equal test_text, filepart.mime.body.to_s
|
17
12
|
end
|
18
13
|
|
19
|
-
|
14
|
+
def test_content_id_disable
|
15
|
+
filepart = MIMEBuilder::Text.new 'Hello world!', :content_id_disable => true
|
16
|
+
|
17
|
+
assert_equal nil, filepart.mime.headers.get('Content-Id')
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,84 +1,181 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mime_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.4.3
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
29
|
+
version: '0.4'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.4.3
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: mime-types
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- -
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
39
|
+
version: '3.1'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- -
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.1'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: multi_json
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.12.1
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.12.1
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: coveralls
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
39
79
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
80
|
+
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: mocha
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rake
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '12'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '12'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: simplecov
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: test-unit
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '3'
|
41
137
|
description: Helper library to build MIME parts
|
42
138
|
email: johncwang@gmail.com
|
43
139
|
executables: []
|
44
140
|
extensions: []
|
45
141
|
extra_rdoc_files: []
|
46
142
|
files:
|
47
|
-
- lib/mime_builder/file.rb
|
48
|
-
- lib/mime_builder/text.rb
|
49
|
-
- lib/mime_builder.rb
|
50
143
|
- CHANGELOG.md
|
144
|
+
- CODE_OF_CONDUCT.md
|
51
145
|
- Gemfile
|
52
|
-
- Gemfile.lock
|
53
146
|
- LICENSE.txt
|
54
|
-
- Rakefile
|
55
147
|
- README.md
|
148
|
+
- Rakefile
|
149
|
+
- lib/mime_builder.rb
|
150
|
+
- lib/mime_builder/file.rb
|
151
|
+
- lib/mime_builder/json.rb
|
152
|
+
- lib/mime_builder/text.rb
|
56
153
|
- test/test_base.rb
|
57
154
|
- test/test_file.pdf
|
58
155
|
- test/test_file.rb
|
156
|
+
- test/test_json.rb
|
59
157
|
- test/test_text.rb
|
60
|
-
homepage: https://github.com/grokify/
|
158
|
+
homepage: https://github.com/grokify/mime-builder-ruby
|
61
159
|
licenses:
|
62
160
|
- MIT
|
63
161
|
metadata: {}
|
64
|
-
post_install_message:
|
162
|
+
post_install_message:
|
65
163
|
rdoc_options: []
|
66
164
|
require_paths:
|
67
165
|
- lib
|
68
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
167
|
requirements:
|
70
|
-
- -
|
168
|
+
- - ">="
|
71
169
|
- !ruby/object:Gem::Version
|
72
170
|
version: '0'
|
73
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
172
|
requirements:
|
75
|
-
- -
|
173
|
+
- - ">="
|
76
174
|
- !ruby/object:Gem::Version
|
77
175
|
version: '0'
|
78
176
|
requirements: []
|
79
|
-
|
80
|
-
|
81
|
-
signing_key:
|
177
|
+
rubygems_version: 3.0.4
|
178
|
+
signing_key:
|
82
179
|
specification_version: 4
|
83
180
|
summary: MIME Builder is a helper to build MIME parts
|
84
181
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
coveralls (0.8.1)
|
5
|
-
json (~> 1.8)
|
6
|
-
rest-client (>= 1.6.8, < 2)
|
7
|
-
simplecov (~> 0.10.0)
|
8
|
-
term-ansicolor (~> 1.3)
|
9
|
-
thor (~> 0.19.1)
|
10
|
-
docile (1.1.5)
|
11
|
-
domain_name (0.5.24)
|
12
|
-
unf (>= 0.0.5, < 1.0.0)
|
13
|
-
http-cookie (1.0.2)
|
14
|
-
domain_name (~> 0.5)
|
15
|
-
json (1.8.3)
|
16
|
-
metaclass (0.0.4)
|
17
|
-
mime (0.4.2)
|
18
|
-
mime-types (2.6.2)
|
19
|
-
mocha (1.1.0)
|
20
|
-
metaclass (~> 0.0.1)
|
21
|
-
netrc (0.10.3)
|
22
|
-
power_assert (0.2.4)
|
23
|
-
rake (10.4.2)
|
24
|
-
rest-client (1.8.0)
|
25
|
-
http-cookie (>= 1.0.2, < 2.0)
|
26
|
-
mime-types (>= 1.16, < 3.0)
|
27
|
-
netrc (~> 0.7)
|
28
|
-
simplecov (0.10.0)
|
29
|
-
docile (~> 1.1.0)
|
30
|
-
json (~> 1.8)
|
31
|
-
simplecov-html (~> 0.10.0)
|
32
|
-
simplecov-html (0.10.0)
|
33
|
-
term-ansicolor (1.3.0)
|
34
|
-
tins (~> 1.0)
|
35
|
-
test-unit (3.1.4)
|
36
|
-
power_assert
|
37
|
-
thor (0.19.1)
|
38
|
-
tins (1.5.2)
|
39
|
-
unf (0.1.4)
|
40
|
-
unf_ext
|
41
|
-
unf_ext (0.0.7.1)
|
42
|
-
|
43
|
-
PLATFORMS
|
44
|
-
ruby
|
45
|
-
|
46
|
-
DEPENDENCIES
|
47
|
-
coveralls
|
48
|
-
mime
|
49
|
-
mime-types
|
50
|
-
mocha
|
51
|
-
rake
|
52
|
-
simplecov
|
53
|
-
test-unit
|