maildrop 0.1.0.pre → 0.1.0

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: 816d3fba6364b09f26b1b72acb80e5bfb3a81e7b
4
- data.tar.gz: f6b0e3f5c9994326b9545f7449f76012789f08dd
3
+ metadata.gz: b2ba3c55371997589e6e2890e437480d95106406
4
+ data.tar.gz: 917e18e2a6d2576ed190c82c119b6f9c0a5a819e
5
5
  SHA512:
6
- metadata.gz: 0d6e6db3cd2840ee0079df70754a2cea00ffd5af41208df9c4c6bfa6f75a8e6ef0969de5862f376b597993e706b1ecccececee2c452cb22af999b19d9b353cf5
7
- data.tar.gz: 32c5df24b504b8f8b564328ee65669d77170b30c1172049ccfda648ea778b5eed2ffb8e5616f7080d8be72f945b5bb8815c73cd548243d46d801de7ab238d88b
6
+ metadata.gz: 28d28fa8ae29b5a7a561f9cdb32d7c643a2bca0b93c1f11c8960c423c7fa9e9f3985e083ab3931187bb05aee56ac683e1215fdfa685a0b2bb48fcacaa5323005
7
+ data.tar.gz: c96c725959a5c763cef7a440f7ad0b413ba31959abcdcbfc3967d8c6f73ec52b2224a6fc9b16cd72cc006654db42518350901400cb541f4f634636f52fe27aec
data/lib/maildrop.rb CHANGED
@@ -1,5 +1,6 @@
1
+ require 'json'
2
+ require 'mail'
1
3
  require 'net/http'
2
- require 'nokogiri'
3
4
  require 'securerandom'
4
5
 
5
6
  require_relative 'maildrop/http'
data/lib/maildrop/http.rb CHANGED
@@ -24,7 +24,7 @@ module Maildrop
24
24
  end
25
25
 
26
26
  def base_url
27
- 'http://maildrop.cc/inbox'
27
+ 'http://maildrop.cc/api/inbox'
28
28
  end
29
29
 
30
30
  def handle_response(response)
@@ -1,37 +1,23 @@
1
1
  module Maildrop::Models
2
2
  class Email
3
- attr_reader :id, :sender, :subject, :date, :mailbox_name
4
-
5
- def initialize(mailbox_name, data)
6
- @id = find_id(data)
7
- @date = find_date(data)
8
- @sender = find_sender(data)
9
- @subject = find_subject(data)
10
- @mailbox_name = mailbox_name
11
- end
12
-
13
- def body
14
- http = Maildrop::HTTP.new
15
- http.get("#{@mailbox_name}/#{@id}/body") # TODO: remove maildrop header!
3
+ def initialize(data)
4
+ @mail = Mail.new(data['body'])
16
5
  end
17
6
 
18
- private
19
-
20
- def find_id(data)
21
- data.attr('data-id')
7
+ def sender
8
+ @mail.from.first
22
9
  end
23
10
 
24
- def find_sender(data)
25
- data.css('td.sender').text
11
+ def subject
12
+ @mail.subject
26
13
  end
27
14
 
28
- def find_subject(data)
29
- data.css('td.subject').text
15
+ def date
16
+ @mail.date
30
17
  end
31
18
 
32
- def find_date(data)
33
- date_string = data.css('td.date').text
34
- DateTime.parse(date_string)
19
+ def body
20
+ @mail.body.decoded
35
21
  end
36
22
  end
37
23
  end
@@ -4,10 +4,23 @@ module Maildrop::Models
4
4
 
5
5
  def initialize(name, data)
6
6
  @name = name
7
- emails = Nokogiri::HTML(data).css('tr').drop(1)
8
- @emails = emails.map do |email_data|
9
- Maildrop::Models::Email.new(name, email_data)
7
+ emails = JSON.parse(data)
8
+ @emails = emails.map do |email|
9
+ data = download_email(email['id'])
10
+ Maildrop::Models::Email.new(data)
10
11
  end
11
12
  end
13
+
14
+ def address
15
+ "#{name}@maildrop.cc"
16
+ end
17
+
18
+ private
19
+
20
+ def download_email(id)
21
+ http = Maildrop::HTTP.new
22
+ response = http.get("#{@name}/#{id}")
23
+ JSON.parse(response)
24
+ end
12
25
  end
13
26
  end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maildrop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre
4
+ version: 0.1.0
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-08-03 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mail
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.6.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.6'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.6.4
13
33
  description: Ruby interface to MailDrop for quick, disposable mailboxes.
14
34
  email: hi@melvin.sh
15
35
  executables: []
@@ -33,12 +53,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
33
53
  requirements:
34
54
  - - ">="
35
55
  - !ruby/object:Gem::Version
36
- version: '0'
56
+ version: 2.0.0
37
57
  required_rubygems_version: !ruby/object:Gem::Requirement
38
58
  requirements:
39
- - - ">"
59
+ - - ">="
40
60
  - !ruby/object:Gem::Version
41
- version: 1.3.1
61
+ version: '0'
42
62
  requirements: []
43
63
  rubyforge_project:
44
64
  rubygems_version: 2.6.6