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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1b242e017dbe6bc717e94d6ef217bab7a7ff6d2
4
- data.tar.gz: fefd7653cf050420e71d3f1434376a8793a9759b
3
+ metadata.gz: 1e8c66cc9be954dfe63a9f841f57ef99dd8beb5c
4
+ data.tar.gz: 4507ce85c36fff99737abbc386e2b9571b5e068c
5
5
  SHA512:
6
- metadata.gz: 1f7e5c60b154659606764c9fb73cf333c194e0aec35ca931a37e292a16f4188b01907ad88e7efdeb6bf1b0088600150b0bb3cf947626804f6fda31d1c2fcf2ea
7
- data.tar.gz: 1e9ff54c3742e05f4be0ddfa5ee9fa2efd9b6cc64b38f19c0d81ff513a4d1b009dd6015e3f17e9860ceaaaf4322a4040e8a1739870dd33ebe986b19ab4bc0319
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('/path/to/file')
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::Filepath('Hi there!')
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::Filepath(
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
@@ -1,5 +1,5 @@
1
1
  module MIMEBuilder
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
 
4
4
  autoload :Filepath, 'mime_builder/file'
5
5
  autoload :Text, 'mime_builder/text'
@@ -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.1
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-23 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime