famailer 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 84d0b79637f02520c6521548114477f57aaaebfb
4
+ data.tar.gz: 4c742e8eacaef53ffc1188b43379d6a2536ff5e0
5
+ SHA512:
6
+ metadata.gz: 7da08b321cd4f338d83538ffc353caea58adadac7f8407a63547d6ec5b3afddad7abe1827324efaef2a97c5bc51efc16450b85343c80a325c81df8d678350e46
7
+ data.tar.gz: 157fce7e4ddddd16d92e854b885a0fcf0e4b73735f3365730717f3b198742d39a0523b3f68ab2189f7330835aed55030f0e6ce9ebace3124129294b29fd3f773
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ famailer (0.0.1)
5
+ nokogiri (~> 1.7, >= 1.7.2)
6
+ rest-client (~> 2.0, >= 2.0.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ byebug (9.0.6)
12
+ domain_name (0.5.20170404)
13
+ unf (>= 0.0.5, < 1.0.0)
14
+ http-cookie (1.0.3)
15
+ domain_name (~> 0.5)
16
+ mime-types (3.1)
17
+ mime-types-data (~> 3.2015)
18
+ mime-types-data (3.2016.0521)
19
+ mini_portile2 (2.2.0)
20
+ netrc (0.11.0)
21
+ nokogiri (1.8.0)
22
+ mini_portile2 (~> 2.2.0)
23
+ rest-client (2.0.2)
24
+ http-cookie (>= 1.0.2, < 2.0)
25
+ mime-types (>= 1.16, < 4.0)
26
+ netrc (~> 0.8)
27
+ unf (0.1.4)
28
+ unf_ext
29
+ unf_ext (0.0.7.4)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ byebug
36
+ famailer!
37
+
38
+ BUNDLED WITH
39
+ 1.14.6
@@ -0,0 +1,14 @@
1
+ ## FAMailer
2
+
3
+ This little gem allows you a use the internal messaging system of an art website. It's very alpha but it works great for my client.
4
+
5
+ ### Usage
6
+
7
+ You need both the 'a' cookie and the 'b' cookie from the service. You can also set the `FA_COOKIE_A` and `FA_COOKIE_B` environment variable.
8
+
9
+ ```
10
+ FAMailer.new({
11
+ fa_cookie_a: "abcde",
12
+ fa_cookie_b: "edcba"
13
+ }).send!(recipient, subject, message)
14
+ ```
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "famailer"
4
+
5
+ FAMailer.new.send!(ARGV[0], ARGV[1], STDIN.read)
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "famailer"
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = "famailer"
9
+ gem.version = FAMailer::VERSION
10
+ gem.authors = ["Victor Goya"]
11
+ gem.email = ["phorque@phorque.it"]
12
+ gem.description = "Mail API for an art website"
13
+ gem.summary = "Mail API for an art website"
14
+ gem.homepage = "https://phorque.it"
15
+
16
+ gem.files = `git ls-files -z`.split("\x0")
17
+ gem.executables = %w(famail)
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+ gem.bindir = 'bin'
21
+
22
+ gem.licenses = ["MIT"]
23
+
24
+ gem.required_ruby_version = "~> 2.0"
25
+
26
+ gem.add_dependency 'rest-client', '~> 2.0', '>= 2.0.2'
27
+ gem.add_dependency 'nokogiri', '~> 1.7', '>= 1.7.2'
28
+
29
+ gem.add_development_dependency "byebug"
30
+ end
@@ -0,0 +1,54 @@
1
+ require "byebug"
2
+ require "nokogiri"
3
+ require "rest-client"
4
+
5
+ class FAMailer
6
+ VERSION = "0.0.2"
7
+ HOST = "http://furaffinity.net"
8
+
9
+ def initialize(options = {})
10
+ @fa_cookie_a = options.delete(:fa_cookie_a) || ENV["FA_COOKIE_A"]
11
+ @fa_cookie_b = options.delete(:fa_cookie_b) || ENV["FA_COOKIE_B"]
12
+ @debug = options.delete(:debug)
13
+ end
14
+
15
+ def send!(recipient, subject, message, options = {})
16
+ puts "#{subject} -> #{recipient}\n---\n#{message}" if @debug
17
+
18
+ site[form['action']].post({
19
+ key: key,
20
+ to: recipient,
21
+ subject: subject,
22
+ message: message
23
+ }) do |response|
24
+ if response.code == 301
25
+ response.follow_redirection do |response|
26
+ puts "Message sent" if @debug && response.code == 302
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ def key
33
+ @key ||= form.css("input[name=key]").first['value']
34
+ end
35
+
36
+ def form
37
+ @form ||= messages_page.css("#MsgForm").first
38
+ end
39
+
40
+ def messages_page
41
+ @messages_page ||= Nokogiri::HTML(site["/msg/pms"].get.body)
42
+ end
43
+
44
+ def site
45
+ @site ||= RestClient::Resource.new(HOST, cookies: cookies)
46
+ end
47
+
48
+ def cookies
49
+ {
50
+ "a" => @fa_cookie_a,
51
+ "b" => @fa_cookie_b
52
+ }
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: famailer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Victor Goya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: nokogiri
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.7'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.7.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.7'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.7.2
53
+ - !ruby/object:Gem::Dependency
54
+ name: byebug
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ description: Mail API for an art website
68
+ email:
69
+ - phorque@phorque.it
70
+ executables:
71
+ - famail
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - Gemfile
76
+ - Gemfile.lock
77
+ - README.md
78
+ - bin/famail
79
+ - famailer.gemspec
80
+ - lib/famailer.rb
81
+ homepage: https://phorque.it
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '2.0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.5.2.1
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Mail API for an art website
105
+ test_files: []