mailsolution 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +6 -0
- data/Rakefile +1 -0
- data/lib/mailsolution.rb +44 -0
- data/lib/mailsolution/version.rb +3 -0
- data/mailsolution.gemspec +23 -0
- data/spec/mailsolution_test.rb +41 -0
- metadata +55 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/mailsolution.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "mailsolution/version"
|
2
|
+
|
3
|
+
module Mailsolution
|
4
|
+
|
5
|
+
class HTTP
|
6
|
+
|
7
|
+
def initialize(aid)
|
8
|
+
require 'uri'
|
9
|
+
@aid = aid.to_i
|
10
|
+
@redirect = "http://62.27.38.101/host/h.php?TYPE=r&AID=#{aid}"
|
11
|
+
@action = "NEW"
|
12
|
+
@attributes = ""
|
13
|
+
@domain = "62.27.38.101"
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def attributes=(attrs)
|
18
|
+
@attributes = attrs.map{|k,v| "&#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}"}.join
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_attributes(attrs)
|
22
|
+
@attributes += attrs.map{|k,v| "&#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}"}.join
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def path
|
27
|
+
"/c/n?AID=#{URI.escape(@aid.to_s)}&ACTION=#{URI.escape(@action)}#{@attributes}&RED=#{URI.escape(@redirect)}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
"http://#{@domain}#{path}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def deliver
|
35
|
+
require 'net/http'
|
36
|
+
begin
|
37
|
+
Timeout.timeout(10) { Net::HTTP.get_response(@domain, path, "80") }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "mailsolution/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "mailsolution"
|
7
|
+
s.version = Mailsolution::VERSION
|
8
|
+
s.authors = ["Sascha Brink"]
|
9
|
+
s.email = ["sascha.brink@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/sbrink/mailsolution"
|
11
|
+
s.summary = %q{A simple interface to mailsolution newsletter api}
|
12
|
+
s.description = %q{A simple interface to mailsolution newsletter api. It only uses the http interface. }
|
13
|
+
|
14
|
+
s.rubyforge_project = "mailsolution"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# s.add_development_dependency "rspec"
|
22
|
+
# s.add_runtime_dependency "rest-client"
|
23
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
$:.push File.expand_path("../lib")
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'mailsolution'
|
4
|
+
|
5
|
+
describe Mailsolution::HTTP do
|
6
|
+
before do
|
7
|
+
@mailsolution = Mailsolution::HTTP.new("123")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should give the corrent base path" do
|
11
|
+
@mailsolution.path.must_equal "/c/n?AID=123&ACTION=NEW&RED=http://62.27.38.101/host/h.php?TYPE=r&AID=123"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be able to add attribute hash" do
|
15
|
+
@mailsolution.attributes= { firstname: "Not" }
|
16
|
+
@mailsolution.path.must_equal "/c/n?AID=123&ACTION=NEW&firstname=Not&RED=http://62.27.38.101/host/h.php?TYPE=r&AID=123"
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
it "should be able to add one attributes" do
|
21
|
+
@mailsolution.update_attributes(firstname: "Not")
|
22
|
+
@mailsolution.path.must_equal "/c/n?AID=123&ACTION=NEW&firstname=Not&RED=http://62.27.38.101/host/h.php?TYPE=r&AID=123"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be able to add multiple attributes" do
|
26
|
+
@mailsolution.update_attributes(firstname: "Not")
|
27
|
+
@mailsolution.update_attributes(lastname: "Sure")
|
28
|
+
@mailsolution.path.must_equal "/c/n?AID=123&ACTION=NEW&firstname=Not&lastname=Sure&RED=http://62.27.38.101/host/h.php?TYPE=r&AID=123"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be able to add multiple attributes" do
|
32
|
+
@mailsolution.attributes= { firstname: "Not", lastname: "Sure" }
|
33
|
+
@mailsolution.path.must_equal "/c/n?AID=123&ACTION=NEW&firstname=Not&lastname=Sure&RED=http://62.27.38.101/host/h.php?TYPE=r&AID=123"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should escape attributes" do
|
37
|
+
@mailsolution.update_attributes(firstname: "% ")
|
38
|
+
@mailsolution.path.must_equal "/c/n?AID=123&ACTION=NEW&firstname=%25%20&RED=http://62.27.38.101/host/h.php?TYPE=r&AID=123"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailsolution
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sascha Brink
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-18 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! 'A simple interface to mailsolution newsletter api. It only uses the
|
15
|
+
http interface. '
|
16
|
+
email:
|
17
|
+
- sascha.brink@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/mailsolution.rb
|
27
|
+
- lib/mailsolution/version.rb
|
28
|
+
- mailsolution.gemspec
|
29
|
+
- spec/mailsolution_test.rb
|
30
|
+
homepage: http://github.com/sbrink/mailsolution
|
31
|
+
licenses: []
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project: mailsolution
|
50
|
+
rubygems_version: 1.8.10
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: A simple interface to mailsolution newsletter api
|
54
|
+
test_files:
|
55
|
+
- spec/mailsolution_test.rb
|