maildrop 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/maildrop.rb +1 -0
- data/lib/maildrop/http.rb +7 -11
- data/lib/maildrop/mailbox.rb +1 -7
- data/lib/maildrop/models/mailbox.rb +15 -7
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfe3a7e30050f4c6ee1ec095b9a12bc2bb94b1e4
|
4
|
+
data.tar.gz: ad850fb0b6efcd8e2ad54738751508ad4212a4e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fae2dc7306af13833b569ba9a3e8112657da59c6e2b87b8a28566a9e1475daaa1dcaeb2487ac53e1eac86e91d87965137415aac4d4712e81e7b424eb1ac4db9d
|
7
|
+
data.tar.gz: 446afc3a8dc33fedebcee487d5341496aa1a4923ab931247a38164fd11c65070c5be5f6d9d6c2ba74b09bceea42abdf745e08dafd12fb6ad62328401893a37d0
|
data/lib/maildrop.rb
CHANGED
data/lib/maildrop/http.rb
CHANGED
@@ -4,33 +4,29 @@ module Maildrop
|
|
4
4
|
class RequestError < StandardError; end
|
5
5
|
|
6
6
|
def get(url)
|
7
|
-
|
7
|
+
response = request(url)
|
8
|
+
handle_response(response)
|
8
9
|
end
|
9
10
|
|
10
11
|
private
|
11
12
|
|
12
13
|
def request(url)
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def perform_request(uri)
|
18
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
19
|
-
http.get(uri.request_uri)
|
14
|
+
url = generate_url(url)
|
15
|
+
::HTTP.get(url)
|
20
16
|
end
|
21
17
|
|
22
18
|
def generate_url(url)
|
23
|
-
|
19
|
+
"#{base_url}/#{url}"
|
24
20
|
end
|
25
21
|
|
26
22
|
def base_url
|
27
|
-
'
|
23
|
+
'https://maildrop.cc/api/inbox'
|
28
24
|
end
|
29
25
|
|
30
26
|
def handle_response(response)
|
31
27
|
case response.code.to_i
|
32
28
|
when 200
|
33
|
-
response.
|
29
|
+
response.to_s
|
34
30
|
when 404
|
35
31
|
raise NotFound
|
36
32
|
else
|
data/lib/maildrop/mailbox.rb
CHANGED
@@ -13,13 +13,7 @@ module Maildrop
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def build_model(name)
|
16
|
-
|
17
|
-
Maildrop::Models::Mailbox.new(name, data)
|
18
|
-
end
|
19
|
-
|
20
|
-
def download_mailbox(name)
|
21
|
-
http = Maildrop::HTTP.new
|
22
|
-
http.get(name)
|
16
|
+
Maildrop::Models::Mailbox.new(name)
|
23
17
|
end
|
24
18
|
end
|
25
19
|
end
|
@@ -1,22 +1,30 @@
|
|
1
1
|
module Maildrop::Models
|
2
2
|
class Mailbox
|
3
|
-
attr_reader :name
|
3
|
+
attr_reader :name
|
4
4
|
|
5
|
-
def initialize(name
|
5
|
+
def initialize(name)
|
6
6
|
@name = name
|
7
|
-
emails = JSON.parse(data)
|
8
|
-
@emails = emails.map do |email|
|
9
|
-
data = download_email(email['id'])
|
10
|
-
Maildrop::Models::Email.new(data)
|
11
|
-
end
|
12
7
|
end
|
13
8
|
|
14
9
|
def address
|
15
10
|
"#{name}@maildrop.cc"
|
16
11
|
end
|
17
12
|
|
13
|
+
def emails
|
14
|
+
emails = JSON.parse(mailbox_data)
|
15
|
+
emails.map do |email|
|
16
|
+
data = download_email(email['id'])
|
17
|
+
Maildrop::Models::Email.new(data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
18
21
|
private
|
19
22
|
|
23
|
+
def mailbox_data
|
24
|
+
http = Maildrop::HTTP.new
|
25
|
+
http.get(@name)
|
26
|
+
end
|
27
|
+
|
20
28
|
def download_email(id)
|
21
29
|
http = Maildrop::HTTP.new
|
22
30
|
response = http.get("#{@name}/#{id}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maildrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Melvin Lammerts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -30,6 +30,26 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.6.4
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: http
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.0.3
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.0.3
|
33
53
|
description: Ruby interface to MailDrop for quick, disposable mailboxes.
|
34
54
|
email: hi@melvin.sh
|
35
55
|
executables: []
|