mime_builder 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -8
- data/lib/mime_builder.rb +1 -1
- data/lib/mime_builder/file.rb +0 -2
- data/test/test_text.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e8c66cc9be954dfe63a9f841f57ef99dd8beb5c
|
4
|
+
data.tar.gz: 4507ce85c36fff99737abbc386e2b9571b5e068c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76916c33698592a13092c35ed30dd62894c61b0acb24ae3516f13beb250446b6ba0919f7dadd4ff1b71926be3fe52f5a1bc1ad46f55f6715b76ca04c06846039
|
7
|
+
data.tar.gz: 3cc0cff3eb0789ca6d0013fd4faab341a1b0f4008d490d408d2e98a95ca636143d214b04df16447f830aec811ff3adf1a3a7fc7764adc3afdda85b6331a0c01f
|
data/README.md
CHANGED
@@ -15,12 +15,39 @@ MIMEBuilder Ruby
|
|
15
15
|
|
16
16
|
This library creates `mime` parts from limited information.
|
17
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
|
+
```
|
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
|
|
@@ -40,20 +67,21 @@ builder = MIMEBuilder::Filepath(
|
|
40
67
|
|
41
68
|
### From String
|
42
69
|
|
70
|
+
Builds a `MIME::Text` object.
|
71
|
+
|
72
|
+
This will optionally delete the following auto-generated header:
|
73
|
+
|
74
|
+
1. `Content-Id`
|
75
|
+
|
43
76
|
```ruby
|
44
|
-
builder = MIMEBuilder::
|
77
|
+
builder = MIMEBuilder::Text.new 'Hi there!'
|
45
78
|
mime_part = builder.mime
|
46
79
|
```
|
47
80
|
|
48
81
|
Options:
|
49
82
|
|
50
83
|
```ruby
|
51
|
-
builder = MIMEBuilder::
|
52
|
-
'Hi there!',
|
53
|
-
{
|
54
|
-
:content_id_disable => true, # remove auto-generated Content-Id header
|
55
|
-
}
|
56
|
-
)
|
84
|
+
builder = MIMEBuilder::Text.new 'Hi there!', :content_id_disable => true
|
57
85
|
```
|
58
86
|
|
59
87
|
## Change Log
|
data/lib/mime_builder.rb
CHANGED
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
|
|
data/test/test_text.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
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
|
|
@@ -16,4 +11,9 @@ class MIMEBuilderTextTest < Test::Unit::TestCase
|
|
16
11
|
assert_equal test_text, filepart.mime.body.to_s
|
17
12
|
end
|
18
13
|
|
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
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime
|